Friday, February 13, 2015

Context Menu


ContextMenuDropDown class
Represents a pop-up menu that enables a control to expose functionality that is specific to the context of the control.
Examples
The following example shows how to create a ContextMenuDropDown object and assign it to an image.
public partial class MyContextMenuDropDown : ContextMenuDropDown
{
// ***** //
public partial class Window1 : LinsMDIWindow
{
Public image;
public Window1()
// Create a contextmenu instance.
FlexContextMenu contextmenu = new FlexContextMenu();
// Create a contextmenudropdown instance.
contextmenu.DropDownMenu = new MyContextMenuDropDown();
// Assign the contextmenu to the image
Image.ContextMenu = contextmenu;
}
}

§  Constructors
1)  public ContextMenuDropDown()
Remarks
Initialize a new instance of ContextMenuDropDown
§  Members
1)  public virtual Rect Bounds { get; }
Remarks
Retrieve both the size and the location of the context menu, in pixels, relative to its parent.
2)  public virtual Rect BoundsAtMDIFrame { get; }
Remarks
Retrieve both the size and the location of the context menu, in pixels, relative to MDI frame.
3)  public virtual long ID { get; set; }               
Remarks
Every ContextMenuDropDown object should have a unique ID. If the user does not assign a number to the ID, a unique number which is larger than FlexConstants.m_nUserDefinedControlStartID (10,000,000) will be automatically generated and assigned to it. If the ID is between FlexConstants.m_nUserDefinedControlStartID (1000) and FlexConstants.m_nUserDefinedControlStartID (10,000,000), then once the context menu is created, it will never been destroyed, and its layout will be persistent and customizable. You can always use LinsUIWPFDockingManager.GetContextMenuFromAllPlacesByID() to retrieve its instance, once it is created.
4)  public FlexCollection<UIElement> Items { get; set; }               
Remarks
Gets or sets all menu items.
5)  public bool ShowToolTip { get; set; }
Remarks
This field decided if the tooltip will be shown, when the mouse hovers above one of the menu items, if the menu item has a tooltip assigned to it.
6)  public string Text { get; set; }
Remarks
Gets or sets the caption of the context menu.
§  Methods
1)  public void EnsureVisible(FlexToolBarBaseButton visibleButton)      
Parameters
visibleButton
Type: FlexToolBarBaseButton
A menu item.            
Remarks
Move the menu item, visibleButton, into view area if it is outside the view area.
2)  public virtual bool HitTest(
Point ptMousePosAtMDIFrame)                 
Parameters
ptMousePosAtMDIFrame
Type: Point
A location which is in MDI Frame coordinate. 
Remarks
Test whether the point, ptMousePosAtMDIFrame, which is in MDI Frame coordinate, is inside this context menu.
3)  public virtual Size MeasureSize()              
Remarks
This calculates how much space the context menu requires. If the user wants to customize the context menu, this method may need to be overridden by the user.
§  Events
1)     public event CloseEventhandler Closed              
Remarks
This event is fired when the context menu closes. 
2)     public event DescendantItemClickedEventhandler DescendantItemClicked              
Remarks
This event is fired when any menu item is clicked.  





Reference:
Command,
Command Events,
Commands Manager,
Create a Context Menu,
Create a Command,
Dynamically Link a Tool Item to a Command Existed in an Optional Assembly,
Features,
FlexToolBarComboBox,
How To,
Index,
Instruction,
LinsUIWPFDockingManager,
Tool Items Manager


No comments:

Post a Comment