diff --git a/.github/Flowcharts/Basic Version- Four Function/Thumbs.db b/.github/Flowcharts/Basic Version- Four Function/Thumbs.db new file mode 100644 index 0000000..b11d7d9 Binary files /dev/null and b/.github/Flowcharts/Basic Version- Four Function/Thumbs.db differ diff --git a/.github/Important Notes/Important note on memory.txt b/.github/Important Notes/Important note on memory.txt new file mode 100644 index 0000000..56f080a --- /dev/null +++ b/.github/Important Notes/Important note on memory.txt @@ -0,0 +1,4 @@ +this design ends up making the an assuming for setting "mem clear". that could cause issues in the future, especially with some of the other planned additions. Be warned +Also uses an inversion in 1 location, but hardcoded elsewhere. Major possible flaw, fix? + +future plan: utilize functions? \ No newline at end of file diff --git a/.github/Information/Completed Components.txt b/.github/Information/Completed Components.txt new file mode 100644 index 0000000..be08617 --- /dev/null +++ b/.github/Information/Completed Components.txt @@ -0,0 +1,4 @@ +Currently implemnted components of the plan is: +4-function +5-function (added modulus) +Memory \ No newline at end of file diff --git a/.github/Planing.txt b/.github/Planing.txt index 6682eb8..13665a1 100644 --- a/.github/Planing.txt +++ b/.github/Planing.txt @@ -1,3 +1,7 @@ Create Plans/ flowcharts -current plans: 4 function \ No newline at end of file +current plans: 4 function (complete) +5 function- modulus (complete) +Memory + +convert to RPN \ No newline at end of file diff --git a/.github/flowcharts/Basic Version- Four Function/Calculator- basis.png b/.github/flowcharts/Basic Version- Four Function/4-function flowchart.png similarity index 100% rename from .github/flowcharts/Basic Version- Four Function/Calculator- basis.png rename to .github/flowcharts/Basic Version- Four Function/4-function flowchart.png diff --git a/Calculator.sln b/Calculator.sln index 2728e22..e406085 100644 --- a/Calculator.sln +++ b/Calculator.sln @@ -5,16 +5,6 @@ VisualStudioVersion = 17.9.34607.119 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Calculator", "Calculator.csproj", "{075FDFF7-D82F-4309-8D4A-39ECED2F8A56}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Information", "Information", "{AF2FEF8F-9F77-4A3C-9345-8B42A0AE58AE}" - ProjectSection(SolutionItems) = preProject - .github\README.md = .github\README.md - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Planing", "Planing", "{3C6331E6-F22F-4A68-A98A-60470DEEF3CA}" - ProjectSection(SolutionItems) = preProject - .github\Planing.txt = .github\Planing.txt - EndProjectSection -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -29,9 +19,6 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {3C6331E6-F22F-4A68-A98A-60470DEEF3CA} = {AF2FEF8F-9F77-4A3C-9345-8B42A0AE58AE} - EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {79602F43-DCBE-4C2E-A6CE-FF2BC5F86E54} EndGlobalSection diff --git a/Program.cs b/Program.cs index a044edc..f098347 100644 --- a/Program.cs +++ b/Program.cs @@ -15,7 +15,8 @@ internal static class Program static void Main() { Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); + // Application.SetCompatibleTextRenderingDefault(false); + // false is default, so it's not needed. Kept as a comment for refferences sake. Being true is actually a detriment Application.Run(new frmCalc()); } } diff --git a/flowchart/Basic Version- Four Function/Calculator- basis.png b/flowchart/Basic Version- Four Function/Calculator- basis.png deleted file mode 100644 index 5c4e5c8..0000000 Binary files a/flowchart/Basic Version- Four Function/Calculator- basis.png and /dev/null differ diff --git a/flowchart/Basic Version- Four Function/Calculator.drawio b/flowchart/Basic Version- Four Function/Calculator.drawio deleted file mode 100644 index 716b74b..0000000 --- a/flowchart/Basic Version- Four Function/Calculator.drawio +++ /dev/null @@ -1 +0,0 @@ -5Vxbs5s2EP41nqYPx8Md/Jg4l06bdjI9D2360pFBNooxIkIc2/31kUBgkDg2J7aRnWbmTKxlQbDab29amNjzze4DAVn8O45gMrGMaDex304sy3S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L142TN6AmlYFnP5h0nYHwrz6hAM6VRZk7p/L8WUY0R9N36JUyoQYTqco/ptDVjCJUqSOU4wKaeyl8ulFYbNJK0jkbfwXE9M1qJ77J9hXEYZfEMOFXqUwexRhiZ8fIE2sOHhey+Vkzh8T8d+9w0= \ No newline at end of file diff --git a/frm_calc.Designer.cs b/frm_calc.Designer.cs index 9723a53..54b081b 100644 --- a/frm_calc.Designer.cs +++ b/frm_calc.Designer.cs @@ -48,9 +48,16 @@ private void InitializeComponent() this.bttn_div = new System.Windows.Forms.Button(); this.bttn_mod = new System.Windows.Forms.Button(); this.bttn_clear = new System.Windows.Forms.Button(); - this.bttn_clearEvery = new System.Windows.Forms.Button(); - this.bttn_0 = new System.Windows.Forms.Button(); + this.bttn_clearAll = new System.Windows.Forms.Button(); this.rtb_ans = new System.Windows.Forms.RichTextBox(); + this.bttn_recalFast = new System.Windows.Forms.Button(); + this.bttn_memStoreFast = new System.Windows.Forms.Button(); + this.txt_memFastPrev = new System.Windows.Forms.TextBox(); + this.bttn_clearMemFast = new System.Windows.Forms.Button(); + this.lst_memFull = new System.Windows.Forms.ListBox(); + this.bttn_0 = new System.Windows.Forms.Button(); + this.bttn_recalFull = new System.Windows.Forms.Button(); + this.txt_previewFull = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // bttnClose @@ -81,7 +88,7 @@ private void InitializeComponent() // txt_debug // this.txt_debug.ImeMode = System.Windows.Forms.ImeMode.Off; - this.txt_debug.Location = new System.Drawing.Point(846, 1); + this.txt_debug.Location = new System.Drawing.Point(913, 1); this.txt_debug.Multiline = true; this.txt_debug.Name = "txt_debug"; this.txt_debug.ReadOnly = true; @@ -158,7 +165,7 @@ private void InitializeComponent() this.bttn_9.Size = new System.Drawing.Size(75, 23); this.bttn_9.TabIndex = 10; this.bttn_9.Text = "9"; - this.bttn_9.UseVisualStyleBackColor = false; + this.bttn_9.UseVisualStyleBackColor = true; this.bttn_9.Click += new System.EventHandler(this.bttn_num_Click); // // bttn_8 @@ -168,7 +175,7 @@ private void InitializeComponent() this.bttn_8.Size = new System.Drawing.Size(75, 23); this.bttn_8.TabIndex = 9; this.bttn_8.Text = "8"; - this.bttn_8.UseVisualStyleBackColor = false; + this.bttn_8.UseVisualStyleBackColor = true; this.bttn_8.Click += new System.EventHandler(this.bttn_num_Click); // // bttn_7 @@ -178,7 +185,7 @@ private void InitializeComponent() this.bttn_7.Size = new System.Drawing.Size(75, 23); this.bttn_7.TabIndex = 8; this.bttn_7.Text = "7"; - this.bttn_7.UseVisualStyleBackColor = false; + this.bttn_7.UseVisualStyleBackColor = true; this.bttn_7.Click += new System.EventHandler(this.bttn_num_Click); // // bttn_sub @@ -189,6 +196,7 @@ private void InitializeComponent() this.bttn_sub.TabIndex = 13; this.bttn_sub.Text = "-"; this.bttn_sub.UseVisualStyleBackColor = false; + this.bttn_sub.Click += new System.EventHandler(this.op_Click); // // bttn_add // @@ -198,6 +206,7 @@ private void InitializeComponent() this.bttn_add.TabIndex = 12; this.bttn_add.Text = "+"; this.bttn_add.UseVisualStyleBackColor = false; + this.bttn_add.Click += new System.EventHandler(this.op_Click); // // bttn_equal // @@ -207,6 +216,7 @@ private void InitializeComponent() this.bttn_equal.TabIndex = 11; this.bttn_equal.Text = "="; this.bttn_equal.UseVisualStyleBackColor = false; + this.bttn_equal.Click += new System.EventHandler(this.bttn_equal_Click); // // bttn_mult // @@ -216,6 +226,7 @@ private void InitializeComponent() this.bttn_mult.TabIndex = 14; this.bttn_mult.Text = "*"; this.bttn_mult.UseVisualStyleBackColor = false; + this.bttn_mult.Click += new System.EventHandler(this.op_Click); // // bttn_div // @@ -225,6 +236,7 @@ private void InitializeComponent() this.bttn_div.TabIndex = 15; this.bttn_div.Text = "/"; this.bttn_div.UseVisualStyleBackColor = false; + this.bttn_div.Click += new System.EventHandler(this.op_Click); // // bttn_mod // @@ -234,6 +246,7 @@ private void InitializeComponent() this.bttn_mod.TabIndex = 16; this.bttn_mod.Text = "%"; this.bttn_mod.UseVisualStyleBackColor = false; + this.bttn_mod.Click += new System.EventHandler(this.op_Click); // // bttn_clear // @@ -243,15 +256,79 @@ private void InitializeComponent() this.bttn_clear.TabIndex = 17; this.bttn_clear.Text = "Clear"; this.bttn_clear.UseVisualStyleBackColor = false; + this.bttn_clear.Click += new System.EventHandler(this.clear_click); + // + // bttn_clearAll // - // bttn_clearEvery + this.bttn_clearAll.Location = new System.Drawing.Point(230, 162); + this.bttn_clearAll.Name = "bttn_clearAll"; + this.bttn_clearAll.Size = new System.Drawing.Size(156, 23); + this.bttn_clearAll.TabIndex = 18; + this.bttn_clearAll.Text = "Clear All"; + this.bttn_clearAll.UseVisualStyleBackColor = false; + this.bttn_clearAll.Click += new System.EventHandler(this.clear_click); + // + // rtb_ans // - this.bttn_clearEvery.Location = new System.Drawing.Point(230, 162); - this.bttn_clearEvery.Name = "bttn_clearEvery"; - this.bttn_clearEvery.Size = new System.Drawing.Size(156, 23); - this.bttn_clearEvery.TabIndex = 18; - this.bttn_clearEvery.Text = "Clear Equation"; - this.bttn_clearEvery.UseVisualStyleBackColor = false; + this.rtb_ans.Location = new System.Drawing.Point(149, 135); + this.rtb_ans.Name = "rtb_ans"; + this.rtb_ans.Size = new System.Drawing.Size(318, 21); + this.rtb_ans.TabIndex = 20; + this.rtb_ans.Text = "0"; + this.rtb_ans.TextChanged += new System.EventHandler(this.rtb_ans_TextChanged); + // + // bttn_recalFast + // + this.bttn_recalFast.Location = new System.Drawing.Point(149, 307); + this.bttn_recalFast.Name = "bttn_recalFast"; + this.bttn_recalFast.Size = new System.Drawing.Size(156, 23); + this.bttn_recalFast.TabIndex = 21; + this.bttn_recalFast.Text = "Recall Rapid Memory"; + this.bttn_recalFast.UseVisualStyleBackColor = true; + this.bttn_recalFast.Visible = false; + this.bttn_recalFast.Click += new System.EventHandler(this.bttn_num_Click); + // + // bttn_memStoreFast + // + this.bttn_memStoreFast.Location = new System.Drawing.Point(311, 307); + this.bttn_memStoreFast.Name = "bttn_memStoreFast"; + this.bttn_memStoreFast.Size = new System.Drawing.Size(156, 23); + this.bttn_memStoreFast.TabIndex = 22; + this.bttn_memStoreFast.Text = "Store Rapid Memory"; + this.bttn_memStoreFast.UseVisualStyleBackColor = true; + this.bttn_memStoreFast.Visible = false; + this.bttn_memStoreFast.Click += new System.EventHandler(this.bttn_memStoreFast_Click); + // + // txt_memFastPrev + // + this.txt_memFastPrev.Location = new System.Drawing.Point(149, 109); + this.txt_memFastPrev.Name = "txt_memFastPrev"; + this.txt_memFastPrev.ReadOnly = true; + this.txt_memFastPrev.Size = new System.Drawing.Size(75, 20); + this.txt_memFastPrev.TabIndex = 0; + this.txt_memFastPrev.TabStop = false; + this.txt_memFastPrev.Visible = false; + this.txt_memFastPrev.WordWrap = false; + // + // bttn_clearMemFast + // + this.bttn_clearMemFast.Location = new System.Drawing.Point(19, 162); + this.bttn_clearMemFast.Name = "bttn_clearMemFast"; + this.bttn_clearMemFast.Size = new System.Drawing.Size(124, 23); + this.bttn_clearMemFast.TabIndex = 23; + this.bttn_clearMemFast.Text = "Clear Rapid Memory"; + this.bttn_clearMemFast.UseVisualStyleBackColor = false; + this.bttn_clearMemFast.Visible = false; + this.bttn_clearMemFast.Click += new System.EventHandler(this.bttn_clearMemFast_Click); + // + // lst_memFull + // + this.lst_memFull.FormattingEnabled = true; + this.lst_memFull.Location = new System.Drawing.Point(607, 119); + this.lst_memFull.Name = "lst_memFull"; + this.lst_memFull.Size = new System.Drawing.Size(120, 95); + this.lst_memFull.TabIndex = 24; + this.lst_memFull.SelectedIndexChanged += new System.EventHandler(this.lst_memFull_SelectedIndexChanged); // // bttn_0 // @@ -263,13 +340,23 @@ private void InitializeComponent() this.bttn_0.UseVisualStyleBackColor = true; this.bttn_0.Click += new System.EventHandler(this.bttn_num_Click); // - // rtb_ans + // bttn_recalFull // - this.rtb_ans.Location = new System.Drawing.Point(149, 135); - this.rtb_ans.Name = "rtb_ans"; - this.rtb_ans.Size = new System.Drawing.Size(318, 21); - this.rtb_ans.TabIndex = 20; - this.rtb_ans.Text = "0"; + this.bttn_recalFull.Location = new System.Drawing.Point(526, 119); + this.bttn_recalFull.Name = "bttn_recalFull"; + this.bttn_recalFull.Size = new System.Drawing.Size(75, 23); + this.bttn_recalFull.TabIndex = 25; + this.bttn_recalFull.Text = "Recall"; + this.bttn_recalFull.UseVisualStyleBackColor = true; + this.bttn_recalFull.Click += new System.EventHandler(this.bttn_num_Click); + // + // txt_previewFull + // + this.txt_previewFull.Location = new System.Drawing.Point(607, 91); + this.txt_previewFull.Name = "txt_previewFull"; + this.txt_previewFull.Size = new System.Drawing.Size(110, 20); + this.txt_previewFull.TabIndex = 26; + this.txt_previewFull.TextChanged += new System.EventHandler(this.txt_previewFull_TextChanged); // // frmCalc // @@ -277,11 +364,18 @@ private void InitializeComponent() this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.Control; this.CancelButton = this.bttnClose; - this.ClientSize = new System.Drawing.Size(1048, 450); + this.ClientSize = new System.Drawing.Size(1113, 489); this.ControlBox = false; + this.Controls.Add(this.txt_previewFull); + this.Controls.Add(this.bttn_recalFull); + this.Controls.Add(this.lst_memFull); + this.Controls.Add(this.bttn_clearMemFast); + this.Controls.Add(this.txt_memFastPrev); + this.Controls.Add(this.bttn_memStoreFast); + this.Controls.Add(this.bttn_recalFast); this.Controls.Add(this.rtb_ans); this.Controls.Add(this.bttn_0); - this.Controls.Add(this.bttn_clearEvery); + this.Controls.Add(this.bttn_clearAll); this.Controls.Add(this.bttn_clear); this.Controls.Add(this.bttn_mod); this.Controls.Add(this.bttn_div); @@ -334,9 +428,16 @@ private void InitializeComponent() private System.Windows.Forms.Button bttn_div; private System.Windows.Forms.Button bttn_mod; private System.Windows.Forms.Button bttn_clear; - private System.Windows.Forms.Button bttn_clearEvery; - private System.Windows.Forms.Button bttn_0; + private System.Windows.Forms.Button bttn_clearAll; private System.Windows.Forms.RichTextBox rtb_ans; + private System.Windows.Forms.Button bttn_recalFast; + private System.Windows.Forms.Button bttn_memStoreFast; + private System.Windows.Forms.TextBox txt_memFastPrev; + private System.Windows.Forms.Button bttn_clearMemFast; + private System.Windows.Forms.ListBox lst_memFull; + private System.Windows.Forms.Button bttn_0; + private System.Windows.Forms.Button bttn_recalFull; + private System.Windows.Forms.TextBox txt_previewFull; } } diff --git a/frm_calc.cs b/frm_calc.cs index b806600..45861fd 100644 --- a/frm_calc.cs +++ b/frm_calc.cs @@ -1,11 +1,24 @@ using System; +using System.Diagnostics.Eventing.Reader; using System.Drawing; +using System.Linq; using System.Windows.Forms; namespace Calculator { public partial class frmCalc : Form { + float num1 = 0; + float num2 = 0; + string op = ""; + string mem = ""; + const string divError = "This is a very complex question. Many people say it's undefinined, but what is that? Well, it can also be considered indeterminent, but that's just the begining. There are many odd results when you get to the smallest part"; + bool firstnum = true; //flag for if it's the first number + string rapidMem = ""; + bool rapidMemClear = true; //whether the memory is clear + string memFull = ""; + + public frmCalc() { InitializeComponent(); @@ -31,6 +44,7 @@ private void frmCalc_Load(object sender, EventArgs e) addItem(debug.ToString(),false); //debug mode? addItem(closeText, true); //close text addItem(confirmClose, false); //confirm close + rapidMemClear = !rapidMemClear; //invert it, as the useage makes it such that the variable should be inverse. Another possible flaw, fix? } const string closeText = "Close"; @@ -49,7 +63,7 @@ private string addItem(string item, bool newEntry) txt_debug.AppendText(item); txt_debug.AppendText(empty); return txt_debug.Text.ToString(); - } + } //debug text boxes private void bttnClose_Click(object sender, EventArgs e) { if ( bttnClose.Text == closeText) // next name @@ -57,33 +71,187 @@ private void bttnClose_Click(object sender, EventArgs e) bttnClose.Text = confirmText; } else { - Application.Exit(); + Application.Exit(); //exit } // close - tmr_ConfirmClose.Start(); + tmr_ConfirmClose.Start(); //timer to allow confirmation - } + } //close after confirm private void txt_debug_TextChanged(object sender, EventArgs e) { - } + } //if change in debug text private void tmr_ConfirmClose_Tick(object sender, EventArgs e) { tmr_ConfirmClose.Stop(); bttnClose.Text = closeText; - } + } //when you hit close, this timer will change the text for 3 seconds. if you hit the button within those 3 seconds the application closes private void bttn_num_Click(object sender, EventArgs e) { - if(rtb_ans.Text == "0") + Button btn = sender as Button; + string val = btn.Text; + bool recall = false; + if (val == bttn_recalFast.Text) + { + val = rapidMem; + recall = true; + } + + + if (rtb_ans.Text == "0" || firstnum) + { + rtb_ans.Text = val; + firstnum = false; + } + else { - rtb_ans.Text = ""; + if ( recall ) + { + rtb_ans.Text = val; //as recalled from memory, set to value from memory + } + else if (btn.Text == bttn_recalFull.Text) //as recalled from full memory, set + { + rtb_ans.Text = txt_previewFull.Text; + } else { + rtb_ans.Text += val; //add entry to text + } }; // also the following works (but sometimes it works in cases like strings to integers. Sometimes it works, sometimes it doesn't. // Button btn = (Button)sender; + } //input numbers + + private void op_Click(object sender, EventArgs e) + { + Button btn = sender as Button; + op = btn.Text; + num1 = float.Parse(rtb_ans.Text); + mem = rtb_ans.Text + op; + rtb_ans.Text = "0"; //set to 0 as after hitting operator you need 0, si? + firstnum = false; + + } //add operators + + private void clear_click(object sender, EventArgs e) + { Button btn = sender as Button; - rtb_ans.Text += btn.Text; + + + num1 = 0; //these three lines clear all the numbers + num2 = 0; + op = ""; + + rtb_ans.Text = "0"; //set answer to 0 + + if (btn.Text == "Clear All") //check if it's clear all, if so wipe both memories as well + { + lst_memFull.Items.Clear(); //clear full memory + rapidMem = ""; //clear rapid mem + rapidMemClear = false; //set clear to say it is clear (due to convoluted reasons the boolean is inverted) + } + firstnum = false; + } //clear equation + + private void bttn_equal_Click(object sender, EventArgs e) + { + num2 = float.Parse(rtb_ans.Text); + mem += rtb_ans.Text; + + switch ( op ) //runs only exact kinda like an if and an equal, with in-built if-else + { + case "+": + rtb_ans.Text = (num1 + num2).ToString(); + break; + case "-": + rtb_ans.Text = (num1 - num2).ToString(); + break; + case "*": + rtb_ans.Text = (num1 * num2).ToString(); + break; + case "/": + if (num2 != 0) + { + rtb_ans.Text = (num1 / num2).ToString(); + } else { + MessageBox.Show(divError); + } + break; + case "%": + if (num2 != 0) + { + rtb_ans.Text = (num1 % num2).ToString(); + } else + { + MessageBox.Show(divError); + } + break; + default: + { + rtb_ans.Text = num1.ToString(); + break; + } + + } + + + mem += "="+rtb_ans.Text; + lst_memFull.Items.Add(mem); + + mem = ""; + num1 = 0; + num2 = 0; + op = ""; + firstnum = true; + } //equals button + + private void rtb_ans_TextChanged(object sender, EventArgs e) + { + string content = rtb_ans.Text; + if (content == "0" || content == "") + { + bttn_memStoreFast.Visible = false; + } else + { + bttn_memStoreFast.Visible = true; + } + } //controll systems based on the answer changeing + + private void bttn_memStoreFast_Click(object sender, EventArgs e) + { + rapidMem = rtb_ans.Text; + txt_memFastPrev.Text = rapidMem; //shows the stored value in the textbox + rapidMemClear = true; //shows memory is not clear, to allow viewing of memory and such + //one flaw: it assumes that this button requires you to be adding to memory. With future design, that could be issue + txt_memFastPrev.Visible = rapidMemClear; + bttn_recalFast.Visible = rapidMemClear; + bttn_clear.Visible = rapidMemClear; + bttn_clearMemFast.Visible = rapidMemClear; + } //store code in fast mem + + private void bttn_clearMemFast_Click(object sender, EventArgs e) + { + rapidMemClear = false; + txt_memFastPrev.Visible = rapidMemClear; + bttn_recalFast.Visible = rapidMemClear; + bttn_clearMemFast.Visible = rapidMemClear; + rapidMem = ""; + } //clear the rapid mem + + private void lst_memFull_SelectedIndexChanged(object sender, EventArgs e) + { + int position = lst_memFull.SelectedIndex; //get intex + memFull = lst_memFull.SelectedItem.ToString(); //get selected item, to manipulate to get the correct item + var memItems = memFull.Split('=').ToList(); + position = memItems.Count; //posistion is also used to find where the equals sign is + memFull = memItems[position-1]; + txt_previewFull.Text = memFull; //set preview box + + } + + private void txt_previewFull_TextChanged(object sender, EventArgs e) + { + } } }