-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculatorInterface.cs
More file actions
445 lines (388 loc) · 17.8 KB
/
Copy pathCalculatorInterface.cs
File metadata and controls
445 lines (388 loc) · 17.8 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
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Drawing;
using CalculatorEvents;
namespace CalculatorInterface
{
public class mainRun
{
public static void Main()
{
System.Windows.Forms.Application.Run(new CWindow("CS-Calculator"));
}
}
public class CWindow : System.Windows.Forms.Form
{
public static System.Windows.Forms.TextBox input;
public static TextBox output;
public static string angleUnit = "rad";
public CWindow(string name)
{
this.Text = name;
this.Size = new System.Drawing.Size(405, 550);
System.Windows.Forms.MainMenu menu = new System.Windows.Forms.MainMenu();
System.Windows.Forms.MenuItem file = new System.Windows.Forms.MenuItem("File");
MenuItem edit = new MenuItem("Edit");
MenuItem tools = new MenuItem("Tools");
MenuItem advanced = new MenuItem("Advanced");
MenuItem settings = new MenuItem("Settings");
MenuItem angleMeasurement = new MenuItem("Angle");
MenuItem degrees = new MenuItem("Degree");
angleMeasurement.MenuItems.Add(degrees);
MenuItem radians = new MenuItem("Radians");
radians.Checked = true;
angleMeasurement.MenuItems.Add(radians);
MenuItem gradians = new MenuItem("Gradians");
angleMeasurement.MenuItems.Add(gradians);
settings.MenuItems.Add(angleMeasurement);
MenuItem help = new MenuItem("Help");
MenuItem about = new MenuItem("About");
help.MenuItems.Add(about);
menu.MenuItems.Add(file);
menu.MenuItems.Add(edit);
menu.MenuItems.Add(tools);
menu.MenuItems.Add(advanced);
menu.MenuItems.Add(settings);
menu.MenuItems.Add(help);
this.Menu = menu;
//TextBoxes
output = new System.Windows.Forms.TextBox();
output.Font = new Font("Courier New", 10);
output.Multiline = true;
output.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
output.Location = new System.Drawing.Point(20, 10);
output.MinimumSize = new System.Drawing.Size(350, 110);
output.MaximumSize = new System.Drawing.Size(350, 110);
this.Controls.Add(output);
input = new System.Windows.Forms.TextBox();
input.Font = new Font("Courier New", 10);
input.Multiline = true;
input.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
input.Location = new System.Drawing.Point(20, 125);
input.MinimumSize = new System.Drawing.Size(350, 45);
input.MaximumSize = new System.Drawing.Size(350, 45);
this.Controls.Add(input);
System.Windows.Forms.Label angle = new Label();
angle.Font = new Font("Arial", 10);
angle.Text = "RAD";
angle.TextAlign = ContentAlignment.MiddleCenter;
angle.BorderStyle = BorderStyle.FixedSingle;
angle.Size = new Size(50, 20);
angle.Location = new Point(20, 180);
this.Controls.Add(angle);
//Buttons
System.Windows.Forms.Button enter = new System.Windows.Forms.Button();
enter.Font = new System.Drawing.Font("Arial", 12);
enter.Text = "=";
enter.Size = new System.Drawing.Size(50, 30);
enter.Location = new System.Drawing.Point(325, 445);
enter.Click += new EventHandler(CEvents.enter_Click);
this.Controls.Add(enter);
Button addition = new Button();
addition.Font = new System.Drawing.Font("Arial", 12);
addition.Text = "+";
addition.Size = new Size(40, 30);
addition.Location = new System.Drawing.Point(335, 410);
addition.Click += new EventHandler(CEvents.button_Click);
this.Controls.Add(addition);
Button subtraction = new Button();
subtraction.Font = new System.Drawing.Font("Arial", 12);
subtraction.Text = "-";
subtraction.Size = new Size(40, 30);
subtraction.Location = new Point(335, 375);
subtraction.Click += new EventHandler(CEvents.button_Click);
this.Controls.Add(subtraction);
Button multiplication = new Button();
multiplication.Font = new System.Drawing.Font("Arial", 12);
multiplication.Text = "*";
multiplication.Size = new System.Drawing.Size(40, 30);
multiplication.Location = new System.Drawing.Point(335, 340);
multiplication.Click += new EventHandler(CEvents.button_Click);
this.Controls.Add(multiplication);
Button division = new Button();
division.Font = new System.Drawing.Font("Arial", 12);
division.Text = "/";
division.Size = new System.Drawing.Size(40, 30);
division.Location = new System.Drawing.Point(335, 305);
division.Click += new EventHandler(CEvents.button_Click);
this.Controls.Add(division);
Button exponentiation = new Button();
exponentiation.Font = new Font("Arial", 12);
exponentiation.Text = "^";
exponentiation.Size = new Size(40, 30);
exponentiation.Location = new Point(335, 270);
exponentiation.Click += new EventHandler(CEvents.button_Click);
this.Controls.Add(exponentiation);
Button clear = new Button();
clear.Font = new Font("Arial", 12);
clear.Text = "CLR";
clear.Size = new Size(50, 25);
clear.Location = new Point(325, 230);
clear.Click += new EventHandler(CEvents.clear_Click);
this.Controls.Add(clear);
Button delete = new Button();
delete.Font = new Font("Arial", 12);
delete.Text = "DEL";
delete.Size = new Size(50, 25);
delete.Location = new Point(270, 230);
delete.Click += new EventHandler(CEvents.delete_Click);
this.Controls.Add(delete);
Button backspace = new Button();
backspace.Font = new Font("Arial", 10);
backspace.Text = "BKSP";
backspace.Size = new Size(50, 25);
backspace.Location = new Point(215, 230);
backspace.Click += new EventHandler(CEvents.backspace_Click);
this.Controls.Add(backspace);
Button answer = new Button();
answer.Font = new Font("Arial", 12);
answer.Text = "ANS";
answer.Size = new Size(50, 25);
answer.Location = new Point(160, 230);
this.Controls.Add(answer);
Button previous = new Button();
previous.Font = new Font("Arial", 10);
previous.Text = "PREV";
previous.Size = new Size(50, 25);
previous.Location = new Point(20, 230);
this.Controls.Add(previous);
Button degree = new Button();
degree.Font = new Font("Arial", 10);
degree.Text = "DEG";
degree.Size = new Size(50, 25);
degree.Location = new Point(20, 180);
//this.Controls.Add(degree);
Button right = new Button();
right.Font = new Font("Arial", 16);
right.Text = "→";
right.Size = new Size(50, 20);
right.Location = new Point(325, 180);
right.Click += new EventHandler(CEvents.right_Click);
this.Controls.Add(right);
Button rightEnd = new Button();
rightEnd.Font = new Font("Arial", 16);
rightEnd.Text = "→|";
rightEnd.Size = new Size(50, 20);
rightEnd.Location = new Point(325, 205);
rightEnd.Click += new EventHandler(CEvents.rightEnd_Click);
this.Controls.Add(rightEnd);
Button left = new Button();
left.Font = new Font("Arial", 16);
left.Text = "←";
left.Size = new Size(50, 20);
left.Location = new Point(270, 180);
left.Click += new EventHandler(CEvents.left_Click);
this.Controls.Add(left);
Button leftEnd = new Button();
leftEnd.Font = new Font("Arial", 16);
leftEnd.Text = "|←";
leftEnd.Size = new Size(50, 20);
leftEnd.Location = new Point(270, 205);
leftEnd.Click += new EventHandler(CEvents.leftEnd_Click);
this.Controls.Add(leftEnd);
//Numberpad
Button zero = new Button();
zero.Font = new Font("Arial", 12);
zero.Text = "0";
zero.Size = new Size(45, 30);
zero.Location = new Point(170, 445);
zero.Click += new EventHandler(CEvents.button_Click);
zero.BackColor = Color.CornflowerBlue;
this.Controls.Add(zero);
Button one = new Button();
one.Font = new Font("Arial", 12);
one.Text = "1";
one.Size = new Size(45, 30);
one.Location = new Point(170, 410);
one.Click += new EventHandler(CEvents.button_Click);
one.BackColor = Color.CornflowerBlue;
this.Controls.Add(one);
Button two = new Button();
two.Font = new Font("Arial", 12);
two.Text = "2";
two.Size = new Size(45, 30);
two.Location = new Point(220, 410);
two.Click += new EventHandler(CEvents.button_Click);
two.BackColor = Color.CornflowerBlue;
this.Controls.Add(two);
Button three = new Button();
three.Font = new Font("Arial", 12);
three.Text = "3";
three.Size = new Size(45, 30);
three.Location = new Point(270, 410);
three.Click += new EventHandler(CEvents.button_Click);
three.BackColor = Color.CornflowerBlue;
this.Controls.Add(three);
Button four = new Button();
four.Font = new Font("Arial", 12);
four.Text = "4";
four.Size = new Size(45, 30);
four.Location = new Point(170, 375);
four.Click += new EventHandler(CEvents.button_Click);
four.BackColor = Color.CornflowerBlue;
this.Controls.Add(four);
Button five = new Button();
five.Font = new Font("Arial", 12);
five.Text = "5";
five.Size = new Size(45, 30);
five.Location = new Point(220, 375);
five.Click += new EventHandler(CEvents.button_Click);
five.BackColor = Color.CornflowerBlue;
this.Controls.Add(five);
Button six = new Button();
six.Font = new Font("Arial", 12);
six.Text = "6";
six.Size = new Size(45, 30);
six.Location = new Point(270, 375);
six.Click += new EventHandler(CEvents.button_Click);
six.BackColor = Color.CornflowerBlue;
this.Controls.Add(six);
Button seven = new Button();
seven.Font = new Font("Arial", 12);
seven.Text = "7";
seven.Size = new Size(45, 30);
seven.Location = new Point(170, 340);
seven.Click += new EventHandler(CEvents.button_Click);
seven.BackColor = Color.CornflowerBlue;
this.Controls.Add(seven);
Button eight = new Button();
eight.Font = new Font("Arial", 12);
eight.Text = "8";
eight.Size = new Size(45, 30);
eight.Location = new Point(220, 340);
eight.Click += new EventHandler(CEvents.button_Click);
eight.BackColor = Color.CornflowerBlue;
this.Controls.Add(eight);
Button nine = new Button();
nine.Font = new Font("Arial", 12);
nine.Text = "9";
nine.Size = new Size(45, 30);
nine.Location = new Point(270, 340);
nine.Click += new EventHandler(CEvents.button_Click);
nine.BackColor = Color.CornflowerBlue;
this.Controls.Add(nine);
Button negative = new Button();
negative.Font = new Font("Arial", 12);
negative.Text = "(-)";
negative.Size = new Size(45, 30);
negative.Location = new Point(270, 445);
negative.Click += new EventHandler(CEvents.button_Click);
this.Controls.Add(negative);
Button decimalPoint = new Button();
decimalPoint.Font = new Font("Arial", 20);
decimalPoint.Text = ".";
decimalPoint.Size = new Size(45, 30);
decimalPoint.Location = new Point(220, 445);
decimalPoint.Click += new EventHandler(CEvents.button_Click);
decimalPoint.TextAlign = ContentAlignment.BottomCenter;
this.Controls.Add(decimalPoint);
Button openParenthesis = new Button();
openParenthesis.Font = new Font("Arial", 12);
openParenthesis.Text = "(";
openParenthesis.Size = new Size(45, 30);
openParenthesis.Location = new Point(220, 305);
openParenthesis.Click += new EventHandler(CEvents.button_Click);
this.Controls.Add(openParenthesis);
Button closedParenthesis = new Button();
closedParenthesis.Font = new Font("Arial", 12);
closedParenthesis.Text = ")";
closedParenthesis.Size = new Size(45, 30);
closedParenthesis.Location = new Point(270, 305);
closedParenthesis.Click += new EventHandler(CEvents.button_Click);
this.Controls.Add(closedParenthesis);
Button Enotation = new Button();
Enotation.Font = new Font("Arial", 12);
Enotation.Text = "EE";
Enotation.Size = new Size(45, 30);
Enotation.Location = new Point(170, 305);
Enotation.Click += new EventHandler(CEvents.button_Click);
this.Controls.Add(Enotation);
Button sine = new Button();
sine.Font = new Font("Arial", 12);
sine.Text = "sin";
sine.Size = new Size(45, 30);
sine.Location = new Point(20, 270);
this.Controls.Add(sine);
Button cosine = new Button();
cosine.Font = new Font("Arial", 12);
cosine.Text = "cos";
cosine.Size = new Size(45, 30);
cosine.Location = new Point(70, 270);
this.Controls.Add(cosine);
Button tangent = new Button();
tangent.Font = new Font("Arial", 12);
tangent.Text = "tan";
tangent.Size = new Size(45, 30);
tangent.Location = new Point(120, 270);
this.Controls.Add(tangent);
Button euler = new Button();
euler.Font = new Font("Arial", 12);
euler.Text = "e";
euler.Size = new Size(45, 30);
euler.Location = new Point(170, 270);
euler.Click += new EventHandler(CEvents.button_Click);
this.Controls.Add(euler);
Button pi = new Button();
pi.Font = new Font("Arial", 12);
pi.Text = "π";
pi.Size = new Size(45, 30);
pi.Location = new Point(220, 270);
pi.Click += new EventHandler(CEvents.button_Click);
this.Controls.Add(pi);
Button gravity = new Button();
gravity.Font = new Font("Arial", 12);
gravity.Text = "g";
gravity.Size = new Size(45, 30);
gravity.Location = new Point(270, 270);
gravity.Click += new EventHandler(CEvents.button_Click);
this.Controls.Add(gravity);
Button derivative = new Button();
derivative.Font = new Font("Arial", 12);
derivative.Text = "d/dx";
derivative.Size = new Size(45, 30);
derivative.Location = new Point(20, 375);
this.Controls.Add(derivative);
Button integral = new Button();
integral.Font = new Font("Arial", 12);
integral.Text = "∫";
integral.Size = new Size(45, 30);
integral.Location = new Point(70, 375);
this.Controls.Add(integral);
Button comma = new Button();
comma.Font = new Font("Arial", 20);
comma.Text = ",";
comma.Size = new Size(45, 30);
comma.Location = new Point(120, 375);
comma.TextAlign = ContentAlignment.BottomCenter;
this.Controls.Add(comma);
Button logarithm = new Button();
logarithm.Font = new Font("Arial", 12);
logarithm.Text = "log";
logarithm.Size = new Size(45, 30);
logarithm.Location = new Point(20, 410);
this.Controls.Add(logarithm);
Button naturalLog = new Button();
naturalLog.Font = new Font("Arial", 12);
naturalLog.Text = "ln";
naturalLog.Size = new Size(45, 30);
naturalLog.Location = new Point(70, 410);
this.Controls.Add(naturalLog);
Button root = new Button();
root.Font = new Font("Arial", 12);
root.Text = "√";
root.Size = new Size(45, 30);
root.Location = new Point(120, 410);
this.Controls.Add(root);
Button factorial = new Button();
factorial.Font = new Font("Courier New", 16);
factorial.Text = "!";
factorial.Size = new Size(45, 30);
factorial.Location = new Point(20, 445);
factorial.Click += new EventHandler(CEvents.button_Click);
this.Controls.Add(factorial);
}
}
}