public GroupManager(ICommandBarContainer container, IServiceProvider serviceProvider, IBarControl control) { if (container == null) { throw new ArgumentNullException("container"); } if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } if (control == null) { throw new ArgumentNullException("control"); } _container = container; _serviceProvider = serviceProvider; _control = control; foreach (NiCommandBarGroup group in _container.Controls) { new GroupControl(_serviceProvider, _control, group); } _container.ItemsChanged += _container_ItemsChanged; }
protected BarControl(IServiceProvider serviceProvider, NiCommandBar bar, IBarControl control) { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } if (bar == null) { throw new ArgumentNullException("bar"); } _menuManager = (NiMenuManager)serviceProvider.GetService(typeof(INiMenuManager)); _env = (NiEnv)serviceProvider.GetService(typeof(INiEnv)); Bar = bar; Bar.AppearanceChanged += Bar_AppearanceChanged; var objectWithSite = control as INiObjectWithSite; if (objectWithSite != null) { ErrorUtil.ThrowOnFailure(objectWithSite.SetSite(serviceProvider)); } Control = control; Control.Tag = this; Control.QueryStatus += (s, e) => _menuManager.QueryStatus(Bar); UpdateItem(); _groupManager = new GroupManager(Bar, serviceProvider, Control); }
protected BarControl(IServiceProvider serviceProvider, NiCommandBar bar, IBarControl control) { if (serviceProvider == null) throw new ArgumentNullException("serviceProvider"); if (bar == null) throw new ArgumentNullException("bar"); _menuManager = (NiMenuManager)serviceProvider.GetService(typeof(INiMenuManager)); _env = (NiEnv)serviceProvider.GetService(typeof(INiEnv)); Bar = bar; Bar.AppearanceChanged += Bar_AppearanceChanged; var objectWithSite = control as INiObjectWithSite; if (objectWithSite != null) ErrorUtil.ThrowOnFailure(objectWithSite.SetSite(serviceProvider)); Control = control; Control.Tag = this; Control.QueryStatus += (s, e) => _menuManager.QueryStatus(Bar); UpdateItem(); _groupManager = new GroupManager(Bar, serviceProvider, Control); }
public GroupControl(IServiceProvider serviceProvider, IBarControl bar, NiCommandBarGroup group) { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } if (bar == null) { throw new ArgumentNullException("bar"); } if (group == null) { throw new ArgumentNullException("group"); } _serviceProvider = serviceProvider; Bar = bar; Group = group; Group.CommandsChanged += Group_CommandsChanged; Group.AppearanceChanged += Group_AppearanceChanged; Separator = new ToolStripSeparator { Tag = this, Alignment = GetAlignment() }; var items = Bar.Items; int insertIndex = items.Count; for (int i = 0; i < items.Count; i++) { var separator = items[i] as ToolStripSeparator; if (separator == null) { continue; } var otherGroup = (GroupControl)separator.Tag; if (Group.Priority < otherGroup.Group.Priority) { insertIndex = i; break; } } items.Insert(insertIndex, Separator); foreach (NiCommandBarControl command in Group.Controls) { CreateControl(command); } Bar.Items.UpdateSeparatorVisibility(); }
public GroupControl(IServiceProvider serviceProvider, IBarControl bar, NiCommandBarGroup group) { if (serviceProvider == null) throw new ArgumentNullException("serviceProvider"); if (bar == null) throw new ArgumentNullException("bar"); if (group == null) throw new ArgumentNullException("group"); _serviceProvider = serviceProvider; Bar = bar; Group = group; Group.CommandsChanged += Group_CommandsChanged; Group.AppearanceChanged += Group_AppearanceChanged; Separator = new ToolStripSeparator { Tag = this, Alignment = GetAlignment() }; var items = Bar.Items; int insertIndex = items.Count; for (int i = 0; i < items.Count; i++) { var separator = items[i] as ToolStripSeparator; if (separator == null) continue; var otherGroup = (GroupControl)separator.Tag; if (Group.Priority < otherGroup.Group.Priority) { insertIndex = i; break; } } items.Insert(insertIndex, Separator); foreach (NiCommandBarControl command in Group.Controls) { CreateControl(command); } Bar.Items.UpdateSeparatorVisibility(); }
public GroupManager(ICommandBarContainer container, IServiceProvider serviceProvider, IBarControl control) { if (container == null) throw new ArgumentNullException("container"); if (serviceProvider == null) throw new ArgumentNullException("serviceProvider"); if (control == null) throw new ArgumentNullException("control"); _container = container; _serviceProvider = serviceProvider; _control = control; foreach (NiCommandBarGroup group in _container.Controls) { new GroupControl(_serviceProvider, _control, group); } _container.ItemsChanged += _container_ItemsChanged; }
public void Dispose() { if (!_disposed) { Bar.AppearanceChanged -= Bar_AppearanceChanged; if (_groupManager != null) { _groupManager.Dispose(); _groupManager = null; } if (Control != null) { Control.Dispose(); Control = null; } _disposed = true; } }