CalculatePage.xaml.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Markup;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. using System.Windows.Shapes;
  17. namespace PPRazumovskiy.Pages
  18. {
  19. /// <summary>
  20. /// Логика взаимодействия для CalculatePage.xaml
  21. /// </summary>
  22. public partial class CalculatePage : Page
  23. {
  24. public CalculatePage()
  25. {
  26. InitializeComponent();
  27. answerDataGrid.Visibility = Visibility.Hidden;
  28. }
  29. private void btn0_Click(object sender, RoutedEventArgs e)
  30. {
  31. exampleTextBox.Text += GlobalElement.allSymbols[0];
  32. exampleTextBox.Focus();
  33. }
  34. private void btn1_Click(object sender, RoutedEventArgs e)
  35. {
  36. exampleTextBox.Text += GlobalElement.allSymbols[1];
  37. exampleTextBox.Focus();
  38. }
  39. private void btn2_Click(object sender, RoutedEventArgs e)
  40. {
  41. exampleTextBox.Text += GlobalElement.allSymbols[2];
  42. exampleTextBox.Focus();
  43. }
  44. private void btn3_Click(object sender, RoutedEventArgs e)
  45. {
  46. exampleTextBox.Text += GlobalElement.allSymbols[3];
  47. exampleTextBox.Focus();
  48. }
  49. private void btn4_Click(object sender, RoutedEventArgs e)
  50. {
  51. exampleTextBox.Text += GlobalElement.allSymbols[4];
  52. exampleTextBox.Focus();
  53. }
  54. private void btn5_Click(object sender, RoutedEventArgs e)
  55. {
  56. exampleTextBox.Text += GlobalElement.allSymbols[5];
  57. exampleTextBox.Focus();
  58. }
  59. private void btn6_Click(object sender, RoutedEventArgs e)
  60. {
  61. exampleTextBox.Text += GlobalElement.allSymbols[6];
  62. exampleTextBox.Focus();
  63. }
  64. private void btn7_Click(object sender, RoutedEventArgs e)
  65. {
  66. exampleTextBox.Text += GlobalElement.allSymbols[7];
  67. exampleTextBox.Focus();
  68. }
  69. private void btn8_Click(object sender, RoutedEventArgs e)
  70. {
  71. exampleTextBox.Text += GlobalElement.allSymbols[8];
  72. exampleTextBox.Focus();
  73. }
  74. private void getAnswerBtn_Click(object sender, RoutedEventArgs e)
  75. {
  76. answerDataGrid.ItemsSource = null;
  77. string text = exampleTextBox.Text;
  78. if (text.Length > 0)
  79. {
  80. if (text[0].ToString() == GlobalElement.allSymbols[0])
  81. {
  82. if (!GlobalElement.allSymbols.Contains(text[text.Length - 1].ToString()))
  83. {
  84. answerDataGrid.AutoGenerateColumns = false;
  85. //var dataContext = new Calculate(text);
  86. //answerDataGrid.ItemsSource = dataContext.CalculateElements;
  87. //foreach (var item in dataContext.CalculateElements)
  88. //{
  89. // answerDataGrid.Columns.Add(
  90. // new DataGridTextColumn { Header = item.Header }
  91. // );
  92. //}
  93. var data = new Calculate(text).All;
  94. //answerDataGrid.ItemsSource = data.ToDataTable().DefaultView;
  95. answerDataGrid.Visibility = Visibility.Visible;
  96. }
  97. }
  98. else
  99. {
  100. if (!GlobalElement.allSymbols.Contains(text[0].ToString()) && !GlobalElement.allSymbols.Contains(text[text.Length - 1].ToString()))
  101. {
  102. answerDataGrid.AutoGenerateColumns = false;
  103. //var dataContext = new Calculate(text);
  104. //answerDataGrid.ItemsSource = dataContext.CalculateElements;
  105. //foreach (var item in dataContext.CalculateElements)
  106. //{
  107. // answerDataGrid.Columns.Add(
  108. // new DataGridTextColumn { Header = item.Header }
  109. // );
  110. //}
  111. var data = new Calculate(text).All;
  112. //answerDataGrid.ItemsSource = data.ToDataTable().DefaultView;
  113. answerDataGrid.Visibility = Visibility.Visible;
  114. }
  115. }
  116. }
  117. }
  118. }
  119. }