private void button1_Click(object sender, EventArgs e) { if (compass.IsLaserOpen()) { if (compass.CloseLaser()) { MessageBox.Show("关闭激光成功"); button1.Text = "打开激光"; } else { MessageBox.Show("关闭激光失败"); } } else { if (compass.OpenLaser()) { MessageBox.Show("打开激光成功"); button1.Text = "关闭激光"; } else { MessageBox.Show("打开激光失败"); } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); DllRegisterServer(); compass = new Compass(); if (compass.IsLaserOpen()) { button1.Text = "关闭激光"; } else { button1.Text = "打开激光"; } bubble = tabPage1.CreateGraphics(); comp = tabPage2.CreateGraphics(); panel1.Hide(); timer1.Interval = 500; timer1.Enabled = true; }