private bool CanControlBeSmall(UIElement e) { if ((e is IRibbonControl) && !(e is IRibbonLargeControl)) { RibbonSize min = RibbonBar.GetMinSize(e); return(min < RibbonSize.Large); } return(e.DesiredSize.Height <= InternalGroupPanel.MaxSmallHeight); }
/// <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); }