Esempio n. 1
0
        private void NewElecCompFromListIndex(int Index)
        {
            switch (Index)
            {
            case 0:
                Resistance r = new Resistance();
                elecCompSet.AddCompAndShow(r, Mycanvas);
                r.Move(100, 100);
                break;

            case 1:
                Capacity c = new Capacity();
                elecCompSet.AddCompAndShow(c, Mycanvas);
                c.Move(100, 100);
                break;

            case 2:
                Wire w = new Wire();
                elecCompSet.AddCompAndShow(w, Mycanvas);
                w.Move(100, 100);
                break;

            case 3:
                Inductance i = new Inductance();
                elecCompSet.AddCompAndShow(i, Mycanvas);
                i.Move(100, 100);
                break;

            case 4:
                OhmMeter o = new OhmMeter();
                elecCompSet.AddCompAndShow(o, Mycanvas);
                o.Move(100, 100);
                break;

            case 5:
                VoltMeter ee = new VoltMeter();
                elecCompSet.AddCompAndShow(ee, Mycanvas);
                ee.Move(100, 100);
                break;

            case 6:
                ElecGround eg = new ElecGround();
                elecCompSet.AddCompAndShow(eg, Mycanvas);
                eg.Move(100, 100);
                break;

            case 7:
                oscilloscopeData myOscilloscopeData = new
                                                      oscilloscopeData(Brushes.Red, oscilloscopeData.Volt_Index,
                                                                       myOscilloscope.m_SyncContext);
                Probe pb = new Probe(Brushes.Red, myOscilloscopeData);
                if (!myOscilloscope.IsVisible)
                {
                    myOscilloscope.Show();
                }
                myOscilloscope.AddData(myOscilloscopeData);
                myOscilloscope.SyncSettings();
                elecCompSet.AddCompAndShow(pb, Mycanvas);
                pb.Move(100, 100);
                break;

            case 8:
                myOscilloscopeData = new
                                     oscilloscopeData(Brushes.Blue, oscilloscopeData.Volt_Index,
                                                      myOscilloscope.m_SyncContext);
                pb = new Probe(Brushes.Blue, myOscilloscopeData);
                if (!myOscilloscope.IsVisible)
                {
                    myOscilloscope.Show();
                }
                myOscilloscope.AddData(myOscilloscopeData);
                myOscilloscope.SyncSettings();
                elecCompSet.AddCompAndShow(pb, Mycanvas);
                pb.Move(100, 100);
                break;

            case 9:
                Power p = new Power();
                elecCompSet.AddCompAndShow(p, Mycanvas);
                p.Move(100, 100);
                break;

            case 10:
                ACPower ap = new ACPower(0, 0.1, 10);
                elecCompSet.AddCompAndShow(ap, Mycanvas);
                ap.Move(100, 100);
                break;
            }
        }
Esempio n. 2
0
        private void ElecCompList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (elecCompList.SelectedItems.Count == 1)
            {
                //MessageBox.Show("Select: " + elecCompList.SelectedIndex);
                switch (elecCompList.SelectedIndex)
                {
                case 0:
                    Resistance r = new Resistance();
                    elecCompSet.AddCompAndShow(r, Mycanvas);
                    r.Move(100, 100);
                    break;

                case 1:
                    Capacity c = new Capacity();
                    elecCompSet.AddCompAndShow(c, Mycanvas);
                    c.Move(100, 100);
                    break;

                case 2:
                    Wire w = new Wire();
                    elecCompSet.AddCompAndShow(w, Mycanvas);
                    w.Move(100, 100);
                    break;

                case 3:
                    Inductance i = new Inductance();
                    elecCompSet.AddCompAndShow(i, Mycanvas);
                    i.Move(100, 100);
                    break;

                case 4:
                    OhmMeter o = new OhmMeter();
                    elecCompSet.AddCompAndShow(o, Mycanvas);
                    o.Move(100, 100);
                    break;

                case 5:
                    VoltMeter ee = new VoltMeter();
                    elecCompSet.AddCompAndShow(ee, Mycanvas);
                    ee.Move(100, 100);
                    break;

                case 6:
                    ElecGround eg = new ElecGround();
                    elecCompSet.AddCompAndShow(eg, Mycanvas);
                    eg.Move(100, 100);
                    break;

                case 7:
                    oscilloscopeData myOscilloscopeData = new
                                                          oscilloscopeData(Brushes.Red, oscilloscopeData.Volt_Index,
                                                                           myOscilloscope.m_SyncContext);
                    Probe pb = new Probe(Brushes.Red, myOscilloscopeData);
                    if (!myOscilloscope.IsVisible)
                    {
                        myOscilloscope.Show();
                    }
                    myOscilloscope.AddData(myOscilloscopeData);
                    myOscilloscope.SyncSettings();
                    elecCompSet.AddCompAndShow(pb, Mycanvas);
                    pb.Move(100, 100);
                    break;

                case 8:
                    myOscilloscopeData = new
                                         oscilloscopeData(Brushes.Blue, oscilloscopeData.Volt_Index,
                                                          myOscilloscope.m_SyncContext);
                    pb = new Probe(Brushes.Blue, myOscilloscopeData);
                    if (!myOscilloscope.IsVisible)
                    {
                        myOscilloscope.Show();
                    }
                    myOscilloscope.AddData(myOscilloscopeData);
                    myOscilloscope.SyncSettings();
                    elecCompSet.AddCompAndShow(pb, Mycanvas);
                    pb.Move(100, 100);
                    break;
                }
            }
        }