private static void Radian_PropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) { LineSettingGraphic control = (LineSettingGraphic)o; control.LineRotateTransform.Angle = (double)e.NewValue * 180 / Math.PI; if (control.Rotation != (double)e.NewValue * 180 / Math.PI) { control.Rotation = (double)e.NewValue * 180 / Math.PI; } }
private static void CaliperCount_PropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) { LineSettingGraphic control = (LineSettingGraphic)o; var newCount = (int)e.NewValue > 150 ? 150 : ((int)e.NewValue < 3 ? 3 : (int)e.NewValue); if (control.CaliperCollection.Count != newCount) { control.CaliperCollection.Clear(); for (int i = 0; i < newCount; i++) { control.CaliperCollection.Add(true); } } }
private static object CaliperCount_CoerceValue(DependencyObject o, object baseValue) { LineSettingGraphic control = (LineSettingGraphic)o; if (baseValue is int count) { if (count < 3) { return(3); } else if (count > 150) { return(150); } else { return(count); } } else { return(3); } }