-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.cs
More file actions
284 lines (239 loc) · 9.1 KB
/
Main.cs
File metadata and controls
284 lines (239 loc) · 9.1 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
using CalEngine;
using ShowCal;
using System.Diagnostics;
namespace Calculator
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
InfixInitialize MainRawInfix = new InfixInitialize();
}
private void Main_Load(object sender, EventArgs e)
{
}
//历史记录窗口调用
private bool HistoryWindowOpen = false;
private CalHistory HistoryWindow;
private void History_Click(object sender, EventArgs e)
{
////这部分还没有开发完全,子窗体注释掉了
//if (HistoryWindow != null && !HistoryWindow.IsDisposed)//当窗口被释放(disposed)时,激活窗口
//{
// HistoryWindow.Activate();
//}
//else//新建并打开窗口
//{
// HistoryWindowOpen = true;
// HistoryWindow = new CalHistory();
// HistoryWindow.FormClosed += (_, __) => HistoryWindowOpen = false;//Lambda表达式,一种无需命名的简洁函数。此处作用是重置HistoryWindowOpen的bool值。
// HistoryWindow.Show(this);
//}
}
private void GitHubToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("explorer.exe", "https://github.com/Snowlights2022/CalculatorProject");//调用默认浏览器,打开项目网页地址~
}
private void button38_Click(object sender, EventArgs e)
{
}
private void Op1_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("(");
ShowCalculate.Text = ShowCalculate.Text + "(";
}
private void Num1_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("1");
ShowCalculate.Text = ShowCalculate.Text + "1";
}
private void Op2_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add(")");
ShowCalculate.Text = ShowCalculate.Text + ")";
}
private void Num7_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("7");
ShowCalculate.Text = ShowCalculate.Text + "7";
}
private void Num4_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("4");
ShowCalculate.Text = ShowCalculate.Text + "4";
}
private void Num9_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("9");
ShowCalculate.Text = ShowCalculate.Text + "9";
}
private void Num0_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("0");
ShowCalculate.Text = ShowCalculate.Text + "0";
}
private void Num2_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("2");
ShowCalculate.Text = ShowCalculate.Text + "2";
}
private void Num3_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("3");
ShowCalculate.Text = ShowCalculate.Text + "3";
}
private void Num5_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("5");
ShowCalculate.Text = ShowCalculate.Text + "5";
}
private void Num6_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("6");
ShowCalculate.Text = ShowCalculate.Text + "6";
}
private void Num8_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("8");
ShowCalculate.Text = ShowCalculate.Text + "8";
}
private void sin_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("sin");
ShowCalculate.Text = ShowCalculate.Text + "sin";
}
private void cos_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("cos");
ShowCalculate.Text = ShowCalculate.Text + "cos";
}
private void tan_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("tan");
ShowCalculate.Text = ShowCalculate.Text + "tan";
}
private void arcsin_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("arctan");
ShowCalculate.Text = ShowCalculate.Text + "arctan";
}
private void arccos_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("arccos");
ShowCalculate.Text = ShowCalculate.Text + "arccos";
}
private void arctan_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("arctan");
ShowCalculate.Text = ShowCalculate.Text + "arctan";
}
private void log_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("log");
ShowCalculate.Text = ShowCalculate.Text + "log";
}
private void ln_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("ln");
ShowCalculate.Text = ShowCalculate.Text + "ln";
}
private void pow_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("pow");
ShowCalculate.Text = ShowCalculate.Text + "pow";
}
private void Calculate_Click(object sender, EventArgs e)
{
InfixInitialize Rawinfix = new InfixInitialize();
Store CalMemory = new Store();
Rawinfix = ShowCal.Calculate.GetExpStarted(Global.MainRawInfix);//获取表达式
if (Global.CalResult_CopyofCalMem != null)//如果有运算结果,继承运算结果到表达式[0]位置
{
ShowCalculate.Text = Global.CalResult_CopyofCalMem + ShowCalculate.Text;
Rawinfix.BracketContent.Insert(0, Global.CalResult_CopyofCalMem);
}
Bracket NEW = new Bracket();
NEW = CalEngine.Cal_Universal.Initialize(Rawinfix);
CalMemory = ShowCal.Calculate.StartCal(NEW);
ShowCalculate.Text = null;
ShowCalculate.Text = CalMemory.CalResult;
//将计算结果情况加入历史记录中
ShowCal.Global.MIDDLE = CalMemory.GetResult();
ShowCal.Global.CalHis.Add(ShowCal.Global.MIDDLE);
}
private void ShowCalculate_TextChanged(object sender, EventArgs e)
{
}
private void Cal1_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("+");
ShowCalculate.Text = ShowCalculate.Text + "+";
}
private void Cal2_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("-");
ShowCalculate.Text = ShowCalculate.Text + "-";
}
private void Cal3_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("*");
ShowCalculate.Text = ShowCalculate.Text + "*";
}
private void button20_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("/");
ShowCalculate.Text = ShowCalculate.Text + "/";
}
private void Num_point_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add(".");
ShowCalculate.Text = ShowCalculate.Text + ".";
}
private void Delete_Click(object sender, EventArgs e)
{
if (Global.MainRawInfix.Count >= 2)//不是空的时候才能删除
{
Global.MainRawInfix.RemoveAt((Global.MainRawInfix.Count - 1));
ShowCalculate.Text = ShowCal.Store.GetResult(Global.MainRawInfix);
}
else if (Global.MainRawInfix.Count == 1)//判断是不是继承的结果,若是则清空系统MEM和显示
{
if (CalEngine.Cal_Simplyfy.IsNumber(Global.MainRawInfix[0]))
{
Global.MainRawInfix.Clear();
ShowCalculate.Text = null;
Global.CalResult_CopyofCalMem = null;//这个也处理掉,防止乱窜
}
}
else if (Global.MainRawInfix.Count == 0)
{
}
}//删除的处理
private void Con_pi_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("π");
ShowCalculate.Text = ShowCalculate.Text + "π";
}
private void Con_e_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add("e");
ShowCalculate.Text = ShowCalculate.Text + "e";
}
private void ParrallelSeparator_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Add(",");
ShowCalculate.Text = ShowCalculate.Text + ",";
}
private void Clean_Click(object sender, EventArgs e)
{
Global.MainRawInfix.Clear();
ShowCalculate.Text = null;
Global.CalResult_CopyofCalMem = null;
}
private void SaveHistorytoFile_Click(object sender, EventArgs e)
{
ShowCal.Store.StoreHistoryToFile();
}
}
}