aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ShiftOS.WinForms/Applications/Calculator.Designer.cs1
-rw-r--r--ShiftOS.WinForms/Applications/Calculator.cs24
2 files changed, 24 insertions, 1 deletions
diff --git a/ShiftOS.WinForms/Applications/Calculator.Designer.cs b/ShiftOS.WinForms/Applications/Calculator.Designer.cs
index 507e382..1f9008e 100644
--- a/ShiftOS.WinForms/Applications/Calculator.Designer.cs
+++ b/ShiftOS.WinForms/Applications/Calculator.Designer.cs
@@ -188,6 +188,7 @@ namespace ShiftOS.WinForms.Applications
this.buttonEquals.TabIndex = 12;
this.buttonEquals.Text = "=";
this.buttonEquals.UseVisualStyleBackColor = true;
+ this.buttonEquals.Click += new System.EventHandler(this.buttonEquals_Click);
//
// buttonPlus
//
diff --git a/ShiftOS.WinForms/Applications/Calculator.cs b/ShiftOS.WinForms/Applications/Calculator.cs
index ee5c2e3..c79494f 100644
--- a/ShiftOS.WinForms/Applications/Calculator.cs
+++ b/ShiftOS.WinForms/Applications/Calculator.cs
@@ -136,14 +136,36 @@ namespace ShiftOS.WinForms.Applications
private void buttonPlus_Click(object sender, EventArgs e)
{
- if (operationnumber == 0 && activeoperation != 1)
+ if (operationnumber == 0 && activeoperation == 0)
{
operationnumber = currentnumber;
activeoperation = 1;
} else
{
+ solve();
+ operationnumber = currentnumber;
+ activeoperation = 1;
+ }
+ }
+
+ private void solve()
+ {
+ switch (activeoperation)
+ {
+ case 1:
+ numBox.Text = (currentnumber + operationnumber).ToString();
+ break;
+ default:
+ break;
}
}
+
+ private void buttonEquals_Click(object sender, EventArgs e)
+ {
+ solve();
+ operationnumber = 0;
+ activeoperation = 0;
+ }
}
}