MainWindow.xaml.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. namespace kursach3
  16. {
  17. /// <summary>
  18. /// Логика взаимодействия для MainWindow.xaml
  19. /// </summary>
  20. public partial class MainWindow : Window
  21. {
  22. public MainWindow()
  23. {
  24. InitializeComponent();
  25. }
  26. public void ClearTextBox()
  27. {
  28. lblFirst.Text = "";
  29. lblSecond.Text = "";
  30. lblAction.Content = "";
  31. lblResult.Text = "";
  32. }
  33. private void btn1_Click(object sender, RoutedEventArgs e)
  34. {
  35. if (lblAction.Content == "")
  36. {
  37. lblFirst.Text += Numbers.One();
  38. }
  39. else
  40. {
  41. lblSecond.Text += Numbers.One();
  42. }
  43. }
  44. private void btn2_Click(object sender, RoutedEventArgs e)
  45. {
  46. if (lblAction.Content == "")
  47. {
  48. lblFirst.Text += Numbers.Two();
  49. }
  50. else
  51. {
  52. lblSecond.Text += Numbers.Two();
  53. }
  54. }
  55. private void btn3_Click(object sender, RoutedEventArgs e)
  56. {
  57. if (lblAction.Content == "")
  58. {
  59. lblFirst.Text += Numbers.Three();
  60. }
  61. else
  62. {
  63. lblSecond.Text += Numbers.Three();
  64. }
  65. }
  66. private void btn4_Click(object sender, RoutedEventArgs e)
  67. {
  68. if (lblAction.Content == "")
  69. {
  70. lblFirst.Text += Numbers.Four();
  71. }
  72. else
  73. {
  74. lblSecond.Text += Numbers.Four();
  75. }
  76. }
  77. private void btn5_Click(object sender, RoutedEventArgs e)
  78. {
  79. if (lblAction.Content == "")
  80. {
  81. lblFirst.Text += Numbers.Five();
  82. }
  83. else
  84. {
  85. lblSecond.Text += Numbers.Five();
  86. }
  87. }
  88. private void btn6_Click(object sender, RoutedEventArgs e)
  89. {
  90. if (lblAction.Content == "")
  91. {
  92. lblFirst.Text += Numbers.Six();
  93. }
  94. else
  95. {
  96. lblSecond.Text += Numbers.Six();
  97. }
  98. }
  99. private void btn7_Click(object sender, RoutedEventArgs e)
  100. {
  101. if (lblAction.Content == "")
  102. {
  103. lblFirst.Text += Numbers.Seven();
  104. }
  105. else
  106. {
  107. lblSecond.Text += Numbers.Seven();
  108. }
  109. }
  110. private void btn8_Click(object sender, RoutedEventArgs e)
  111. {
  112. if (lblAction.Content == "")
  113. {
  114. lblFirst.Text += Numbers.Eight();
  115. }
  116. else
  117. {
  118. lblSecond.Text += Numbers.Eight();
  119. }
  120. }
  121. private void btn9_Click(object sender, RoutedEventArgs e)
  122. {
  123. if (lblAction.Content == "")
  124. {
  125. lblFirst.Text += Numbers.Nine();
  126. }
  127. else
  128. {
  129. lblSecond.Text += Numbers.Nine();
  130. }
  131. }
  132. private void btn0_Click(object sender, RoutedEventArgs e)
  133. {
  134. if (lblAction.Content == "")
  135. {
  136. lblFirst.Text += Numbers.Zero();
  137. }
  138. else
  139. {
  140. lblSecond.Text += Numbers.Zero();
  141. }
  142. }
  143. private void btnClear_Click(object sender, RoutedEventArgs e)
  144. {
  145. ClearTextBox();
  146. }
  147. private void btnPlus_Click(object sender, RoutedEventArgs e)
  148. {
  149. lblAction.Content = "+";
  150. }
  151. private void btnMinus_Click(object sender, RoutedEventArgs e)
  152. {
  153. lblAction.Content = "-";
  154. }
  155. private void btnMult_Click(object sender, RoutedEventArgs e)
  156. {
  157. lblAction.Content = "*";
  158. }
  159. }
  160. }