Ejemplo n.º 1
0
        /// <summary>
        /// Gets the array of group level key tips.
        /// </summary>
        /// <returns>Array of KeyTipInfo; otherwise null.</returns>
        public KeyTipInfo[] GetGroupKeyTips()
        {
            ViewLayoutRibbonGroups groups = _viewFiller as ViewLayoutRibbonGroups;

            // If we contain a groups layout
            if (groups != null)
            {
                KeyTipInfoList keyTips = new KeyTipInfoList();

                // Grab the list of key tips for all groups
                keyTips.AddRange(groups.GetGroupKeyTips());

                // Remove all those that do not intercept the view rectangle
                for (int i = 0; i < keyTips.Count; i++)
                {
                    if (!_viewClipRect.Contains(keyTips[i].ClientRect))
                    {
                        keyTips[i].Visible = false;
                    }
                }

                return(keyTips.ToArray());
            }
            else
            {
                return new KeyTipInfo[] { }
            };
        }
Ejemplo n.º 2
0
        private void SyncChildrenToRibbonTabs()
        {
            // Remove all child elements
            Clear();

            // Create a new lookup that reflects any changes in tabs
            TabToView regenerate = new TabToView();

            // Make sure we have a view element to match each tab
            foreach (KryptonRibbonTab tab in Ribbon.RibbonTabs)
            {
                ViewLayoutRibbonScrollPort view = null;

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

                // If a new tab, create a view for it now
                if (view == null)
                {
                    ViewLayoutRibbonGroups groups = new ViewLayoutRibbonGroups(Ribbon, tab, NeedPaintDelegate);
                    view = new ViewLayoutRibbonScrollPort(Ribbon, Orientation.Horizontal, groups, false, SCROLL_SPEED, NeedPaintDelegate);
                    view.TransparentBackground = true;
                    groups.NeedPaintDelegate   = view.ViewControlPaintDelegate;
                }

                // Make sure only the selected tab is visible
                view.Visible = (Ribbon.SelectedTab == tab);

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

                // Remove no longer needed reference
                _tabToView.Remove(tab);
            }

            // Switch to using the lookup with only the current options inside
            TabToView redundant = _tabToView;

            _tabToView = regenerate;

            // Add the view elements in same order as the tab definitions
            foreach (KryptonRibbonTab tab in Ribbon.RibbonTabs)
            {
                Add(_tabToView[tab]);
            }

            // Dispose of all the no longer needed child tabs
            foreach (ViewBase oldChild in redundant.Values)
            {
                oldChild.Dispose();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the previous focus item based on the current item as provided.
        /// </summary>
        /// <param name="current">The view that is currently focused.</param>
        /// <returns>ViewBase of item; otherwise false.</returns>
        public ViewBase GetPreviousFocusItem(ViewBase current)
        {
            ViewBase view = null;
            ViewLayoutRibbonGroups groups = _viewFiller as ViewLayoutRibbonGroups;

            // If we contain a groups layout
            if (groups != null)
            {
                // Ask the groups for the previous focus item
                view = groups.GetPreviousFocusItem(current);

                // Make sure client area of view is visible
                if (view != null)
                {
                    ScrollIntoView(view.ClientRectangle, true);
                }
            }

            return(view);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the view element group that the provided point is inside.
        /// </summary>
        /// <param name="pt">Mouse point.</param>
        /// <returns>Reference if inside a group; otherwise null.</returns>
        public ViewDrawRibbonGroup ViewGroupFromPoint(Point pt)
        {
            // There can only be groups showing for the currently selected tab
            if (Ribbon.SelectedTab != null)
            {
                // Get the scroll port for this tab
                ViewLayoutRibbonScrollPort viewScrollPort = _tabToView[Ribbon.SelectedTab];

                // The first child of the scroll port is always the view control
                ViewLayoutControl viewControl = viewScrollPort[0] as ViewLayoutControl;

                // The first child of the view control is always the ribbon groups
                ViewLayoutRibbonGroups viewGroups = viewControl.ChildView as ViewLayoutRibbonGroups;

                // Ask the view groups to find a matching group
                return(viewGroups.ViewGroupFromPoint(pt));
            }

            return(null);
        }