internal RibbonPanelPopup(RibbonPanel panel) { DoubleBuffered = true; _sensor = new RibbonSensor(this, panel.Owner, panel.OwnerTab); _sensor.PanelLimit = panel; _panel = panel; _panel.PopUp = this; using (Graphics g = CreateGraphics()) { Size s = panel.MeasureSize(this, new RibbonElementMeasureSizeEventArgs(g, GetSizeMode(panel))); //s.Width+=3; s.Height+=3; Size = s; panel.SetBounds(new Rectangle(0, 0, Size.Width, Size.Height)); panel.UpdateItemsRegions(g, GetSizeMode(panel)); } foreach (RibbonItem item in panel.Items) { item.SetCanvas(this); } }
internal override void SetOwnerPanel(RibbonPanel ownerPanel) { base.SetOwnerPanel(ownerPanel); _dropDownItems.SetOwnerPanel(ownerPanel); }
public RibbonElementSizeMode GetSizeMode(RibbonPanel pnl) { if (pnl.FlowsTo == RibbonPanelFlowDirection.Right) { return RibbonElementSizeMode.Medium; } else { return RibbonElementSizeMode.Large; } }
/// <summary> /// Sets the currently selected panel /// </summary> /// <param name="panel"></param> private void SetSelectedPanel(RibbonPanel panel, int mouseX, int mouseY) { if (panel == _lastSelectedPanel) return; if (_lastSelectedPanel != null) { _lastSelectedPanel.SetSelected(false, mouseX, mouseY ); RedrawPanel(_lastSelectedPanel); } if (panel != null) { panel.SetSelected(true, mouseX, mouseY); RedrawPanel(panel); } _lastSelectedPanel = panel; }
/// <summary> /// Redraws the specified panel /// </summary> /// <param name="panel"></param> private void RedrawPanel(RibbonPanel panel) { //RibbonElementSizeMode size = panel.SizeMode; //if (panel.PopUp != null) //{ // size = RibbonElementSizeMode.Large; //} //using (Graphics g = Control.CreateGraphics()) //{ // g.SetClip(panel.Bounds); // panel.OnPaint(this, new RibbonElementPaintEventArgs(panel.Bounds, g, size, Control)); //} Control.Invalidate(panel.Bounds); }
/// <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> /// Sets the value of the OwnerPanel property /// </summary> /// <param name="ownerPanel">RibbonPanel where this item is located</param> internal virtual void SetOwnerPanel(RibbonPanel ownerPanel) { _ownerPanel = ownerPanel; }
public RibbonPanelRenderEventArgs(Ribbon owner, Graphics g, Rectangle clip, RibbonPanel panel, System.Windows.Forms.Control canvas) : base(owner, g, clip) { Panel = panel; Canvas = canvas; }