aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlempamo <[email protected]>2017-07-14 17:29:22 -0500
committerGitHub <[email protected]>2017-07-14 17:29:22 -0500
commit4b7db2e4223640e15507c1f07d139654fd0c4318 (patch)
tree66f4e89cd6c53b093fd00b395aaea832ec3bf83c
parentd8adb912b065de9a4d8a4260915332946ac0d96d (diff)
parent14d1d663f5c6f5f98719223c41005e96a0ac6830 (diff)
downloadhistacom2-4b7db2e4223640e15507c1f07d139654fd0c4318.tar.gz
histacom2-4b7db2e4223640e15507c1f07d139654fd0c4318.tar.bz2
histacom2-4b7db2e4223640e15507c1f07d139654fd0c4318.zip
Merge pull request #126 from jtsshieh/master
Calc
-rw-r--r--TimeHACK.Main/OS/Win95/Win95Apps/WinClassicCalculator.Designer.cs78
-rw-r--r--TimeHACK.Main/OS/Win95/Win95Apps/WinClassicCalculator.cs268
2 files changed, 118 insertions, 228 deletions
diff --git a/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicCalculator.Designer.cs b/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicCalculator.Designer.cs
index 49a47d0..70ad0a2 100644
--- a/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicCalculator.Designer.cs
+++ b/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicCalculator.Designer.cs
@@ -54,7 +54,7 @@
this.Button16 = new System.Windows.Forms.Button();
this.Button24 = new System.Windows.Forms.Button();
this.Button12 = new System.Windows.Forms.Button();
- this.Button6 = new System.Windows.Forms.Button();
+ this.one = new System.Windows.Forms.Button();
this.Button15 = new System.Windows.Forms.Button();
this.Button17 = new System.Windows.Forms.Button();
this.Button13 = new System.Windows.Forms.Button();
@@ -90,6 +90,7 @@
this.AboutCalculatorToolStripMenuItem.Name = "AboutCalculatorToolStripMenuItem";
this.AboutCalculatorToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.AboutCalculatorToolStripMenuItem.Text = "About Calculator";
+ this.AboutCalculatorToolStripMenuItem.Click += new System.EventHandler(this.AboutCalculatorToolStripMenuItem_Click);
//
// StandardToolStripMenuItem
//
@@ -118,15 +119,17 @@
//
this.PasteCtrlVToolStripMenuItem1.BackColor = System.Drawing.Color.Silver;
this.PasteCtrlVToolStripMenuItem1.Name = "PasteCtrlVToolStripMenuItem1";
- this.PasteCtrlVToolStripMenuItem1.Size = new System.Drawing.Size(150, 22);
+ this.PasteCtrlVToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
this.PasteCtrlVToolStripMenuItem1.Text = "Paste Ctrl+V";
+ this.PasteCtrlVToolStripMenuItem1.Click += new System.EventHandler(this.PasteCtrlVToolStripMenuItem1_Click);
//
// CopyCtrlCToolStripMenuItem1
//
this.CopyCtrlCToolStripMenuItem1.BackColor = System.Drawing.Color.Silver;
this.CopyCtrlCToolStripMenuItem1.Name = "CopyCtrlCToolStripMenuItem1";
- this.CopyCtrlCToolStripMenuItem1.Size = new System.Drawing.Size(150, 22);
+ this.CopyCtrlCToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
this.CopyCtrlCToolStripMenuItem1.Text = "Copy Ctrl+C";
+ this.CopyCtrlCToolStripMenuItem1.Click += new System.EventHandler(this.CopyCtrlCToolStripMenuItem1_Click);
//
// EditToolStripMenuItem1
//
@@ -160,7 +163,7 @@
this.Button27.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.Button27.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Button27.ForeColor = System.Drawing.Color.Firebrick;
- this.Button27.Location = new System.Drawing.Point(157, 71);
+ this.Button27.Location = new System.Drawing.Point(159, 71);
this.Button27.Name = "Button27";
this.Button27.Size = new System.Drawing.Size(49, 28);
this.Button27.TabIndex = 84;
@@ -262,7 +265,7 @@
this.Button22.Text = "sqrt";
this.Button22.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.Button22.UseVisualStyleBackColor = true;
- this.Button22.Click += new System.EventHandler(this.Button22_Click);
+ this.Button22.Click += new System.EventHandler(this.arithmitic_click);
//
// Button4
//
@@ -289,7 +292,7 @@
this.Button23.TabIndex = 79;
this.Button23.Text = "1/x";
this.Button23.UseVisualStyleBackColor = true;
- this.Button23.Click += new System.EventHandler(this.Button23_Click);
+ this.Button23.Click += new System.EventHandler(this.arithmitic_click);
//
// Button11
//
@@ -303,7 +306,7 @@
this.Button11.TabIndex = 70;
this.Button11.Text = "9";
this.Button11.UseVisualStyleBackColor = true;
- this.Button11.Click += new System.EventHandler(this.Button11_Click);
+ this.Button11.Click += new System.EventHandler(this.number_click);
//
// Button7
//
@@ -317,7 +320,7 @@
this.Button7.TabIndex = 62;
this.Button7.Text = "4";
this.Button7.UseVisualStyleBackColor = true;
- this.Button7.Click += new System.EventHandler(this.Button7_Click);
+ this.Button7.Click += new System.EventHandler(this.number_click);
//
// Button16
//
@@ -331,7 +334,7 @@
this.Button16.TabIndex = 71;
this.Button16.Text = "0";
this.Button16.UseVisualStyleBackColor = true;
- this.Button16.Click += new System.EventHandler(this.Button16_Click);
+ this.Button16.Click += new System.EventHandler(this.number_click);
//
// Button24
//
@@ -345,7 +348,7 @@
this.Button24.TabIndex = 78;
this.Button24.Text = "%";
this.Button24.UseVisualStyleBackColor = true;
- this.Button24.Click += new System.EventHandler(this.Button24_Click);
+ this.Button24.Click += new System.EventHandler(this.arithmitic_click);
//
// Button12
//
@@ -359,21 +362,21 @@
this.Button12.TabIndex = 69;
this.Button12.Text = "3";
this.Button12.UseVisualStyleBackColor = true;
- this.Button12.Click += new System.EventHandler(this.Button12_Click);
- //
- // Button6
- //
- this.Button6.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
- this.Button6.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.Button6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.Button6.ForeColor = System.Drawing.Color.Blue;
- this.Button6.Location = new System.Drawing.Point(63, 173);
- this.Button6.Name = "Button6";
- this.Button6.Size = new System.Drawing.Size(36, 28);
- this.Button6.TabIndex = 63;
- this.Button6.Text = "1";
- this.Button6.UseVisualStyleBackColor = true;
- this.Button6.Click += new System.EventHandler(this.Button6_Click);
+ this.Button12.Click += new System.EventHandler(this.number_click);
+ //
+ // one
+ //
+ this.one.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
+ this.one.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+ this.one.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.one.ForeColor = System.Drawing.Color.Blue;
+ this.one.Location = new System.Drawing.Point(63, 173);
+ this.one.Name = "one";
+ this.one.Size = new System.Drawing.Size(36, 28);
+ this.one.TabIndex = 63;
+ this.one.Text = "1";
+ this.one.UseVisualStyleBackColor = true;
+ this.one.Click += new System.EventHandler(this.number_click);
//
// Button15
//
@@ -401,7 +404,7 @@
this.Button17.TabIndex = 77;
this.Button17.Text = "+";
this.Button17.UseVisualStyleBackColor = true;
- this.Button17.Click += new System.EventHandler(this.Button17_Click);
+ this.Button17.Click += new System.EventHandler(this.arithmitic_click);
//
// Button13
//
@@ -415,7 +418,7 @@
this.Button13.TabIndex = 68;
this.Button13.Text = "6";
this.Button13.UseVisualStyleBackColor = true;
- this.Button13.Click += new System.EventHandler(this.Button13_Click);
+ this.Button13.Click += new System.EventHandler(this.number_click);
//
// Button5
//
@@ -429,7 +432,7 @@
this.Button5.TabIndex = 64;
this.Button5.Text = "7";
this.Button5.UseVisualStyleBackColor = true;
- this.Button5.Click += new System.EventHandler(this.Button5_Click);
+ this.Button5.Click += new System.EventHandler(this.number_click);
//
// Button14
//
@@ -443,7 +446,7 @@
this.Button14.TabIndex = 73;
this.Button14.Text = ".";
this.Button14.UseVisualStyleBackColor = true;
- this.Button14.Click += new System.EventHandler(this.Button14_Click);
+ this.Button14.Click += new System.EventHandler(this.number_click);
//
// Button18
//
@@ -457,7 +460,7 @@
this.Button18.TabIndex = 76;
this.Button18.Text = "/";
this.Button18.UseVisualStyleBackColor = true;
- this.Button18.Click += new System.EventHandler(this.Button18_Click);
+ this.Button18.Click += new System.EventHandler(this.arithmitic_click);
//
// Button8
//
@@ -471,7 +474,7 @@
this.Button8.TabIndex = 67;
this.Button8.Text = "8";
this.Button8.UseVisualStyleBackColor = true;
- this.Button8.Click += new System.EventHandler(this.Button8_Click);
+ this.Button8.Click += new System.EventHandler(this.number_click);
//
// Button10
//
@@ -485,7 +488,7 @@
this.Button10.TabIndex = 65;
this.Button10.Text = "5";
this.Button10.UseVisualStyleBackColor = true;
- this.Button10.Click += new System.EventHandler(this.Button10_Click);
+ this.Button10.Click += new System.EventHandler(this.number_click);
//
// Button20
//
@@ -499,7 +502,7 @@
this.Button20.TabIndex = 74;
this.Button20.Text = "*";
this.Button20.UseVisualStyleBackColor = true;
- this.Button20.Click += new System.EventHandler(this.Button20_Click);
+ this.Button20.Click += new System.EventHandler(this.arithmitic_click);
//
// Button19
//
@@ -513,7 +516,7 @@
this.Button19.TabIndex = 75;
this.Button19.Text = "-";
this.Button19.UseVisualStyleBackColor = true;
- this.Button19.Click += new System.EventHandler(this.Button19_Click);
+ this.Button19.Click += new System.EventHandler(this.arithmitic_click);
//
// Button9
//
@@ -527,7 +530,7 @@
this.Button9.TabIndex = 66;
this.Button9.Text = "2";
this.Button9.UseVisualStyleBackColor = true;
- this.Button9.Click += new System.EventHandler(this.Button9_Click);
+ this.Button9.Click += new System.EventHandler(this.number_click);
//
// MenuStrip2
//
@@ -575,7 +578,7 @@
this.Controls.Add(this.Button16);
this.Controls.Add(this.Button24);
this.Controls.Add(this.Button12);
- this.Controls.Add(this.Button6);
+ this.Controls.Add(this.one);
this.Controls.Add(this.Button15);
this.Controls.Add(this.Button17);
this.Controls.Add(this.Button13);
@@ -590,7 +593,6 @@
this.Controls.Add(this.MenuStrip2);
this.Name = "WinClassicCalculator";
this.Size = new System.Drawing.Size(270, 247);
- this.Load += new System.EventHandler(this.WinClassicCalculator_Load);
this.MenuStrip2.ResumeLayout(false);
this.MenuStrip2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
@@ -626,7 +628,7 @@
internal System.Windows.Forms.Button Button16;
internal System.Windows.Forms.Button Button24;
internal System.Windows.Forms.Button Button12;
- internal System.Windows.Forms.Button Button6;
+ internal System.Windows.Forms.Button one;
internal System.Windows.Forms.Button Button15;
internal System.Windows.Forms.Button Button17;
internal System.Windows.Forms.Button Button13;
diff --git a/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicCalculator.cs b/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicCalculator.cs
index 9e923bb..71ded89 100644
--- a/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicCalculator.cs
+++ b/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicCalculator.cs
@@ -13,6 +13,9 @@ namespace TimeHACK.OS.Win95.Win95Apps
{
public partial class WinClassicCalculator : UserControl
{
+ double prevnum = 0;
+ string operation = "";
+ bool operation_pressed = false;
public WinClassicCalculator()
{
InitializeComponent();
@@ -30,258 +33,143 @@ namespace TimeHACK.OS.Win95.Win95Apps
}
txtNumbers.Paint += (sender, args) => Paintbrush.PaintClassicBordersIndented(sender, args, 2);
}
- public double prevnum = 0;
- public bool iszero = true;
- public bool neg = false;
- public bool isdecimal = false;
- public string coperator;
- public void appendnum(string num)
+ private void number_click(object sender, EventArgs e)
{
- if (iszero == true)
- {
+ if (txtNumbers.Text.Contains("∞"))
txtNumbers.Clear();
- txtNumbers.Text += (num);
- iszero = false;
- }
- else
+ if ((txtNumbers.Text == "0") || (operation_pressed))
+ txtNumbers.Text = "";
+ operation_pressed = false;
+ Button num = (Button)sender;
+ if (num.Text == ".")
{
- if (iszero == false)
- {
- txtNumbers.Text += (num);
- }
+ if (!txtNumbers.Text.Contains("."))
+ txtNumbers.Text = txtNumbers.Text + num.Text;
}
-
- }
- private void Button6_Click(object sender, EventArgs e)
- {
- appendnum("1");
- }
-
- private void Button9_Click(object sender, EventArgs e)
- {
- appendnum("2");
- }
-
- private void Button21_Click(object sender, EventArgs e)
- {
- Calculate();
- }
-
- private void Button12_Click(object sender, EventArgs e)
- {
- appendnum("3");
- }
-
- private void Button7_Click(object sender, EventArgs e)
- {
- appendnum("4");
- }
-
- private void Button10_Click(object sender, EventArgs e)
- {
- appendnum("5");
- }
-
- private void Button13_Click(object sender, EventArgs e)
- {
- appendnum("6");
- }
-
- private void Button5_Click(object sender, EventArgs e)
- {
- appendnum("7");
- }
-
- private void Button8_Click(object sender, EventArgs e)
- {
- appendnum("8");
+ else
+ txtNumbers.Text = txtNumbers.Text + num.Text;
}
- private void Button11_Click(object sender, EventArgs e)
+ private void Button27_Click(object sender, EventArgs e)
{
- appendnum("9");
+ txtNumbers.Text = "0";
}
- private void Button16_Click(object sender, EventArgs e)
+ private void Button26_Click(object sender, EventArgs e)
{
-
- if (iszero == false)
- {
- txtNumbers.Text += (0);
- }
+ prevnum = 0;
+ operation = "";
+ operation_pressed = false;
+ txtNumbers.Text = "0";
}
private void Button25_Click(object sender, EventArgs e)
{
- if (txtNumbers.Text != "0")
+ if (txtNumbers.Text.Length>0)
{
- txtNumbers.Text = txtNumbers.Text.Remove(txtNumbers.Text.Length - 1);
+ txtNumbers.Text = txtNumbers.Text.Remove(txtNumbers.Text.Length - 1, 1);
}
- if (txtNumbers.TextLength < 1)
+ if (txtNumbers.Text =="")
{
txtNumbers.Text = "0";
}
-
}
- private void Button15_Click(object sender, EventArgs e)
+ private void arithmitic_click(object sender, EventArgs e)
{
- if (neg == false)
+ Button num = (Button)sender;
+ if (txtNumbers.Text.Contains("∞"))
+ txtNumbers.Clear();
+ if (prevnum != 0)
{
- txtNumbers.Text = "-" + txtNumbers.Text;
- neg = true;
+ if (num.Text == "sqrt")
+ prevnum = Math.Sqrt(double.Parse(txtNumbers.Text));
+ if (num.Text == "1/x")
+ prevnum = Convert.ToDouble(1.0 / Convert.ToDouble(txtNumbers.Text));
+ if (num.Text == "%")
+ prevnum = Convert.ToDouble(txtNumbers.Text) / 100;
+ Button21.PerformClick();
+ operation = num.Text;
+ operation_pressed = true;
}
- else
+ else if (num.Text == "sqrt")
{
- txtNumbers.Text = txtNumbers.Text.Replace("-", "");
- neg = false;
+ prevnum = Math.Sqrt(double.Parse(txtNumbers.Text));
+ txtNumbers.Text = prevnum.ToString();
}
- }
-
- private void Button14_Click(object sender, EventArgs e)
- {
-
- if (isdecimal == false)
+ else if (num.Text == "1/x")
{
- appendnum(".");
- isdecimal = true;
+ prevnum = Convert.ToDouble(1.0 / Convert.ToDouble(txtNumbers.Text));
+ txtNumbers.Text = prevnum.ToString();
}
- }
-
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (txtNumbers.Text.Contains(".") == false)
+ else if (num.Text == "%")
{
- isdecimal = false;
+ prevnum = Convert.ToDouble(txtNumbers.Text) / 100;
+ txtNumbers.Text = prevnum.ToString();
}
- if (txtNumbers.Text == "0")
+ else
{
- iszero = true;
+ operation = num.Text;
+ prevnum = double.Parse(txtNumbers.Text);
+ txtNumbers.Text = "0";
+ operation_pressed = true;
}
}
-
- private void WinClassicCalculator_Load(object sender, EventArgs e)
- {
- timer1.Start();
- }
-
- private void AboutCalculatorToolStripMenuItem_Click(object sender, EventArgs e)
- {
-
- WindowManager wm = new WindowManager();
- wm.StartAboutBox95("Calculator", null, Properties.Resources.WinClassicCalc);
- }
-
- private void Button26_Click(object sender, EventArgs e)
- {
- prevnum = 0;
- txtNumbers.Text = "0";
- isdecimal = false;
- iszero = true;
- neg = false;
- }
-
- private void Button27_Click(object sender, EventArgs e)
- {
- txtNumbers.Text = "0";
- isdecimal = false;
- iszero = true;
- neg = false;
- }
- public void Calculate()
+
+ private void Button21_Click(object sender, EventArgs e)
{
- switch (coperator)
+ if (txtNumbers.Text.Contains("∞"))
+ txtNumbers.Clear();
+ switch (operation)
{
case "+":
- if (prevnum == 0)
- {
- break;
- }
txtNumbers.Text = (prevnum + double.Parse(txtNumbers.Text)).ToString();
- prevnum = double.Parse(txtNumbers.Text);
break;
case "-":
- if (prevnum == 0)
- {
- break;
- }
txtNumbers.Text = (prevnum - double.Parse(txtNumbers.Text)).ToString();
- prevnum = double.Parse(txtNumbers.Text);
break;
case "*":
- if (prevnum == 0)
- {
- break;
- }
txtNumbers.Text = (prevnum * double.Parse(txtNumbers.Text)).ToString();
- prevnum = double.Parse(txtNumbers.Text);
break;
case "/":
- if (prevnum == 0)
- {
- break;
- }
txtNumbers.Text = (prevnum / double.Parse(txtNumbers.Text)).ToString();
- prevnum = double.Parse(txtNumbers.Text);
break;
}
+ prevnum = Int32.Parse(txtNumbers.Text);
+ operation = "";
}
- private void Button22_Click(object sender, EventArgs e)
- {
- double sq = double.Parse(txtNumbers.Text);
- txtNumbers.Text = Math.Sqrt(sq).ToString();
- }
-
- private void Button17_Click(object sender, EventArgs e)
- {
- coperator = "+";
- Calculate();
- prevnum = double.Parse(txtNumbers.Text);
- iszero = true;
- }
-
- private void Button19_Click(object sender, EventArgs e)
+ private void AboutCalculatorToolStripMenuItem_Click(object sender, EventArgs e)
{
- coperator = "-";
- Calculate();
- prevnum = double.Parse(txtNumbers.Text);
- txtNumbers.Text = "0";
+ WindowManager wm = new WindowManager();
+ wm.StartAboutBox95("Calculator", "Microsoft Calculator", Properties.Resources.WinClassicCalc);
}
- private void Button20_Click(object sender, EventArgs e)
+ private void Button15_Click(object sender, EventArgs e)
{
- coperator = "*";
- Calculate();
- prevnum = double.Parse(txtNumbers.Text);
- txtNumbers.Text = "0";
- }
- private void Button18_Click(object sender, EventArgs e)
- {
- coperator = "/";
- Calculate();
- prevnum = double.Parse(txtNumbers.Text);
- txtNumbers.Text = "0";
}
- private void Button23_Click(object sender, EventArgs e)
+ private void CopyCtrlCToolStripMenuItem1_Click(object sender, EventArgs e)
{
- double a;
- a = Convert.ToDouble(1.0 / Convert.ToDouble(txtNumbers.Text));
- txtNumbers.Text = Convert.ToString(a);
+ txtNumbers.Copy();
}
- private void Button24_Click(object sender, EventArgs e)
+ private void PasteCtrlVToolStripMenuItem1_Click(object sender, EventArgs e)
{
- double a;
- a = Convert.ToDouble(txtNumbers.Text) / Convert.ToDouble(100);
- txtNumbers.Text = Convert.ToString(a);
+ string pasteText = Clipboard.GetText();
+ string strippedText = "";
+ for (int i = 0; i < pasteText.Length; i++)
+ {
+ if (char.IsDigit(pasteText[i]))
+ strippedText += pasteText[i].ToString();
+ MessageBox.Show("Test");
+ }
+ if (strippedText!=pasteText)
+ {
+ txtNumbers.Text = pasteText;
+ }
}
- private void Button12_Click_1(object sender, EventArgs e)
- {
-
- }
}
}