Class CommandBarController
The CommandBarController acts as a central point of control for the CommandBars hosted on a form.
Inheritance
System.Object
CommandBarController
Implements
System.IDisposable
System.ComponentModel.ISupportInitialize
Assembly: Syncfusion.Tools.Windows.dll
public class CommandBarController : BaseComponent, IThemeProvider, IDisposable, ISupportInitialize, ICBControllerDesignerInvoke, IVisualStyle
The sample code shows how to create and initialize a CommandBarController, create a CommandBar
control that is initially docked to the top border of the form and hosts a Panel control and finally add
the CommandBar to the CommandBarController's collection.
private void InitializeCommandBars()
{
// Create the CommandBarController
this.commandBarController1 = new Syncfusion.Windows.Forms.Tools.CommandBarController();
((System.ComponentModel.ISupportInitialize)(this.commandBarController1)).BeginInit();
// Set the CommandBarController's host form
this.commandBarController1.HostForm = this;
this.commandBarController1.PersistState = true;
// Create the CommandBar control
this.commandBarAddress = new Syncfusion.Windows.Forms.Tools.CommandBar();
// Set the CommandBar Layout/Behavior/Appearance attributes
this.commandBarAddress.DockBorder = Syncfusion.Windows.Forms.Tools.DockBorder.Top;
this.commandBarAddress.HideDropDownButton = true;
this.commandBarAddress.MaxLength = 400;
this.commandBarAddress.MinHeight = 26;
this.commandBarAddress.MinLength = 50;
this.commandBarAddress.Name = "commandBarAddress";
this.commandBarAddress.RowIndex = 1;
this.commandBarAddress.RowOffset = 1;
this.commandBarAddress.Text = "Address";
// Create the ComboBox control and add it to the CommandBars Controls collection
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.commandBarAddress.Controls.AddRange(new System.Windows.Forms.Control[] {this.comboBox1});
// Add the CommandBar to the CommandBarController.CommandBars collection
this.commandBarController1.CommandBars.Add(this.commandBarAddress);
((System.ComponentModel.ISupportInitialize)(this.commandBarController1)).EndInit();
}</code></pre></coderef>
Private Sub InitializeCommandBars()
' Create the CommandBarController
Me.commandBarController1 = New Syncfusion.Windows.Forms.Tools.CommandBarController(Me.components)
CType(Me.commandBarController1, System.ComponentModel.ISupportInitialize).BeginInit()
' Set the CommandBarController's host form
Me.commandBarController1.HostForm = Me
Me.commandBarController1.PersistState = True
' Create the CommandBar control
Me.commandBarAddress = New Syncfusion.Windows.Forms.Tools.CommandBar()
' Set the CommandBar Layout/Behavior/Appearance attributes
Me.commandBarAddress.DockState = Syncfusion.Windows.Forms.Tools.CommandBarDockState.Top
Me.commandBarAddress.MaxLength = 400
Me.commandBarAddress.MinHeight = 26
Me.commandBarAddress.MinLength = 50
Me.commandBarAddress.Name = "commandBarAddress"
Me.commandBarAddress.RowIndex = 1
Me.commandBarAddress.RowOffset = 1
Me.commandBarAddress.Text = "Address"
' Create the ComboBox control and add it to the CommandBars Controls collection
Me.comboBox1 = New System.Windows.Forms.ComboBox()
Me.commandBarAddress.Controls.AddRange(New System.Windows.Forms.Control() {Me.comboBox1})
' Add the CommandBar to the CommandBarControllers CommandBars // collection
Me.commandBarController1.CommandBars.Add(Me.commandBarAddress)
CType(Me.commandBarController1, System.ComponentModel.ISupportInitialize).EndInit()
End Sub</code></pre></coderef>
Constructors
Declaration
public CommandBarController()
Declaration
public CommandBarController(IContainer container)
Parameters
Type |
Name |
Description |
System.ComponentModel.IContainer |
container |
An object implementing the System.ComponentModel.IContainer
interface to associate with this instance of the CommandBarController.
|
Fields
Declaration
protected CommandBarController.CommandBarsCollection alCommandBars
Field Value
Declaration
protected ArrayList alDelayLoadBars
Field Value
Type |
System.Collections.ArrayList |
Declaration
protected ArrayList alFreezeAddBars
Field Value
Type |
System.Collections.ArrayList |
Declaration
protected ArrayList alFreezeRelayoutBars
Field Value
Type |
System.Collections.ArrayList |
Declaration
protected ArrayList alFreezeRemoveBars
Field Value
Type |
System.Collections.ArrayList |
Declaration
protected bool bBackColorSet
Field Value
Declaration
protected bool bDisableButtons
Field Value
Declaration
protected bool bInitializationComplete
Field Value
Declaration
protected bool bLoadVisibility
Field Value
Declaration
protected bool bPersistState
Field Value
Declaration
protected bool bThemesEnabled
Field Value
Declaration
protected CommandBarDockBorder cbDockBorder
Field Value
Declaration
protected Color clrBackColor
Field Value
Type |
System.Drawing.Color |
Declaration
protected CommandDockBar CommandDockBarB
Field Value
Declaration
protected CommandDockBar CommandDockBarL
Field Value
Declaration
protected CommandDockBar CommandDockBarR
Field Value
Declaration
protected CommandDockBar CommandDockBarT
Field Value
Declaration
protected CommandBar focusedCBar
Field Value
frmMain
Declaration
Field Value
Type |
System.Windows.Forms.Form |
Colorschemes for Office2007 visual style.
Declaration
protected Office2007Theme m_office2007Theme
Field Value
Colorschemes for Office2010 visual style.
Declaration
protected Office2010Theme m_office2010Theme
Field Value
Need this to avoid recursive mdichild and owned forms activating.
Especially issue occurs when activating mdichild form, which is in minimized state, and
has some floating forms related to it's ChildBarManager.
Declaration
protected int nFreezeActivation
Field Value
Declaration
protected int nFreezeLayout
Field Value
Declaration
protected MemoryStream strmDefault
Field Value
Type |
System.IO.MemoryStream |
Declaration
protected const string strPersistKey = "CommandBarInfo"
Field Value
Declaration
protected VisualStyle tbStyle
Field Value
Declaration
protected Type typeCBSerializer
Field Value
wndMainFrm
Declaration
protected CommandBarController.AppMainFormWnd wndMainFrm
Field Value
Declaration
protected CBCtrlrSerializationWrapper wpprCBController
Field Value
Properties
Gets or sets the background color used to draw the host form's dockable regions.
Declaration
public Color BackColor { get; set; }
Property Value
Type |
Description |
System.Drawing.Color |
A System.Drawing.Color that represents the background color.
|
Returns a reference to the CommandBars that belong to this CommandBarController.
Declaration
public CommandBarController.CommandBarsCollection CommandBars { get; }
Property Value
Gets or sets the CommandBarSerializer
Declaration
public Type CommandBarSerializer { get; set; }
Property Value
Gets or sets the edges of the form along which CommandBars are allowed to dock.
Declaration
public CommandBarDockBorder EnabledDockBorders { get; set; }
Property Value
Declaration
protected CommandBar FocusedCommandBar { get; set; }
Property Value
Declaration
protected bool FreezeActivation { get; set; }
Property Value
Gets or sets FreezeLayout
Declaration
public bool FreezeLayout { get; set; }
Property Value
Gets or sets the host form.
Declaration
public Form HostForm { get; set; }
Property Value
Type |
Description |
System.Windows.Forms.Form |
The Form that will host the CommandBars.
|
Gets or Sets the MetroColor
Declaration
public Color MetroBackColor { get; set; }
Property Value
Type |
System.Drawing.Color |
Gets or Sets the MetroColor
Declaration
public Color MetroColor { get; set; }
Property Value
Type |
System.Drawing.Color |
Gets colors for Office2007 visual style.
Declaration
protected Office2007Colors Office2007ColorTable { get; }
Property Value
Gets or sets colorschemes for Office2007 visual style.
Declaration
public Office2007Theme Office2007Theme { get; set; }
Property Value
Gets colors for Office2010 visual style.
Declaration
protected Office2010Colors Office2010ColorTable { get; }
Property Value
Gets or sets colorschemes for Office2010 visual style.
Declaration
public Office2010Theme Office2010Theme { get; set; }
Property Value
Declaration
protected virtual string PersistenceID { get; }
Property Value
Indicates whether the application's CommandBars state should be persisted.
Declaration
public bool PersistState { get; set; }
Property Value
Type |
Description |
System.Boolean |
When TRUE the application's CommandBars state will be persisted. The default is FALSE.
|
Gets a value indicating whether the control's elements are aligned RightToLeft.
Declaration
public virtual RightToLeft RightToLeft { get; }
Property Value
Type |
System.Windows.Forms.RightToLeft |
Gets or sets the visual style of the CommandBars.
Declaration
public VisualStyle Style { get; set; }
Property Value
Indicates whether XP Themes (visual styles) should be used for CommandBars.
Declaration
public bool ThemesEnabled { get; set; }
Property Value
Type |
Description |
System.Boolean |
True to turn on themes; false otherwise.
|
Declaration
public CommandBarControllerVisualStyle ThemeStyle { get; set; }
Property Value
Declaration
public bool UseBackwardCompatiblity { get; set; }
Property Value
Methods
Declaration
[Obsolete("This method will be removed in a future version. Please use the more flexible ApplyDeserializedState(IList) variant, instead.")]
protected void ApplyDeserializedState(IEnumerator ebarlist)
Parameters
Type |
Name |
Description |
System.Collections.IEnumerator |
ebarlist |
|
Declaration
protected void ApplyDeserializedState(IList ebarlist)
Parameters
Type |
Name |
Description |
System.Collections.IList |
ebarlist |
|
Declaration
public virtual void BeginInit()
Brings the CommandBar to the front of the z-order.
Declaration
public void BringToFront()
Declaration
protected void ChildControl_DockChanged(object sender, EventArgs e)
Parameters
Type |
Name |
Description |
System.Object |
sender |
|
System.EventArgs |
e |
|
Declaration
protected virtual CommandDockBar CreateCommandDockBar()
Returns
Overridden. See System.ComponentModel.Component.Dispose(System.Boolean).
Declaration
protected override void Dispose(bool disposing)
Parameters
Type |
Name |
Description |
System.Boolean |
disposing |
|
Declaration
public virtual void EndInit()
Gets the list of commandBars in the commandBars Collection.
Declaration
public virtual CommandBarController.CommandBarsCollection GetCommandBarsList()
Returns
Helps to override the ControlName settings in control
Declaration
public override string GetControlName(string controlName)
Parameters
Type |
Name |
Description |
System.String |
controlName |
|
Returns
Overrides
Declaration
public CommandDockBar GetDockBar(CommandBarDockBorder dockstyle)
Parameters
Returns
Declaration
protected CommandDockBar GetDockBar(CommandBarDockState border)
Parameters
Returns
Declaration
protected CommandDockBar GetDockBar(Point ptscreen)
Parameters
Type |
Name |
Description |
System.Drawing.Point |
ptscreen |
|
Returns
Declaration
protected virtual CBCtrlrSerializationWrapper GetPersistanceData()
Returns
Declaration
protected void HostForm_BackColorChanged(object sender, EventArgs e)
Parameters
Type |
Name |
Description |
System.Object |
sender |
|
System.EventArgs |
e |
|
Declaration
protected void HostForm_Closing(object sender, CancelEventArgs e)
Parameters
Type |
Name |
Description |
System.Object |
sender |
|
System.ComponentModel.CancelEventArgs |
e |
|
Declaration
protected void HostForm_ControlAdded(object sender, ControlEventArgs e)
Parameters
Type |
Name |
Description |
System.Object |
sender |
|
System.Windows.Forms.ControlEventArgs |
e |
|
Declaration
protected void HostForm_ControlRemoved(object sender, ControlEventArgs e)
Parameters
Type |
Name |
Description |
System.Object |
sender |
|
System.Windows.Forms.ControlEventArgs |
e |
|
Declaration
protected void HostForm_Layout(object sender, LayoutEventArgs levent)
Parameters
Type |
Name |
Description |
System.Object |
sender |
|
System.Windows.Forms.LayoutEventArgs |
levent |
|
Declaration
protected void HostForm_Load(object sender, EventArgs e)
Parameters
Type |
Name |
Description |
System.Object |
sender |
|
System.EventArgs |
e |
|
Declaration
protected void HostForm_RightToLeftChanged(object sender, EventArgs e)
Parameters
Type |
Name |
Description |
System.Object |
sender |
|
System.EventArgs |
e |
|
Declaration
protected void HostForm_SystemColorsChanged(object sender, EventArgs e)
Parameters
Type |
Name |
Description |
System.Object |
sender |
|
System.EventArgs |
e |
|
Declaration
protected void InitializeCBController()
Declaration
protected virtual void InitializeDockBars()
Layout the bars which are docked.
Declaration
public void LayoutDockBarsExceptBar(CommandDockBar dockBarToIgnore)
Parameters
Type |
Name |
Description |
CommandDockBar |
dockBarToIgnore |
The dock bar which should be ignored while layouting.
|
Overloaded. Retrieves the persisted state of the CommandBar objects from Isolated Storage.
Declaration
public bool LoadCommandBarState()
Returns
Type |
Description |
System.Boolean |
TRUE if the load is successful; FALSE otherwise.
|
Declaration
public bool LoadCommandBarState(AppStateSerializer serializer)
Parameters
Type |
Name |
Description |
AppStateSerializer |
serializer |
An instance of AppStateSerializer, from which to load.
|
Returns
Type |
Description |
System.Boolean |
TRUE if the load is successful.
|
Retrieves the persisted state of the CommandBar objects using the specified storage and location.
Declaration
[Obsolete("This method will be removed in a future version. Please use the more flexible LoadCommandBarState(AppStateSerializer) variant, instead.", false)]
public bool LoadCommandBarState(SerializeMode mode, object persistpath)
Parameters
Type |
Name |
Description |
SerializeMode |
mode |
A SerializeMode value describing the persistence medium.
|
System.Object |
persistpath |
The name of the IsolatedStorage/INI/XML file or registry key containing the persisted information.
|
Returns
Type |
Description |
System.Boolean |
TRUE if the load is successful.
|
Loads the command bar state from cache
Declaration
public void LoadCommandBarStateFromCache(CommandBar cbar)
Parameters
Restores the default state of the CommandBar objects.
Declaration
public bool LoadDesignerCommandBarState()
Returns
Type |
Description |
System.Boolean |
TRUE if the load is successful.
|
Declaration
protected virtual void OnDockBarStateChanged(CommandBarController.DockBarStateEventArgs args)
Parameters
Raises the ProvidePersisteceID event.
Declaration
protected virtual void OnProvidePresistenceID(ProvidePersistenceIDEventArgs e)
Parameters
Declaration
protected virtual void OnStyleChanged()
Helps to apply the ThemeName settings in control
Declaration
public override void OnThemeNameChanged(string themeName)
Parameters
Type |
Name |
Description |
System.String |
themeName |
ThemeName
|
Overrides
Declaration
protected virtual void OnThemesEnabledChanged()
Reads deserialized data to CommandBar.
Declaration
protected virtual void ReadDeserializedData(CommandBar commandBar)
Parameters
Declaration
protected void RecalcBorderLayout(CommandBarDockState border)
Parameters
Forces a layout recalculation on the specified CommandBar.
Declaration
public void RecalcLayout(CommandBar cbar)
Parameters
Type |
Name |
Description |
CommandBar |
cbar |
The CommandBar for which the layout is to be recalculated.
|
Overloaded. Forces a layout recalculation.
Declaration
public void RecalcLayout(CommandBarDockBorder style)
Parameters
Declaration
protected virtual void RemoveCommandBarData(CommandBar commandBar)
Parameters
Resumes the back color to default value.
Declaration
public void ResetBackColor()
Resumes the dock bar z-order to default value.
Declaration
public void ResetDockBarZOrder()
Overloaded. Persists the current state of the CommandBar objects to IsolatedStorage.
Declaration
public void SaveCommandBarState()
Declaration
public void SaveCommandBarState(AppStateSerializer serializer)
Parameters
Persists the current state of the CommandBar objects using the specified storage medium and location.
Declaration
[Obsolete("This method will be removed in a future version. Please use the more flexible SaveCommandBarState(AppStateSerializer) variant, instead.", false)]
public void SaveCommandBarState(SerializeMode mode, object persistpath)
Parameters
Type |
Name |
Description |
SerializeMode |
mode |
A SerializeMode value describing the persistence medium.
|
System.Object |
persistpath |
The name of the IsolatedStorage/INI/XML file or registry key in which the
state information is to be persisted.
|
Sends the CommandBar to the back of the z-order.
Declaration
Declaration
protected void SetBarsTransparency()
Declaration
protected void SetCommandBarInitialPosition(CommandBar cbar)
Parameters
Declaration
protected void SetInitialDockedPosition(CommandBar cbar)
Parameters
Declaration
protected void SetInitialFloatingPosition(CommandBar cbar)
Parameters
Declaration
protected bool ShouldSerializeBackColor()
Returns
Declaration
protected void ToggleCommandBarFloatState(bool bactivate)
Parameters
Type |
Name |
Description |
System.Boolean |
bactivate |
|
Events
Declaration
protected event CommandBarController.DockBarStateChangedHandler DockBarStateChanged
Event Type
Occurs when CommandBars' layout is internally resumed.
Declaration
public event EventHandler LayoutResumed
Event Type
Occurs when CommandBars' layout is internally suspended.
Declaration
public event EventHandler LayoutSuspended
Event Type
Lets you specify a unique ID used to distinguish the persistence information
of different instances of your Form type.
Declaration
[Obsolete("ProvidePersisteceID is deprecated, please use ProvidePersistenceID instead.")]
public event ProvidePersistenceIDEventHandler ProvidePersisteceID
Event Type
Lets you specify a unique ID used to distinguish the persistence information
of different instances of your Form type.
Declaration
public event ProvidePersistenceIDEventHandler ProvidePersistenceID
Event Type
Occurs when the Style property is changed.
Declaration
public event EventHandler StyleChanged
Event Type
Declaration
public event EventHandler ThemesEnabledChanged
Event Type
Explicit Interface Implementations
Declaration
string IVisualStyle.VisualTheme { get; set; }
Returns
Declaration
CommandDockBar ICBControllerDesignerInvoke.GetCommandDockBarB()
Returns
Declaration
CommandDockBar ICBControllerDesignerInvoke.GetCommandDockBarL()
Returns
Declaration
CommandDockBar ICBControllerDesignerInvoke.GetCommandDockBarR()
Returns
Declaration
CommandDockBar ICBControllerDesignerInvoke.GetCommandDockBarT()
Returns
Declaration
void ICBControllerDesignerInvoke.InitializeCBController()
Implements
System.IDisposable
System.ComponentModel.ISupportInitialize
See Also