internal RibbonDropDown( RibbonItem parentItem, IEnumerable<RibbonItem> items, Ribbon ownerRibbon) : this(parentItem, items, ownerRibbon, RibbonElementSizeMode.DropDown) { }
internal RibbonDropDown( RibbonItem parentItem, IEnumerable<RibbonItem> items, Ribbon ownerRibbon, RibbonElementSizeMode measuringSize) : this() { _items = items; _ownerRibbon = ownerRibbon; _sizingGripHeight = 12; _parentItem = parentItem; _sensor = new RibbonSensor(this, OwnerRibbon, items); _MeasuringSize = measuringSize; if (Items != null) foreach (RibbonItem item in Items) { item.SetSizeMode(RibbonElementSizeMode.DropDown); item.SetCanvas(this); } UpdateSize(); UpdateItemsBounds(); }
public RibbonItemBoundsEventArgs(Ribbon owner, Graphics g, Rectangle clip, RibbonItem item, Rectangle bounds) : base(owner, g, clip, item) { Bounds = bounds; }
public RibbonItemRenderEventArgs(Ribbon owner, Graphics g, Rectangle clip, RibbonItem item) : base(owner, g, clip) { Item = item; }
/// <summary> /// Selects the specified item as the currently selected sub-item /// </summary> /// <param name="item"></param> private void SetSelectedSubItem(RibbonItem item) { if (item == _lastSelectedSubItem) return; if (_lastSelectedSubItem != null) { _lastSelectedSubItem.SetSelected(false); RedrawItem(_lastSelectedSubItem, GetContentBounds(_lastSelectedSubItemParent)); } if (item != null) { item.SetSelected(true); RedrawItem(item, GetContentBounds(_lastSelectedSubItemParent)); } _lastSelectedSubItem = item; }
/// <summary> /// Selects the specified item as the currently selected item /// </summary> /// <param name="item"></param> private void SetSelectedItem(RibbonItem item) { if (item == _lastSelectedItem) return; if (_lastSelectedItem != null) { _lastSelectedItem.SetSelected(false); RedrawItem(_lastSelectedItem); } if (item != null) { item.SetSelected(true); RedrawItem(item); } _lastSelectedItem = item; }
/// <summary> /// Redraws the specified item, intersected by the specified rectangle /// </summary> /// <param name="item"></param> /// <param name="clipIntersect"></param> private void RedrawItem(RibbonItem item, Rectangle clipIntersect) { Rectangle clip = Rectangle.FromLTRB( item.Bounds.Left, item.Bounds.Top, item.Bounds.Right + 1, item.Bounds.Bottom + 1); if (clipIntersect.IsEmpty) { clip = (item.Bounds); } else { clip = (Rectangle.Intersect(item.Bounds, clipIntersect)); } Control.Invalidate(clip); }
/// <summary> /// /// </summary> /// <param name="item"></param> /// <param name="clipIntersect"></param> private void RedrawItem(RibbonItem item) { RedrawItem(item, Rectangle.Empty); }
/// <summary> /// Tries to extract from IContainsRibbonItems.GetContentBounds() /// </summary> /// <param name="item"></param> /// <returns></returns> private Rectangle GetContentBounds(RibbonItem item) { IContainsSelectableRibbonItems cont = item as IContainsSelectableRibbonItems; if (cont == null) { return Rectangle.Empty; } else { return cont.GetContentBounds(); } }
/// <summary> /// Senses the mouse button up /// </summary> /// <param name="e"></param> public void SenseMouseUp(System.Windows.Forms.MouseEventArgs e) { if (Disposed) throw new ObjectDisposedException(GetType().Name); RibbonPanel mouseUpPanel = null; RibbonItem mouseUpItem = null; RibbonPanel hittedPanel = null; RibbonItem hittedItem = null; if (!SenseOnlyItems) { if (MouseUpTabScroll(e.X, e.Y)) return; ///Check for the selected panel if (Tab.TabContentBounds.Contains(e.X, e.Y) || PanelLimit != null) { foreach (RibbonPanel panel in GetPanelsToSense()) { if (panel.Bounds.Contains(e.X, e.Y)) { hittedPanel = panel; if (PanelLimit == null || PanelLimit == hittedPanel) { mouseUpPanel = panel; panel.OnMouseUp(e); } break; } } } if (mouseUpPanel != null && mouseUpPanel == _mouseDownPanel) { _mouseDownPanel = null; mouseUpPanel.OnClick(EventArgs.Empty); } if (hittedPanel != null) { hittedPanel.OnMouseUp(e); } } ///Check for the selected item if (hittedPanel != null || SenseOnlyItems) { IEnumerable<RibbonItem> items = SenseOnlyItems ? ItemsToSense : hittedPanel.Items; foreach (RibbonItem item in items) { if (item.Bounds.Contains(e.X, e.Y)) { item.OnMouseUp(e); hittedItem = item; mouseUpItem = item; RedrawItem(item); break; } } } ///Check for sub-items on the item ///(This should be recursive, but it's not necessary so far) if (hittedItem != null && hittedItem is IContainsSelectableRibbonItems) { foreach (RibbonItem item in (hittedItem as IContainsSelectableRibbonItems).GetItems()) { if (item.Bounds.Contains(e.X, e.Y)) { item.OnMouseUp(e); mouseUpItem = item; RedrawItem(item, GetContentBounds(hittedItem)); break; } } } if (mouseUpItem == _mouseDownItem && mouseUpItem != null) { _mouseDownItem = null; mouseUpItem.OnClick(EventArgs.Empty); } }
/// <summary> /// Senses the movement of the mouse /// </summary> /// <param name="e"></param> public void SenseMouseMove(System.Windows.Forms.MouseEventArgs e) { if (Disposed) throw new ObjectDisposedException(GetType().Name); RibbonPanel hittedPanel = null; RibbonItem hittedItem = null; RibbonItem hittedSubItem = null; bool subItemChanged = false; if (!SenseOnlyItems) { if (MouseMoveTabScroll(e.X, e.Y)) return; ///Check for the selected panel if (Tab.TabContentBounds.Contains(e.X, e.Y) || PanelLimit != null) { foreach (RibbonPanel panel in GetPanelsToSense()) { if (panel.Bounds.Contains(e.X, e.Y)) { SetSelectedPanel(panel, e.X, e.Y); if (panel.PopUp != null) { hittedPanel = panel; } hittedPanel = panel; break; } } } if (hittedPanel != null) hittedPanel.OnMouseMove(e); ///If no panel, unselect last panel if (hittedPanel == null && _lastSelectedPanel != null) { SetSelectedPanel(null, e.X, e.Y); SetSelectedItem(null); SetSelectedSubItem(null); } } ///Check for the selected item if ((hittedPanel != null && (hittedPanel.SizeMode != RibbonElementSizeMode.Overflow || hittedPanel.PopUp != null)) || SenseOnlyItems) { IEnumerable<RibbonItem> items = SenseOnlyItems ? ItemsToSense : hittedPanel.Items; foreach (RibbonItem item in items) { if (item.Bounds.Contains(e.X, e.Y)) { if (item != _lastSelectedSubItemParent) SetSelectedSubItem(null); SetSelectedItem(item); hittedItem = item; break; } } } ///Check for sub-items on the item ///(This should be recursive, but it's not necessary so far) if (hittedItem != null && hittedItem is IContainsSelectableRibbonItems) { foreach (RibbonItem item in (hittedItem as IContainsSelectableRibbonItems).GetItems()) { if (item.Bounds.Contains(e.X, e.Y)) { _lastSelectedSubItemParent = hittedItem; subItemChanged = item != _lastSelectedSubItem; SetSelectedSubItem(item); hittedSubItem = item; break; } } } ///if no hitted item, unselect last item if (hittedItem == null && _lastSelectedItem != null) { SetSelectedItem(null); SetSelectedSubItem(null); } if (hittedPanel != null) { hittedPanel.OnMouseMove(e); } if (hittedItem != null) hittedItem.OnMouseMove(e); ///If no hitted sub-item, unselect last item if ((hittedSubItem == null && _lastSelectedSubItem != null)) { SetSelectedSubItem(null); } if(hittedSubItem != null) hittedSubItem.OnMouseMove(e); }
/// <summary> /// Inserts the specified item at the desired index /// </summary> /// <param name="index">Desired index of the item</param> /// <param name="item">Item to insert</param> public new void Insert(int index, RibbonItem item) { CheckRestrictions(item as RibbonButton); item.SetOwner(Owner); item.SetOwnerPanel(OwnerPanel); item.SetOwnerTab(OwnerTab); base.Insert(index, item); }
/// <summary> /// Inserts the specified item at the desired index /// </summary> /// <param name="index">Desired index of the item</param> /// <param name="item">Item to insert</param> public new void Insert(int index, RibbonItem item) { item.MaxSizeMode = RibbonElementSizeMode.Compact; item.SetOwnerGroup(OwnerGroup); base.Insert(index, item); }
/// <summary> /// Adds the specified item to the collection /// </summary> public new void Add(RibbonItem item) { item.MaxSizeMode = RibbonElementSizeMode.Compact; item.SetOwnerGroup(OwnerGroup); base.Add(item); }
/// <summary> /// Sets the value of the OwnerList property /// </summary> /// <param name="ownerList"></param> internal virtual void SetOwnerGroup(RibbonItemGroup ownerGroup) { _ownerItem = ownerGroup; }