This class contains information about image size, visibility, and label visibility for a particular size configuration of a Ribbon control.
Inheritance: System.Windows.Freezable
 public static void SetDefaultControlSizeDefinition(DependencyObject element, RibbonControlSizeDefinition value)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     element.SetValue(DefaultControlSizeDefinitionProperty, value);
 }
Exemple #2
0
        private static object CoerceDefaultControlSizeDefinition(DependencyObject d, object baseValue)
        {
            if (baseValue == null)
            {
                RibbonControlGroup controlGroup = (RibbonControlGroup)d;
                RibbonImageSize    imageSize    = RibbonImageSize.Collapsed;
                bool isLabelVisible             = false;
                int  itemCount  = controlGroup.Items.Count;
                bool childFound = false;

                // Get the largest ControlSizeDefinition variant for all
                // the child controls and construct a union ControlSizeDefinition.
                for (int i = 0; i < itemCount; i++)
                {
                    RibbonControl ribbonControl = controlGroup.ItemContainerGenerator.ContainerFromIndex(i) as RibbonControl;
                    if (ribbonControl != null && ribbonControl.Visibility != Visibility.Collapsed)
                    {
                        UIElement contentChild = ribbonControl.ContentChild;
                        if (contentChild != null && contentChild.Visibility != Visibility.Collapsed)
                        {
                            RibbonControlSizeDefinition currentLargeCsd = RibbonControlService.GetDefaultControlSizeDefinition(contentChild);
                            if (currentLargeCsd == null)
                            {
                                contentChild.CoerceValue(RibbonControlService.DefaultControlSizeDefinitionProperty);
                                currentLargeCsd = RibbonControlService.GetDefaultControlSizeDefinition(contentChild);
                            }

                            if (currentLargeCsd != null)
                            {
                                childFound = true;
                                if (imageSize == RibbonImageSize.Collapsed)
                                {
                                    imageSize = currentLargeCsd.ImageSize;
                                }
                                else if (currentLargeCsd.ImageSize == RibbonImageSize.Large)
                                {
                                    imageSize = RibbonImageSize.Large;
                                }

                                isLabelVisible |= currentLargeCsd.IsLabelVisible;

                                if (isLabelVisible && imageSize == RibbonImageSize.Large)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
                if (childFound)
                {
                    return(RibbonControlSizeDefinition.GetFrozenControlSizeDefinition(imageSize, isLabelVisible));
                }
            }
            return(baseValue);
        }
 private static object CoerceControlSizeDefinition(DependencyObject d, object baseValue)
 {
     if (baseValue == null)
     {
         RibbonControlSizeDefinition defaultControlSizeDefinition = RibbonControlService.GetDefaultControlSizeDefinition(d);
         if (defaultControlSizeDefinition == null)
         {
             d.CoerceValue(DefaultControlSizeDefinitionProperty);
             defaultControlSizeDefinition = RibbonControlService.GetDefaultControlSizeDefinition(d);
         }
         return(defaultControlSizeDefinition);
     }
     return(baseValue);
 }
        private static object CoerceDefaultControlSizeDefinition(DependencyObject d, object baseValue)
        {
            if (baseValue == null)
            {
                RibbonImageSize imageSize = RibbonImageSize.Collapsed;
                if (RibbonControlService.GetLargeImageSource(d) != null)
                {
                    imageSize = RibbonImageSize.Large;
                }
                else if (RibbonControlService.GetSmallImageSource(d) != null)
                {
                    imageSize = RibbonImageSize.Small;
                }
                bool isLabelVisible = !string.IsNullOrEmpty(RibbonControlService.GetLabel(d));

                return(RibbonControlSizeDefinition.GetFrozenControlSizeDefinition(imageSize, isLabelVisible));
            }
            return(baseValue);
        }
 /// <summary>
 ///     Set size definition which is applied to the control when it is displayed as a part of a QuickAccessToolBar.
 /// </summary>
 public static void SetQuickAccessToolBarControlSizeDefinition(DependencyObject element, RibbonControlSizeDefinition value)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     element.SetValue(QuickAccessToolBarControlSizeDefinitionProperty, value);
 }