private void DigitalCommandCanExecute(object sender, CanExecuteRoutedEventArgs e) { if (e.Parameter != null) { var number = Int32.Parse((string)e.Parameter); if (!_isInputed) { e.CanExecute = ValidateValueRange(number); } else { try { var newValue = Int32.Parse(ValueCurrent.ToString() + number); e.CanExecute = ValidateValueRange(newValue); } catch (FormatException) { e.CanExecute = false; return; } } } }
private void DigitalCommandExecuted(object Sender, ExecutedRoutedEventArgs e) { var number = double.Parse((string)e.Parameter); if (!_isInputed) { ValueCurrent = number; StringValueCurrent = ValueCurrent.ToString(); _isInputed = true; } else if (_isDotCount == 1) { StringValueCurrent = StringValueCurrent + number; ValueCurrent = StringValueCurrent.ToDouble(); _isInputed = true; } else { var str = StringValueCurrent + number; ValueCurrent = Double.Parse(str); StringValueCurrent = str; _isInputed = true; } if (ValueCurrent < ValueMin || ValueCurrent > ValueMax) { IsValid = true; } else { IsValid = false; } }
private void BackspaceCommandExecuted(object sender, ExecutedRoutedEventArgs e) { var str = ValueCurrent.ToString(); if (str.Length == 1) { ValueCurrent = null; return; } string tempStr; if (str.Length > 2 && str[str.Length - 2] == '.') { tempStr = str.Remove(str.Length - 2); } else { tempStr = str.Remove(str.Length - 1); } if (tempStr == "-") { ValueCurrent = null; return; } ValueCurrent = Int32.Parse(tempStr); }
private void MinCommandExecuted(object Sender, ExecutedRoutedEventArgs e) { if (!_isInputed) { _isInputed = true; _isPositiveNum = false; StringValueCurrent = "-" + StringValueCurrent; ValueCurrent = StringValueCurrent.ToDouble(); } _isInputed = true; if (ValueCurrent > 0) { ValueCurrent -= 2 * ValueCurrent; StringValueCurrent = ValueCurrent.ToString(); } else if (ValueCurrent == 0) { StringValueCurrent = "-0."; ValueCurrent = StringValueCurrent.ToDouble(); } // ValueCurrent = ValueMin; // IsValid = true; if ((ValueCurrent < ValueMin) || (ValueCurrent > ValueMax) || StringValueCurrent.Length > 5) { IsValid = false; } else { IsValid = true; } }
private void MaxCommandExecuted(object Sender, ExecutedRoutedEventArgs e) { _isInputed = true; if (ValueCurrent < 0) { ValueCurrent -= 2 * ValueCurrent; StringValueCurrent = ValueCurrent.ToString(); } else if (ValueCurrent == 0) { StringValueCurrent = "0."; } _isPositiveNum = true; // ValueCurrent = ValueMax; // IsValid = true; if ((ValueCurrent < ValueMin) || (ValueCurrent > ValueMax) || StringValueCurrent.Length > 5) { IsValid = false; } else { IsValid = true; } }
private void BackspaceCommandCanExecute(object sender, CanExecuteRoutedEventArgs e) { if (ValueCurrent == null) { return; } var str = ValueCurrent.ToString(); if (str.Length > 0) { e.CanExecute = true; } }
private void DigitalCommandExecuted(object sender, ExecutedRoutedEventArgs e) { var number = Int32.Parse((string)e.Parameter); if (!_isInputed) { ValueCurrent = number; _isInputed = true; } else { var str = ValueCurrent.ToString() + number; ValueCurrent = Int32.Parse(str); } }
private void NegativeCommandExecuted(object Sender, ExecutedRoutedEventArgs e) { if (!_isInputed) { _isInputed = true; StringValueCurrent = ""; ValueCurrent = 0; } ValueCurrent -= 2 * ValueCurrent; if (ValueCurrent == 0) { StringValueCurrent = ""; } else { StringValueCurrent = ValueCurrent.ToString(); } }
private void DigitalCommandCanExecute(object Sender, CanExecuteRoutedEventArgs e) { if (e.Parameter != null) { double number = double.Parse((string)e.Parameter); if (!_isInputed) { e.CanExecute = ValidateValueRange(number); } else { try { if (_isDot) { if (_isDotCount == 1) { var str = Double.Parse(ValueCurrent.ToString() + "." + number); e.CanExecute = ValidateValueRange(str); } } else { var str = Double.Parse(ValueCurrent.ToString() + number); e.CanExecute = ValidateValueRange(str); } // _isDot = false; // StringValueCurrent = ValueCurrent.ToString(); // var newValue = Double.Parse(ValueCurrent.ToString() + number); // e.CanExecute = ValidateValueRange(newValue); } catch (FormatException) { e.CanExecute = false; return; } } } }
private void MinCommandExecuted(object Sender, ExecutedRoutedEventArgs e) { _isInputed = true; ValueCurrent = ValueMin; StringValueCurrent = ValueCurrent.ToString(); }