Ejemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            double  V       = double.Parse(textBox11.Text);
            double  R1      = double.Parse(textBox15.Text);
            double  R2      = double.Parse(textBox14.Text);
            double  R3      = double.Parse(textBox13.Text);
            double  R4      = 0;
            Circuit circuit = new Circuit(V, R1, R2, R3, R4);

            if (this.radioButton6.Checked == true)
            {
                double ca1;
                ca1 = Cacu3.Ca3(circuit);
                string output1 = ca1.ToString();
                MessageBox.Show("V= " + textBox11.Text + " R1= " + textBox15.Text + " Ω " + " R2= " + textBox14.Text + " Ω " + " R3= " + textBox13.Text + " Ω  I = " + output1 + " A");
            }
            else if (this.radioButton5.Checked == true)
            {
                double ca2;
                ca2 = Cacu4.Ca4(circuit);
                string output2 = ca2.ToString();
                MessageBox.Show("V= " + textBox11.Text + " R1= " + textBox15.Text + " Ω " + " R2= " + textBox14.Text + " Ω " + " R3= " + textBox13.Text + " Ω  I = " + output2 + " A");
            }
            else if (this.radioButton5.Checked == false && this.radioButton6.Checked == false)
            {
                errorProvider1.SetError(radioButton5, "请选择电路类型!");
            }
        }
Ejemplo n.º 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            AmpCalculator circuitCalc;
            double        V       = double.Parse(textBox11.Text);
            double        R1      = double.Parse(textBox15.Text);
            double        R2      = double.Parse(textBox14.Text);
            double        R3      = double.Parse(textBox13.Text);
            double        R4      = 0;
            Circuit       circuit = new Circuit(V, R1, R2, R3, R4);

            if (this.radioButton6.Checked == true)
            {
                circuitCalc = new Cacu3(circuit);
                MessageBox.Show("V= " + textBox11.Text + " R1= " + textBox15.Text + " Ω " + " R2= " + textBox14.Text + " Ω " + " R3= " + textBox13.Text + " Ω ");
                MessageBox.Show(" I = " + circuitCalc.CalculateAmp().ToString() + " A ");
            }
            else if (this.radioButton5.Checked == true)
            {
                circuitCalc = new Cacu4(circuit);
                MessageBox.Show("V= " + textBox11.Text + " R1= " + textBox15.Text + " Ω " + " R2= " + textBox14.Text + " Ω " + " R3= " + textBox13.Text + " Ω  ");
                MessageBox.Show(" I = " + circuitCalc.CalculateAmp().ToString() + " A ");
            }
            else if (this.radioButton5.Checked == false && this.radioButton6.Checked == false)
            {
                errorProvider1.SetError(radioButton5, "请选择电路类型!");
            }
        }