private GroupControl GetGroupControl(NiCommandBarGroup group) { return(_control.Items .OfType <ToolStripSeparator>() .Select(p => (GroupControl)p.Tag) .Single(p => p.Group == group)); }
private GroupControl GetGroupControl(NiCommandBarGroup group) { return _control.Items .OfType<ToolStripSeparator>() .Select(p => (GroupControl)p.Tag) .Single(p => p.Group == group); }
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(); }