Repository navigation
Expand file tree
/
Copy pathForm1.cs
More file actions
395 lines (338 loc) · 10.4 KB
/
Copy pathForm1.cs
File metadata and controls
395 lines (338 loc) · 10.4 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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Media;
namespace Translator
{
public partial class TranslatorPage : Form
{
private Button[] DecButtons = new Button[10];
private Button[] BinButtons = new Button[2];
private Button[] HexButtons = new Button[16];
private Button[] HexDecButtons = new Button[10];
public TranslatorPage()
{
InitializeComponent();
}
private void TranslatorPage_Load(object sender, EventArgs e)
{
DecButtons[0] = DecBtn0;
DecButtons[1] = DecBtn1;
DecButtons[2] = DecBtn2;
DecButtons[3] = DecBtn3;
DecButtons[4] = DecBtn4;
DecButtons[5] = DecBtn5;
DecButtons[6] = DecBtn6;
DecButtons[7] = DecBtn7;
DecButtons[8] = DecBtn8;
DecButtons[9] = DecBtn9;
BinButtons[0] = BinBtn0;
BinButtons[1] = BinBtn1;
HexButtons[0] = HexBtn0;
HexButtons[1] = HexBtn1;
HexButtons[2] = HexBtn2;
HexButtons[3] = HexBtn3;
HexButtons[4] = HexBtn4;
HexButtons[5] = HexBtn5;
HexButtons[6] = HexBtn6;
HexButtons[7] = HexBtn7;
HexButtons[8] = HexBtn8;
HexButtons[9] = HexBtn9;
HexButtons[10] = HexBtnA;
HexButtons[11] = HexBtnB;
HexButtons[12] = HexBtnC;
HexButtons[13] = HexBtnD;
HexButtons[14] = HexBtnE;
HexButtons[15] = HexBtnF;
HexDecButtons[0] = HexDecBtn0;
HexDecButtons[1] = HexDecBtn1;
HexDecButtons[2] = HexDecBtn2;
HexDecButtons[3] = HexDecBtn3;
HexDecButtons[4] = HexDecBtn4;
HexDecButtons[5] = HexDecBtn5;
HexDecButtons[6] = HexDecBtn6;
HexDecButtons[7] = HexDecBtn7;
HexDecButtons[8] = HexDecBtn8;
HexDecButtons[9] = HexDecBtn9;
}
#region Binary Page
#region Decimal Buttons
private void DecBtn0_Click(object sender, EventArgs e)
{
BinInpBox.AppendText("0");
}
private void DecBtn1_Click(object sender, EventArgs e)
{
BinInpBox.AppendText("1");
}
private void DecBtn2_Click(object sender, EventArgs e)
{
BinInpBox.AppendText("2");
}
private void DecBtn3_Click(object sender, EventArgs e)
{
BinInpBox.AppendText("3");
}
private void DecBtn4_Click(object sender, EventArgs e)
{
BinInpBox.AppendText("4");
}
private void DecBtn5_Click(object sender, EventArgs e)
{
BinInpBox.AppendText("5");
}
private void DecBtn6_Click(object sender, EventArgs e)
{
BinInpBox.AppendText("6");
}
private void DecBtn7_Click(object sender, EventArgs e)
{
BinInpBox.AppendText("7");
}
private void DecBtn8_Click(object sender, EventArgs e)
{
BinInpBox.AppendText("8");
}
private void DecBtn9_Click(object sender, EventArgs e)
{
BinInpBox.AppendText("9");
}
#endregion
#region Binary Buttons
private void BinBtn0_Click(object sender, EventArgs e)
{
BinInpBox.AppendText("0");
}
private void BinBtn1_Click(object sender, EventArgs e)
{
BinInpBox.AppendText("1");
}
#endregion
private void BinToIntBtn_CheckedChanged(object sender, EventArgs e)
{
BinInpBox.Clear();
BinOutBox.Clear();
foreach (Button btn in DecButtons)
{
btn.Visible = false;
}
foreach(Button btn in BinButtons)
{
btn.Visible = true;
}
}
private void IntToBinBtn_CheckedChanged(object sender, EventArgs e)
{
BinInpBox.Clear();
BinOutBox.Clear();
foreach(Button btn in BinButtons)
{
btn.Visible = false;
}
foreach(Button btn in DecButtons)
{
btn.Visible = true;
}
}
private void BinTraBtn_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(BinInpBox.Text))
{
if (IntToBinBtn.Checked)
{
try
{
BinOutBox.Text = "Int to bin";
//BinOutBox.Text = [Metodo de conversão da dll]
}
catch (Exception)
{
SystemSounds.Beep.Play();
MessageBox.Show("Número inválido", "Erro de número");
}
}
else if (BinToIntBtn.Checked)
{
try
{
BinOutBox.Text = "Bin to int";
//BinOutBox.Text = [Metodo de conversão da dll]
}
catch (Exception)
{
SystemSounds.Beep.Play();
MessageBox.Show("Número inválido", "Erro de número");
}
}
}
else
{
SystemSounds.Beep.Play();
MessageBox.Show("Nenhum nímero foi digitado", "Error NULL");
}
}
#endregion
#region HEX Page
#region HEX Buttons
private void HexBtn0_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("0");
}
private void HexBtn1_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("1");
}
private void HexBtn2_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("2");
}
private void HexBtn3_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("3");
}
private void HexBtn4_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("4");
}
private void HexBtn5_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("5");
}
private void HexBtn6_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("6");
}
private void HexBtn7_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("7");
}
private void HexBtn8_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("8");
}
private void HexBtn9_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("9");
}
private void HexBtnA_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("A");
}
private void HexBtnB_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("B");
}
private void HexBtnC_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("C");
}
private void HexBtnD_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("D");
}
private void HexBtnE_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("E");
}
private void HexBtnF_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("F");
}
#endregion
#region HEX Decimal Buttons
private void HexDecBtn0_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("0");
}
private void HexDecBtn1_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("1");
}
private void HexDecBtn2_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("2");
}
private void HexDecBtn3_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("3");
}
private void HexDecBtn4_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("4");
}
private void HexDecBtn5_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("5");
}
private void HexDecBtn6_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("6");
}
private void HexDecBtn7_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("7");
}
private void HexDecBtn8_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("8");
}
private void HexDecBtn9_Click(object sender, EventArgs e)
{
HexInpBox.AppendText("9");
}
#endregion
private void HexToIntBtn_CheckedChanged(object sender, EventArgs e)
{
HexInpBox.Clear();
HexOutBox.Clear();
foreach (Button btn in HexDecButtons)
{
btn.Visible = false;
}
foreach (Button btn in HexButtons)
{
btn.Visible = true;
}
}
private void IntToHexBtn_CheckedChanged(object sender, EventArgs e)
{
HexInpBox.Clear();
HexOutBox.Clear();
foreach (Button btn in HexButtons)
{
btn.Visible = false;
}
foreach(Button btn in HexDecButtons)
{
btn.Visible = true;
}
}
private void TraHexBtn_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(HexInpBox.Text))
{
if (HexToIntBtn.Checked)
{
HexOutBox.Text = "HEX to Integer";
}
if(IntToHexBtn.Checked)
{
HexOutBox.Text = "Integer to HEX";
}
}
else
{
SystemSounds.Beep.Play();
MessageBox.Show("Nenhum nímero foi digitado", "Error NULL");
}
}
#endregion
}
}