/// <summary> /// Method to mix two <c>SolidColorBrush</c> objects at a given opacity /// </summary> /// <param name="this"> /// Background <c>SolidColorBrush</c> object /// </param> /// <param name="foreground"> /// Foreground <c>SolidColorBrush</c> object /// </param> /// <param name="opacity"> /// Opacity value [0.0-1.0] of the overlayed foreground <c>SolidColorBrush</c> object /// </param> /// <returns> /// The mixed <c>SolidColorBrush</c> object /// </returns> public static SolidColorBrush Blend( [NotNull] this SolidColorBrush @this, [NotNull] SolidColorBrush foreground, double opacity) { @this.IsNotNull(nameof(@this)); foreground.IsNotNull(nameof(foreground)); return(@this .Color .Blend( foreground.Color, opacity) .ToSCB()); }
public static SolidColorBrush SetIdentity( [NotNull] this SolidColorBrush @this, [CanBeNull] MaterialIdentity materialIdentity) { @this.IsNotNull(nameof(@this)); if ((@this.CanFreeze && @this.IsFrozen) || @this.IsSealed) { //@this.Changed += (s, args) => //{ //}; var cloned = @this.Clone(); cloned.SetValue( MDH.IdentityProperty, materialIdentity); cloned.Freeze(); return(cloned); } else { //@this.Changed += (s, args) => //{ //}; var existingIdentity = @this.GetIdentity(); if (existingIdentity != null) { if (!existingIdentity.Equals(materialIdentity)) { } } @this.SetValue( MDH.IdentityProperty, materialIdentity); if (@this.CanFreeze) { @this.Freeze(); } return(@this); } }
public static MaterialIdentity GetIdentity( [NotNull] this SolidColorBrush @this) { @this.IsNotNull(nameof(@this)); var boxedValue = @this.GetValue(MDH.IdentityProperty); var identity = boxedValue as MaterialIdentity; if (boxedValue == null || boxedValue == DependencyProperty.UnsetValue || identity == null) { return(null); } return(identity); }
public static SolidColorBrush Interpolate( [NotNull] this SolidColorBrush @this, [NotNull] SolidColorBrush brush, double percentage) { @this.IsNotNull(nameof(@this)); brush.IsNotNull(nameof(brush)); if (percentage.IsNotWithin((0d, 1d))) { throw new ArgumentOutOfRangeException( nameof(percentage), percentage, "The percentage parameter must be between 0 and 1, inclusively."); } return(@this .Color .Interpolate( brush.Color, percentage) .ToSCB()); }