-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.xaml.cs
More file actions
292 lines (263 loc) · 10.5 KB
/
Copy pathMainWindow.xaml.cs
File metadata and controls
292 lines (263 loc) · 10.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace ByteArithmetic
{
/// <summary>
/// Логика взаимодействия для MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
InterfaceClass UIElements = new InterfaceClass();
LocalizationClass LocalePRJ = new LocalizationClass();
public MainWindow()
{
InitializeComponent();
//Присовение UI
LocalePRJ.ExTBox = TextBoxInput;
LocalePRJ.ExLBox = InputText;
LocalePRJ.ExBlock = TextBlockStat;
LocalePRJ.ExLBlock = OutputText;
LocalePRJ.ExGridF = GridFunc;
LocalePRJ.ButtonClean = BClean;
LocalePRJ.ButtonProcess = BProcess;
LocalePRJ.ButtonExample = BExample;
LocalePRJ.ConsoleLabel = ConsoleL;
LocalePRJ.GridLogText = GridLog;
LocalePRJ.LabelLogText = LogLabel;
LocalePRJ.ConsoleLabelText = LogBox;
LocalePRJ.ButtonCleanCosnole = BCClean;
LocalePRJ.Info = Information;
//Скрытие элементов
LocalePRJ.Hide();
CurLang.Visibility = Visibility.Hidden;
//Выравнивание GRID
UIElements.ExG = GridLang;
UIElements.MarginLag(300, 0, 0, 120);
}
private void CheckBox_Checked_RU(object sender, RoutedEventArgs e)
{
if (CB_Ru.IsChecked == false)
{
CurLang.Content = "";
//Выравнивание GRID
UIElements.ExG = GridLang;
UIElements.MarginLag(300, 0, 0, 120);
//Скрытие
LocalePRJ.Hide();
} else
{
CurLang.Content = "Вы выбрали Русский.";
CurLang.Visibility = Visibility.Visible;
//Выравнивание GRID
UIElements.ExG = GridLang;
UIElements.MarginLag(569, 0, 0, 10);
//Первод и отображение
LocalePRJ.ChangeOnRu();
LocalePRJ.Show();
}
if (CB_En.IsChecked == true)
{
CB_En.IsChecked = false;
CurLang.Content = "Вы выбрали Русский.";
CurLang.Visibility = Visibility.Visible;
//Выравнивание GRID
UIElements.ExG = GridLang;
UIElements.MarginLag(569, 0, 0, 10);
//Первод и отображение
LocalePRJ.ChangeOnRu();
LocalePRJ.Show();
}
}
private void CheckBox_Checked_EN(object sender, RoutedEventArgs e)
{
if (CB_En.IsChecked == false)
{
CurLang.Content = "";
//Выравнивание GRID
UIElements.ExG = GridLang;
UIElements.MarginLag(300, 0, 0, 120);
//Скрытие
LocalePRJ.Hide();
}
else
{
CurLang.Content = "You have chosen English.";
CurLang.Visibility = Visibility.Visible;
//Выравнивание GRID
UIElements.ExG = GridLang;
UIElements.MarginLag(569, 0, 0, 10);
//Первод и отображение
LocalePRJ.ChangeOnEn();
LocalePRJ.Show();
}
if (CB_Ru.IsChecked == true)
{
CB_Ru.IsChecked = false;
CurLang.Content = "You have chosen English.";
CurLang.Visibility = Visibility.Visible;
//Выравнивание GRID
UIElements.ExG = GridLang;
UIElements.MarginLag(569, 0, 0, 10);
//Первод и отображение
LocalePRJ.ChangeOnEn();
LocalePRJ.Show();
}
}
private void BClean_Click(object sender, RoutedEventArgs e)
{
TextBoxInput.Clear();
LogBox.Text = null;
TextBlockStat.Text = null;
if (CB_Ru.IsChecked == true)
{
LogBox.Text = ">> Произведена очистка всех блоков.";
}
else
{
LogBox.Text = ">> All blocks are cleared.";
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
TextBoxInput.Clear();
TextBlockStat.Text = null;
string NotNull = LogBox.Text;
if (CB_Ru.IsChecked == true)
{
if (NotNull.Length > 0)
{
LogBox.Text = string.Concat(NotNull, "\n>> Произведена очистка блоков кроме логов.");
}
else
{
LogBox.Text = ">> Произведена очистка блоков кроме логов.";
}
}
else
{
if (NotNull.Length > 0)
{
LogBox.Text = string.Concat(NotNull, "\n>> Cleared blocks except logs.");
}
else
{
LogBox.Text = ">> Cleared blocks except logs.";
}
}
}
private void BProcess_Click(object sender, RoutedEventArgs e)
{
ExecutionProcessing();
}
private void ExecutionProcessing()
{
int Warning = 0;
string AllText = TextBoxInput.Text;
if (AllText != "")
{
string[] AllTextOnBlocks = AllText.Split(new Char[] { ' ' });
int NumOfBlocks = AllTextOnBlocks.Length;
//Проверка, что текст это действительно байт последовательность
for (int i = 0; i< AllTextOnBlocks.Length; i ++)
{
if (AllTextOnBlocks[i].Length != 2)
{
Warning = 1;
}
}
//Конец проверки
int NumOfSpace = AllText.Length - 2 * NumOfBlocks;
int NumOfSymbols = AllText.Length;
SetStatistics(NumOfBlocks, NumOfSpace, NumOfSymbols, Warning);
}
else
{
TextBlockStat.Text = null;
if (CB_Ru.IsChecked == true)
{
TextBlockStat.Text = "Ошибка ввода данных!";
}
else
{
TextBlockStat.Text = "Data entry error!";
}
}
}
private void SetStatistics(int NumberOfBlocks, int NumberOfSpace, int NumberOfSymbols, int WarningNotByte)
{
TextBlockStat.Text = null;
if (CB_Ru.IsChecked == true)
{
TextBlockStat.Text =
"Блоков: " + NumberOfBlocks + "\n" +
"Пробелов: " + NumberOfSpace + "\n" +
"Символов: " + NumberOfSymbols + "\n";
if (WarningNotByte == 1)
{
string Temp = TextBlockStat.Text;
Temp += "\n\nОбратите внимание: введённые данные не представляют байт последовательности";
TextBlockStat.Text = Temp;
}
string NotNull = LogBox.Text;
if (NotNull.Length > 0)
{ LogBox.Text = string.Concat(NotNull, "\nБлоков: " +
NumberOfBlocks + ", пробелов: " +
NumberOfSpace + ", символов: " +
NumberOfSymbols); }
else
{ LogBox.Text = "Блоков: " + NumberOfBlocks + ", пробелов: " + NumberOfSpace + ", символов: " + NumberOfSymbols; }
}
else
{
TextBlockStat.Text =
"Blocks: " + NumberOfBlocks + "\n" +
"Spaces: " + NumberOfSpace + "\n" +
"Characters: " + NumberOfSymbols + "\n";
if (WarningNotByte == 1)
{
string Temp = TextBlockStat.Text;
Temp += "\n\nNote: the data entered does not represent a byte of the sequence";
TextBlockStat.Text = Temp;
}
string NotNull = LogBox.Text;
if (NotNull.Length > 0)
{ LogBox.Text = string.Concat(NotNull, "\nBlocks: " +
NumberOfBlocks + ", spaces: " +
NumberOfSpace + ", characters: " +
NumberOfSymbols); }
else
{ LogBox.Text = "Blocks: " + NumberOfBlocks + ", spaces: " + NumberOfSpace + ", characters: " + NumberOfSymbols; }
}
}
private void BExample_Click(object sender, RoutedEventArgs e)
{
TextBoxInput.Clear();
TextBoxInput.Text = "d0 9f d1 80 d0 b8 d0 bc d0 b5 d1 80 20 45 78 61 6d 70 6c 65";
ExecutionProcessing();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
MessageBoxResult result =
MessageBox.Show(
"Автор данного ПО - Бородин Дмитрий; \n" +
"Адрес VK - http://vk.com/id60202849; \n" +
"Среда разработки - IDE Microsoft Visual Studio 2019 Enterprise; \n" +
"Язык разработки - C#, графический интерфейс - WPF \n",
"Сведения об авторе и среде разработки",
MessageBoxButton.OK,
MessageBoxImage.None);
}
}
}