private void ValueButtons(char numberButton) { if (Screen.Text == "") { if (Screen.Text == "" && numberButton != '.') { Screen.Text = $"{Screen.Text}{numberButton}"; History.Text += numberButton; CountingInput += numberButton; } else { Screen.Text = $"0."; History.Text += "0."; CountingInput += "0."; } } else { if (CountingInput.Last() == '+' || CountingInput.Last() == '-' || CountingInput.Last() == '*' || CountingInput.Last() == '/') { Screen.Text = ""; Screen.Text = $"{numberButton}"; History.Text += numberButton; CountingInput += numberButton; } else { if (Screen.Text == "0" && numberButton != '.') { Screen.Text = $"{numberButton}"; History.Text = History.Text.TrimEnd(History.Text.Last()); CountingInput = CountingInput.TrimEnd(CountingInput.Last()); History.Text += numberButton; CountingInput += numberButton; } else { Screen.Text = $"{Screen.Text}{numberButton}"; History.Text += numberButton; CountingInput += numberButton; } } } }
private void BackSpaceButton_Click(object sender, RoutedEventArgs e) { if (Screen.Text != "") { if (!(CountingInput.Last() == '+' || CountingInput.Last() == '-' || CountingInput.Last() == '*' || CountingInput.Last() == '/')) { CountingInput = CountingInput.Substring(0, CountingInput.Length - 1); History.Text = History.Text.Substring(0, History.Text.Length - 1); Screen.Text = Screen.Text.Substring(0, Screen.Text.Length - 1); if (Screen.Text == "-") { Screen.Text = ""; CountingInput = CountingInput.Substring(0, CountingInput.Length - 1); History.Text = History.Text.Substring(0, History.Text.Length - 1); } } } }
private void ActionButton(string mathaction) { if (Screen.Text != "") { if (CountingInput.Last() == '+' || CountingInput.Last() == '-' || CountingInput.Last() == '*' || CountingInput.Last() == '/') { History.Text = History.Text.TrimEnd(History.Text.Last()); History.Text += mathaction; CountingInput = CountingInput.TrimEnd(CountingInput.Last()); CountingInput += mathaction; } else { History.Text += mathaction; CountingInput += mathaction; } } }