N
NavnathK
Guest
Hello,
I have a property called "Coordinates" in a property grid. I have created a custom editor to edit the value of this property. Here is the definition of this property:
private string coordinates = "";
[Category("Contextual Menu")]
[DisplayName("1) Coordinates")]
[Editor(typeof(UITypeEditors.UIControlCoordinateTypeEditor), typeof(System.Drawing.Design.UITypeEditor))]
public string Coordinates
{
get
{
if (string.IsNullOrEmpty(coordinates))
return "";
else
return this.coordinates;
}
set
{
if (string.IsNullOrEmpty(value))
this.coordinates = "";
else
this.coordinates = value;
}
}
Definition of UIControlCoordinateTypeEditor is as below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Design;
using System.Windows.Forms;
using Gma.UserActivityMonitor;
namespace QAliber.Repository.CommonTestCases.UITypeEditors
{
class UIControlCoordinateTypeEditor : UITypeEditor
{
string MouseClickLocation { get; set; }
public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
{
if (context != null)
{
return System.Drawing.Design.UITypeEditorEditStyle.Modal;
}
return base.GetEditStyle(context);
}
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
{
if (value is string)
{
DialogResult dialogResult = MessageBox.Show("Track?", "Track Mouse Location", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
//do something
HookManager.MouseClick += HookManager_MouseClick;
}
else if (dialogResult == DialogResult.No)
{
//do something else
}
return base.EditValue(context, provider, value);
}
private void HookManager_MouseClick(object sender, MouseEventArgs e)
{
Console.WriteLine("x={0} y={1}", e.X, e.Y);
this.MouseClickLocation = e.Location.ToString();
}
}
}
Now, I want to return this.MouseClickLocation that I got in HookManager_MouseClick, from the method EditValue.
How can I do this?
Thank you in advance!
Continue reading...
I have a property called "Coordinates" in a property grid. I have created a custom editor to edit the value of this property. Here is the definition of this property:
private string coordinates = "";
[Category("Contextual Menu")]
[DisplayName("1) Coordinates")]
[Editor(typeof(UITypeEditors.UIControlCoordinateTypeEditor), typeof(System.Drawing.Design.UITypeEditor))]
public string Coordinates
{
get
{
if (string.IsNullOrEmpty(coordinates))
return "";
else
return this.coordinates;
}
set
{
if (string.IsNullOrEmpty(value))
this.coordinates = "";
else
this.coordinates = value;
}
}
Definition of UIControlCoordinateTypeEditor is as below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Design;
using System.Windows.Forms;
using Gma.UserActivityMonitor;
namespace QAliber.Repository.CommonTestCases.UITypeEditors
{
class UIControlCoordinateTypeEditor : UITypeEditor
{
string MouseClickLocation { get; set; }
public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
{
if (context != null)
{
return System.Drawing.Design.UITypeEditorEditStyle.Modal;
}
return base.GetEditStyle(context);
}
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
{
if (value is string)
{
DialogResult dialogResult = MessageBox.Show("Track?", "Track Mouse Location", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
//do something
HookManager.MouseClick += HookManager_MouseClick;
}
else if (dialogResult == DialogResult.No)
{
//do something else
}
return base.EditValue(context, provider, value);
}
private void HookManager_MouseClick(object sender, MouseEventArgs e)
{
Console.WriteLine("x={0} y={1}", e.X, e.Y);
this.MouseClickLocation = e.Location.ToString();
}
}
}
Now, I want to return this.MouseClickLocation that I got in HookManager_MouseClick, from the method EditValue.
How can I do this?
Thank you in advance!
Continue reading...