Monday, January 3, 2011

How to link a command item to its documentation in Windows Forms Applications

The following examples demonstrate how to link a command item to its documentation with LinsUI Layout Manager 2.1.
Examples 1:
First define a unique ID for m_nColorsDropDownID, and a detail description for the command item 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 command item 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;
}
}

Examples 2:
First define a unique ID for m_nColorsDropDownID, and a rich text format(RTF) documentation file for the command item in LinsResource class as following. The RTF file must be stored under the directory defined by FlexUISettings. DefaultHelpFilePath.

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"),   
 // Link the help button to a rich text format file           
 CommandHelpFileAttribute("ColorHelp.rtf")]    
public const long m_nColorsDropDownID = FlexConstants.m_nUserDefinedControlStartID + 5;
}

Then assign the unique ID to the tag of the command item 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;
}
}

Examples 3:
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")]    
public const long m_nColorsDropDownID = FlexConstants.m_nUserDefinedControlStartID + 5;
}

Then assign the unique ID to the tag of the command item, and define the handler function for the HELPBUTTON_CLICK 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 HELPBUTTON_CLICK event 
// once user clicks at the help button on Tooltip, this event will be fired
// user can use this to link to the command’s help documentation
[CommandIDAttribute(LinsResource.m_nColorsDropDownID),
 CommandEventAttribute(CUSTOM_TI_EVENT.HELPBUTTON_CLICK)]
public void OnColorDropDownHelpButtonClick(object sender, HelpButtonEventArgs ev)
{
}

No comments:

Post a Comment