//Кнопка ДЕЛЕНИЯ // Все так как и в суммировании private void Division_button_click(object sender, RoutedEventArgs e) { if (lbl.Content.ToString() != "" && lbl.Content.ToString() != "Error") { Equal_button.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); } first_number = Convert.ToDouble(txtBox.Text); lbl.Content = txtBox.Text + " /"; txtBox.Text = "0"; operation = "Division"; }
// Событие нажатия клавиши на клавиатуре private void Window_KeyDown(object sender, KeyEventArgs e) { KeyboardInput keyin = new KeyboardInput(); string input_key = keyin.Keyboard(sender, e).ToString(); int test1 = 0; for (int i = 0; i < 10; i++) { if (input_key == i.ToString()) { Test(input_key); test1++; } } switch (input_key) { case ".": Test(input_key); test1++; break; case ",": Test(input_key); test1++; break; case "sum": Sum_button.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); break; case "subtract": Subtract_button.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); break; case "division": Division_button.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); break; case "multiply": Multiply_button.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); break; case "enter": Equal_button.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); break; case "backspace": Backspace_button.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); break; default: break; } }
//Кнопка СУММИРОВАНИЯ private void Sum_botton_click(object sender, RoutedEventArgs e) { if (lbl.Content.ToString() != "" && lbl.Content.ToString() != "Error") // Прверка случая когда после суммирования не была нажата кнопка равно { Equal_button.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); // Вызов собития нажатия кнопки равно } first_number = Convert.ToDouble(txtBox.Text); // Первому числу присваивается значение строки в тексбоксе lbl.Content = txtBox.Text + " +"; // Показывает в label какое было последнее число и какая операция дальше будет выполнена txtBox.Text = "0"; operation = "Sum"; }
private void Operator(object sender, EventArgs e) { //This equation ejecute one operation per time when one operator buuton eis pressed Button b = (Button)sender; if (value != 0) { Equal_button.PerformClick(); opera_click = true; opera = b.Text; equation.Text = value + " " + opera; } else { opera = b.Text; value = Double.Parse(result.Text); opera_click = true; equation.Text = value + " " + opera; } }