Saturday, February 14, 2015

How to create a command for a tool item with LinsUIWPF Suite


Prerequisite: Follow the link How to create a new project to create your application with LinsUIWPF Suite.

1.     Assign a unique ID, which is between FlexConstants.m_nUserDefinedControlStartID (1000) and FlexConstants.m_nUserDefinedControlStartID (10,000,000), to the CommandID property of the tool item.
<src:FlexMenuItem ID="1022" CommandID="1001" Text=”My Command” Name=”myToolItem”/>
2.     Create a class as follows,
class MyCommand : LinsUICommand
{
public MyCommand(long nCommandID, object data) base(nCommandID, data)
{
}

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;
}
}
3.     Create the command with the given unique ID (here is 1001). This will automatically link the command to the tool item.
public partial class Window1 : LinsMDIWindow
{
public Window1()
{
InitializeComponent();
MyCommand myCommand = new MyCommand(1001, null);
}
} 



References:
Assign a Help Document to a Tool Item,
Commands,
Command Events,
Commands Manager,
Dynamically Link a Tool Item to a Command Existed in an Optional Assembly,
Features,
How To,
Index,
Instruction,

No comments:

Post a Comment