//SPECIALS SPECIALS SPECIALS private void Click_equals(object sender, EventArgs e) { if (this.screen.Text.Length > 0 && activeParenthesis == 0) { if (SafteyNet.LastClosedParenthesis(this.screen.Text) == true || (SafteyNet.LastNumbers(this.screen.Text) == true && usedOperator == true)) { string result = StringToNum.CalculateEverything(screenText); screenText = result; if (screenText.Length > 12) //max char in screen is 12 { result = result.Remove(result[screenText.Length - 13]); } this.screen.Text = result; activeParenthesis = 0; activeDecimals = false; activePlusMinus = false; activePower = false; activeDividePower = false; usedOperator = false; GrayEquals(); } } }
private void Click_parenthesis(object sender, EventArgs e) { if (activePower == false && SafteyNet.EmptyString(this.screen.Text) == true || SafteyNet.LastOperators(this.screen.Text) == true || SafteyNet.LastOpenParenthesis(this.screen.Text) == true) { if (SafteyNet.LastSpecials(this.screen.Text) == false) { this.screen.Text = SafteyNet.TooLargeScreen(this.screen.Text); screenText += "("; this.screen.Text += "("; activeDecimals = false; activeParenthesis++; GrayEquals(); } } else if (activeParenthesis > 0) { this.screen.Text = SafteyNet.TooLargeScreen(this.screen.Text); screenText += ")"; this.screen.Text += ")"; activeDecimals = false; activePlusMinus = false; activePower = false; activeDividePower = false; activeParenthesis--; GrayEquals(); } }
private void Click_plusMinus(object sender, EventArgs e) { if (SafteyNet.EmptyString(this.screen.Text) == true) { this.screen.Text = SafteyNet.TooLargeScreen(this.screen.Text); screenText += "(-"; this.screen.Text += "(-"; activeParenthesis++; activeDecimals = false; activePlusMinus = true; usedOperator = true; GrayEquals(); } else { if (SafteyNet.LastOpenParenthesis(this.screen.Text) == true || SafteyNet.LastOperators(this.screen.Text) == true) { if (SafteyNet.LastNegative(this.screen.Text) == false && SafteyNet.LastSpecials(this.screen.Text) == false) { this.screen.Text = SafteyNet.TooLargeScreen(this.screen.Text); screenText += "(-"; this.screen.Text += "(-"; activeParenthesis++; activeDecimals = false; activePlusMinus = true; usedOperator = true; GrayEquals(); } } } }
private void Click_add(object sender, EventArgs e) { if (activePower == false && SafteyNet.EmptyString(this.screen.Text) == false) { if (SafteyNet.LastNumbers(this.screen.Text) == true || SafteyNet.LastClosedParenthesis(this.screen.Text) == true) { if (activePlusMinus == true) { this.screen.Text = SafteyNet.TooLargeScreen(this.screen.Text); screenText += ")"; this.screen.Text += ")"; this.screen.Text = SafteyNet.TooLargeScreen(this.screen.Text); screenText += "+"; this.screen.Text += "+"; activePlusMinus = false; } else { this.screen.Text = SafteyNet.TooLargeScreen(this.screen.Text); screenText += "+"; this.screen.Text += "+"; } activeDecimals = false; usedOperator = true; GrayEquals(); } } }
private void Click_nine(object sender, EventArgs e) { if (SafteyNet.EmptyString(this.screen.Text) == true || SafteyNet.LastClosedParenthesis(this.screen.Text) == false) { this.screen.Text = SafteyNet.TooLargeScreen(this.screen.Text); screenText += "9"; this.screen.Text += "9"; GrayEquals(); } }
private void Click_period(object sender, EventArgs e) { if (activePower == false && activeDecimals == false && SafteyNet.EmptyString(this.screen.Text) == false) { if (SafteyNet.LastNumbers(this.screen.Text) == true) { this.screen.Text = SafteyNet.TooLargeScreen(this.screen.Text); screenText += "."; this.screen.Text += "."; activeDecimals = true; GrayEquals(); } } }
private void GrayEquals() //changes the color of equals to show if it's usable { if (this.screen.Text.Length > 0 && activeParenthesis == 0) { if (SafteyNet.LastClosedParenthesis(this.screen.Text) == true || (SafteyNet.LastNumbers(this.screen.Text) == true && usedOperator == true)) { this.equals.BackColor = System.Drawing.Color.White; this.equals.FlatAppearance.MouseDownBackColor = Control.DefaultBackColor; this.equals.FlatAppearance.MouseOverBackColor = Control.DefaultBackColor; } else { this.equals.BackColor = System.Drawing.Color.LightGray; this.equals.FlatAppearance.MouseDownBackColor = System.Drawing.Color.LightGray; this.equals.FlatAppearance.MouseOverBackColor = System.Drawing.Color.LightGray; } } else { this.equals.BackColor = System.Drawing.Color.LightGray; this.equals.FlatAppearance.MouseDownBackColor = System.Drawing.Color.LightGray; this.equals.FlatAppearance.MouseOverBackColor = System.Drawing.Color.LightGray; } }