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); }
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; } } }
/// <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; } } }