From 7c98ee84485ffcf755b168de920b742efe2bd248 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Resende Menezes Date: Fri, 9 Feb 2024 09:12:57 -0300 Subject: [PATCH 01/11] CommitTeste1 --- Calculadora Forms/Calculadora.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Calculadora Forms/Calculadora.cs b/Calculadora Forms/Calculadora.cs index 1c24c6b..a5c3016 100644 --- a/Calculadora Forms/Calculadora.cs +++ b/Calculadora Forms/Calculadora.cs @@ -35,7 +35,7 @@ private void btMais_Click(object sender, EventArgs e) obj.operacao = 1; - if(obj.valor1 == 0) //Erro aqui, assim o valor vai ser sempre 0 pois ele é inserido só dentro do if + if(obj.valor1 == 0) //Erro aqui, assim o valor vai ser sempre 0 pois ele é inserido só dentro do ifdasd { tbOperacao.Text = tbDisplay.Text + " +"; obj.valor1 = int.Parse(tbDisplay.Text); From d2f5ff23fa963716656148b7665bc9610d741898 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Resende Menezes Date: Fri, 9 Feb 2024 09:18:16 -0300 Subject: [PATCH 02/11] CommitTeste2 --- Calculadora Forms/Calculadora.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Calculadora Forms/Calculadora.cs b/Calculadora Forms/Calculadora.cs index a5c3016..1c24c6b 100644 --- a/Calculadora Forms/Calculadora.cs +++ b/Calculadora Forms/Calculadora.cs @@ -35,7 +35,7 @@ private void btMais_Click(object sender, EventArgs e) obj.operacao = 1; - if(obj.valor1 == 0) //Erro aqui, assim o valor vai ser sempre 0 pois ele é inserido só dentro do ifdasd + if(obj.valor1 == 0) //Erro aqui, assim o valor vai ser sempre 0 pois ele é inserido só dentro do if { tbOperacao.Text = tbDisplay.Text + " +"; obj.valor1 = int.Parse(tbDisplay.Text); From ec576ad43552ef989d81e283fca873a08b4f6968 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Resende Menezes Date: Fri, 9 Feb 2024 09:20:29 -0300 Subject: [PATCH 03/11] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9a9d6ba..4804949 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# Calculadora Forms \ No newline at end of file +# Calculadora Forms + +Branch de testes e desenvolvimento From 3ee525f79b233adfdfba97432b35dd21c02053bc Mon Sep 17 00:00:00 2001 From: Pedro Henrique Resende Menezes Date: Fri, 9 Feb 2024 15:37:56 -0300 Subject: [PATCH 04/11] Commit1 --- Calculadora Forms/Calculadora.cs | 43 +++++++++++++++++--------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/Calculadora Forms/Calculadora.cs b/Calculadora Forms/Calculadora.cs index 1c24c6b..53687d3 100644 --- a/Calculadora Forms/Calculadora.cs +++ b/Calculadora Forms/Calculadora.cs @@ -14,6 +14,13 @@ public partial class Calculadora : Form { bool ordem = true; + public double valor1; + + public double valor2; + + public int operacao; + + public Calculadora() { InitializeComponent(); @@ -33,12 +40,12 @@ private void btMais_Click(object sender, EventArgs e) { Calculos obj = new Calculos(); - obj.operacao = 1; + operacao = 1; - if(obj.valor1 == 0) //Erro aqui, assim o valor vai ser sempre 0 pois ele é inserido só dentro do if + if(valor1 == 0) { tbOperacao.Text = tbDisplay.Text + " +"; - obj.valor1 = int.Parse(tbDisplay.Text); + valor1 = double.Parse(tbDisplay.Text); } else { @@ -52,15 +59,16 @@ private void btIgual_Click(object sender, EventArgs e) { Calculos obj = new Calculos(); - obj.valor2 = int.Parse(tbDisplay.Text); + valor2 = double.Parse(tbDisplay.Text); - switch (obj.operacao) + switch (operacao) { case 1: - tbDisplay.Text = obj.Soma().ToString(); + double result = obj.Soma(valor1,valor2); + tbDisplay.Text = result.ToString(); break; - case 2: + /*case 2: tbDisplay.Text = obj.Sub().ToString(); break; @@ -74,40 +82,35 @@ private void btIgual_Click(object sender, EventArgs e) default: MessageBox.Show("Insira uma operação para o cálculo"); - break; + break;*/ } - obj.valor1 = 0; - obj.valor2 = 0; - obj.operacao = 0; + valor1 = 0; + valor2 = 0; + operacao = 0; tbOperacao.Text = ""; } } class Calculos { - public double valor1; - - public double valor2; - - public int operacao; - public double Soma() + public double Soma(double valor1, double valor2) { return valor1 + valor2; } - public double Sub() + public double Sub(double valor1, double valor2) { return valor1 - valor2; } - public double Multi() + public double Multi(double valor1, double valor2) { return valor1 * valor2; } - public double Divi() + public double Divi(double valor1, double valor2) { if(valor1 == 0 || valor2 == 0) { From 0e1c742d1001a48ad6f21af70241818d997646f3 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Resende Menezes Date: Fri, 9 Feb 2024 15:45:18 -0300 Subject: [PATCH 05/11] Commit11 --- Calculadora Forms/Calculadora.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Calculadora Forms/Calculadora.cs b/Calculadora Forms/Calculadora.cs index 53687d3..a29f096 100644 --- a/Calculadora Forms/Calculadora.cs +++ b/Calculadora Forms/Calculadora.cs @@ -81,9 +81,8 @@ private void btIgual_Click(object sender, EventArgs e) break; default: - MessageBox.Show("Insira uma operação para o cálculo"); + MessageBox.Show("Insira uma operação para o cálculo");adsad break;*/ - } valor1 = 0; valor2 = 0; From b207706f5f9b445fa2c26f209238c7bceb20a80f Mon Sep 17 00:00:00 2001 From: Pedro Henrique Resende Menezes Date: Fri, 9 Feb 2024 15:50:03 -0300 Subject: [PATCH 06/11] Testee --- Calculadora_Windows-Forms | 1 + 1 file changed, 1 insertion(+) create mode 160000 Calculadora_Windows-Forms diff --git a/Calculadora_Windows-Forms b/Calculadora_Windows-Forms new file mode 160000 index 0000000..e6c3455 --- /dev/null +++ b/Calculadora_Windows-Forms @@ -0,0 +1 @@ +Subproject commit e6c34555dd9c02ddc3a1670d7675198f52fc7920 From e1e228673e313095bd9b340b908ef7dc33412419 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Resende Menezes Date: Fri, 9 Feb 2024 15:50:43 -0300 Subject: [PATCH 07/11] Teseeee --- Calculadora Forms/Calculadora.cs | 27 ++++++++++++++------------- Calculadora_Windows-Forms | 1 - 2 files changed, 14 insertions(+), 14 deletions(-) delete mode 160000 Calculadora_Windows-Forms diff --git a/Calculadora Forms/Calculadora.cs b/Calculadora Forms/Calculadora.cs index a29f096..7489881 100644 --- a/Calculadora Forms/Calculadora.cs +++ b/Calculadora Forms/Calculadora.cs @@ -64,25 +64,26 @@ private void btIgual_Click(object sender, EventArgs e) switch (operacao) { case 1: - double result = obj.Soma(valor1,valor2); + double result = obj.Soma(valor1, valor2); tbDisplay.Text = result.ToString(); break; - /*case 2: - tbDisplay.Text = obj.Sub().ToString(); - break; + /*case 2: + tbDisplay.Text = obj.Sub().ToString(); + break; - case 3: - tbDisplay.Text = obj.Multi().ToString(); - break; + case 3: + tbDisplay.Text = obj.Multi().ToString(); + break; - case 4: - tbDisplay.Text = obj.Divi().ToString(); - break; + case 4: + tbDisplay.Text = obj.Divi().ToString(); + break; - default: - MessageBox.Show("Insira uma operação para o cálculo");adsad - break;*/ + default: + MessageBox.Show("Insira uma operação para o cálculo");adsad + break;*/ + } valor1 = 0; valor2 = 0; diff --git a/Calculadora_Windows-Forms b/Calculadora_Windows-Forms deleted file mode 160000 index e6c3455..0000000 --- a/Calculadora_Windows-Forms +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e6c34555dd9c02ddc3a1670d7675198f52fc7920 From ee58840b221c8da0bc55361c5e2e5d71ce8c09f3 Mon Sep 17 00:00:00 2001 From: Pedro Henrique Resende Menezes Date: Fri, 9 Feb 2024 15:53:10 -0300 Subject: [PATCH 08/11] testeeee --- Calculadora Forms/Calculadora.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Calculadora Forms/Calculadora.cs b/Calculadora Forms/Calculadora.cs index 7489881..c7564a2 100644 --- a/Calculadora Forms/Calculadora.cs +++ b/Calculadora Forms/Calculadora.cs @@ -81,7 +81,7 @@ private void btIgual_Click(object sender, EventArgs e) break; default: - MessageBox.Show("Insira uma operação para o cálculo");adsad + MessageBox.Show("Insira uma operação para o cálculo");adsadASD break;*/ } From 7641b235a6e871b999fc1f3fb93f2abc5a340efd Mon Sep 17 00:00:00 2001 From: Pedro Henrique Resende Menezes Date: Fri, 9 Feb 2024 16:51:56 -0300 Subject: [PATCH 09/11] Commit2 --- Calculadora Forms/Calculadora.cs | 46 +++++++++++++++++++------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/Calculadora Forms/Calculadora.cs b/Calculadora Forms/Calculadora.cs index c7564a2..4949048 100644 --- a/Calculadora Forms/Calculadora.cs +++ b/Calculadora Forms/Calculadora.cs @@ -46,49 +46,57 @@ private void btMais_Click(object sender, EventArgs e) { tbOperacao.Text = tbDisplay.Text + " +"; valor1 = double.Parse(tbDisplay.Text); + tbDisplay.Text = ""; } else { btIgual_Click(sender, e); } - - tbDisplay.Text = ""; } private void btIgual_Click(object sender, EventArgs e) { Calculos obj = new Calculos(); - valor2 = double.Parse(tbDisplay.Text); + double result = 0; - switch (operacao) + if(tbDisplay.Text == "") { - case 1: - double result = obj.Soma(valor1, valor2); - tbDisplay.Text = result.ToString(); - break; + MessageBox.Show("Insira um valor"); + } + else + { + valor2 = double.Parse(tbDisplay.Text); - /*case 2: - tbDisplay.Text = obj.Sub().ToString(); + switch (operacao) + { + case 1: + result = obj.Soma(valor1, valor2); + break; + + case 2: + result = obj.Sub(valor1, valor2); break; case 3: - tbDisplay.Text = obj.Multi().ToString(); + result = obj.Multi(valor1, valor2); break; case 4: - tbDisplay.Text = obj.Divi().ToString(); + result = obj.Divi(valor1, valor2); break; default: - MessageBox.Show("Insira uma operação para o cálculo");adsadASD - break;*/ - } + MessageBox.Show("Insira uma operação para o cálculo"); + break; + } - valor1 = 0; - valor2 = 0; - operacao = 0; - tbOperacao.Text = ""; + tbDisplay.Text = result.ToString(); + valor1 = 0; + valor2 = 0; + operacao = 0; + tbOperacao.Text = ""; + } } } From c469c78435dd28fa6ce8618785b3533f4aa6beca Mon Sep 17 00:00:00 2001 From: Pedro Henrique Resende Menezes Date: Sat, 10 Feb 2024 10:40:42 -0300 Subject: [PATCH 10/11] VerCompleta01 --- Calculadora Forms/Calculadora.Designer.cs | 170 +++++++++++++++++---- Calculadora Forms/Calculadora.cs | 173 +++++++++++++++++++++- 2 files changed, 314 insertions(+), 29 deletions(-) diff --git a/Calculadora Forms/Calculadora.Designer.cs b/Calculadora Forms/Calculadora.Designer.cs index b5a4a9f..112fdb4 100644 --- a/Calculadora Forms/Calculadora.Designer.cs +++ b/Calculadora Forms/Calculadora.Designer.cs @@ -42,13 +42,21 @@ private void InitializeComponent() this.tbOperacao = new System.Windows.Forms.TextBox(); this.btMais = new System.Windows.Forms.Button(); this.btIgual = new System.Windows.Forms.Button(); + this.btMenos = new System.Windows.Forms.Button(); + this.btVezes = new System.Windows.Forms.Button(); + this.btPonto = new System.Windows.Forms.Button(); + this.btSinal = new System.Windows.Forms.Button(); + this.btDividir = new System.Windows.Forms.Button(); + this.btApagar = new System.Windows.Forms.Button(); + this.btLimpar = new System.Windows.Forms.Button(); + this.btReset = new System.Windows.Forms.Button(); this.SuspendLayout(); // // bd1 // - this.bd1.Location = new System.Drawing.Point(80, 330); + this.bd1.Location = new System.Drawing.Point(12, 286); this.bd1.Name = "bd1"; - this.bd1.Size = new System.Drawing.Size(75, 23); + this.bd1.Size = new System.Drawing.Size(75, 48); this.bd1.TabIndex = 0; this.bd1.Text = "1"; this.bd1.UseVisualStyleBackColor = true; @@ -56,91 +64,100 @@ private void InitializeComponent() // // bd2 // - this.bd2.Location = new System.Drawing.Point(187, 330); + this.bd2.Location = new System.Drawing.Point(93, 288); this.bd2.Name = "bd2"; - this.bd2.Size = new System.Drawing.Size(75, 23); + this.bd2.Size = new System.Drawing.Size(75, 48); this.bd2.TabIndex = 1; this.bd2.Text = "2"; this.bd2.UseVisualStyleBackColor = true; + this.bd2.Click += new System.EventHandler(this.bd2_Click); // // bd3 // - this.bd3.Location = new System.Drawing.Point(302, 330); + this.bd3.Location = new System.Drawing.Point(174, 286); this.bd3.Name = "bd3"; - this.bd3.Size = new System.Drawing.Size(75, 23); + this.bd3.Size = new System.Drawing.Size(75, 48); this.bd3.TabIndex = 2; this.bd3.Text = "3"; this.bd3.UseVisualStyleBackColor = true; + this.bd3.Click += new System.EventHandler(this.bd3_Click); // // bd4 // - this.bd4.Location = new System.Drawing.Point(80, 279); + this.bd4.Location = new System.Drawing.Point(12, 235); this.bd4.Name = "bd4"; - this.bd4.Size = new System.Drawing.Size(75, 23); + this.bd4.Size = new System.Drawing.Size(75, 45); this.bd4.TabIndex = 3; this.bd4.Text = "4"; this.bd4.UseVisualStyleBackColor = true; + this.bd4.Click += new System.EventHandler(this.bd4_Click); // // bd5 // - this.bd5.Location = new System.Drawing.Point(187, 279); + this.bd5.Location = new System.Drawing.Point(93, 237); this.bd5.Name = "bd5"; - this.bd5.Size = new System.Drawing.Size(75, 23); + this.bd5.Size = new System.Drawing.Size(75, 46); this.bd5.TabIndex = 4; this.bd5.Text = "5"; this.bd5.UseVisualStyleBackColor = true; + this.bd5.Click += new System.EventHandler(this.bd5_Click); // // bd6 // - this.bd6.Location = new System.Drawing.Point(302, 279); + this.bd6.Location = new System.Drawing.Point(174, 235); this.bd6.Name = "bd6"; - this.bd6.Size = new System.Drawing.Size(75, 23); + this.bd6.Size = new System.Drawing.Size(75, 45); this.bd6.TabIndex = 5; this.bd6.Text = "6"; this.bd6.UseVisualStyleBackColor = true; + this.bd6.Click += new System.EventHandler(this.bd6_Click); // // bd7 // - this.bd7.Location = new System.Drawing.Point(80, 231); + this.bd7.Location = new System.Drawing.Point(12, 187); this.bd7.Name = "bd7"; - this.bd7.Size = new System.Drawing.Size(75, 23); + this.bd7.Size = new System.Drawing.Size(75, 42); this.bd7.TabIndex = 6; this.bd7.Text = "7"; this.bd7.UseVisualStyleBackColor = true; + this.bd7.Click += new System.EventHandler(this.bd7_Click); // // bd8 // - this.bd8.Location = new System.Drawing.Point(187, 231); + this.bd8.Location = new System.Drawing.Point(93, 185); this.bd8.Name = "bd8"; - this.bd8.Size = new System.Drawing.Size(75, 23); + this.bd8.Size = new System.Drawing.Size(75, 46); this.bd8.TabIndex = 7; this.bd8.Text = "8"; this.bd8.UseVisualStyleBackColor = true; + this.bd8.Click += new System.EventHandler(this.bd8_Click); // // bd9 // - this.bd9.Location = new System.Drawing.Point(302, 231); + this.bd9.Location = new System.Drawing.Point(174, 187); this.bd9.Name = "bd9"; - this.bd9.Size = new System.Drawing.Size(75, 23); + this.bd9.Size = new System.Drawing.Size(75, 42); this.bd9.TabIndex = 8; this.bd9.Text = "9"; this.bd9.UseVisualStyleBackColor = true; + this.bd9.Click += new System.EventHandler(this.bd9_Click); // // bd0 // - this.bd0.Location = new System.Drawing.Point(187, 384); + this.bd0.Location = new System.Drawing.Point(93, 342); this.bd0.Name = "bd0"; - this.bd0.Size = new System.Drawing.Size(75, 23); + this.bd0.Size = new System.Drawing.Size(75, 48); this.bd0.TabIndex = 9; this.bd0.Text = "0"; this.bd0.UseVisualStyleBackColor = true; + this.bd0.Click += new System.EventHandler(this.bd0_Click); // // tbDisplay // this.tbDisplay.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.tbDisplay.Location = new System.Drawing.Point(111, 142); + this.tbDisplay.Location = new System.Drawing.Point(12, 59); this.tbDisplay.Name = "tbDisplay"; - this.tbDisplay.Size = new System.Drawing.Size(297, 20); + this.tbDisplay.Size = new System.Drawing.Size(321, 20); this.tbDisplay.TabIndex = 10; this.tbDisplay.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.tbDisplay.TextChanged += new System.EventHandler(this.textBox1_TextChanged); @@ -148,16 +165,16 @@ private void InitializeComponent() // tbOperacao // this.tbOperacao.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.tbOperacao.Location = new System.Drawing.Point(111, 112); + this.tbOperacao.Location = new System.Drawing.Point(23, 62); this.tbOperacao.Name = "tbOperacao"; this.tbOperacao.Size = new System.Drawing.Size(88, 13); this.tbOperacao.TabIndex = 11; // // btMais // - this.btMais.Location = new System.Drawing.Point(413, 330); + this.btMais.Location = new System.Drawing.Point(258, 286); this.btMais.Name = "btMais"; - this.btMais.Size = new System.Drawing.Size(75, 23); + this.btMais.Size = new System.Drawing.Size(75, 48); this.btMais.TabIndex = 12; this.btMais.Text = "+"; this.btMais.UseVisualStyleBackColor = true; @@ -165,19 +182,108 @@ private void InitializeComponent() // // btIgual // - this.btIgual.Location = new System.Drawing.Point(413, 384); + this.btIgual.Location = new System.Drawing.Point(258, 340); this.btIgual.Name = "btIgual"; - this.btIgual.Size = new System.Drawing.Size(75, 23); + this.btIgual.Size = new System.Drawing.Size(75, 48); this.btIgual.TabIndex = 13; this.btIgual.Text = "="; this.btIgual.UseVisualStyleBackColor = true; this.btIgual.Click += new System.EventHandler(this.btIgual_Click); // + // btMenos + // + this.btMenos.Location = new System.Drawing.Point(258, 235); + this.btMenos.Name = "btMenos"; + this.btMenos.Size = new System.Drawing.Size(75, 46); + this.btMenos.TabIndex = 14; + this.btMenos.Text = "-"; + this.btMenos.UseVisualStyleBackColor = true; + this.btMenos.Click += new System.EventHandler(this.btMenos_Click); + // + // btVezes + // + this.btVezes.Location = new System.Drawing.Point(258, 187); + this.btVezes.Name = "btVezes"; + this.btVezes.Size = new System.Drawing.Size(75, 42); + this.btVezes.TabIndex = 15; + this.btVezes.Text = "x"; + this.btVezes.UseVisualStyleBackColor = true; + this.btVezes.Click += new System.EventHandler(this.btVezes_Click); + // + // btPonto + // + this.btPonto.Location = new System.Drawing.Point(174, 340); + this.btPonto.Name = "btPonto"; + this.btPonto.Size = new System.Drawing.Size(75, 48); + this.btPonto.TabIndex = 16; + this.btPonto.Text = ","; + this.btPonto.UseVisualStyleBackColor = true; + this.btPonto.Click += new System.EventHandler(this.btPonto_Click); + // + // btSinal + // + this.btSinal.Location = new System.Drawing.Point(12, 340); + this.btSinal.Name = "btSinal"; + this.btSinal.Size = new System.Drawing.Size(75, 48); + this.btSinal.TabIndex = 17; + this.btSinal.Text = "+/-"; + this.btSinal.UseVisualStyleBackColor = true; + this.btSinal.Click += new System.EventHandler(this.btSinal_Click); + // + // btDividir + // + this.btDividir.Location = new System.Drawing.Point(258, 139); + this.btDividir.Name = "btDividir"; + this.btDividir.Size = new System.Drawing.Size(75, 42); + this.btDividir.TabIndex = 18; + this.btDividir.Text = "/"; + this.btDividir.UseVisualStyleBackColor = true; + this.btDividir.Click += new System.EventHandler(this.btDividir_Click); + // + // btApagar + // + this.btApagar.Location = new System.Drawing.Point(174, 139); + this.btApagar.Name = "btApagar"; + this.btApagar.Size = new System.Drawing.Size(75, 42); + this.btApagar.TabIndex = 19; + this.btApagar.Text = "Apagar"; + this.btApagar.UseVisualStyleBackColor = true; + this.btApagar.Click += new System.EventHandler(this.btApagar_Click); + // + // btLimpar + // + this.btLimpar.Location = new System.Drawing.Point(93, 139); + this.btLimpar.Name = "btLimpar"; + this.btLimpar.Size = new System.Drawing.Size(75, 42); + this.btLimpar.TabIndex = 20; + this.btLimpar.Text = "Limpar"; + this.btLimpar.UseVisualStyleBackColor = true; + this.btLimpar.Click += new System.EventHandler(this.btLimpar_Click); + // + // btReset + // + this.btReset.Location = new System.Drawing.Point(12, 139); + this.btReset.Name = "btReset"; + this.btReset.Size = new System.Drawing.Size(75, 42); + this.btReset.TabIndex = 21; + this.btReset.Text = "Resetar"; + this.btReset.UseVisualStyleBackColor = true; + this.btReset.Click += new System.EventHandler(this.btReset_Click); + // // Calculadora // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(544, 450); + this.BackColor = System.Drawing.SystemColors.ActiveCaption; + this.ClientSize = new System.Drawing.Size(345, 412); + this.Controls.Add(this.btReset); + this.Controls.Add(this.btLimpar); + this.Controls.Add(this.btApagar); + this.Controls.Add(this.btDividir); + this.Controls.Add(this.btSinal); + this.Controls.Add(this.btPonto); + this.Controls.Add(this.btVezes); + this.Controls.Add(this.btMenos); this.Controls.Add(this.btIgual); this.Controls.Add(this.btMais); this.Controls.Add(this.tbOperacao); @@ -215,6 +321,14 @@ private void InitializeComponent() private System.Windows.Forms.TextBox tbOperacao; private System.Windows.Forms.Button btMais; private System.Windows.Forms.Button btIgual; + private System.Windows.Forms.Button btMenos; + private System.Windows.Forms.Button btVezes; + private System.Windows.Forms.Button btPonto; + private System.Windows.Forms.Button btSinal; + private System.Windows.Forms.Button btDividir; + private System.Windows.Forms.Button btApagar; + private System.Windows.Forms.Button btLimpar; + private System.Windows.Forms.Button btReset; } } diff --git a/Calculadora Forms/Calculadora.cs b/Calculadora Forms/Calculadora.cs index 4949048..58ada46 100644 --- a/Calculadora Forms/Calculadora.cs +++ b/Calculadora Forms/Calculadora.cs @@ -12,7 +12,7 @@ namespace Calculadora_Forms { public partial class Calculadora : Form { - bool ordem = true; + bool cond; public double valor1; @@ -31,11 +31,59 @@ private void textBox1_TextChanged(object sender, EventArgs e) } + //Números + private void bd0_Click(object sender, EventArgs e) + { + tbDisplay.Text += "0"; + } + private void bd1_Click(object sender, EventArgs e) { tbDisplay.Text += "1"; } + private void bd2_Click(object sender, EventArgs e) + { + tbDisplay.Text += "2"; + } + + private void bd3_Click(object sender, EventArgs e) + { + tbDisplay.Text += "3"; + } + + private void bd4_Click(object sender, EventArgs e) + { + tbDisplay.Text += "4"; + } + + private void bd5_Click(object sender, EventArgs e) + { + tbDisplay.Text += "5"; + } + + private void bd6_Click(object sender, EventArgs e) + { + tbDisplay.Text += "6"; + } + + private void bd7_Click(object sender, EventArgs e) + { + tbDisplay.Text += "7"; + } + + private void bd8_Click(object sender, EventArgs e) + { + tbDisplay.Text += "8"; + } + + private void bd9_Click(object sender, EventArgs e) + { + tbDisplay.Text += "9"; + } + + //Funções das operações + private void btMais_Click(object sender, EventArgs e) { Calculos obj = new Calculos(); @@ -54,6 +102,128 @@ private void btMais_Click(object sender, EventArgs e) } } + private void btMenos_Click(object sender, EventArgs e) + { + Calculos obj = new Calculos(); + + operacao = 2; + + if (valor1 == 0) + { + tbOperacao.Text = tbDisplay.Text + " -"; + valor1 = double.Parse(tbDisplay.Text); + tbDisplay.Text = ""; + } + else + { + btIgual_Click(sender, e); + } + } + + private void btVezes_Click(object sender, EventArgs e) + { + Calculos obj = new Calculos(); + + operacao = 3; + + if (valor1 == 0) + { + tbOperacao.Text = tbDisplay.Text + " x"; + valor1 = double.Parse(tbDisplay.Text); + tbDisplay.Text = ""; + } + else + { + btIgual_Click(sender, e); + } + } + + private void btDividir_Click(object sender, EventArgs e) + { + Calculos obj = new Calculos(); + + operacao = 4; + + if (valor1 == 0) + { + tbOperacao.Text = tbDisplay.Text + " /"; + valor1 = double.Parse(tbDisplay.Text); + tbDisplay.Text = ""; + } + else + { + btIgual_Click(sender, e); + } + } + + //Funções auxiliares + + private void btReset_Click(object sender, EventArgs e) + { + tbDisplay.Text = ""; + tbOperacao.Text = ""; + valor1 = 0; + valor2 = 0; + } + + private void btLimpar_Click(object sender, EventArgs e) + { + tbDisplay.Text = ""; + } + + private void btApagar_Click(object sender, EventArgs e) + { + string displayCompl = ""; + + for (int i = 0; i < tbDisplay.Text.Length - 1; i++) + { + displayCompl += tbDisplay.Text[i]; + } + + tbDisplay.Text = displayCompl; + } + + private void btSinal_Click(object sender, EventArgs e) + { + if (tbDisplay.Text[0] == '-') + { + string displayCompl = ""; + + for (int i = 1; i < tbDisplay.Text.Length; i++) + { + displayCompl += tbDisplay.Text[i]; + } + + tbDisplay.Text = displayCompl; + } + else + { + string modificado = tbDisplay.Text.Insert(0, "-"); + tbDisplay.Text = modificado; + } + } + + private void btPonto_Click(object sender, EventArgs e) + { + cond = false; + + for (int i = 0; i < tbDisplay.Text.Length; i++) + { + if (tbDisplay.Text[i] == ',') + { + cond = true; + MessageBox.Show("Insira apenas uma vírgula"); + } + } + + if (cond == false) + { + tbDisplay.Text += ","; + } + } + + //Função igual + private void btIgual_Click(object sender, EventArgs e) { Calculos obj = new Calculos(); @@ -98,6 +268,7 @@ private void btIgual_Click(object sender, EventArgs e) tbOperacao.Text = ""; } } + } class Calculos From 3ac6d1d67a5e1554a667b08583e1f7eaf8592edb Mon Sep 17 00:00:00 2001 From: Pedro Henrique Resende Menezes Date: Sat, 10 Feb 2024 10:46:32 -0300 Subject: [PATCH 11/11] Cores01 --- Calculadora Forms/Calculadora.Designer.cs | 24 +++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Calculadora Forms/Calculadora.Designer.cs b/Calculadora Forms/Calculadora.Designer.cs index 112fdb4..43b8f9f 100644 --- a/Calculadora Forms/Calculadora.Designer.cs +++ b/Calculadora Forms/Calculadora.Designer.cs @@ -172,42 +172,46 @@ private void InitializeComponent() // // btMais // + this.btMais.BackColor = System.Drawing.SystemColors.ActiveBorder; this.btMais.Location = new System.Drawing.Point(258, 286); this.btMais.Name = "btMais"; this.btMais.Size = new System.Drawing.Size(75, 48); this.btMais.TabIndex = 12; this.btMais.Text = "+"; - this.btMais.UseVisualStyleBackColor = true; + this.btMais.UseVisualStyleBackColor = false; this.btMais.Click += new System.EventHandler(this.btMais_Click); // // btIgual // + this.btIgual.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128))))); this.btIgual.Location = new System.Drawing.Point(258, 340); this.btIgual.Name = "btIgual"; this.btIgual.Size = new System.Drawing.Size(75, 48); this.btIgual.TabIndex = 13; this.btIgual.Text = "="; - this.btIgual.UseVisualStyleBackColor = true; + this.btIgual.UseVisualStyleBackColor = false; this.btIgual.Click += new System.EventHandler(this.btIgual_Click); // // btMenos // + this.btMenos.BackColor = System.Drawing.SystemColors.ActiveBorder; this.btMenos.Location = new System.Drawing.Point(258, 235); this.btMenos.Name = "btMenos"; this.btMenos.Size = new System.Drawing.Size(75, 46); this.btMenos.TabIndex = 14; this.btMenos.Text = "-"; - this.btMenos.UseVisualStyleBackColor = true; + this.btMenos.UseVisualStyleBackColor = false; this.btMenos.Click += new System.EventHandler(this.btMenos_Click); // // btVezes // + this.btVezes.BackColor = System.Drawing.SystemColors.ActiveBorder; this.btVezes.Location = new System.Drawing.Point(258, 187); this.btVezes.Name = "btVezes"; this.btVezes.Size = new System.Drawing.Size(75, 42); this.btVezes.TabIndex = 15; this.btVezes.Text = "x"; - this.btVezes.UseVisualStyleBackColor = true; + this.btVezes.UseVisualStyleBackColor = false; this.btVezes.Click += new System.EventHandler(this.btVezes_Click); // // btPonto @@ -232,42 +236,46 @@ private void InitializeComponent() // // btDividir // + this.btDividir.BackColor = System.Drawing.SystemColors.ActiveBorder; this.btDividir.Location = new System.Drawing.Point(258, 139); this.btDividir.Name = "btDividir"; this.btDividir.Size = new System.Drawing.Size(75, 42); this.btDividir.TabIndex = 18; this.btDividir.Text = "/"; - this.btDividir.UseVisualStyleBackColor = true; + this.btDividir.UseVisualStyleBackColor = false; this.btDividir.Click += new System.EventHandler(this.btDividir_Click); // // btApagar // + this.btApagar.BackColor = System.Drawing.SystemColors.ButtonHighlight; this.btApagar.Location = new System.Drawing.Point(174, 139); this.btApagar.Name = "btApagar"; this.btApagar.Size = new System.Drawing.Size(75, 42); this.btApagar.TabIndex = 19; this.btApagar.Text = "Apagar"; - this.btApagar.UseVisualStyleBackColor = true; + this.btApagar.UseVisualStyleBackColor = false; this.btApagar.Click += new System.EventHandler(this.btApagar_Click); // // btLimpar // + this.btLimpar.BackColor = System.Drawing.SystemColors.ButtonHighlight; this.btLimpar.Location = new System.Drawing.Point(93, 139); this.btLimpar.Name = "btLimpar"; this.btLimpar.Size = new System.Drawing.Size(75, 42); this.btLimpar.TabIndex = 20; this.btLimpar.Text = "Limpar"; - this.btLimpar.UseVisualStyleBackColor = true; + this.btLimpar.UseVisualStyleBackColor = false; this.btLimpar.Click += new System.EventHandler(this.btLimpar_Click); // // btReset // + this.btReset.BackColor = System.Drawing.SystemColors.ButtonHighlight; this.btReset.Location = new System.Drawing.Point(12, 139); this.btReset.Name = "btReset"; this.btReset.Size = new System.Drawing.Size(75, 42); this.btReset.TabIndex = 21; this.btReset.Text = "Resetar"; - this.btReset.UseVisualStyleBackColor = true; + this.btReset.UseVisualStyleBackColor = false; this.btReset.Click += new System.EventHandler(this.btReset_Click); // // Calculadora