private void OnMouseEnterControl(object sender, EventArgs e)
        {
            // Reset the active group setting
            _activeGroup = null;

            // Find the parent group instance
            ViewBase parent = Parent;

            // Keep going till we get to the top or find a group
            while (parent != null)
            {
                if (parent is ViewDrawRibbonGroup)
                {
                    _activeGroup = (ViewDrawRibbonGroup)parent;
                    break;
                }

                // Move up a level
                parent = parent.Parent;
            }

            // If we found a group we are inside
            if (_activeGroup != null)
            {
                _activeGroup.Tracking = true;
                _needPaint(this, new NeedLayoutEventArgs(false, _activeGroup.ClientRectangle));
            }
        }
Exemplo n.º 2
0
 private void OnMouseLeaveControl(object sender, EventArgs e)
 {
     // If we have a cached group we made active
     if (_activeGroup != null)
     {
         _activeGroup.Tracking = false;
         _needPaint(this, new NeedLayoutEventArgs(false, _activeGroup.ClientRectangle));
         _activeGroup = null;
     }
 }
        /// <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;
        }
        /// <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;
        }
Exemplo n.º 5
0
        /// <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("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>
        /// Gets the last focus item from the groups.
        /// </summary>
        /// <returns>ViewBase of item; otherwise false.</returns>
        public ViewBase GetLastFocusItem()
        {
            ViewBase view = null;

            ViewDrawRibbonGroup[] groups = new ViewDrawRibbonGroup[_groupToView.Count];
            _groupToView.Values.CopyTo(groups, 0);

            // Search each group until one of them returns a focus item
            for (int i = groups.Length - 1; i >= 0; i--)
            {
                view = groups[i].GetLastFocusItem();
                if (view != null)
                {
                    break;
                }
            }

            return(view);
        }
        private void SyncChildrenToRibbonGroups()
        {
            // Remove all child elements
            Clear();

            // Create a new lookup that reflects any changes in groups
            GroupToView regenerate = new GroupToView();

            // Make sure we have a view element to match each group
            foreach (KryptonRibbonGroup group in _ribbonTab.Groups)
            {
                ViewDrawRibbonGroup view = null;

                // Get the currently cached view for the group
                if (_groupToView.ContainsKey(group))
                {
                    view = _groupToView[group];
                }

                // If a new group, create a view for it now
                if (view == null)
                {
                    view = new ViewDrawRibbonGroup(_ribbon, group, _needPaint);
                }

                // Add to the lookup for future reference
                regenerate.Add(group, view);
            }

            if (_groupSepCache.Count < _ribbonTab.Groups.Count)
            {
                for (int i = _groupSepCache.Count; i < _ribbonTab.Groups.Count; i++)
                {
                    _groupSepCache.Add(new ViewLayoutRibbonSeparator(0, true));
                }
            }

            // Update size of all separators to match ribbon shape
            Size sepSize = SeparatorSize;

            foreach (ViewLayoutRibbonSeparator sep in _groupSepCache)
            {
                sep.SeparatorSize = sepSize;
            }

            // We ignore the first separator
            bool ignoreSep = true;

            // Add child elements appropriate for each ribbon group
            for (int i = 0; i < _ribbonTab.Groups.Count; i++)
            {
                KryptonRibbonGroup ribbonGroup = _ribbonTab.Groups[i];

                // Only make the separator visible if the group is and not the first sep
                bool groupVisible = (_ribbon.InDesignHelperMode || ribbonGroup.Visible);
                _groupSepCache[i].Visible       = groupVisible && !ignoreSep;
                regenerate[ribbonGroup].Visible = groupVisible;

                // Only add a separator for the second group onwards
                if (groupVisible && ignoreSep)
                {
                    ignoreSep = false;
                }

                Add(_groupSepCache[i]);
                Add(regenerate[ribbonGroup]);

                // Remove entries we still are using
                if (_groupToView.ContainsKey(ribbonGroup))
                {
                    _groupToView.Remove(ribbonGroup);
                }
            }

            // When in design time help mode
            if (_ribbon.InDesignHelperMode)
            {
                // Create the design time 'Add Group' first time it is needed
                if (_viewAddGroup == null)
                {
                    _viewAddGroup = new ViewDrawRibbonDesignGroup(_ribbon, _needPaint);
                }

                // Always add at end of the list of groups
                Add(_viewAddGroup);
            }

            // Dispose of views no longer required
            foreach (ViewDrawRibbonGroup group in _groupToView.Values)
            {
                group.Dispose();
            }

            // No longer need the old lookup
            _groupToView = regenerate;
        }