System.Windows.Media.ValidateEnums.IsFillRuleValid C# (CSharp) Method

IsFillRuleValid() public static method

Returns whether or not an enumeration instance a valid value. This method is designed to be used with ValidateValueCallback, and thus matches it's prototype.
public static IsFillRuleValid ( object valueObject ) : bool
valueObject object /// Enumeration value to validate. ///
return bool
        public static bool IsFillRuleValid(object valueObject)
        {
            FillRule value = (FillRule) valueObject;

            return (value == FillRule.EvenOdd) || 
                   (value == FillRule.Nonzero);
        }                                
    }

Usage Example

Beispiel #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="figures">A collection of figures</param>
        /// <param name="fillRule">The fill rule (OddEven or NonZero)</param>
        /// <param name="transform">A transformation to apply to the input</param>
        public PathGeometry(IEnumerable <PathFigure> figures, FillRule fillRule, Transform transform)
        {
            Transform = transform;
            if (ValidateEnums.IsFillRuleValid(fillRule))
            {
                FillRule = fillRule;

                if (figures != null)
                {
                    foreach (PathFigure item in figures)
                    {
                        Figures.Add(item);
                    }
                }
                else
                {
                    throw new ArgumentNullException("figures");
                }

                SetDirty();
            }
        }
ValidateEnums