public static void SetDefaultControlSizeDefinition(DependencyObject element, RibbonControlSizeDefinition value) { if (element == null) { throw new ArgumentNullException("element"); } element.SetValue(DefaultControlSizeDefinitionProperty, value); }
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 bool IsStarChild(UIElement child, out double weight) { weight = 0; RibbonControlSizeDefinition controlDef = RibbonControlService.GetControlSizeDefinition(child); if (controlDef != null) { weight = controlDef.Width.Value; return(controlDef.Width.IsStar); } return(false); }
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 CoerceIsCollapsed(DependencyObject d, object baseValue) { InRibbonGallery irg = (InRibbonGallery)d; if (DependencyPropertyHelper.GetValueSource(irg, IsCollapsedProperty).BaseValueSource != BaseValueSource.Local) { RibbonControlSizeDefinition csd = irg.ControlSizeDefinition; if (csd != null) { return(csd.IsCollapsed); } } 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); }
protected virtual void OnControlSizeDefinitionChanged(RibbonControlSizeDefinition OldValue, RibbonControlSizeDefinition NewValue) { }