Esempio n. 1
0
        private void InitializeToolStripItem(RadToolStripItem item, RadToolStrip toolStripUnderMouseCursor)
        {
            item.Grip.ParentToolStripItem        = item;
            item.Grip.Capture                    = true;
            item.Grip.FromFloating               = true;
            item.itemsLayout.ParentToolStripItem = item;
            item.Text = this.Text;
            NotifyToolStripItemsChanged(toolStripUnderMouseCursor.ToolStripManager);
            this.toolStripManager.formList.Remove(this);

            Orientation orientation = toolStripUnderMouseCursor.ToolStripManager.Orientation;

            item.Orientation = orientation;
            RadToolStripItemControl itemControl = this.Controls[0] as RadToolStripItemControl;

            for (int j = 0; j < itemControl.Items.Count; j++)
            {
                RadItem childItem = itemControl.Items[j];

                if (orientation == Orientation.Vertical)
                {
                    if (childItem is RadComboBoxElement || childItem is RadTextBoxElement)
                    {
                        childItem.Visibility = ElementVisibility.Collapsed;
                    }
                }

                item.Items.Add(childItem);
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        private Size GetRealToolStripItemSize(RadToolStripItem toolStripItem)
        {
            Size sz = Size.Empty;

            if (toolStripItem != null)
            {
                foreach (RadItem item in toolStripItem.Items)
                {
                    if (sz.Height < item.FullBoundingRectangle.Height)
                    {
                        sz.Height = item.FullBoundingRectangle.Height;
                    }

                    if (sz.Width < item.FullBoundingRectangle.Width)
                    {
                        sz.Width = item.FullBoundingRectangle.Width;
                    }
                }
                sz.Height  = Math.Max(sz.Height, toolStripItem.MinSize.Height);
                sz.Height += toolStripItem.Margin.Bottom + toolStripItem.Margin.Top;

                sz.Width  = Math.Max(sz.Width, toolStripItem.MinSize.Width);
                sz.Width += toolStripItem.Margin.Left + toolStripItem.Margin.Right;
                if (toolStripItem.HasBorder())
                {
                    sz.Height += 2;
                    sz.Width  += 2;
                }
            }


            return(sz);
        }
Esempio n. 5
0
        private Stack <RadElement> GetItemsFromToolStripItems(RadToolStripItem toolStripItem)
        {
            Stack <RadElement> items = new Stack <RadElement>();

            for (int i = 0; i < toolStripItem.Items.Count; i++)
            {
                items.Push(toolStripItem.Items[i]);
            }
            return(items);
        }
            public OverflowDropDownMenuItem(RadItem associatedItem, RadToolStripItem toolStripItem, ImageList imageList)
            {
                this.associatedItem = associatedItem;

                this.Text = associatedItem.Text;
                if (associatedItem as RadFakeElement != null)
                {
                    this.Text = (associatedItem as RadFakeElement).AssociatedItem.Text;
                }

                if ((associatedItem as RadButtonElement) != null)
                {
                    this.Image      = (associatedItem as RadButtonElement).Image;
                    this.ImageKey   = (associatedItem as RadButtonElement).ImageKey;
                    this.ImageIndex = (associatedItem as RadButtonElement).ImageIndex;
                }

                if ((associatedItem as RadDropDownButtonElement) != null)
                {
                    this.Image      = (associatedItem as RadDropDownButtonElement).Image;
                    this.ImageKey   = (associatedItem as RadDropDownButtonElement).ImageKey;
                    this.ImageIndex = (associatedItem as RadDropDownButtonElement).ImageIndex;
                }

                if (associatedItem as RadFakeElement != null)
                {
                    if ((associatedItem as RadFakeElement).AssociatedItem as RadButtonElement != null)
                    {
                        this.Image      = ((associatedItem as RadFakeElement).AssociatedItem as RadButtonElement).Image;
                        this.ImageIndex = ((associatedItem as RadFakeElement).AssociatedItem as RadButtonElement).ImageIndex;
                        this.ImageKey   = ((associatedItem as RadFakeElement).AssociatedItem as RadButtonElement).ImageKey;
                    }

                    if ((associatedItem as RadFakeElement).AssociatedItem as RadDropDownButtonElement != null)
                    {
                        this.Image      = ((associatedItem as RadFakeElement).AssociatedItem as RadDropDownButtonElement).Image;
                        this.ImageIndex = ((associatedItem as RadFakeElement).AssociatedItem as RadDropDownButtonElement).ImageIndex;
                        this.ImageKey   = ((associatedItem as RadFakeElement).AssociatedItem as RadDropDownButtonElement).ImageKey;
                    }
                }

                if (associatedItem.Text == "")
                {
                    if (toolStripItem.Text != "")
                    {
                        this.Text = toolStripItem.Text;
                    }
                    else
                    {
                        this.Text = RadToolStripLocalizationProvider.CurrentProvider.GetLocalizationString(
                            RadToolStripLocalizationStringId.NoTextAssociated);
                    }
                }
            }
 /// <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();
 }
Esempio n. 8
0
        private void AddCheckToListBox(RadToolStripItem item, FloatingForm form, RadToolStripManager manager)
        {
            CheckItem checkBox = new CheckItem(item, form, manager);

            checkBox.Alignment       = ContentAlignment.MiddleLeft;
            this.radListBox1.Visible = true;

            if (item != null)
            {
                if (item.Text == "")
                {
                    return;
                }

                checkBox.Text = item.Text;
                if (item.Visibility == ElementVisibility.Visible)
                {
                    checkBox.ToggleState = ToggleState.On;
                }
                else
                {
                    checkBox.ToggleState = ToggleState.Off;
                }
            }
            else if (form != null)
            {
                checkBox.Text = form.Text;
                if (form.Visible)
                {
                    checkBox.ToggleState = ToggleState.On;
                }
                else
                {
                    checkBox.ToggleState = ToggleState.Off;
                }
            }

            checkBox.MinSize = new Size(150, 20);
            checkBox.Click  += new EventHandler(checkBox_Click);

            if (!this.radListBox1.Items.Contains(checkBox))
            {
                this.radListBox1.Items.Add(checkBox);
            }
        }
Esempio n. 9
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);
        }
Esempio n. 10
0
 public ToolStripDragEventArgs(RadToolStripElement currentRow, RadToolStripItem currentToolStripItem)
 {
     this.currentRow           = currentRow;
     this.currentToolStripItem = currentToolStripItem;
 }
Esempio n. 11
0
 public CheckItem(RadToolStripItem item, FloatingForm form, RadToolStripManager manager)
 {
     this.associatedItem    = item;
     this.associatedForm    = form;
     this.associatedManager = manager;
 }
Esempio n. 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;
                }
            }
        }
Esempio n. 13
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);
        }
Esempio n. 14
0
        private void PerformDocking()
        {
            RadToolStrip     toolStripUnderMouseCursor = null;
            RadToolStripItem item = new RadToolStripItem();

            if (this.directionToResize == ResizeDirection.None)
            {
                for (int i = 0; i < toolStripManager.DockingSites.Count; i++)
                {
                    toolStripUnderMouseCursor = toolStripManager.DockingSites[i] as RadToolStrip;
                    toolStripUnderMouseCursor.Focus();
                    if (toolStripUnderMouseCursor.ToolStripManager.Orientation == Orientation.Horizontal)
                    {
                        toolStripUnderMouseCursor.ToolStripManager.resizeTimer.Interval = 10;
                    }
                    else
                    {
                        toolStripUnderMouseCursor.ToolStripManager.resizeTimer.Interval = 10;
                    }

                    Rectangle rangeRect = toolStripUnderMouseCursor.RectangleToScreen(toolStripUnderMouseCursor.ClientRectangle);

                    int edgeOffset = 20;
                    if (toolStripUnderMouseCursor.ToolStripManager.Orientation == Orientation.Horizontal)
                    {
                        rangeRect = new Rectangle(rangeRect.X, rangeRect.Y - edgeOffset, rangeRect.Width, rangeRect.Height + 2 * edgeOffset);
                    }
                    else
                    {
                        rangeRect = new Rectangle(rangeRect.X - edgeOffset, rangeRect.Y, rangeRect.Width + edgeOffset, rangeRect.Height);
                    }


                    if (rangeRect.Height == 0)
                    {
                        rangeRect = new Rectangle(rangeRect.X, rangeRect.Y, rangeRect.Width, rangeRect.Height + edgeOffset);
                    }
                    else
                    if (rangeRect.Width == 0)
                    {
                        rangeRect = new Rectangle(rangeRect.X - edgeOffset, rangeRect.Y, rangeRect.Width + 2 * edgeOffset, rangeRect.Height);
                    }
                    if (this.Controls.Count > 0)
                    {
                        if ((this.Controls[0] as RadToolStripItemControl).Items.Count > 0)
                        {
                            if (rangeRect.Contains(Cursor.Position))
                            {
                                item.FloatingFormPreferredSize = this.Size;
                                item.ShrinkWidths = this.shrinkWidths;
                                item.FloatingCloseButton.Visible    = this.Controls[1].Visible;
                                item.FloatingOverFlowButton.Visible = this.Controls[2].Visible;

                                InsertToAppropriatePosition(toolStripUnderMouseCursor.ToolStripManager, item, rangeRect);
                                item.Key = this.Key;

                                this.InitializeToolStripItem(item, toolStripUnderMouseCursor);
                                this.Capture = false;
                                this.Controls.Clear();

                                this.Close();
                            }
                        }
                    }
                }
            }
        }
Esempio n. 15
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;
                }
            }
        }