Friday, February 13, 2015

FlexToolBarComboBox


FlexToolBarComboBox class
It derived from FlexToolBarBaseButton. This tool item presents users with a list of options.
Examples
The following example shows how to use the CommandID attribute of a tool item.
public partial class FontListComboBox : FlexToolBarComboBox
{
public FontListComboBox() : base()
{
// ******* //
CommandID = FONTLIST_COMMAND_ID;
}
}

class FontListCommand : LinsUICommand
{
public FontListCommand(long nCommandID, object data) : base(nCommandID, data)
{
// Assign a help file to this command. The help file must be stored at the location
// specified by FlexUISettings.DefaultHelpFilePath,
HelpFile = "FontSelcttion.rtf";
}

[CommandEventAttribute(COMMAND_EVENT.SELECTED_INDEX_CHANGED)]
protected void SelectionIndexChangedEnter(object sender, EventArgs e)
{
// Execute your command //
}

[CommandEventAttribute(COMMAND_EVENT.HELPBUTTON_CLICK)]
protected void HelpClick(object sender, EventArgs e)
{
// ******* //
}

[CommandEventAttribute(COMMAND_EVENT. INITIALIZE)]
protected void OnInitialize(object sender, EventArgs e)
{
// ******* //
}

public override bool CanExecute(object parameter)
{
return true;
}
}

public partial class MainWindow : LinsMDIWindow
{
public MainWindow()
{
InitializeComponent();
CreateCommands();
}

private void CreateCommands()
{
// Create FontList command instance
LinsUICommand command = new FontListCommand(FONTLIST_COMMAND_ID, null);
}
}

§  Constructors
1)  public FlexToolBarComboBox()
Remarks
Initialize a new instance of FlexToolBarComboBox
§  Members
1)  public virtual ToolBarItemDisplayStyle Appearence { get; set; }
Remarks
Gets or sets the appearance of the tool item. The default is ToolBarItemDisplayStyle.ImageAndText. It can be one of the following values,
§   None:             
Assigned Text and assigned Icon are to be rendered.
§   Text:                
Only Text is to be rendered.
§   Image:         
Only Icon is to be rendered.
§   ImageAndText:              
Both Text and Icon are to be rendered.
2)  public virtual Rect Bounds { get; }
Remarks
Retrieve both the size and the location of the tool item, in pixels, relative to its parent.
3)  public virtual Rect BoundsAtMDIFrame { get; }
Remarks
Retrieve both the size and the location of the tool item, in pixels, relative to MDI frame.
4)  public virtual bool Checked { get; set; }
Remarks
Gets or sets the check status of the tool item. The default is false.
5)  public long CommandID { get; set; }               
Remarks
If this attribute is assigned, then this tool item will be associated to the correspondent command with the same CommandID. See the above example for creating a command. 
6)  public double ComboBoxLength { get; set; }               
Remarks
Gets or sets the dropdown list length, in pixels.
7)  public int Count { get; }               
Remarks
Gets the number of the list items.
8)  public double DropDownHeight { get; set; }
Remarks
Gets or sets the dropdown list height, in pixels.
9)  public FontFamily Font { get; set; }
Remarks
Gets or sets the font of the tool item. The default is SystemFonts.MenuFontFamily.
10)public Color FontColor { get; set; }
Remarks
Gets or sets the font color of the tool item. The default is SystemManager.FlexParameters.DefaultToolItemFontColor.
11)public double FontSize { get; set; }
Remarks
Gets or sets the font size of the tool item. The default is SystemFonts.MenuFontSize.
12)public FontStyle FontStyle { get; set; }
Remarks
Gets or sets the font style of the tool item. The default is normal.
13)public FontWeight FontWeight { get; set; }
Remarks
Gets or sets the font weight of the tool item. The default is normal.
14)public string HelpContext { get; set; }
Remarks
Gets or sets the help content for the tool item. If this tool item has been associated to a command (CommandID attribute is assigned), then this attribute will be ignored, instead the COMMAND_EVENT.HELPBUTTON_CLICK event defined inside the correspondent command will be executed once the help button on the tooltip is clicked.
15)public string HelpFile { get; set; }
Remarks
Gets or sets the help file for the tool item. If this tool item has been associated to a command (CommandID attribute is assigned), then this attribute will be ignored, instead the COMMAND_EVENT.HELPBUTTON_CLICK event defined inside the correspondent command will be executed once the help button on the tooltip is clicked.
16)public virtual ImageSource Icon { get; set; }
Remarks
Gets or sets the icon of the tool item.
17)public double IconSize { get; set; }
Remarks
Gets or sets the icon size of the tool item. The default is 16 pixels.
18)public virtual long ID { get; set; }               
Remarks
Every tool item 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 tool item is created, it will never been destroyed, and its layout will be persistent and customizable. You can always use LinsUIToolItemManager.GetToolItem() to retrieve its instance, once it is created.
19)public bool IsCheckable { get; set; }
Remarks
Gets or sets the check ability of the tool item. The default is false.
20)public virtual bool IsSubMenu { get; }
Remarks
Always false.
21)public FlexCollection<FlexListItem> Items { get; }               
Remarks
Gets the list of selections.
22)public virtual TextImageRelation Relation { get; set; }
Remarks
Gets or sets the appearance of the tool item. The default is TextImageRelation.TextBeforeImage. It can be one of the following values,
§   Overlay:             
The Icon and the Text share the same space.
§   ImageAboveText:                
The Icon is displayed vertically above the Text.
§   TextAboveImage:         
The Text is displayed vertically above the Icon.
§   ImageBeforeText:              
The Icon is displayed horizontally before the Text.
§   TextBeforeImage:              
The Text is displayed horizontally before the Icon.
23)public int SelectedIndex { get; set; }               
Remarks
Gets or sets the new selected index.
24)public FlexListItem SelectedItem { get; set; }               
Remarks
Gets or sets the new selected item.
25)public bool ShowImage { get; set; }               
Remarks
True, the assigned icon will be rendered together with the combobox.
26)public override string Text { get; set; }
Remarks
Gets or sets the text of the tool item.
27)public string ToolTipText { get; set; }
Remarks
Gets or sets the tooltip of the tool item.
§  Methods
1)  public int AddItem(
FlexListItem item)                 
Parameters
item
Type: FlexListItem
An item. 
Return
The index of the added item if successful; otherwise, -1.
Remarks
Append the item to the end of the selection list.
2)  public FlexListItem GetItem (
int nIndex)                 
Parameters
nIndex
Type: int
A zero-based index. 
Return
An item of the selection list or null if the index is out of range.
3)  public int GetItemIndex(
FlexListItem item)                 
Parameters
item
Type: FlexListItem
A selection. 
Return
The index of the item.
4)  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 tool item.
5)  public bool InsertItem(
int nIndex,
FlexListItem item)                 
Parameters
nIndex
Type: int
The specific position, a zero-based index, where the item is going to be inserted into the selection list. 
item
Type: FlexListItem
An item to be inserted into the selection list. 
Return
True if successful; otherwise, false.
Remarks
Insert the item to the selection list at the specific location. If the index is out of the range, it will fail.
6)  public override Size MeasureSize(
bool bDropDown,
FLEX_DOCKING_ALIGN nDock)              
Parameters
bDropDown
Type: bool
True, if this tool item is on a dropdown list, for example a context menu or a sub-menu.            
nDock
Type: FLEX_DOCKING_ALIGN
The docking style of the tool item’s container. Always pass in FLEX_DOCKING_ALIGN.TOP, except the container is a FlexToolBar, and then pass the toolbar’s FlexDock.           
Remarks
This calculates how much space the tool item requires. If the user wants to customize the tool item, this method may need to be overridden by the user.
7)  public virtual void OnDragEnter(
DragEventArgs e)                 
Parameters
e
Type: DragEventArgs
An object that contains event data. 
Remarks
Called when the drag drop operation is in progress and the pointer enters the tool item bounds.
8)  public virtual void OnDragLeave(
DragEventArgs e)                 
Parameters
e
Type: DragEventArgs
An object that contains event data. 
Remarks
Called when the drag drop operation is in progress and the pointer leaves the tool item bounds.
9)  public virtual void OnDragOver(
DragEventArgs e)                 
Parameters
e
Type: DragEventArgs
An object that contains event data. 
Remarks
Called when the drag drop operation is in progress and the pointer is within the tool item bounds.
10)public virtual void OnDrop(
DragEventArgs e)                 
Parameters
e
Type: DragEventArgs
An object that contains event data. 
Remarks
Called when the dragged item is dropped on the tool item.
11)public virtual void OnSelectionChanged(
RoutedEventArgs e)                 
Parameters
e
Type: RoutedEventArgs
An object that contains event data. 
Remarks
Called when selection changed.
12)public virtual void OnTextChanged(
TextChangedEventArgs e)                 
Parameters
e
Type: TextChangedEventArgs
An object that contains event data. 
Remarks
Called when the user changes the text in the text box.
13)public virtual void Refresh()              
Remarks
This forces to redraw the tool item. 
14)public bool RemoveItem(
FlexListItem item)                 
Parameters
item
Type: FlexListItem
An item of the selection list. 
Return
True, if removing the selection successfully; otherwise, false.
Remarks
Remove the item.
15)public bool RemoveItem(
int nIndex)                 
Parameters
nIndex
Type: int
The zero-based index of the item which is going ti be removed from the selection list. 
Return
True, if removing the selection successfully; otherwise, false.
Remarks
Remove the item.
16)public void RemoveAllItems()                 
Remarks
Remove all items in the selection list.
17)public virtual void SetItems(
FlexCollection<FlexListItem> lsItems)                 
Parameters
lsItems
Type: FlexCollection<FlexListItem>
A collection of selections. 
Remarks
Sets the new selection list.
§  Events
1)     public event DropDownHeightChangedEventhandler DropDownHeightChanged             
Remarks
This event is fired when the dropdown list length has been changed.  
2)     public event RoutedEventHandler GotFocus              
Remarks
This event is fired when the tool item receives focus. 
3)     public event HitReturnEventhandler HitReturn             
Remarks
This event is fired when the Return key is released.   
4)     public event RoutedEventHandler LostFocus              
Remarks
This event is fired when the tool item lost focus.  
5)     public event SelectedIndexChangedEventhandler SelectedIndexChanged              
Remarks
This event is fired when the selection has been changed.  


References:

No comments:

Post a Comment