public bool Connect() { bool flag = false; CameraSelectionDialog camSlnDlg = new CameraSelectionDialog(); camSlnDlg.Show(); camSlnDlg.Hide(); //if (camSlnDlg.ShowModal()) { try { ManagedPGRGuid[] selectedGuids = camSlnDlg.GetSelectedCameraGuids(); ManagedPGRGuid guidToUse = selectedGuids[0]; ManagedBusManager busMgr = new ManagedBusManager(); m_camera = new ManagedCamera(); // Connect to the first selected GUID m_camera.Connect(guidToUse); m_camCtlDlg.Connect(m_camera); CameraInfo camInfo = m_camera.GetCameraInfo(); camInfo.vendorName = "MicroTest"; camInfo.modelName = "v1"; // UpdateFormCaption(camInfo); // Set embedded timestamp to on EmbeddedImageInfo embeddedInfo = m_camera.GetEmbeddedImageInfo(); embeddedInfo.timestamp.onOff = true; //embeddedInfo.exposure.onOff = true; embeddedInfo.shutter.onOff = true; //tbox_uptime.Text = embeddedInfo.timestamp.ToString(); m_camera.SetEmbeddedImageInfo(embeddedInfo); flag = true; } catch (IndexOutOfRangeException e) { m_camCtlDlg.Disconnect(); if (m_camera != null) { m_camera.Disconnect(); } flag = false; throw e; } } return(flag); }
private void Form1_Load(object sender, EventArgs e) { //MessageBox.Show("VS2013"); textBox1.Text = Properties.Settings.Default.mirrorAngleStep; textBox2.Text = Properties.Settings.Default.mirrorAngle; textBoxDCMotorTime.Text = Properties.Settings.Default.motorTime; textBoxDCMotor2Time.Text = Properties.Settings.Default.motor2Time; Directory.CreateDirectory(savepath); Directory.CreateDirectory(savepath + "\\SavedMaxima\\"); PulseStopWatch.Start(); comboBox1.Items.Clear(); foreach (string item in System.IO.Ports.SerialPort.GetPortNames()) { comboBox1.Items.Add(item); } //comboBox1.SelectedItem = Properties.Settings.Default.myserialport; try { comboBox1.SelectedItem = comboBox1.Items[0]; } catch { } My_count = 0; Hide(); //CameraSelectionDialog camSlnDlg = new CameraSelectionDialog(); //bool retVal = camSlnDlg.ShowModal(); //if (retVal) if (true) { try { //ManagedPGRGuid[] selectedGuids = camSlnDlg.GetSelectedCameraGuids(); //ManagedPGRGuid guidToUse = selectedGuids[0]; ManagedBusManager busMgr = new ManagedBusManager(); /*InterfaceType ifType = busMgr.GetInterfaceTypeFromGuid(guidToUse); * if (ifType == InterfaceType.GigE) * { * m_camera = new ManagedGigECamera(); * } * else * { * m_camera = new ManagedCamera(); * }*/ m_camera = new ManagedCamera(); // Connect to the first selected GUID //m_camera.Connect(guidToUse); uint serial1 = busMgr.GetCameraSerialNumberFromIndex(0); ManagedPGRGuid guid = busMgr.GetCameraFromSerialNumber(serial1); m_camera.Connect(guid); m_camCtlDlg.Connect(m_camera); CameraInfo camInfo = m_camera.GetCameraInfo(); UpdateFormCaption(camInfo); // Set embedded timestamp to on EmbeddedImageInfo embeddedInfo = m_camera.GetEmbeddedImageInfo(); embeddedInfo.timestamp.onOff = true; m_camera.SetEmbeddedImageInfo(embeddedInfo); m_camera.StartCapture(); m_grabImages = true; StartGrabLoop(); } catch (FC2Exception ex) { //MessageBox.Show("Camera not detected. Make sure you have connected a camera"); label14.Show(); Debug.WriteLine("Failed to load form successfully: " + ex.Message); // Environment.ExitCode = -1; //Application.Exit(); //return; } toolStripButtonStart.Enabled = false; toolStripButtonStop.Enabled = true; } else { Environment.ExitCode = -1; Application.Exit(); return; } Show(); chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false; chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled = false; // chart1.ChartAreas[0].AxisY. //chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.LineColor = Color.Gray; //chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.LineColor = Color.Gray; chart1.Series[0].BorderWidth = 3; /* * if (checkBoxGraph.Checked) { timerGraph.Start(); } * else { timerGraph.Stop(); }*/ }
private void Form1_Load(object sender, EventArgs e) { Hide(); CameraSelectionDialog camSlnDlg = new CameraSelectionDialog(); bool retVal = camSlnDlg.ShowModal(); if (retVal) { try { ManagedPGRGuid[] selectedGuids = camSlnDlg.GetSelectedCameraGuids(); if (selectedGuids.Length == 0) { Debug.WriteLine("No cameras selected!"); Close(); return; } ManagedPGRGuid guidToUse = selectedGuids[0]; ManagedBusManager busMgr = new ManagedBusManager(); InterfaceType ifType = busMgr.GetInterfaceTypeFromGuid(guidToUse); if (ifType == InterfaceType.GigE) { m_camera = new ManagedGigECamera(); } else { m_camera = new ManagedCamera(); } // Connect to the first selected GUID m_camera.Connect(guidToUse); m_camCtlDlg.Connect(m_camera); CameraInfo camInfo = m_camera.GetCameraInfo(); UpdateFormCaption(camInfo); // Set embedded timestamp to on EmbeddedImageInfo embeddedInfo = m_camera.GetEmbeddedImageInfo(); embeddedInfo.timestamp.onOff = true; m_camera.SetEmbeddedImageInfo(embeddedInfo); m_camera.StartCapture(); m_grabImages = true; StartGrabLoop(); } catch (FC2Exception ex) { Debug.WriteLine("Failed to load form successfully: " + ex.Message); Close(); } } else { Close(); } Show(); }