private void OnConfigurationButtonClick(object sender, EventArgs e) { ManagedPGRGuid[] guids = GetCurrentSelectedGuids(); foreach (ManagedPGRGuid guid in guids) { try { InterfaceType ifType = m_busMgr.GetInterfaceTypeFromGuid(guid); ManagedCameraBase camera; if (ifType == InterfaceType.GigE) { camera = new ManagedGigECamera(); } else { camera = new ManagedCamera(); } camera.Connect(guid); CameraInfo camInfo = camera.GetCameraInfo(); DialogHolder dialogHolder; if (m_activeDialogs.TryGetValue(camInfo.serialNumber, out dialogHolder)) { camera.Disconnect(); dialogHolder.camCtlMF.ReconnectCamera(guid); dialogHolder.camCtlMF.ShowWindow(); } else { CameraControlMainFrame camControlDialog; camControlDialog = new CameraControlMainFrame(); camControlDialog.Connect(camera); if (m_currentCustomTitle != null) { camControlDialog.SetTitle(m_currentCustomTitle); } camControlDialog.ShowWindow(); dialogHolder = new DialogHolder(camera, camControlDialog); m_activeDialogs.Add(camInfo.serialNumber, dialogHolder); } } catch (FC2Exception ex) { string error = string.Format("Failed to launch camera control dialog for camera: {0}", ex.Message); Debug.WriteLine(error); MessageBox.Show(error, "FlyCapture2", MessageBoxButtons.OK, MessageBoxIcon.Error); ex.Dispose(); return; } } }
static void Main() { ManagedBusManager busMgr = new ManagedBusManager(); // Pop up the camera selection dialog FlyCapture2Managed.Gui.CameraSelectionDialog camSlnDlg = new FlyCapture2Managed.Gui.CameraSelectionDialog(); if (camSlnDlg.ShowModal() == false) { MessageBox.Show("No cameras selected.", "Flycapture2", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } ManagedPGRGuid[] selectedGuids = camSlnDlg.GetSelectedCameraGuids(); // Only start the first selected camera ManagedPGRGuid guid = selectedGuids[0]; InterfaceType ifType; ManagedCameraBase camera; try { ifType = busMgr.GetInterfaceTypeFromGuid(guid);//unable to handle this error } catch (FC2Exception ex) { string error = string.Format("Failed to get interface for camera. {0}", ex.Message); Console.WriteLine(error); MessageBox.Show(error, "Flycapture 2", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (ifType == InterfaceType.GigE) { camera = new ManagedGigECamera(); } else { camera = new ManagedCamera(); } camera.Connect(guid); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); CameraControlMainFrame mainWindow = new CameraControlMainFrame(); mainWindow.Connect(camera); mainWindow.ShowWindow(); }