The user can update the command UI state very easily with LinsUI Layout Manager 2.1.
The following example demonstrates how to specify and code the handler for the UPDATE_COMMAND_UI event of a Dropdown control
First define a unique ID for m_nColorsDropDownID in LinsResource class as following,
using LinsUI;
public static class LinsResource
{
// The Category name
[CommandGroupNameAttribute("Colors"),
// Tell the application, it is a dropdown button
CommandTypeAttribute(TSITEM_TYPEID.DROPDOWNBUTTON),
// Tooltip for the menu item
ToolTipAttribute("Select a color"),
// The detail description
DetailDescriptionAttribute("Select a color for the selected shapes.")]
public const long m_nColorsDropDownID = FlexConstants.m_nUserDefinedControlStartID + 5;
}
Then assign the unique ID to the tag of the menu item, and define the handler function for the UPDATE_COMMAND_UI event as following,
public partial class ColorsMenu : LinsUI.LinsMenuStrip
{
private ToolStripMenuItem m_Colors;
public ColorsMenu()
{
InitializeComponent();
m_Colors = new ToolStripMenuItem();
// Assign an unique ID to the m_Colors menu dropdown item
m_Colors.Tag = LinsResource.m_nColorsDropDownID;
}
// define the handler function for the UPDATE_COMMAND_UI event
// when system is on idle, this event will be fired, and
// user can use this to update the user interface for the Color dropdown
[CommandIDAttribute(LinsResource.m_nColorsDropDownID),
CommandEventAttribute(CUSTOM_TI_EVENT.UPDATE_COMMAND_UI)]
public void OnUpdateUIColorDropDown(object sender, UpdateUIEventArgs ev)
{
ev.Enabled = true;
}
No comments:
Post a Comment