public static void OnDataChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { GameParametrControl control = (GameParametrControl)sender; if (e.Property == TextProperty) { control.text.Content = (string)e.NewValue; } else if (e.Property == ValueProperty) { double d = (double)e.NewValue; if (double.IsNaN(d)) { control.value.Content = "-"; } else if (double.IsPositiveInfinity(d)) { control.value.Content = "беск."; } else if (double.IsNegativeInfinity(d)) { control.value.Content = "-беск."; } else { control.value.Content = d.ToString(); if (control.InGameCell) { control.value.Content += "×"; } } } else if (e.Property == IncrementProperty) { double d = (double)e.NewValue; control.increment.Content = d.ToString("+0.##;-0.##;←"); control.increment.Foreground = new SolidColorBrush(Colors.Green); if (double.IsNaN(d)) { control.increment.Content = "-"; } else if (double.IsPositiveInfinity(d)) { control.increment.Content = "∞"; } else if (double.IsNegativeInfinity(d)) { control.increment.Foreground = new SolidColorBrush(Colors.Red); control.increment.Content = "-∞"; } else { if (d != 0) { if (d < 0) { control.increment.Foreground = new SolidColorBrush(Colors.Red); } if (control.InGameCell) { control.increment.Content += "×"; } } } } }
public static void OnImageChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { GameParametrControl control = (GameParametrControl)sender; control.image.Source = (ImageSource)e.NewValue; }