1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Threading.Tasks;
9 using System.Windows.Forms;
10
11 namespace Demo
12 {
13 public partial class Form1 : Form
14 {
15 double a = 0;
16 double b = 0;
17 bool c = false;
18 string d;
19
20 public Form1()
21 {
22 InitializeComponent();
23 }
24
25 private void textBox1_TextChanged(object sender, EventArgs e)
26 {
27
28 }
29
30 private void button12_Click(object sender, EventArgs e)
31 {
32 c = true;
33 b = double.Parse(textBox1.Text);
34 d = "*";
35 }
36
37 private void button17_Click(object sender, EventArgs e)
38 {
39 c = true;
40 b = double.Parse(textBox1.Text);
41 d = "ln";
42 }
43
44 private void Form1_Load(object sender, EventArgs e)
45 {
46
47 }
48
49 private void button18_Click(object sender, EventArgs e)
50 {
51 c = true;
52 b = double.Parse(textBox1.Text);
53 d = "log";
54 }
55
56 private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
57 {
58 System.Diagnostics.Process.Start("http://www.cnblogs.com/tyx0604/");
59 }
60
61 private void button14_Click(object sender, EventArgs e)
62 {
63 textBox1.Text = "";
64 }
65
66 private void button15_Click(object sender, EventArgs e)
67 {
68 switch (d)
69 {
70 case "+": a = b + double.Parse(textBox1.Text); break;
71 case "-": a = b - double.Parse(textBox1.Text); break;
72 case "*": a = b * double.Parse(textBox1.Text); break;
73 case "/": a = b / double.Parse(textBox1.Text); break;
74 case "x2": a = b * double.Parse(textBox1.Text); break;
75 case "sqrt": a = Math.Sqrt(b); break;
76 case "log": a = Math.Log(double.Parse(textBox1.Text), b); break;
77 case "ln": a = Math.Log(b, Math.E); break;
78 }
79 textBox1.Text = a + "";
80 c = true;
81 }
82
83 private void button19_Click(object sender, EventArgs e)
84 {
85 if (c == true)
86 {
87 textBox1.Text = "";
88 c = false;
89 }
90 textBox1.Text += "1";
91 }
92
93 private void button9_Click(object sender, EventArgs e)
94 {
95 if (c == true)
96 {
97 textBox1.Text = "";
98 c = false;
99 }
100 textBox1.Text += "1";
101 }
102
103 private void button10_Click(object sender, EventArgs e)
104 {
105 if (c == true)
106 {
107 textBox1.Text = "";
108 c = false;
109 }
110 textBox1.Text += "2";
111 }
112
113 private void button11_Click(object sender, EventArgs e)
114 {
115 if (c == true)
116 {
117 textBox1.Text = "";
118 c = false;
119 }
120 textBox1.Text += "3";
121 }
122
123 private void button5_Click(object sender, EventArgs e)
124 {
125 if (c == true)
126 {
127 textBox1.Text = "";
128 c = false;
129 }
130 textBox1.Text += "4";
131 }
132
133 private void button6_Click(object sender, EventArgs e)
134 {
135 if (c == true)
136 {
137 textBox1.Text = "";
138 c = false;
139 }
140 textBox1.Text += "5";
141 }
142
143 private void button7_Click(object sender, EventArgs e)
144 {
145 if (c == true)
146 {
147 textBox1.Text = "";
148 c = false;
149 }
150 textBox1.Text += "6";
151 }
152
153 private void button1_Click(object sender, EventArgs e)
154 {
155 if (c == true)
156 {
157 textBox1.Text = "";
158 c = false;
159 }
160 textBox1.Text += "7";
161 }
162
163 private void button2_Click(object sender, EventArgs e)
164 {
165 if (c == true)
166 {
167 textBox1.Text = "";
168 c = false;
169 }
170 textBox1.Text += "8";
171 }
172
173 private void button3_Click(object sender, EventArgs e)
174 {
175 if (c == true)
176 {
177 textBox1.Text = "";
178 c = false;
179 }
180 textBox1.Text += "9";
181 }
182
183 private void button13_Click(object sender, EventArgs e)
184 {
185 if (c == true)
186 {
187 textBox1.Text = "";
188 c = false;
189 }
190 textBox1.Text += "0";
191 if (d == "/")
192 {
193 textBox1.Clear();
194 MessageBox.Show("除数不能为零", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
195 }
196 }
197
198 private void button4_Click(object sender, EventArgs e)
199 {
200 c = true;
201 b = double.Parse(textBox1.Text);
202 d = "+";
203 }
204
205 private void button8_Click(object sender, EventArgs e)
206 {
207 c = true;
208 b = double.Parse(textBox1.Text);
209 d = "-";
210 }
211
212 private void button16_Click(object sender, EventArgs e)
213 {
214 c = true;
215 b = double.Parse(textBox1.Text);
216 d = "/";
217 }
218
219 private void button17_Click_1(object sender, EventArgs e)
220 {
221 c = true;
222 b = double.Parse(textBox1.Text);
223 d = "x2";
224 }
225
226 private void button18_Click_1(object sender, EventArgs e)
227 {
228 c = true;
229 b = double.Parse(textBox1.Text);
230 d = "sqrt";
231 }
232
233 private void button19_Click_1(object sender, EventArgs e)
234 {
235 c = true;
236 b = double.Parse(textBox1.Text);
237 d = "log";
238 }
239
240 private void button20_Click(object sender, EventArgs e)
241 {
242 c = true;
243 b = double.Parse(textBox1.Text);
244 d = "ln";
245 }
246 }
247 }