示例#1
0
        private int GetTotalHeightOfItems(RadToolStripItem item)
        {
            RadToolStripElement _element = null;
            int height = -1;

            foreach (RadToolStripElement element in this.Items)
            {
                if (element.Items.Contains(item))
                {
                    _element = element;
                }
            }

            if (_element != null)
            {
                foreach (RadToolStripItem _item in _element.Items)
                {
                    if (_item.Visibility == ElementVisibility.Visible)
                    {
                        height += _item.FullBoundingRectangle.Height;
                    }
                }
            }

            return(height);
        }
示例#2
0
        private int GetTotalWidthOfItems(RadToolStripItem item)
        {
            if (item.Visibility == ElementVisibility.Collapsed)
            {
                return(0);
            }

            RadToolStripElement _element = null;
            int width = -1;

            foreach (RadToolStripElement element in this.Items)
            {
                if (element.Items.Contains(item))
                {
                    _element = element;
                }
            }

            if (_element != null)
            {
                foreach (RadToolStripItem _item in _element.Items)
                {
                    if (_item.Visibility == ElementVisibility.Visible)
                    {
                        width += _item.FullBoundingRectangle.Width;
                    }
                }
            }

            return(width);
        }
示例#3
0
        private void radButton4_Click(object sender, EventArgs e)
        {
            int count = 0;

            foreach (CheckItem item in this.radListBox1.Items)
            {
                if (!(item.ToggleState == ToggleState.On))
                {
                    count++;
                }
            }

            if (count > 0)
            {
                DialogResult d = MessageBox.Show(
                    RadToolStripLocalizationProvider.CurrentProvider.GetLocalizationString(RadToolStripLocalizationStringId.ResetToolBarsAlertMessage)
                    , "RadToolStrip", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

                if (d == DialogResult.OK)
                {
                    foreach (CheckItem item in this.radListBox1.Items)
                    {
                        RadToolStripManager manager = item.AssociatedManager;
                        manager.SuspendLayout();

                        for (int i = 0; i < manager.elementList.Count; i++)
                        {
                            RadToolStripElement element = manager.elementList[i] as RadToolStripElement;
                            if (element != null && element.Items.Contains(item.AssociatedItem))
                            {
                                element.Orientation = manager.Orientation;
                                manager.Items.Add(element);
                                manager.elementList.Remove(element);
                                break;
                            }
                        }

                        manager.ResumeLayout(false);

                        if (item.AssociatedItem != null)
                        {
                            item.AssociatedItem.Visibility = ElementVisibility.Visible;
                            item.AssociatedItem.Margin     = new Padding(0, 0, 0, 0);
                            item.ToggleState = ToggleState.On;
                        }
                        else if (item.AssociatedForm != null)
                        {
                            item.AssociatedForm.Show();
                            item.ToggleState = ToggleState.On;
                        }
                    }
                }
            }
        }
示例#4
0
 private void items_ItemsChanged(RadItemCollection changed, RadItem tartet, ItemsChangeOperation operation)
 {
     if (operation == ItemsChangeOperation.Inserted)
     {
         RadToolStripElement element = tartet as RadToolStripElement;
         if (element != null)
         {
             element.Orientation = this.Orientation;
         }
     }
 }
示例#5
0
        private int VisibleItemsOnRow(RadToolStripElement element)
        {
            int i = 0;

            foreach (RadToolStripItem item in element.Items)
            {
                if (item.Visibility == ElementVisibility.Visible)
                {
                    i++;
                }
            }
            return(i);
        }
 /// <summary>
 /// Initializes the overflow drop down button with the ToolStripItem owner of the
 /// ToolStripItemsOverFlow instance and the parent element.
 /// </summary>
 public void InitializeOverflowDropDown(RadToolStripItem toolStripItem)
 {
     this.items                 = toolStripItem.Items;
     this.toolStripItem         = toolStripItem;
     this.dropDownButton        = new RadToolStripOverFlowButtonElement();
     this.DropDownButton.Click += new EventHandler(DropDownButton_Click);
     this.DropDownButton.ZIndex = 10000;
     this.DropDownButton.SetValue(ToolStripItemLayout.IsOverFlowButtonElementProperty, true);
     this.DropDownButton.Margin    = new System.Windows.Forms.Padding(0, 0, 0, 0);
     this.DropDownButton.Alignment = ContentAlignment.TopLeft;
     this.lastParent      = this.toolStripItem.ParentToolStripElement;
     this.hiddenItems     = new Stack <RadItem>();
     this.hiddenItemsList = new ArrayList();
     this.fakeItemsList   = new ArrayList();
 }
示例#7
0
        private int GetElementPreferredWidth(RadToolStripElement element)
        {
            int width         = 0;
            int valueToReturn = 0;

            foreach (RadToolStripItem item in element.Items)
            {
                if (width < GetRealToolStripItemSize(item).Width)
                {
                    width = GetRealToolStripItemSize(item).Width;
                }
            }

            valueToReturn = width + element.Margin.Left + element.Margin.Right;
            //		if (element.HasBorder()) valueToReturn += 2;
            return(Math.Max((element.MinSize.Width + element.Margin.Left + element.Margin.Right), valueToReturn));
        }
示例#8
0
        private int GetElementPreferredHeight(RadToolStripElement element)
        {
            int height        = 0;
            int valueToReturn = 0;

            foreach (RadToolStripItem item in element.Items)
            {
                if (height < GetRealToolStripItemSize(item).Height)
                {
                    height = GetRealToolStripItemSize(item).Height;
                }
            }

            valueToReturn = height + element.Margin.Top + element.Margin.Bottom;
            if (element.HasBorder())
            {
                valueToReturn += 2;
            }
            return(Math.Max((element.MinSize.Height + element.Margin.Top + element.Margin.Bottom), valueToReturn));
        }
        /// <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;
            }
        }
示例#10
0
        public override ControlStyleBuilderInfoList GetThemeDesignedControls(Control previewSurface)
        {
            RadToolStripElement element = new RadToolStripElement();

            element.Size         = new Size(600, element.Size.Height);
            element.AutoSizeMode = RadAutoSizeMode.WrapAroundChildren;
            RadToolStripItem item = new RadToolStripItem();

            item.Size         = new Size(600, item.Size.Height);
            item.AutoSizeMode = RadAutoSizeMode.WrapAroundChildren;
            element.Items.Add(item);
            item.Items.Add(new RadButtonElement("one"));
            item.Items.Add(new RadDropDownButtonElement());
            item.Items.Add(new RadToolStripSeparatorItem());
            item.Items.Add(new RadToggleButtonElement());
            item.Items.Add(new RadRepeatButtonElement());
            item.Items.Add(new RadImageButtonElement());
            item.Items.Add(new RadRadioButtonElement());
            item.Items.Add(new RadCheckBoxElement());
            item.Items.Add(new RadTextBoxElement());
            item.Items.Add(new RadMaskedEditBoxElement());
            item.Items.Add(new RadSplitButtonElement());
            item.Items.Add(new RadApplicationMenuButtonElement());

            RadComboBoxElement combo = new RadComboBoxElement();

            combo.AutoSizeMode = RadAutoSizeMode.WrapAroundChildren;
            item.Items.Add(combo);

            RadTextBoxElement textBoxElement = new RadTextBoxElement();

            textBoxElement.AutoSizeMode = RadAutoSizeMode.WrapAroundChildren;
            item.Items.Add(textBoxElement);

            RadToolStrip toolStrip = new RadToolStrip();

            toolStrip.BeginInit();
            toolStrip.AutoSize = false;

            toolStrip.Bounds = new Rectangle(30, 30, 400, 50);
            toolStrip.Items.Add(element);
            toolStrip.AllowFloating = false;
            toolStrip.AllowDragging = false;
            toolStrip.EndInit();

            RadToolStrip toolStripStructure = new RadToolStrip();

            toolStripStructure.BeginInit();
            toolStripStructure.AllowDragging = false;
            toolStripStructure.AllowFloating = false;
            toolStripStructure.AutoSize      = false;

            RadToolStripElement structureElement = new RadToolStripElement();

            structureElement.Size         = new Size(600, structureElement.Size.Height);
            structureElement.AutoSizeMode = RadAutoSizeMode.WrapAroundChildren;
            RadToolStripItem structureItem = new RadToolStripItem();

            structureItem.Size         = new Size(600, structureItem.Size.Height);
            structureItem.AutoSizeMode = RadAutoSizeMode.WrapAroundChildren;

            structureElement.Items.Add(structureItem);
            structureItem.Items.Add(new RadButtonElement("one"));
            structureItem.Items.Add(new RadDropDownButtonElement());
            structureItem.Items.Add(new RadToolStripSeparatorItem());
            structureItem.Items.Add(new RadToggleButtonElement());
            structureItem.Items.Add(new RadRepeatButtonElement());
            structureItem.Items.Add(new RadImageButtonElement());
            structureItem.Items.Add(new RadRadioButtonElement());
            structureItem.Items.Add(new RadCheckBoxElement());
            structureItem.Items.Add(new RadTextBoxElement());
            structureItem.Items.Add(new RadMaskedEditBoxElement());
            structureItem.Items.Add(new RadSplitButtonElement());
            structureItem.Items.Add(new RadApplicationMenuButtonElement());
            combo = new RadComboBoxElement();
            combo.AutoSizeMode = RadAutoSizeMode.WrapAroundChildren;
            structureItem.Items.Add(combo);

            textBoxElement = new RadTextBoxElement();
            textBoxElement.AutoSizeMode = RadAutoSizeMode.WrapAroundChildren;
            structureItem.Items.Add(textBoxElement);

            toolStripStructure.Bounds = new Rectangle(30, 30, 450, 50);

            toolStripStructure.Items.Add(structureElement);

            toolStripStructure.EndInit();

            ControlStyleBuilderInfo designed = new ControlStyleBuilderInfo(toolStrip, toolStripStructure.RootElement);

            designed.MainElementClassName = typeof(RadToolStripElement).FullName;
            ControlStyleBuilderInfoList res = new ControlStyleBuilderInfoList();

            res.Add(designed);

            return(res);
        }
示例#11
0
 public ToolStripDragEventArgs(RadToolStripElement currentRow, RadToolStripItem currentToolStripItem)
 {
     this.currentRow           = currentRow;
     this.currentToolStripItem = currentToolStripItem;
 }
示例#12
0
        private void checkBox_Click(object sender, EventArgs e)
        {
            RadToolStripManager manager = (sender as CheckItem).AssociatedManager;
            CheckItem           item    = sender as CheckItem;
            RadToolStripItem    strip   = item.AssociatedItem;

            if (strip != null)
            {
                if (strip.Visibility == ElementVisibility.Collapsed)
                {
                    for (int i = 0; i < manager.elementList.Count; i++)
                    {
                        RadToolStripElement element = manager.elementList[i] as RadToolStripElement;
                        if (element != null && element.Items.Contains(strip))
                        {
                            element.Orientation = manager.Orientation;
                            manager.Items.Add(element);
                            manager.elementList.Remove(element);
                            break;
                        }
                    }

                    strip.Visibility = ElementVisibility.Visible;
                    strip.Margin     = new Padding(0, 0, 0, 0);
                    strip.InvalidateLayout();
                }
                else
                {
                    strip.Visibility = ElementVisibility.Collapsed;
                    strip.Margin     = new Padding(0, 0, 0, 0);
                    strip.InvalidateLayout();

                    foreach (RadToolStripElement element in manager.Items)
                    {
                        if (element.Items.Contains(strip))
                        {
                            if (VisibleItemsOnRow(element) == 0)
                            {
                                RadToolStripElement myElement = new RadToolStripElement();
                                foreach (RadToolStripItem currentItem in element.Items)
                                {
                                    currentItem.ParentToolStripElement      = myElement;
                                    currentItem.Grip.ParentToolStripElement = myElement;
                                    myElement.Items.Add(currentItem);
                                }

                                manager.elementList.Add(myElement);

                                manager.Items.Remove(element);
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                if (item.AssociatedForm.Visible)
                {
                    item.AssociatedForm.Visible = false;
                }
                else
                {
                    item.AssociatedForm.Visible = true;
                }
            }
        }
 public ToolStripChangedEventArgs(RadToolStripElement oldValue, RadToolStripElement newValue)
 {
     this.oldValue = oldValue;
     this.newValue = newValue;
 }
示例#14
0
        private void InsertToAppropriatePosition(RadToolStripManager toolStripManager, RadToolStripItem item, Rectangle rangeRect)
        {
            toolStripManager.SuspendLayout();
            if (toolStripManager.Items.Count > 0)
            {
                if (toolStripManager.Orientation == Orientation.Horizontal)
                {
                    RadToolStripElement element    = new RadToolStripElement();
                    Rectangle           topRect    = new Rectangle(rangeRect.X, rangeRect.Y, rangeRect.Width, 25);
                    Rectangle           bottomRect = new Rectangle(rangeRect.X, rangeRect.Bottom - 25, rangeRect.Width, 25);

                    if ((topRect.Contains(this.Location)) && (toolStripManager.parentAutoSize))
                    {
                        toolStripManager.Items.Insert(0, element);
                        element.Items.Add(item);
                        item.InvalidateLayout();
                    }
                    else
                    {
                        if (bottomRect.Contains(this.Location) && toolStripManager.parentAutoSize)
                        {
                            toolStripManager.Items.Add(element);
                            element.Items.Add(item);
                            item.InvalidateLayout();
                        }
                        else
                        {
                            (toolStripManager.Items[0] as RadToolStripElement).Items.Add(item);
                            item.InvalidateLayout();
                        }
                    }
                }
                else
                {
                    RadToolStripElement element = new RadToolStripElement();
                    element.Orientation = Orientation.Vertical;
                    Rectangle leftRect  = new Rectangle(rangeRect.X - 25, rangeRect.Y, 25, rangeRect.Height);
                    Rectangle rightRect = new Rectangle(rangeRect.Right - 25, rangeRect.Y, 25, rangeRect.Height);

                    if (leftRect.Contains(this.Location) && toolStripManager.parentAutoSize)
                    {
                        toolStripManager.Items.Insert(0, element);
                        element.Items.Add(item);
                        item.InvalidateLayout();
                    }
                    else
                    {
                        if (rightRect.Contains(this.Location) && toolStripManager.parentAutoSize)
                        {
                            toolStripManager.Items.Add(element);
                            element.Items.Add(item);
                            item.InvalidateLayout();
                        }
                        else
                        {
                            (toolStripManager.Items[0] as RadToolStripElement).Items.Add(item);
                            item.InvalidateLayout();
                        }
                    }
                }
            }
            else
            {
                RadToolStripElement element = new RadToolStripElement();
                toolStripManager.Items.Add(element);
                (toolStripManager.Items[0] as RadToolStripElement).Items.Add(item);
                item.InvalidateLayout();
            }
            if (this.fadeTimer != null)
            {
                this.fadeTimer.Stop();
            }

            if (this.fadeStartTimer != null)
            {
                this.fadeStartTimer.Stop();
            }

            if (this.backFadeTimer != null)
            {
                this.backFadeTimer.Stop();
            }

            toolStripManager.ResumeLayout(true);
        }
示例#15
0
        protected override void OnPropertyChanged(RadPropertyChangedEventArgs e)
        {
            if (e.Property == ShowOverflowButtonProperty)
            {
                bool value = (bool)e.NewValue;

                ElementVisibility visible;
                if (value)
                {
                    visible = ElementVisibility.Visible;
                }
                else
                {
                    visible = ElementVisibility.Hidden;
                }

                foreach (RadToolStripElement toolStripElement in this.Items)
                {
                    foreach (RadToolStripItem item in toolStripElement.Items)
                    {
                        item.OverflowManager.DropDownButton.Visibility = visible;
                    }
                }
            }

            if (e.Property == ToolStripOrientationProperty)
            {
                Orientation newOrientation = (Orientation)e.NewValue;
                OnOrientationChanged(new ToolStripOrientationEventArgs((Orientation)e.OldValue, newOrientation));

                if (newOrientation == Orientation.Horizontal)
                {
                    this.verticalLayout.Orientation         = Orientation.Vertical;
                    this.verticalLayout.EqualChildrenHeight = false;
                    this.verticalLayout.EqualChildrenWidth  = true;
                    for (int i = 0; i < this.Items.Count; i++)
                    {
                        RadToolStripElement toolStripElement = this.Items[i] as RadToolStripElement;
                        if (toolStripElement != null)
                        {
                            toolStripElement.Orientation = Orientation.Horizontal;
                        }
                        foreach (RadElement element in toolStripElement.Items)
                        {
                            element.SetValue(ToolStripOrientationProperty, Orientation.Horizontal);
                            foreach (RadElement fillElement in element.Children)
                            {
                                fillElement.SetValue(ToolStripOrientationProperty, Orientation.Horizontal);
                            }
                        }
                    }
                }
                else
                {
                    this.verticalLayout.Orientation         = Orientation.Horizontal;
                    this.verticalLayout.EqualChildrenWidth  = false;
                    this.verticalLayout.EqualChildrenHeight = true;
                    for (int i = 0; i < this.Items.Count; i++)
                    {
                        RadToolStripElement toolStripElement = this.Items[i] as RadToolStripElement;
                        if (toolStripElement != null)
                        {
                            toolStripElement.Orientation = Orientation.Vertical;
                        }
                        foreach (RadElement element in toolStripElement.Items)
                        {
                            element.SetValue(ToolStripOrientationProperty, Orientation.Vertical);
                            foreach (RadElement fillElement in element.Children)
                            {
                                fillElement.SetValue(ToolStripOrientationProperty, Orientation.Vertical);
                            }
                        }
                    }
                }
            }

            base.OnPropertyChanged(e);
        }
示例#16
0
        /// <summary>
        /// Toggles tool strip item visibility by a given key.
        /// </summary>
        /// <param name="key"></param>
        public void ToggleToolStripItemVisibilityByKey(string key)
        {
            object sender = GetItemByKey(key);

            if (sender as RadToolStripItem != null)
            {
                RadToolStripItem item = sender as RadToolStripItem;

                if (item.Visibility == ElementVisibility.Collapsed)
                {
                    item.Visibility = ElementVisibility.Visible;
                    item.Margin     = new Padding(0, 0, 0, 0);
                    item.InvalidateLayout();

                    for (int i = 0; i < this.elementList.Count; i++)
                    {
                        RadToolStripElement element = this.elementList[i] as RadToolStripElement;
                        if (element != null && element.Items.Contains(item))
                        {
                            element.Orientation = this.Orientation;
                            this.Items.Add(element);
                            this.elementList.Remove(element);
                            break;
                        }
                    }
                }
                else
                {
                    item.Visibility = ElementVisibility.Collapsed;

                    item.Margin = new Padding(0, 0, 0, 0);
                    item.InvalidateLayout();


                    foreach (RadToolStripElement element in this.Items)
                    {
                        if (element.Items.Contains(item))
                        {
                            if (VisibleItemsOnRow(element) == 0)
                            {
                                RadToolStripElement myElement = new RadToolStripElement();
                                foreach (RadToolStripItem currentItem in element.Items)
                                {
                                    currentItem.ParentToolStripElement      = myElement;
                                    currentItem.Grip.ParentToolStripElement = myElement;
                                    myElement.Items.Add(currentItem);
                                }

                                this.elementList.Add(myElement);

                                this.Items.Remove(element);
                            }
                            break;
                        }
                    }
                }
            }
            else
            {
                if ((sender as FloatingForm).Visible)
                {
                    (sender as FloatingForm).Visible = false;
                }
                else
                {
                    (sender as FloatingForm).Visible = true;
                }
            }
        }