private void buttonConnect_Click(object sender, EventArgs e) { if (cam.IsConnected) { // if we are already connected, just disable the button and cancel the display thread, the actual disconnection takes place in the *_RunWorkerCompleted method. buttonConnect.Enabled = false; backgroundWorkerGetFrames.CancelAsync(); } else { // connect the camera and start the display background worker. buttonConnect.Enabled = false; try { cam.Connect(); BluetechnixEth argos = cam as BluetechnixEth; if (null != argos) { argos.SnapshotModeEnabled = true; argos.ActivateChannel(ChannelNames.Color); argos.ActivateChannel(ChannelNames.Amplitude); argos.ActivateChannel(ChannelNames.Distance); } } catch (Exception ex) { MessageBox.Show("Connection error: " + ex.Message); buttonConnect.Enabled = true; return; } buttonConnect.Text = "Disconnect"; backgroundWorkerGetFrames.RunWorkerAsync(); buttonConnect.Enabled = true; } }
/// <summary> /// Standard constructor. /// </summary> public TestGUIForm() { InitializeComponent(); this.FormClosing += TestGUIForm_FormClosing; cam = new BluetechnixEth(); // CLEye-specific set-up code BluetechnixEth argos = cam as BluetechnixEth; if (null != argos) { argos.IPAddress = "192.168.1.147"; } }