Exemple #1
0
        private static object CoerceEndAngleValue(DependencyObject d, object value)
        {
            // keep EndAngle in sync with Slice and SweepDirection
            Pie pie = (Pie)d;

            if (pie.IsUpdatingSlice || pie.IsUpdatingSweepDirection ||
                (pie.IsUpdatingStartAngle && pie.Mode == PieMode.Slice))
            {
                double newValue = pie.StartAngle + ((pie.SweepDirection == SweepDirection.Clockwise) ? 1.0 : -1.0) * pie.Slice * 360;
                if (!DoubleHelper.AreVirtuallyEqual((double)value, newValue))
                {
                    value = newValue;
                }
            }
            return(value);
        }
Exemple #2
0
        private static object CoerceSliceValue(DependencyObject d, object value)
        {
            // keep Slice in sync with EndAngle, StartAngle, and SweepDirection
            Pie pie = (Pie)d;

            if (pie.IsUpdatingEndAngle || pie.IsUpdatingStartAngle || pie.IsUpdatingSweepDirection)
            {
                double slice    = Math.Max(-360.0, Math.Min(360.0, (pie.EndAngle - pie.StartAngle))) / ((pie.SweepDirection == SweepDirection.Clockwise) ? 360.0 : -360.0);
                double newValue = DoubleHelper.AreVirtuallyEqual(slice, 0) ? 0 : (slice < 0) ? slice + 1 : slice;
                if (!DoubleHelper.AreVirtuallyEqual((double)value, newValue))
                {
                    value = newValue;
                }
            }
            return(value);
        }
Exemple #3
0
        private static object CoerceSweepDirectionValue(DependencyObject d, object value)
        {
            // keep SweepDirection in sync with EndAngle and StartAngle
            Pie pie = (Pie)d;

            if (pie.IsUpdatingEndAngle || pie.IsUpdatingStartAngle || pie.IsUpdatingMode)
            {
                if (DoubleHelper.AreVirtuallyEqual(pie.StartAngle, pie.EndAngle))
                {
                    // if the values are equal, use previously coerced value
                    value = pie.SweepDirection;
                }
                else
                {
                    value = (pie.EndAngle < pie.StartAngle) ? SweepDirection.Counterclockwise : SweepDirection.Clockwise;
                }
            }
            return(value);
        }