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 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; } } }