RadNumericUpDown OwnerAsRadNumericUpDown() { RadNumericUpDown owner = base.Owner as RadNumericUpDown; if (null == owner) { throw new InvalidOperationException("The Owner have to be a RadNumericUpDown"); } return(owner); }
void IRangeValueProvider.SetValue(double value) { this.GuarantyEnabled(); RadNumericUpDown owner = this.OwnerAsRadNumericUpDown(); if (value < owner.Minimum || value > owner.Maximum) { throw new ArgumentOutOfRangeException("value"); } owner.Value = value; }
internal virtual double GetValue() { RadNumericUpDown owner = this.OwnerAsRadNumericUpDown(); int decimals = owner.GetDecimals(); double ownerValue = owner.Value; double result = Math.Round(ownerValue, decimals); #if TRACE_RadNumericUpDownAutomationPeer System.Diagnostics.Debug.WriteLine(string.Format( "RadNumericUpDownAutomationPeer.GetValue() >> result:> {0} = round( {1}, {2}) owner = {3}", result, ownerValue, decimals, owner)); #endif return(result); }
/// <summary> /// /// </summary> /// <param name="value"></param> void IValueProvider.SetValue(string value) { if (!base.IsEnabled()) { throw new ElementNotEnabledException(); } RadNumericUpDown owner = this.OwnerAsRadNumericUpDown(); if (!owner.IsEditable) { throw new InvalidOperationException(); } if (value == null) { throw new ArgumentNullException("value"); } // throw new System.NotImplementedException(); owner.ContentText = value; }
private static void OnIsIntegerChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { RadNumericUpDown numeric = sender as RadNumericUpDown; var isInteger = (bool)e.NewValue; switch (numeric.ValueFormat) { case ValueFormat.Numeric: numeric.NumberFormatInfo.NumberDecimalDigits = isInteger ? 0 : CultureInfo.CurrentCulture.NumberFormat.NumberDecimalDigits; break; case ValueFormat.Currency: numeric.NumberFormatInfo.CurrencyDecimalDigits = isInteger ? 0 : CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalDigits; break; case ValueFormat.Percentage: numeric.NumberFormatInfo.PercentDecimalDigits = isInteger ? 0 : CultureInfo.CurrentCulture.NumberFormat.PercentDecimalDigits; break; } numeric.UpdateText(); }
/// <summary> /// /// </summary> /// <param name="owner"></param> public RadNumericUpDownAutomationPeer(RadNumericUpDown owner) : base(owner) { }