void OnSave() { using (var calcQuick = new CalcQuickBase()) { CalculationResultText = calcQuick.ParseAndCompute(formulaText); OnPropertyChanged("CategoryReal.TotalValues"); OnSaveValue?.Invoke(double.Parse(calculationResultText), Calendar.Date.Value.DateTime); } }
private void TextBox_KeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e) { if (sender is TextBox textbox && e.Key == Windows.System.VirtualKey.Enter) { FormulaText = textbox.Text; using (var calcQuick = new CalcQuickBase()) { CalculationResultText = calcQuick.ParseAndCompute(formulaText); OnPropertyChanged(nameof(CalculationResultText)); } } }
void HandleKeyPressed(object param) { var value = (string)param; var calculatorKey = (CalculatorKey)Enum.Parse(typeof(CalculatorKey), value, true); switch (calculatorKey) { case CalculatorKey.One: case CalculatorKey.Two: case CalculatorKey.Three: case CalculatorKey.Four: case CalculatorKey.Five: case CalculatorKey.Six: case CalculatorKey.Seven: case CalculatorKey.Eight: case CalculatorKey.Nine: case CalculatorKey.Zero: FormulaText += ((int)calculatorKey).ToString(); OnPropertyChanged(nameof(CalculationResultText)); break; case CalculatorKey.Equal: if (!string.IsNullOrEmpty(formulaText)) { using (var calcQuick = new CalcQuickBase()) { CalculationResultText = calcQuick.ParseAndCompute(formulaText); OnPropertyChanged(nameof(CalculationResultText)); } } break; case CalculatorKey.Point: FormulaText += cultureInfoPL.NumberFormat.NumberDecimalSeparator; break; case CalculatorKey.Minus: FormulaText += '-'; break; case CalculatorKey.Multiply: FormulaText += '*'; break; case CalculatorKey.Divide: FormulaText += '/'; break; case CalculatorKey.Plus: FormulaText += '+'; break; case CalculatorKey.Backspace: if (!string.IsNullOrEmpty(FormulaText)) { FormulaText = FormulaText.Substring(0, FormulaText.Length - 1); } break; } return; }