public static void SetBrushesToImageSource(ImageSource imageSource, BrushCollection brushCollection) { if (imageSource != null && brushCollection != null) { var brushProps = GetBrushesPropsFromImageSource(imageSource); for (int i = 0; i < brushProps.Length && i < brushCollection.Count; ++i) { var brushProp = brushProps[i]; var brush = brushCollection[i]; brushProp.Dp.SetValue(brushProp.Prop, brush); } } }
private static void ContentBrushPropertyChangedCallback(DependencyObject dp, DependencyPropertyChangedEventArgs args) { var brushes = GetContentBrushes(dp) as BrushCollection; var brushesCreated = false; if (brushes == null) { brushes = new BrushCollection(); brushesCreated = true; } if (brushes.Count == 1 && (ReferenceEquals(brushes[0], args.OldValue))) { brushes[0] = args.NewValue as Brush; } if (brushes.Count == 0) { brushes.Add(args.NewValue as Brush); } if (brushesCreated) { SetContentBrushes(dp, brushes); } }
internal static void SetBrushesToClonedImageSource(Image image, ImageSource imageSource, BrushCollection brushes) { var clonedImageSource = EnsureClonedSource(image, imageSource); SetBrushesToImageSource(clonedImageSource, brushes); if (clonedImageSource != null && !ReferenceEquals(clonedImageSource, image.Source)) { image.Source = clonedImageSource; } }
public static void SetContentBrushes(DependencyObject element, BrushCollection value) { element.SetValue(ContentBrushesProperty, value); }