Ejemplo n.º 1
0
        /// <summary>
        /// Verifies if this Thickness contains only valid values
        /// The set of validity checks is passed as parameters.
        /// </summary>
        /// <param name='thick'>Thickness value</param>
        /// <param name='allowNegative'>allows negative values</param>
        /// <param name='allowNaN'>allows Double.NaN</param>
        /// <param name='allowPositiveInfinity'>allows Double.PositiveInfinity</param>
        /// <param name='allowNegativeInfinity'>allows Double.NegativeInfinity</param>
        /// <returns>Whether or not the thickness complies to the range specified</returns>
        public static bool IsValid(Thickness thick, bool allowNegative, bool allowNaN, bool allowPositiveInfinity, bool allowNegativeInfinity)
        {
            if (!allowNegative)
            {
                if (thick.Left < 0d || thick.Right < 0d || thick.Top < 0d || thick.Bottom < 0d)
                {
                    return(false);
                }
            }

            if (!allowNaN)
            {
                if (DoubleUtil.IsNaN(thick.Left) || DoubleUtil.IsNaN(thick.Right) ||
                    DoubleUtil.IsNaN(thick.Top) || DoubleUtil.IsNaN(thick.Bottom))
                {
                    return(false);
                }
            }

            if (!allowPositiveInfinity)
            {
                if (double.IsPositiveInfinity(thick.Left) || double.IsPositiveInfinity(thick.Right) ||
                    double.IsPositiveInfinity(thick.Top) || double.IsPositiveInfinity(thick.Bottom))
                {
                    return(false);
                }
            }

            if (!allowNegativeInfinity)
            {
                if (double.IsNegativeInfinity(thick.Left) || double.IsNegativeInfinity(thick.Right) ||
                    double.IsNegativeInfinity(thick.Top) || double.IsNegativeInfinity(thick.Bottom))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Verifies if this CornerRadius contains only valid values
        /// The set of validity checks is passed as parameters.
        /// </summary>
        /// <param name='corner'>CornerRadius value</param>
        /// <param name='allowNegative'>allows negative values</param>
        /// <param name='allowNaN'>allows Double.NaN</param>
        /// <param name='allowPositiveInfinity'>allows Double.PositiveInfinity</param>
        /// <param name='allowNegativeInfinity'>allows Double.NegativeInfinity</param>
        /// <returns>Whether or not the CornerRadius complies to the range specified</returns>
        public static bool IsValid(CornerRadius corner, bool allowNegative, bool allowNaN, bool allowPositiveInfinity, bool allowNegativeInfinity)
        {
            if (!allowNegative)
            {
                if (corner.TopLeft < 0d || corner.TopRight < 0d || corner.BottomLeft < 0d || corner.BottomRight < 0d)
                {
                    return(false);
                }
            }

            if (!allowNaN)
            {
                if (DoubleUtil.IsNaN(corner.TopLeft) || DoubleUtil.IsNaN(corner.TopRight) ||
                    DoubleUtil.IsNaN(corner.BottomLeft) || DoubleUtil.IsNaN(corner.BottomRight))
                {
                    return(false);
                }
            }

            if (!allowPositiveInfinity)
            {
                if (double.IsPositiveInfinity(corner.TopLeft) || double.IsPositiveInfinity(corner.TopRight) ||
                    double.IsPositiveInfinity(corner.BottomLeft) || double.IsPositiveInfinity(corner.BottomRight))
                {
                    return(false);
                }
            }

            if (!allowNegativeInfinity)
            {
                if (double.IsNegativeInfinity(corner.TopLeft) || double.IsNegativeInfinity(corner.TopRight) ||
                    double.IsNegativeInfinity(corner.BottomLeft) || double.IsNegativeInfinity(corner.BottomRight))
                {
                    return(false);
                }
            }

            return(true);
        }