Added plus & equals functionality

This commit is contained in:
lempamo 2017-02-25 12:18:08 -05:00
parent 6a50e9fdda
commit d23d4826f0
2 changed files with 25 additions and 2 deletions

View file

@ -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
//

View file

@ -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;
}
}
}