コード例 #1
0
        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;
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
ファイル: ComboBoxControl.cs プロジェクト: vector-man/netide
        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();
        }
コード例 #5
0
        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);
        }
コード例 #6
0
ファイル: ControlControl.cs プロジェクト: netide/netide
        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;
        }
コード例 #7
0
ファイル: GroupControl.cs プロジェクト: netide/netide
        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;
        }
コード例 #8
0
ファイル: GroupControl.cs プロジェクト: netide/netide
        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();
        }
コード例 #9
0
 public LabelControl(IServiceProvider serviceProvider, NiCommandBarControl control)
     : base(serviceProvider, control, ToolStripItemDisplayStyle.None)
 {
 }