Esempio n. 1
0
File: CNum.cs Progetto: Daoting/dt
        static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            CNum   c   = (CNum)d;
            double val = (double)e.NewValue;

            if (double.IsInfinity(val))
            {
                throw new ArgumentException("无效值");
            }

            if (c._levelsFromRootCall == 0)
            {
                c._requestedVal = val;
                c._initialVal   = (double)e.OldValue;
            }
            c._levelsFromRootCall++;
            c.CoerceValue();
            c._levelsFromRootCall--;
            if (c._levelsFromRootCall == 0)
            {
                if (!AreClose(c._initialVal, val))
                {
                    c.OnValueChanged(new ValueChangedEventArgs <double>(c._initialVal, val));
                }
            }
        }
Esempio n. 2
0
File: CNum.cs Progetto: Daoting/dt
        static void OnIsIntegerChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            CNum c         = (CNum)d;
            bool isInteger = (bool)e.NewValue;

            switch (c.ValueFormat)
            {
            case ValueFormat.Numeric:
                c.NumberFormatInfo.NumberDecimalDigits = isInteger ? 0 : CultureInfo.CurrentCulture.NumberFormat.NumberDecimalDigits;
                break;

            case ValueFormat.Currency:
                c.NumberFormatInfo.CurrencyDecimalDigits = isInteger ? 0 : CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalDigits;
                break;

            case ValueFormat.Percentage:
                c.NumberFormatInfo.PercentDecimalDigits = isInteger ? 0 : CultureInfo.CurrentCulture.NumberFormat.PercentDecimalDigits;
                break;
            }
            c.UpdateText();
        }
Esempio n. 3
0
File: CNum.cs Progetto: Daoting/dt
        static void OnMinimumPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            CNum c = (CNum)d;

            if (!IsValidDoubleValue((double)e.NewValue))
            {
                throw new ArgumentException("无效最小值");
            }
            if (c._levelsFromRootCall == 0)
            {
                c._initialMax = c.Maximum;
                c._initialVal = c.Value;
            }
            c._levelsFromRootCall++;
            c.CoerceMaximum();
            c.CoerceValue();
            c._levelsFromRootCall--;
            if (c._levelsFromRootCall == 0)
            {
                // UI 自动化
            }
        }