Esempio n. 1
0
        public RibbonControlGroupCollection Reduce(IEnumerable <RibbonItem> items, int reduceLevel)
        {
            var grouppedItems = RibbonUtils.GroupItems(items.AsIList(), item => RibbonItemStyle.Default);

            if (reduceLevel == 0)
            {
                return(grouppedItems);
            }

            do
            {
                var current = reduceLevel;
                for (var iGroup = grouppedItems.Count - 1; iGroup >= 0 && reduceLevel > 0; iGroup--)
                {
                    var controlGroup = grouppedItems[iGroup];
                    if (controlGroup.CanReduce == false)
                    {
                        continue;
                    }

                    grouppedItems[iGroup] = controlGroup.Reduce();
                    reduceLevel--;
                }

                if (reduceLevel == current)
                {
                    break;
                }
            } while (reduceLevel > 0);

            return(grouppedItems);
        }
        RibbonControlGroupCollection IRibbonGroupReducer.Reduce(IEnumerable <RibbonItem> items, int reduceLevel)
        {
            var itemList = items.AsIList();

            var actualLevel = Math.Min(reduceLevel, Count - 1);

            if (actualLevel < 0)
            {
                foreach (var item in itemList)
                {
                    item.ActualItemStyle = RibbonItemStyle.Default;
                }
            }
            else
            {
                var reduceLevelDefinition = this[actualLevel];
                var definitions           = reduceLevelDefinition.Definitions;
                var itemDefinitionsCount  = definitions.Count;
                for (var i = 0; i < itemList.Count; i++)
                {
                    itemList[i].ActualItemStyle = i < itemDefinitionsCount ? definitions[i].ItemStyle : RibbonItemStyle.Default;
                }
            }

            return(RibbonUtils.GroupItems(itemList, null));
        }
Esempio n. 3
0
 public int GetReduceLevelsCount(IEnumerable <RibbonItem> items)
 {
     return(RibbonUtils.GroupItems(items.AsIList(), item => RibbonItemStyle.Default).Select(g => g.ReduceLevelCount).Sum());
 }