Esempio n. 1
0
        private static void OnMaxValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            double     maxValue   = (double)e.NewValue;
            NumericBox numericBox = (NumericBox)sender;

            numericBox.MaxValue = maxValue;
        }
Esempio n. 2
0
        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);
        }
Esempio n. 4
0
        void NumericBox_LostFocus(object sender, RoutedEventArgs e)
        {
            NumericBox numericBox = sender as NumericBox;

            if (string.IsNullOrEmpty(numericBox.Text))
            {
                numericBox.Text = this.CurValue.ToString();
            }
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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
            {
            }
        }
Esempio n. 7
0
        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;
            }
        }