private void button2_Click_1(object sender, EventArgs e) { AmpCalculator circuitCalc; double V = double.Parse(textBox6.Text); double R1 = double.Parse(textBox10.Text); double R2 = double.Parse(textBox9.Text); double R3 = double.Parse(textBox8.Text); double R4 = double.Parse(textBox7.Text); Circuit circuit = new Circuit(V, R1, R2, R3, R4); if (this.图一.Checked == true) { circuitCalc = new Cacu1(circuit); MessageBox.Show("V= " + textBox6.Text + " R1= " + textBox10.Text + " Ω " + " R2= " + textBox9.Text + " Ω " + " R3= " + textBox8.Text + " Ω " + " R4= " + textBox7.Text + " Ω "); MessageBox.Show(" I = " + circuitCalc.CalculateAmp().ToString() + " A "); } else if (this.radioButton3.Checked == true) { circuitCalc = new Cacu2(circuit); MessageBox.Show("V= " + textBox6.Text + " R1= " + textBox10.Text + " Ω " + " R2= " + textBox9.Text + " Ω " + " R3= " + textBox8.Text + " Ω " + " R4= " + textBox7.Text + " Ω "); MessageBox.Show(" I = " + circuitCalc.CalculateAmp().ToString() + " A "); } else if (this.radioButton3.Checked == false && this.图一.Checked == false) { errorProvider1.SetError(radioButton3, "请选择电路类型!"); } }
private void button2_Click_1(object sender, EventArgs e) { double V = double.Parse(textBox6.Text); double R1 = double.Parse(textBox10.Text); double R2 = double.Parse(textBox9.Text); double R3 = double.Parse(textBox8.Text); double R4 = double.Parse(textBox7.Text); Circuit circuit = new Circuit(V, R1, R2, R3, R4); if (this.图一.Checked == true) {//判断是否为空 double ca1; ca1 = Cacu1.Ca1(circuit); string output1 = ca1.ToString(); MessageBox.Show("V= " + textBox6.Text + " R1= " + textBox10.Text + " Ω " + " R2= " + textBox9.Text + " Ω " + " R3= " + textBox8.Text + " Ω " + " R4= " + textBox7.Text + " Ω " + "I = " + output1 + " A"); } else if (this.radioButton3.Checked == true) { double ca2; ca2 = Cacu2.Ca2(circuit); string output2 = ca2.ToString(); MessageBox.Show("V= " + textBox6.Text + " R1= " + textBox10.Text + " Ω " + " R2= " + textBox9.Text + " Ω " + " R3= " + textBox8.Text + " Ω " + " R4= " + textBox7.Text + " Ω " + "I = " + output2 + " A"); } else if (this.radioButton3.Checked == false && this.图一.Checked == false) { errorProvider1.SetError(radioButton3, "请选择电路类型!"); } }
private void button2_Click_1(object sender, EventArgs e) { double V = double.Parse(textBox10.Text); double R1 = double.Parse(textBox9.Text); double R2 = double.Parse(textBox8.Text); double R3 = double.Parse(textBox7.Text); double R4 = double.Parse(textBox6.Text); Circuit circuit = new Circuit(V, R1, R2, R3, R4); double ca1; ca1 = Cacu1.Ca1(circuit); string output1 = ca1.ToString(); MessageBox.Show("V= " + textBox10.Text + " R1= " + textBox9.Text + " Ω " + " R2= " + textBox8.Text + " Ω " + " R3= " + textBox7.Text + " Ω " + " R4= " + textBox6.Text + " Ω " + "I = " + output1 + " A"); }