/// <summary> /// Initialize a new instance of the ViewRibbonPopupGroupManager class. /// </summary> /// <param name="control">Owning control.</param> /// <param name="ribbon">Owning ribbon control instance.</param> /// <param name="root">View for group we are tracking.</param> /// <param name="viewGroup">Group to track.</param> /// <param name="needPaintDelegate">Delegate for performing painting.</param> public ViewRibbonPopupGroupManager(Control control, KryptonRibbon ribbon, ViewBase root, ViewDrawRibbonGroup viewGroup, NeedPaintHandler needPaintDelegate) : base(control, root) { Debug.Assert(ribbon != null); Debug.Assert(viewGroup != null); Debug.Assert(needPaintDelegate != null); _ribbon = ribbon; _viewGroup = viewGroup; _needPaintDelegate = needPaintDelegate; }
/// <summary> /// Perform mouse movement handling. /// </summary> /// <param name="e">A MouseEventArgs that contains the event data.</param> /// <param name="rawPt">The actual point provided from the windows message.</param> public override void MouseMove(MouseEventArgs e, Point rawPt) { Debug.Assert(e != null); // Validate incoming reference if (e == null) { throw new ArgumentNullException(nameof(e)); } if (!_ribbon.InDesignMode) { // Only interested if the application window we are inside is active or a docking floating window is active if (_active || (CommonHelper.ActiveFloatingWindow != null)) { // Only hot track groups if in the correct mode if (_minimizedMode == _ribbon.RealMinimizedMode) { // Get the view group instance that matches this point ViewDrawRibbonGroup viewGroup = _viewGroups.ViewGroupFromPoint(new Point(e.X, e.Y)); // Is there a change in active group? if (viewGroup != _activeGroup) { if (_activeGroup != null) { _activeGroup.Tracking = false; _activeGroup.PerformNeedPaint(false, _activeGroup.ClientRectangle); } _activeGroup = viewGroup; if (_activeGroup != null) { _activeGroup.Tracking = true; _activeGroup.PerformNeedPaint(false, _activeGroup.ClientRectangle); } } } } } // Remember to call base class for standard mouse processing base.MouseMove(e, rawPt); }
/// <summary> /// Initialize a new instance of the ViewDrawRibbonGroupImage class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="ribbonGroup">Reference to ribbon group definition.</param> /// <param name="viewGroup">Reference to top level group element.</param> public ViewDrawRibbonGroupImage(KryptonRibbon ribbon, KryptonRibbonGroup ribbonGroup, ViewDrawRibbonGroup viewGroup) { Debug.Assert(ribbon != null); Debug.Assert(ribbonGroup != null); Debug.Assert(viewGroup != null); _ribbon = ribbon; _ribbonGroup = ribbonGroup; _viewGroup = viewGroup; _viewSize_2007 = new Size((int)(30 * FactorDpiX), (int)(31 * FactorDpiY)); _viewSize_2010 = new Size((int)(31 * FactorDpiX), (int)(31 * FactorDpiY)); _imageSize = new Size((int)(16 * FactorDpiX), (int)(16 * FactorDpiY)); IMAGE_OFFSET_X = (int)(7 * FactorDpiX); IMAGE_OFFSET_Y_2007 = (int)(4 * FactorDpiY); IMAGE_OFFSET_Y_2010 = (int)(7 * FactorDpiY); }
/// <summary> /// Show the group popup relative to the parent group instance. /// </summary> /// <param name="parentGroup">Parent group instance.</param> /// <param name="parentScreenRect">Screen rectangle of the parent.</param> public void ShowCalculatingSize(ViewDrawRibbonGroup parentGroup, Rectangle parentScreenRect) { // Prevent ribbon from laying out the same group as we are // about to get the preferred size from. This reentrancy can // happen if the group has a custom control that is then moved // to be reparented to the popup group and so therefore cause // a layout of the main ribbon. _ribbon.SuspendLayout(); SuspendLayout(); try { // Find the size the group requests to be Size popupSize; using (ViewLayoutContext context = new(this, Renderer)) { popupSize = ViewGroup.GetPreferredSize(context); } // Override the height to enforce the correct group height popupSize.Height = _ribbon.CalculatedValues.GroupHeight; // Mark the group as showing as a popup _ribbonGroup.ShowingAsPopup = true; // Request we be shown below the parent screen rect Show(CalculateBelowPopupRect(parentScreenRect, popupSize)); } finally { // Reverse the suspend call _ribbon.ResumeLayout(); ResumeLayout(); } }