private static void OnMaxValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { double maxValue = (double)e.NewValue; NumericBox numericBox = (NumericBox)sender; numericBox.MaxValue = maxValue; }
private static void OnCurValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { double value = (double)e.NewValue; NumericBox numericBox = (NumericBox)sender; numericBox.Text = value.ToString(); }
private void MarkerFrequency_PreviewMouseWheel(object sender, MouseWheelEventArgs e) { NumericBox numericBox = sender as NumericBox; double currentValue = Utility.FrequencyStringToValue(numericBox.Text); double stepvalue = mViewModel.Span / 100; double newValue = currentValue + (e.Delta > 0 ? stepvalue : -stepvalue); numericBox.Text = Utility.FrequencyValueToString(newValue); }
void NumericBox_LostFocus(object sender, RoutedEventArgs e) { NumericBox numericBox = sender as NumericBox; if (string.IsNullOrEmpty(numericBox.Text)) { numericBox.Text = this.CurValue.ToString(); } }
private static void OnDigitsChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { int digits = (int)e.NewValue; NumericBox numericBox = (NumericBox)sender; numericBox.CurValue = (double)Math.Round(numericBox.CurValue, digits); numericBox.MinValue = (double)Math.Round(numericBox.MinValue, digits); numericBox.MaxValue = (double)Math.Round(numericBox.MaxValue, digits); }
void NumericBox_PreviewMouseWheel(object sender, MouseWheelEventArgs e) { try { if (Unit != "") { //If there is Unit set, cannot directly convert the value, MouseWheel shoudl be handled in other place return; } NumericBox numericBox = sender as NumericBox; double oldValue = Convert.ToSingle(numericBox.Text); double newValue = oldValue + (e.Delta > 0 ? 1 : -1); numericBox.Text = newValue.ToString(); } catch { } }
void NumericBox_TextChanged(object sender, TextChangedEventArgs e) { NumericBox numericBox = sender as NumericBox; if (string.IsNullOrEmpty(numericBox.Text)) { return; } TrimZeroStart(); double value = MinValue; if (!double.TryParse(numericBox.Text, out value)) { return; } if (value != this.CurValue) { this.CurValue = value; } }