From d23d4826f0302770284f51966e6b24290fab52d3 Mon Sep 17 00:00:00 2001 From: lempamo Date: Sat, 25 Feb 2017 12:18:08 -0500 Subject: [PATCH] Added plus & equals functionality --- .../Applications/Calculator.Designer.cs | 1 + ShiftOS.WinForms/Applications/Calculator.cs | 26 +++++++++++++++++-- 2 files changed, 25 insertions(+), 2 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; + } } }