private void ChangeText() { Text = NumberType == EnumNumberType.Amount ? FormatterHelper.Format(Amount.Value) : FormatterHelper.FormatPercentage(Amount.Value); }
private void OnHandlerUnfocused(object sender, FocusEventArgs e) { decimal value = 0; if (decimal.TryParse(Text, out value)) { if (MaximumAmount.IsNotNull() && value > MaximumAmount) { Amount = MaximumAmount; Text = NumberType == EnumNumberType.Amount ? FormatterHelper.Format(Amount.Value) : FormatterHelper.FormatPercentage(Amount.Value); } else if (MinimumAmount.IsNotNull() && value < MinimumAmount) { Amount = MinimumAmount; Text = NumberType == EnumNumberType.Amount ? FormatterHelper.Format(Amount.Value) : FormatterHelper.FormatPercentage(Amount.Value); } else { Amount = value; Text = NumberType == EnumNumberType.Amount ? FormatterHelper.Format(Amount.Value) : FormatterHelper.FormatPercentage(Amount.Value); } } else { Text = string.Empty; Amount = 0; } }
private string FormatPercentage(object value) => FormatterHelper.FormatPercentage(System.Convert.ToDecimal(value));