Showing posts with label LinsUI Layout Manager. Show all posts
Showing posts with label LinsUI Layout Manager. Show all posts

Monday, January 3, 2011

Initialize a toolstripitem in Windows Forms Applications

The user can initialize a toolstripitem very easily with LinsUI Layout Manager 2.1.
The following example demonstrates how to specify and code the handler for the INITIALIZE 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 INITIALIZE 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 INITIALIZE event
// when the Color dropdown is created, this event will be fired and only fired once.
// The user can use this event to do initialization
[CommandIDAttribute(LinsResource.m_nColorsDropDownID),
// The event type, here is an initialize event    
 CommandEventAttribute(CUSTOM_TI_EVENT.INITIALIZE)]
void ColorsInitialize(object sender, System.EventArgs e)
{
// Add all possible colors into the Color dropdown list
foreach (Color_Name pair in DemoManager.m_lsColorName)
{
this.m_Colors.DropDownItems.Add(pair.m_csName);
}
}

Update the command UI state in Windows Forms Applications

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;
}