Esempio n. 1
0
        public FloatingForm(RadToolStripManager toolStripManager)
        {
            InitializeComponent();

            this.VisibleChanged += new EventHandler(FloatingForm_VisibleChanged);
            this.FormBorderStyle = FormBorderStyle.None;
            this.ShowInTaskbar   = false;
            this.MaximizeBox     = false;
            this.MinimizeBox     = false;
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.Opaque, true);
            this.StartPosition     = FormStartPosition.Manual;
            this.MinimumSize       = new Size(20, 19);
            this.shrinkWidths      = new Stack <int>();
            this.toolStripManager  = toolStripManager;
            this.directionToResize = ResizeDirection.None;
            this.TopMost           = true;
            this.ForeColor         = Color.White;
            this.Font = new Font(this.Font, FontStyle.Bold);

            this.fadeTimer      = new Timer();
            this.fadeStartTimer = new Timer();
            this.backFadeTimer  = new Timer();

            this.fadeTimer.Tick      += new EventHandler(fadeTimer_Tick);
            this.fadeTimer.Interval   = 100;
            this.fadeStartTimer.Tick += new EventHandler(fadeStartTimer_Tick);
            this.backFadeTimer.Tick  += new EventHandler(backFadeTimer_Tick);
        }
Esempio n. 2
0
 private void NotifyToolStripItemsChanged(RadToolStripManager manager)
 {
     foreach (RadToolStripElement element in manager.Items)
     {
         foreach (RadToolStripItem item in element.Items)
         {
             item.OverflowManager.ManagerChanged = true;
         }
     }
 }
Esempio n. 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;
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        public ToolStripDialogForm(RadToolStripManager manager)
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
            this.ShowInTaskbar = false;
            this.MinimizeBox   = false;
            this.MaximizeBox   = false;
            this.manager       = manager;
            this.Shape         = new RoundRectShape(5);
            this.radTitleBar1.RootElement.Shape = new RoundRectShape(5);
            this.radTitleBar1.RootElement.ApplyShapeToControl = true;

            this.BorderWidth = 1;
            this.Load       += new EventHandler(ToolStripDialogForm_Load);
        }
Esempio n. 5
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. 6
0
        public override Size GetPreferredSizeCore(Size proposedSize)
        {
            Size res = base.GetPreferredSizeCore(proposedSize);

            Orientation         orientation = this.Orientation;
            RadToolStripManager tsm         = this.ParentToolStripManager;

            if (tsm != null)
            {
                orientation = tsm.Orientation;
            }

            if (orientation == Orientation.Horizontal)
            {
                res.Width = proposedSize.Width - this.LayoutEngine.GetBorderSize().Width - this.Margin.Horizontal;
            }
            else
            {
                res.Height = proposedSize.Height - this.LayoutEngine.GetBorderSize().Height - this.Margin.Vertical;
            }

            return(res);
        }
Esempio n. 7
0
        protected override void CreateChildItems(RadElement parent)
        {
            this.toolStripManager = new RadToolStripManager();
            this.toolStripManager.AutoSizeMode        = RadAutoSizeMode.WrapAroundChildren;
            this.toolStripManager.Items.ItemsChanged += new ItemChangedDelegate(Items_ItemsChanged);

            parent.Children.Add(this.toolStripManager);

            this.toolStripManager.RootElement = this.RootElement;

            this.toolStripManager.OrientationChanged +=
                delegate(object sender, ToolStripOrientationEventArgs args) { OnOrientationChanged(args); };
            this.toolStripManager.RowChanged +=
                delegate(object sender, ToolStripChangedEventArgs args) { OnRowChanged(args); };

            this.toolStripManager.DragEnded +=
                delegate(object sender, ToolStripDragEventArgs args) { OnDragEnded(args); };
            this.toolStripManager.DragEnding +=
                delegate(object sender, ToolStripDragEventArgs args) { OnDragEnding(args); };
            this.toolStripManager.DragStarted +=
                delegate(object sender, ToolStripDragEventArgs args) { OnDragStarted(args); };
            this.toolStripManager.DragStarting +=
                delegate(object sender, ToolStripDragEventArgs args) { OnDragStarting(args); };
        }
        /// <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;
            }
        }
Esempio n. 9
0
 public CheckItem(RadToolStripItem item, FloatingForm form, RadToolStripManager manager)
 {
     this.associatedItem    = item;
     this.associatedForm    = form;
     this.associatedManager = manager;
 }
Esempio n. 10
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. 11
0
        public void LoadDataInPanel()
        {
            // Note:
            // When you finish with refactoring it pls let me know
            // because I'd like to test the behavior of the control.
            // B.Markov
            if (this.manager != null)
            {
                if (this.manager.DockingSites.Count > 0)
                {
                    for (int i = 0; i < this.manager.DockingSites.Count; i++)
                    {
                        RadToolStrip        toolStrip = this.manager.DockingSites[i] as RadToolStrip;
                        RadToolStripManager manager   = toolStrip.ToolStripManager;

                        foreach (RadToolStripElement element in manager.Items)
                        {
                            foreach (RadToolStripItem item in element.Items)
                            {
                                AddCheckToListBox(item, null, manager);
                            }
                        }

                        foreach (RadToolStripElement element in manager.elementList)
                        {
                            foreach (RadToolStripItem item in element.Items)
                            {
                                AddCheckToListBox(item, null, manager);
                            }
                        }

                        foreach (FloatingForm form in manager.formList)
                        {
                            AddCheckToListBox(null, form, manager);
                        }
                    }
                }
                else
                {
                    foreach (RadToolStripElement element in this.manager.Items)
                    {
                        foreach (RadToolStripItem item in element.Items)
                        {
                            AddCheckToListBox(item, null, this.manager);
                        }
                    }
                    foreach (RadToolStripElement element in this.manager.elementList)
                    {
                        foreach (RadToolStripItem item in element.Items)
                        {
                            AddCheckToListBox(item, null, this.manager);
                        }
                    }

                    foreach (FloatingForm form in this.manager.formList)
                    {
                        AddCheckToListBox(null, form, this.manager);
                    }
                }
                this.load = true;
            }
        }
Esempio n. 12
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);
        }