//Making sure that we have at minimum 2 Teeth; private static object OnCoerceTeeth(DependencyObject obj, object baseValue) { CogWheelShape shape = (CogWheelShape)obj; int value = (int)baseValue; if (value < 2) { value = 2; } return(value); }
//Restrict percentage values between 0 and 100 for Bevel, MiddleRadiusOffset, InnerRadiusOffset; private static object OnCoercePercentageValue(DependencyObject obj, object baseValue) { CogWheelShape shape = (CogWheelShape)obj; int value = (int)baseValue; if (value < 0) { value = 0; } if (value > 100) { value = 100; } return(value); }
//Making sure that Rotation is between 0 and 360; private static object OnCoerceRotationAngle(DependencyObject obj, object baseValue) { CogWheelShape shape = (CogWheelShape)obj; double value = (double)baseValue; if (value < 0) { value = 0; } if (value > 360) { value = 360; } return(value); }