예제 #1
0
 private GroupControl GetGroupControl(NiCommandBarGroup group)
 {
     return(_control.Items
            .OfType <ToolStripSeparator>()
            .Select(p => (GroupControl)p.Tag)
            .Single(p => p.Group == group));
 }
예제 #2
0
 private GroupControl GetGroupControl(NiCommandBarGroup group)
 {
     return _control.Items
         .OfType<ToolStripSeparator>()
         .Select(p => (GroupControl)p.Tag)
         .Single(p => p.Group == group);
 }
예제 #3
0
        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();
        }
예제 #4
0
        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();
        }