Ejemplo n.º 1
0
            public int Compare(object x, object y)
            {
                OverflowDropDownMenuItem item1 = (OverflowDropDownMenuItem)x;
                OverflowDropDownMenuItem item2 = (OverflowDropDownMenuItem)y;

                return(item1.AssociatedItem.Text.CompareTo(item2.AssociatedItem.Text));
            }
Ejemplo n.º 2
0
        public void PrepareDropDownItems()
        {
            DropDownButton.Items.Clear();

            foreach (RadItem item in this.items)
            {
                OverflowDropDownMenuItem corresponding = new OverflowDropDownMenuItem(item);
                corresponding.AssociatedItem = item;
                corresponding.Click         += new EventHandler(corresponding_Click);
                DropDownButton.Items.Add(corresponding);
            }
        }
Ejemplo n.º 3
0
        private void corresponding_Click(object sender, EventArgs e)
        {
            OverflowDropDownMenuItem dropDownItem = (OverflowDropDownMenuItem)sender;

            if (dropDownItem.AssociatedItem.Visibility == ElementVisibility.Visible)
            {
                dropDownItem.AssociatedItem.Visibility = ElementVisibility.Collapsed;
                if (dropDownItem.AssociatedItem as RadFakeElement != null)
                {
                    (dropDownItem.AssociatedItem as RadFakeElement).AssociatedItem.Visibility = ElementVisibility.Collapsed;
                }
                dropDownItem.IsChecked = false;
            }
            else
            {
                if (this.toolStripItem.ParentToolStripManager.Orientation == Orientation.Horizontal)
                {
                    dropDownItem.AssociatedItem.Visibility = ElementVisibility.Visible;

                    if (dropDownItem.AssociatedItem as RadFakeElement != null)
                    {
                        RefreshParentToolStrip();
                    }
                    dropDownItem.IsChecked = true;
                }
                else
                {
                    if (this.toolStripItem.ParentToolStripManager.Orientation == Orientation.Vertical)
                    {
                        if (!((dropDownItem.AssociatedItem is RadTextBoxElement) || (dropDownItem.AssociatedItem is RadComboBoxElement)))
                        {
                            if (dropDownItem.AssociatedItem as RadFakeElement != null)
                            {
                                RefreshParentToolStrip();
                            }

                            this.toolStripItem.InvalidateLayout();
                            dropDownItem.AssociatedItem.Visibility = ElementVisibility.Visible;
                            dropDownItem.IsChecked = true;
                        }
                    }
                }
            }


            RefreshItems();

            this.toolStripItem.LayoutEngine.SetLayoutInvalidated(true);
            this.toolStripItem.LayoutEngine.PerformParentLayout();
            InvalidateAllToolStripItems();
        }
Ejemplo n.º 4
0
        private void corresponding_Click(object sender, EventArgs e)
        {
            OverflowDropDownMenuItem dropDownItem = (OverflowDropDownMenuItem)sender;

            this.DropDownButton.HideDropDown();
            //Ticket ID: 296681
            //This mimics the behavior of the TabStrip when clicking on
            //item to select it. The item focuses its container control in this case.
            //Without this we do not behave the same way when selecting an item over the drop down,
            //and selecting an item by clicking on it.
            dropDownItem.AssociatedItem.SetFocus();

            this.tabStripElement.SetSelectedTab(dropDownItem.AssociatedItem);

            if (overFlowBehavior != OverFlowBehavior.VisualStudioStyle)
            {
                this.tabStripElement.ScrollIntoView((TabItem)dropDownItem.AssociatedItem);
                return;
            }
            else
            {
                if (this.tabStripElement.UseNewLayoutSystem)
                {
                    TabItem tabItem = dropDownItem.AssociatedItem as TabItem;
                    SelectTabItem(tabItem);
                }
                else
                {
                    if ((this.tabStripElement.TabsPosition == TabPositions.Top) || (this.tabStripElement.TabsPosition == TabPositions.Bottom))
                    {
                        if (dropDownItem.AssociatedItem.BoundingRectangle.Right >= this.tabStripElement.Parent.Bounds.Right)
                        {
                            RearrangeItems(dropDownItem.AssociatedItem as TabItem);
                        }
                    }
                    else
                    {
                        if (dropDownItem.AssociatedItem.BoundingRectangle.Y + dropDownItem.AssociatedItem.FullSize.Width
                            >= this.tabStripElement.Parent.Bounds.Bottom)
                        {
                            RearrangeItems(dropDownItem.AssociatedItem as TabItem);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void resetItem_Click(object sender, EventArgs e)
        {
            if (sender as OverflowDropDownMenuItem != null)
            {
                OverflowDropDownMenuItem item = (OverflowDropDownMenuItem)(sender as OverflowDropDownMenuItem).HierarchyParent;

                foreach (RadItem childItem in (item.AssociatedItem as RadToolStripItem).Items)
                {
                    if (this.toolStripItem.ParentToolStripManager.Orientation == Orientation.Vertical)
                    {
                        if (!((childItem is RadTextBoxElement) || (childItem is RadComboBoxElement)))
                        {
                            childItem.Visibility = ElementVisibility.Visible;
                        }
                    }
                    else
                    {
                        childItem.Visibility = ElementVisibility.Visible;
                    }
                }
                (item.AssociatedItem as RadToolStripItem).InvalidateLayout();
                for (int i = 0; i < item.Items.Count; i++)
                {
                    OverflowDropDownMenuItem myItem = item.Items[i] as OverflowDropDownMenuItem;
                    if (myItem != null)
                    {
                        myItem.IsChecked = true;
                    }
                }

                (sender as OverflowDropDownMenuItem).IsChecked = false;
            }

            toolStripItem.LayoutEngine.SetLayoutInvalidated(true);
            toolStripItem.LayoutEngine.PerformParentLayout();
            InvalidateAllToolStripItems();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes the drop down behavior of the drop down items.
        /// </summary>
        public void PrepareDropDownItems()
        {
            this.lastParent  = this.toolStripItem.ParentToolStripElement;
            this.lastManager = this.toolStripItem.ParentToolStripManager;

            this.DropDownButton.Items.Clear();
            if (this.toolStripItem.ElementTree != null)
            {
                this.imageList = this.toolStripItem.ElementTree.ComponentTreeHandler.ImageList;
            }
            RadItem addOrRemoveItem = new RadItem();

            addOrRemoveItem.Text = RadToolStripLocalizationProvider.CurrentProvider.GetLocalizationString(
                RadToolStripLocalizationStringId.AddorRemoveButtons);

            this.CreateStackOverflowBehavior();
            this.InvalidateAllToolStripItems();

            this.rootItem           = new OverflowDropDownMenuItem(addOrRemoveItem, this.toolStripItem, this.imageList);
            rootItem.AssociatedItem = addOrRemoveItem;
            this.DropDownButton.Items.Add(rootItem);

            Graphics g = this.toolStripItem.ElementTree.Control.CreateGraphics();

            SizeF stringSize = g.MeasureString(addOrRemoveItem.Text, addOrRemoveItem.Font);

            this.layout.MinSize = new Size((int)stringSize.Width, 0);
            this.layout.MaxSize = new Size(this.layout.MinSize.Width, 0);
            g.Dispose();

            foreach (RadToolStripItem toolItem in this.toolStripItem.ParentToolStripElement.Items)
            {
                OverflowDropDownMenuItem corresponding = new OverflowDropDownMenuItem(toolItem, this.toolStripItem, this.imageList);
                corresponding.AssociatedItem = toolItem;

                foreach (RadItem item in toolItem.Items)
                {
                    OverflowDropDownMenuItem correspondingItem = new OverflowDropDownMenuItem(item, toolItem, this.imageList);

                    correspondingItem.AssociatedItem = item;
                    correspondingItem.Click         += new EventHandler(corresponding_Click);

                    if (item.Visibility == ElementVisibility.Visible)
                    {
                        correspondingItem.IsChecked = true;
                        this.visibleItemsCount++;
                    }
                    else
                    {
                        correspondingItem.IsChecked = false;
                    }

                    corresponding.Items.Add(correspondingItem);
                }

                corresponding.Items.Add(new RadMenuSeparatorItem());

                RadItem myItem = new RadItem();
                myItem.Text = RadToolStripLocalizationProvider.CurrentProvider.GetLocalizationString(RadToolStripLocalizationStringId.ResetToolBar);

                resetItem = new OverflowDropDownMenuItem(myItem, this.toolStripItem, this.imageList);


                resetItem.AssociatedItem = myItem;
                resetItem.Click         += new EventHandler(resetItem_Click);

                corresponding.Items.Add(resetItem);

                rootItem.Items.Add(corresponding);
            }

            RadItem customizeItem = new RadItem();

            customizeItem.Text = RadToolStripLocalizationProvider.CurrentProvider.GetLocalizationString(RadToolStripLocalizationStringId.Customize);

            CustomizeItem = new OverflowDropDownMenuItem(customizeItem, this.toolStripItem, this.imageList);

            CustomizeItem.AssociatedItem = customizeItem;
            CustomizeItem.Click         += new EventHandler(CustomizeItem_Click);

            rootItem.Items.Add(new RadMenuSeparatorItem());
            rootItem.Items.Add(CustomizeItem);

            if (!this.showRootItem)
            {
                rootItem.Visibility = ElementVisibility.Collapsed;
            }

            if (!this.showCustomizeItem)
            {
                this.CustomizeItem.Visibility = ElementVisibility.Collapsed;
            }

            if (!this.showResetItem)
            {
                this.CustomizeItem.Visibility = ElementVisibility.Collapsed;
            }
        }