//<-- private void button_BackSpace_Click(object sender, EventArgs e) { if (textBox1.TextLength != 0) { if (state == StateCacl.HasLeftOperand) { if (textBox1.TextLength - 1 == 0) { textBox1.Clear(); state = StateCacl.NoN; } else { textBox1.Text = textBox1.Text.Remove(textBox1.TextLength - 1, 1); } } else if (state == StateCacl.HasZnak) { textBox1.Text = textBox1.Text.Remove(textBox1.TextLength - 1, 1); state = StateCacl.HasLeftOperand; } else if (state == StateCacl.HasRightOperand) { if (textBox1.TextLength - 1 == GetOperatorIndex() + 1) { state = StateCacl.HasZnak; } textBox1.Text = textBox1.Text.Remove(textBox1.TextLength - 1, 1); } } }
//= private void button_Result_Click(object sender, EventArgs e) { if (state == StateCacl.HasRightOperand) { int operInd = GetOperatorIndex(); b = float.Parse(textBox1.Text.Substring(operInd + 1, textBox1.TextLength - operInd - 1)); Calculate(); textBox1.Text = string.Format("{0:f2}", c.ToString()); a = c; state = StateCacl.HasLeftOperand; } }
private void button_Dev_Click(object sender, EventArgs e) { if (state == StateCacl.HasLeftOperand) { a = float.Parse(textBox1.Text); textBox1.Text += "/"; oper = Oper.Divide; state = StateCacl.HasZnak; } else if (state == StateCacl.HasZnak) { textBox1.Text = textBox1.Text.Remove(textBox1.TextLength - 1, 1); textBox1.Text += "/"; oper = Oper.Divide; } }
private void button_Three_Click(object sender, EventArgs e) { if (state == StateCacl.HasRightOperand || state == StateCacl.HasZnak) { textBox1.Text += 3; state = StateCacl.HasRightOperand; } else if (state == StateCacl.NoN) { textBox1.Text = "3"; state = StateCacl.HasLeftOperand; } else if (state == StateCacl.HasLeftOperand) { textBox1.Text += 3; } }
//. private void button_dot_Click(object sender, EventArgs e) { if (state == StateCacl.NoN) { textBox1.Text = "0,"; state = StateCacl.HasLeftOperand; } else if (state == StateCacl.HasZnak) { textBox1.Text += "0,"; state = StateCacl.HasRightOperand; } else { char[] Ch = { ',', '.' }; if (textBox1.Text.IndexOfAny(Ch) == -1) { textBox1.Text += ","; } } }
private void Form1_Load(object sender, EventArgs e) { c = 0; textBox1.Text = c.ToString(); state = StateCacl.NoN; }
//C private void button_C_Click(object sender, EventArgs e) { state = StateCacl.NoN; c = 0; textBox1.Text = c.ToString(); }