LinsUICommand
class
Represents
a command of a tool item.
Examples
The
following example shows how to create a LinsUICommand object.
class MyCommand : LinsUICommand
{
public
MyCommand(long nCommandID, object data) : base(nCommandID, data)
{
HelpFile
= "zoom.rtf";
InputKeyGesture
= new
System.Windows.Input.KeyGesture(
System.Windows.Input.Key.Z,
System.Windows.Input.ModifierKeys.Control);
}
public override void
Execute(object parameter)
{
base.Execute(parameter);
///////////////////////////////////
//
Execute your command here
///////////////////////////////////
}
[CommandEventAttribute(COMMAND_EVENT.HELPBUTTON_CLICK)]
protected void HelpClick(object sender, EventArgs e)
{
/////////////////////////////////////////////////
//
Create and show your own help document here when the ? help button is
clicked
/////////////////////////////////////////////////
}
public override bool
CanExecute(object parameter)
{
return true;
}
}
§
Constructors
1) public
LinsUICommand(
long
nCommandID,
object data)
Parameters
nCommandID
Type:
long
The
assigned unique ID.
data
Type:
object
Customer’s
data, it can be null.
Remarks
Initialize
a new instance of LinsUICommand.
§
Members
1) public long CommandID { get; set; }
Remarks
Every
LinsUICommand object should have a unique ID, which should be between
FlexConstants.m_nUserDefinedControlStartID
(1000)
and FlexConstants.m_nUserDefinedControlStartID
(10,000,000).
You can always use LinsUICommandManager.TryGetCommand() to
retrieve its instance, once it is created.
2) public object Data { get; set; }
Remarks
Customer’s
data. It can be null.
3) public string HelpContext { get; set; }
Remarks
Gets
or sets the content of the tooltip.
4) public string HelpFile { get; set; }
Remarks
Gets
or sets the file which will be loaded into the tooltip content.
The file can be either a text file or a Rich Text Format(RTF) file.
Please
reference the link How to assign a help document to a tool item.
5) public KeyGesture InputKeyGesture { get; set; }
Remarks
Define
a keyboard combination that can be used to invoke this command.
§
Methods
1) public virtual bool CanExecute(
object
parameter)
Parameters
parameter
Type:
object
Customer’s
data which is used to decide if the tool item should be
enabled/disabled.
Remarks
If
return false,
then the tool item is disabled and the command will unable to be
executed.
If
return true,
then the tool item is enabled and the command will be able to be
executed.
2) public virtual void
Execute(
object
parameter)
Parameters
parameter
Type:
object
Customer’s
data.
Remarks
Execute
the command.
No comments:
Post a Comment