Ejemplo n.º 1
0
        public Form1()
        {
            InitializeComponent();

            string mypath = Path.Combine(GlobalConfig.udiskdir2, "screen");

            btn_capture.Visible = false;
            lbl_davalue.Visible = false;

            //Cursor.Hide();
            processor = new Processor();

            digi_upbtns = new RectButton[] { rbtn_1up, rbtn_2up, rbtn_3up, rbtn_4up, rbtn_5up, rbtn_6up  };
            digi_dnbtns = new RectButton[] { rbtn_1dn, rbtn_2dn, rbtn_3dn, rbtn_4dn, rbtn_5dn, rbtn_6dn  };
            dlg_choice = new ChoiceWnd();
            dlg_kbd = new kbdWnd();
            range_btns = new RectButton[] { btn_range0, btn_range1, btn_range2, btn_range3, btn_range4, btn_range5, btn_range6 };
            string[] range_string = new String[] { "200µΩ/600A", "2mΩ/200A", "20mΩ/100A", "200mΩ/80A", "2Ω/10A", "4Ω/5A", "20Ω/1A" };
            led_ohm.ColorLight = Color.Red;
            led_ohm.ColorBackground = this.BackColor;
            led_ohm.ElementWidth = 12;
            led_ohm.RecreateSegments(led_ohm.ArrayCount);
            led_current.ColorLight = Color.DarkGreen;
            led_current.ColorBackground = this.BackColor;
            led_current.ElementWidth = 8;
            led_current.RecreateSegments(led_current.ArrayCount);
            led_current.Value = "0.0000";

            btn_zeroon.bgColor = this.BackColor;
            btn_zeroon.SetStyle(Color.Bisque, MyButtonType.roundRectButton);
            btn_zeroon.Text = "清零";
            btn_zeroon.ValidClick += new EventHandler((o, e) =>
            {
                led_current.Value = "     ";
                processor.ZeroON();
            });

            btn_turnon.bgColor = this.BackColor;
            for (int i = 0; i < digi_upbtns.Length; i++)
            {
                RectButton rb = digi_upbtns[i];
                rb.bgColor = this.BackColor;
                rb.SetStyle(Color.DarkOrange, MyButtonType.triangleupButton);

                rb.ValidClick += new EventHandler((o, e) =>
                {
                    if (processor.iRange >= 0)
                    {
                        TickDigit(digi_upbtns.Length - NameInArray(o, digi_upbtns), true);
                        RefreshDisplay(false);
                    }
                });
            }
            for (int i = 0; i < digi_dnbtns.Length; i++)
            {
                RectButton rb = digi_dnbtns[i];
                rb.bgColor = this.BackColor;
                rb.SetStyle(Color.DarkOrange, MyButtonType.trianglednButton);
                rb.ValidClick += new EventHandler((o,e)=>
                {
                    if (processor.iRange >= 0)
                    {
                        TickDigit(digi_upbtns.Length - NameInArray(o, digi_dnbtns) , false);
                        RefreshDisplay(false);
                    }
                });
            }
            btn_turnon.SetStyle(Color.Green, MyButtonType.round2Button);
            btn_turnon.Text = "OFF";
            btn_turnon.ValidClick += new EventHandler((o, e) =>
            {
                if (!processor.bOn)
                    dt_lastoutput = DateTime.Now.AddSeconds(2);
                processor.bOn = !processor.bOn;
                RefreshDisplay(false);
            });

            for (int i = 0; i < range_btns.Length; i++)
            {
                RectButton rb = range_btns[i];
                rb.bgColor = this.BackColor;
                rb.Text = range_string[i];
                rb.SetStyle(Color.Green, MyButtonType.roundRectButton);

                rb.ValidClick += new EventHandler((o, e) =>
                {
                    int newrange = NameInArray(o, range_btns);
                    if( newrange == processor.iRange)
                        return;

                    try
                    {
                        if (Math.Abs(double.Parse(led_current.Value)) < 0.1)
                        {
                            processor.iRange = newrange;
                            RefreshDisplay(true);
                        }
                        else
                        {
                            Program.MsgShow("请关闭输入电流后,再进行量程切换。");
                        }
                    }
                    catch
                    {
                    }
                });
            }
            tm = new Timer();
            tm.Interval = 500;
            tm.Tick += new EventHandler((o, e) =>
            {
                lbl_datetime.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                if (DateTime.Now.Subtract(dt_lastoutput).TotalSeconds < 1)
                {
                    dt_lastoutput = DateTime.Now;
                    return;
                }
                lbl_davalue.Text = DeviceMgr.LastAction + "\r\n" + processor.DAValue;
                processor.RefreshOutput();
                if (processor.Current > -999)
                {
                    UpdateCurrentDisplay(processor.Current);
                    processor.Current = -9999;
                }
            });
            tm.Enabled = true;
            led_ohm.Click += new EventHandler(led_ohm_Click);
            DeviceMgr.Reset();

            RefreshDisplay(true);
        }
Ejemplo n.º 2
0
        public Form1()
        {
            InitializeComponent();
            //ShowCursor(0);
            processor = new Processor();

            digi_upbtns = new RectButton[] { rbtn_1up, rbtn_2up, rbtn_3up, rbtn_4up, rbtn_5up, rbtn_6up };
            digi_dnbtns = new RectButton[] { rbtn_1dn, rbtn_2dn, rbtn_3dn, rbtn_4dn, rbtn_5dn, rbtn_6dn };
            dlg_choice  = new ChoiceWnd();
            dlg_kbd     = new kbdWnd();
            range_btns  = new RectButton[] { btn_range0, btn_range1, btn_range2, btn_range3, btn_range4, btn_range5, btn_range6 };
            string[] range_string = new String[] { "200µΩ/600A", "2mΩ/200A", "20mΩ/100A", "200mΩ/80A", "2Ω/10A", "4Ω/5A", "20Ω/1A" };
            led_ohm.ColorLight      = Color.Red;
            led_ohm.ColorBackground = this.BackColor;
            led_ohm.ElementWidth    = 12;
            led_ohm.RecreateSegments(led_ohm.ArrayCount);
            led_current.ColorLight      = Color.DarkGreen;
            led_current.ColorBackground = this.BackColor;
            led_current.ElementWidth    = 8;
            led_current.RecreateSegments(led_current.ArrayCount);
            led_current.Value = "0.0000";

            btn_zeroon.bgColor = this.BackColor;
            btn_zeroon.SetStyle(Color.Bisque, MyButtonType.roundRectButton);
            btn_zeroon.Text        = "清零";
            btn_zeroon.ValidClick += new EventHandler((o, e) =>
            {
                led_current.Value = "     ";
                processor.ZeroON();
            });

            btn_turnon.bgColor = this.BackColor;
            for (int i = 0; i < digi_upbtns.Length; i++)
            {
                RectButton rb = digi_upbtns[i];
                rb.bgColor = this.BackColor;
                rb.SetStyle(Color.DarkOrange, MyButtonType.triangleupButton);

                rb.ValidClick += new EventHandler((o, e) =>
                {
                    if (processor.iRange >= 0)
                    {
                        TickDigit(digi_upbtns.Length - NameInArray(o, digi_upbtns), true);
                        RefreshDisplay(false);
                    }
                });
            }
            for (int i = 0; i < digi_dnbtns.Length; i++)
            {
                RectButton rb = digi_dnbtns[i];
                rb.bgColor = this.BackColor;
                rb.SetStyle(Color.DarkOrange, MyButtonType.trianglednButton);
                rb.ValidClick += new EventHandler((o, e) =>
                {
                    if (processor.iRange >= 0)
                    {
                        TickDigit(digi_upbtns.Length - NameInArray(o, digi_dnbtns), false);
                        RefreshDisplay(false);
                    }
                });
            }
            btn_turnon.SetStyle(Color.Green, MyButtonType.round2Button);
            btn_turnon.Text        = "OFF";
            btn_turnon.ValidClick += new EventHandler((o, e) =>
            {
                if (!processor.bOn)
                {
                    dt_lastoutput = DateTime.Now.AddSeconds(2);
                }
                processor.bOn = !processor.bOn;
                RefreshDisplay(false);
            });

            for (int i = 0; i < range_btns.Length; i++)
            {
                RectButton rb = range_btns[i];
                rb.bgColor = this.BackColor;
                rb.Text    = range_string[i];
                rb.SetStyle(Color.Green, MyButtonType.roundRectButton);

                rb.ValidClick += new EventHandler((o, e) =>
                {
                    int newrange = NameInArray(o, range_btns);
                    if (newrange == processor.iRange)
                    {
                        return;
                    }

                    try
                    {
                        if (Math.Abs(double.Parse(led_current.Value)) < 0.1)
                        {
                            processor.iRange = newrange;
                            RefreshDisplay(true);
                        }
                        else
                        {
                            Program.MsgShow("请关闭输入电流后,再进行量程切换。");
                        }
                    }
                    catch
                    {
                    }
                });
            }
            tm          = new Timer();
            tm.Interval = 500;
            tm.Tick    += new EventHandler((o, e) =>
            {
                lbl_datetime.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                if (DateTime.Now.Subtract(dt_lastoutput).TotalSeconds < 1)
                {
                    dt_lastoutput = DateTime.Now;
                    return;
                }
                processor.RefreshOutput();
                if (processor.Current > -999)
                {
                    UpdateCurrentDisplay(processor.Current);
                    processor.Current = -9999;
                }
            });
            tm.Enabled = true;
            tm.Start();
            led_ohm.Click += new EventHandler(led_ohm_Click);
            DeviceMgr.Reset();

            RefreshDisplay(true);
        }