Exemplo n.º 1
0
        //Gets the maximum possible ReductionLevel that would change any of the controls.
        private int GetMaxLevel()
        {
            int max = 1;

            foreach (UIElement e in Controls)
            {
                if (e is IRibbonControl)
                {
                    RibbonSizeCollection reduction = RibbonBar.GetReduction(e);
                    int m = reduction != null ? reduction.Count : 3;
                    max = Math.Max(max, m);
                }
                if (e is IRibbonGallery)
                {
                    RibbonGalleryColumns columns = RibbonGallery.GetReductionColumns(e);
                    int m = columns != null ? columns.Count : 3;
                    max = Math.Max(max, m);
                }
            }
            return(max);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the RibbonSize for a control for a specific level.
        /// </summary>
        /// <param name="control">The control for which to retreive a RibbonSize.</param>
        /// <param name="level">The reduction Level (0=large, 2=medium,3=small,4=minimized,...).</param>
        /// <param name="index">The index of the control in the group.</param>
        /// <returns>The RibbonSize for the control.</returns>
        RibbonSize GetControlSize(DependencyObject control, int level, int index)
        {
            RibbonSizeCollection reductions = RibbonBar.GetReduction(control);

            if (reductions != null && reductions.Count > 0)
            {
                level = Math.Max(0, Math.Min(level, reductions.Count - 1));
                return(reductions[level]);
            }
            RibbonSize size;

            switch (level)
            {
            case 0: size = GetDefaultSizeForLevel0(index); break;

            case 1: size = GetDefaultSizeForLevel1(index); break;

            case 2: size = GetDefaultSizeForLevel2(index); break;

            default: size = RibbonSize.Minimized; break;
            }

            RibbonSize min = RibbonBar.GetMinSize(control);
            RibbonSize max = RibbonBar.GetMaxSize(control);

            if (size < min)
            {
                size = min;
            }
            if (size > max)
            {
                size = max;
            }

            return(size);
        }