protected ControlControl(IServiceProvider serviceProvider, NiCommandBarControl control, ToolStripItem item, ToolStripItemDisplayStyle defaultDisplayStyle) { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } if (control == null) { throw new ArgumentNullException("control"); } if (item == null) { throw new ArgumentNullException("item"); } NiCommand = control; Item = item; DefaultDisplayStyle = defaultDisplayStyle; Item.Tag = this; UpdateItem(); NiCommand.AppearanceChanged += Control_AppearanceChanged; }
private void CreateControl(NiCommandBarControl command) { ControlControl control; if (command is NiCommandBarButton) { control = Bar.CreateButton(_serviceProvider, (NiCommandBarButton)command); } else if (command is NiCommandBarComboBox) { control = Bar.CreateComboBox(_serviceProvider, (NiCommandBarComboBox)command); } else if (command is NiCommandBarTextBox) { control = Bar.CreateTextBox(_serviceProvider, (NiCommandBarTextBox)command); } else if (command is NiCommandBarPopup) { control = Bar.CreatePopup(_serviceProvider, (NiCommandBarPopup)command); } else if (command is NiCommandBarLabel) { control = Bar.CreateLabel(_serviceProvider, (NiCommandBarLabel)command); } else { throw new NotSupportedException(); } command.AppearanceChanged += command_AppearanceChanged; var items = Bar.Items; int insertIndex = items.Count; for (int i = items.IndexOf(Separator) + 1; i < items.Count; i++) { var otherControl = items[i].Tag as ControlControl; if ( items[i] is ToolStripSeparator || (otherControl != null && command.Priority < otherControl.NiCommand.Priority) ) { insertIndex = i; break; } } control.Item.Alignment = GetAlignment(); items.Insert(insertIndex, control.Item); Bar.Items.UpdateSeparatorVisibility(); }
public TextBoxControl(IServiceProvider serviceProvider, NiCommandBarControl control) : base(serviceProvider, control, ToolStripItemDisplayStyle.None) { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } _serviceProvider = serviceProvider; Item.Leave += (s, e) => Publish(); Item.TextChanged += (s, e) => Publish(); }
public ComboBoxControl(IServiceProvider serviceProvider, NiCommandBarControl control) : base(serviceProvider, control, ToolStripItemDisplayStyle.None) { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } _serviceProvider = serviceProvider; Item.DropDown += (s, e) => RequestValues(); Item.DropDownClosed += (s, e) => Publish(); Item.Leave += (s, e) => Publish(); Item.SelectedIndexChanged += (s, e) => Publish(); }
private bool TryGetIndexOfCommand(NiCommandBarControl command, out int index) { var items = Bar.Items; for (int i = 0; i < items.Count; i++) { var control = items[i].Tag as ControlControl; if (control != null && control.NiCommand == command) { index = i; return(true); } } index = -1; return(false); }
protected ControlControl(IServiceProvider serviceProvider, NiCommandBarControl control, ToolStripItem item, ToolStripItemDisplayStyle defaultDisplayStyle) { if (serviceProvider == null) throw new ArgumentNullException("serviceProvider"); if (control == null) throw new ArgumentNullException("control"); if (item == null) throw new ArgumentNullException("item"); NiCommand = control; Item = item; DefaultDisplayStyle = defaultDisplayStyle; Item.Tag = this; UpdateItem(); NiCommand.AppearanceChanged += Control_AppearanceChanged; }
private bool TryGetIndexOfCommand(NiCommandBarControl command, out int index) { var items = Bar.Items; for (int i = 0; i < items.Count; i++) { var control = items[i].Tag as ControlControl; if (control != null && control.NiCommand == command) { index = i; return true; } } index = -1; return false; }
private void CreateControl(NiCommandBarControl command) { ControlControl control; if (command is NiCommandBarButton) control = Bar.CreateButton(_serviceProvider, (NiCommandBarButton)command); else if (command is NiCommandBarComboBox) control = Bar.CreateComboBox(_serviceProvider, (NiCommandBarComboBox)command); else if (command is NiCommandBarTextBox) control = Bar.CreateTextBox(_serviceProvider, (NiCommandBarTextBox)command); else if (command is NiCommandBarPopup) control = Bar.CreatePopup(_serviceProvider, (NiCommandBarPopup)command); else if (command is NiCommandBarLabel) control = Bar.CreateLabel(_serviceProvider, (NiCommandBarLabel)command); else throw new NotSupportedException(); command.AppearanceChanged += command_AppearanceChanged; var items = Bar.Items; int insertIndex = items.Count; for (int i = items.IndexOf(Separator) + 1; i < items.Count; i++) { var otherControl = items[i].Tag as ControlControl; if ( items[i] is ToolStripSeparator || (otherControl != null && command.Priority < otherControl.NiCommand.Priority) ) { insertIndex = i; break; } } control.Item.Alignment = GetAlignment(); items.Insert(insertIndex, control.Item); Bar.Items.UpdateSeparatorVisibility(); }
public LabelControl(IServiceProvider serviceProvider, NiCommandBarControl control) : base(serviceProvider, control, ToolStripItemDisplayStyle.None) { }