Exemple #1
0
        /// <summary>
        /// Gets the last focus item from the container.
        /// </summary>
        /// <returns>ViewBase of item; otherwise false.</returns>
        public ViewBase GetLastFocusItem()
        {
            ViewBase view = null;

            // Scan all the children, which must be items
            foreach (ViewBase child in this.Reverse())
            {
                // Only interested in visible children!
                if (child.Visible)
                {
                    if (child is IRibbonViewGroupItemView)
                    {
                        // Cast to correct type
                        IRibbonViewGroupItemView item = (IRibbonViewGroupItemView)child;

                        // If it can provide a view, then use it
                        view = item.GetLastFocusItem();
                        if (view != null)
                        {
                            break;
                        }
                    }
                }
            }

            return(view);
        }
Exemple #2
0
        /// <summary>
        /// Gets the array of group level key tips.
        /// </summary>
        /// <param name="keyTipList">List to add new entries into.</param>
        public void GetGroupKeyTips(KeyTipInfoList keyTipList)
        {
            int visibleIndex = 0;
            int lineHint     = (_currentSize == GroupItemSize.Small ? 1 : 4);

            // Scan all the children, which must be containers or items
            foreach (ViewBase child in this)
            {
                // Only interested in visible children!
                if (child.Visible)
                {
                    // Is this a container item
                    if (child is IRibbonViewGroupContainerView)
                    {
                        IRibbonViewGroupContainerView container = (IRibbonViewGroupContainerView)child;
                        container.GetGroupKeyTips(keyTipList);
                    }
                    else if (child is IRibbonViewGroupItemView)
                    {
                        IRibbonViewGroupItemView item = (IRibbonViewGroupItemView)child;
                        item.GetGroupKeyTips(keyTipList, lineHint);

                        // Depending on size we check to adjust the lint hint
                        switch (_currentSize)
                        {
                        case GroupItemSize.Large:
                            if (visibleIndex == _split1Large)
                            {
                                lineHint = 5;
                            }
                            break;

                        case GroupItemSize.Medium:
                            if (visibleIndex == _split1Medium)
                            {
                                lineHint = 5;
                            }
                            break;

                        case GroupItemSize.Small:
                            if (visibleIndex == _split1Small)
                            {
                                lineHint = 2;
                            }
                            else if (visibleIndex == _split2Small)
                            {
                                lineHint = 3;
                            }
                            break;
                        }
                    }

                    // Track number of visible items, as the split indexes are based on
                    // visible items and not on the total number of child view items
                    visibleIndex++;
                }
            }
        }
Exemple #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>
        /// <param name="matched">Has the current focus item been matched yet.</param>
        /// <returns>ViewBase of item; otherwise false.</returns>
        public ViewBase GetPreviousFocusItem(ViewBase current, ref bool matched)
        {
            ViewBase view = null;

            // Scan all the children, which must be containers
            foreach (ViewBase child in this.Reverse())
            {
                // Only interested in visible children!
                if (child.Visible)
                {
                    // Is this a container item
                    if (child is IRibbonViewGroupContainerView)
                    {
                        // Cast to correct type
                        IRibbonViewGroupContainerView container = (IRibbonViewGroupContainerView)child;

                        // Already matched means we need the next item we come across,
                        // otherwise we continue with the attempt to find previous
                        if (matched)
                        {
                            view = container.GetLastFocusItem();
                        }
                        else
                        {
                            view = container.GetPreviousFocusItem(current, ref matched);
                        }

                        if (view != null)
                        {
                            break;
                        }
                    }
                    else if (child is IRibbonViewGroupItemView)
                    {
                        // Cast to correct type
                        IRibbonViewGroupItemView item = (IRibbonViewGroupItemView)child;

                        // Already matched means we need the next item we come across,
                        // otherwise we continue with the attempt to find previous
                        if (matched)
                        {
                            view = item.GetLastFocusItem();
                        }
                        else
                        {
                            view = item.GetPreviousFocusItem(current, ref matched);
                        }

                        if (view != null)
                        {
                            break;
                        }
                    }
                }
            }

            return(view);
        }
Exemple #4
0
        private void ResetSize()
        {
            foreach (ViewBase item in this)
            {
                IRibbonViewGroupItemView viewItem = item as IRibbonViewGroupItemView;
                viewItem?.ResetGroupItemSize();
            }

            SetCurrentSize(_ribbonTriple.ItemSizeCurrent);
        }
Exemple #5
0
        private void ApplySize(GroupItemSize size)
        {
            foreach (ViewBase item in this)
            {
                IRibbonViewGroupItemView viewItem = item as IRibbonViewGroupItemView;
                viewItem?.SetGroupItemSize(size);
            }

            SetCurrentSize(size);
        }
        private void ResetSize()
        {
            foreach (ViewBase item in this)
            {
                IRibbonViewGroupItemView viewItem = item as IRibbonViewGroupItemView;
                viewItem?.ResetGroupItemSize();
            }

            CurrentSize = _ribbonLines.ItemSizeCurrent;
        }
Exemple #7
0
        /// <summary>
        /// Reset the group item size to the item definition.
        /// </summary>
        public void ResetGroupItemSize()
        {
            foreach (KryptonRibbonGroupItem item in _ribbonCluster.Items)
            {
                IRibbonViewGroupItemView viewItemSize = _itemToView[item] as IRibbonViewGroupItemView;
                viewItemSize.ResetGroupItemSize();
            }

            // Our current size is based on the parent one
            ViewLayoutRibbonGroupLines viewLines = (ViewLayoutRibbonGroupLines)Parent;

            _currentSize = (viewLines.CurrentSize == GroupItemSize.Small ? GroupItemSize.Small : GroupItemSize.Medium);
        }
Exemple #8
0
        /// <summary>
        /// Override the group item size if possible.
        /// </summary>
        /// <param name="size">New size to use.</param>
        public void SetGroupItemSize(GroupItemSize size)
        {
            // Sync child elements to the current group items
            SyncChildrenToRibbonGroupItems();

            foreach (KryptonRibbonGroupItem item in _ribbonCluster.Items)
            {
                IRibbonViewGroupItemView viewItemSize = _itemToView[item] as IRibbonViewGroupItemView;
                viewItemSize.SetGroupItemSize(size);
            }

            _currentSize = size;
        }
        /// <summary>
        /// Gets the last focus item from the group.
        /// </summary>
        /// <returns>ViewBase of item; otherwise false.</returns>
        public ViewBase GetLastFocusItem()
        {
            ViewBase view = null;

            if (_ribbonGroup.Visible)
            {
                // The dialog box launcher is the last item (if present)
                view = DialogView.GetFocusView();

                if (view == null)
                {
                    // Scan all the children, which must be containers
                    foreach (ViewBase child in this.Reverse())
                    {
                        // Only interested in visible children!
                        if (child.Visible)
                        {
                            // Is this a container item
                            if (child is IRibbonViewGroupContainerView)
                            {
                                // Cast to correct type
                                IRibbonViewGroupContainerView container = (IRibbonViewGroupContainerView)child;

                                // If it can provide a view, then use it
                                view = container.GetLastFocusItem();
                                if (view != null)
                                {
                                    break;
                                }
                            }
                            else if (child is IRibbonViewGroupItemView)
                            {
                                // Cast to correct type
                                IRibbonViewGroupItemView item = (IRibbonViewGroupItemView)child;

                                // If it can provide a view, then use it
                                view = item.GetLastFocusItem();
                                if (view != null)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            return(view);
        }
Exemple #10
0
 /// <summary>
 /// Gets the array of group level key tips.
 /// </summary>
 /// <param name="keyTipList">List to add new entries into.</param>
 public void GetGroupKeyTips(KeyTipInfoList keyTipList)
 {
     // Scan all the children, which must be items
     foreach (ViewBase child in this)
     {
         // Only interested in visible children!
         if (child.Visible)
         {
             if (child is IRibbonViewGroupItemView)
             {
                 IRibbonViewGroupItemView item = (IRibbonViewGroupItemView)child;
                 item.GetGroupKeyTips(keyTipList, this.IndexOf(child) + 1);
             }
         }
     }
 }
Exemple #11
0
        private void ApplySize(GroupItemSize size)
        {
            CurrentSize = size;
            GroupItemSize itemSize = GroupItemSize.Medium;

            switch (size)
            {
            case GroupItemSize.Large:
                _sizeList  = _sizeLargeList;
                _viewList  = _viewLargeList;
                _viewToGap = _viewToLargeGap;
                itemSize   = GroupItemSize.Medium;
                break;

            case GroupItemSize.Medium:
                _sizeList  = _sizeMediumList;
                _viewList  = _viewMediumList;
                _viewToGap = _viewToMediumGap;
                itemSize   = GroupItemSize.Small;
                break;

            case GroupItemSize.Small:
                _sizeList  = _sizeSmallList;
                _viewList  = _viewSmallList;
                _viewToGap = _viewToSmallGap;
                itemSize   = GroupItemSize.Small;
                break;

            default:
                // Should never happen!
                Debug.Assert(false);
                break;
            }

            foreach (ViewBase item in this)
            {
                IRibbonViewGroupItemView viewItem = item as IRibbonViewGroupItemView;
                if (viewItem != null)
                {
                    viewItem.SetGroupItemSize(itemSize);
                }
            }
        }
Exemple #12
0
        /// <summary>
        /// Gets the first focus item from the container.
        /// </summary>
        /// <returns>ViewBase of item; otherwise false.</returns>
        public ViewBase GetFirstFocusItem()
        {
            ViewBase view = null;

            // Scan all the children, which must be containers
            foreach (ViewBase child in this)
            {
                // Only interested in visible children!
                if (child.Visible)
                {
                    // Is this a container item
                    if (child is IRibbonViewGroupContainerView)
                    {
                        // Cast to correct type
                        IRibbonViewGroupContainerView container = (IRibbonViewGroupContainerView)child;

                        // If it can provide a view, then use it
                        view = container.GetFirstFocusItem();
                        if (view != null)
                        {
                            break;
                        }
                    }
                    else if (child is IRibbonViewGroupItemView)
                    {
                        // Cast to correct type
                        IRibbonViewGroupItemView item = (IRibbonViewGroupItemView)child;

                        // If it can provide a view, then use it
                        view = item.GetFirstFocusItem();
                        if (view != null)
                        {
                            break;
                        }
                    }
                }
            }

            return(view);
        }
Exemple #13
0
        /// <summary>
        /// Gets the next focus item based on the current item as provided.
        /// </summary>
        /// <param name="current">The view that is currently focused.</param>
        /// <param name="matched">Has the current focus item been matched yet.</param>
        /// <returns>ViewBase of item; otherwise false.</returns>
        public ViewBase GetNextFocusItem(ViewBase current, ref bool matched)
        {
            ViewBase view = null;

            // Scan all the children, which must be items
            foreach (ViewBase child in this)
            {
                // Only interested in visible children!
                if (child.Visible)
                {
                    if (child is IRibbonViewGroupItemView)
                    {
                        // Cast to correct type
                        IRibbonViewGroupItemView item = (IRibbonViewGroupItemView)child;

                        // Already matched means we need the next item we come across,
                        // otherwise we continue with the attempt to find next
                        if (matched)
                        {
                            view = item.GetFirstFocusItem();
                        }
                        else
                        {
                            view = item.GetNextFocusItem(current, ref matched);
                        }

                        if (view != null)
                        {
                            break;
                        }
                    }
                }
            }

            return(view);
        }
Exemple #14
0
        /// <summary>
        /// Gets the next focus item based on the current item as provided.
        /// </summary>
        /// <param name="current">The view that is currently focused.</param>
        /// <param name="matched">Has the current focus item been matched yet.</param>
        /// <returns>ViewBase of item; otherwise false.</returns>
        public ViewBase GetNextFocusItem(ViewBase current, ref bool matched)
        {
            ViewBase view = null;

            // Scan all the children, which must be containers
            foreach (ViewBase child in this)
            {
                // Only interested in visible children!
                if (child.Visible)
                {
                    if (child is IRibbonViewGroupItemView)
                    {
                        // Cast to correct type
                        IRibbonViewGroupItemView item = (IRibbonViewGroupItemView)child;

                        // If already matched, then we need to next item we find,
                        // otherwise we are still looking for the next item
                        if (matched)
                        {
                            view = item.GetFirstFocusItem();
                        }
                        else
                        {
                            view = item.GetNextFocusItem(current, ref matched);
                        }

                        if (view != null)
                        {
                            break;
                        }
                    }
                }
            }

            return(view);
        }
        /// <summary>
        /// Gets the next focus item based on the current item as provided.
        /// </summary>
        /// <param name="current">The view that is currently focused.</param>
        /// <param name="matched">Has the current focus item been matched yet.</param>
        /// <returns>ViewBase of item; otherwise false.</returns>
        public ViewBase GetNextFocusItem(ViewBase current, ref bool matched)
        {
            ViewBase view = null;

            // Scan all the children, which must be containers
            foreach (ViewBase child in this)
            {
                // Only interested in visible children!
                if (child.Visible)
                {
                    // Is this a container item
                    if (child is IRibbonViewGroupContainerView)
                    {
                        // Cast to correct type
                        IRibbonViewGroupContainerView container = (IRibbonViewGroupContainerView)child;

                        // Already matched means we need the next item we come across,
                        // otherwise we continue with the attempt to find next
                        if (matched)
                        {
                            view = container.GetFirstFocusItem();
                        }
                        else
                        {
                            view = container.GetNextFocusItem(current, ref matched);
                        }

                        if (view != null)
                        {
                            break;
                        }
                    }
                    else if (child is IRibbonViewGroupItemView)
                    {
                        // Cast to correct type
                        IRibbonViewGroupItemView item = (IRibbonViewGroupItemView)child;

                        // Already matched means we need the next item we come across,
                        // otherwise we continue with the attempt to find next
                        if (matched)
                        {
                            view = item.GetFirstFocusItem();
                        }
                        else
                        {
                            view = item.GetNextFocusItem(current, ref matched);
                        }

                        if (view != null)
                        {
                            break;
                        }
                    }
                }
            }

            // If still nothing...
            if (view == null)
            {
                // If matched then try using the dialog box launcher
                if (matched)
                {
                    if (_ribbonGroup.Visible)
                    {
                        view = DialogView.GetFocusView();
                    }
                }
                else
                {
                    matched = (DialogView.GetFocusView() == current);
                }
            }

            return(view);
        }