private void InitializeBasicInformation() { m_cameraInformationTable = new CameraInformationDisplayPanel(); m_cameraInformationTable.SetCopyButtonVisible(true); m_cameraInformationTable.OnCopyClick += new EventHandler(OnCopyButtonClick); m_cameraInformationTable.Dock = DockStyle.Fill; m_basicInfoPanel.Controls.Add(m_cameraInformationTable); m_gigEInformationTable = new GigEInformationDisplayPanel(); m_gigEInformationTable.Dock = DockStyle.Fill; m_gigEInfoPanel.Controls.Add(m_gigEInformationTable); if (m_camera == null || m_camera.IsConnected() == false) { return; } m_cameraInformationTable.Camera = m_camera; m_cameraInformationTable.UpdateCameraInformation(m_camInfo); m_basicInfoPanel.Height = m_cameraInformationTable.MinimumSize.Height; if (m_camInfo.interfaceType != InterfaceType.GigE) { m_gigeLabel.Hide(); m_gigEInformationTable.Hide(); m_mainTableLayoutPanel.Controls.Remove(m_gigEInfoPanel); m_mainTableLayoutPanel.SetColumnSpan(m_basicInfoPanel, 2); } else { m_gigEInformationTable.Camera = m_camera; m_gigEInformationTable.UpdateGigECameraInformation(m_camInfo); m_gigEInfoPanel.Height = m_gigEInformationTable.MinimumSize.Height; m_gigeLabel.Show(); m_gigEInformationTable.Show(); } }
private void DisplayCameraInformationFromRowIndex(int rowIndex) { if (rowIndex == -1) { // Nothing is selected return; } bool badCamera = false; string cellContent = m_cameraDataGridView.Rows[rowIndex].Cells[0].Value.ToString(); if (m_badCameraInfo.ContainsKey(cellContent)) { badCamera = true; } if (m_cameraDataGridView.Rows[rowIndex].DefaultCellStyle.BackColor == IMCOMPATIBLE_DRIVER) { badCamera = true; } if (badCamera) { try { CameraInfo camInfo; m_badCameraInfo.TryGetValue(m_cameraDataGridView.Rows[rowIndex].Cells[0].Value.ToString(), out camInfo); if (camInfo != null) { ShowGigEInformation(); m_cameraInfoPanel.Camera = null; m_cameraInfoPanel.UpdateBadCameraInformation(camInfo); m_cameraInfoDisplayPanel.Height = m_cameraInfoPanel.MinimumSize.Height; m_cameraInfoDisplayPanel.Width = m_cameraInfoPanel.MinimumSize.Width; m_gigEInfoPanel.Camera = null; m_gigEInfoPanel.UpdateBadGigECameraInformation(camInfo); m_gigeInfoDisplayPanel.Height = m_gigEInfoPanel.MinimumSize.Height; m_gigeInfoDisplayPanel.Width = m_gigEInfoPanel.MinimumSize.Width; m_needShrinkWindowHeight = true; AdjustWindowMinimumSize(); } else { camInfo = new CameraInfo(); camInfo.interfaceType = InterfaceType.Unknown; camInfo.maximumBusSpeed = BusSpeed.Unknown; camInfo.pcieBusSpeed = PCIeBusSpeed.Unknown; HideGigEInformation(); m_cameraInfoPanel.Camera = null; m_cameraInfoPanel.UpdateBadCameraInformation(camInfo); m_cameraInfoDisplayPanel.Height = m_cameraInfoPanel.MinimumSize.Height; m_cameraInfoDisplayPanel.Width = m_cameraInfoPanel.MinimumSize.Width; m_needShrinkWindowHeight = true; AdjustWindowMinimumSize(); } ////if window shrink is needed and current interface ////is not GigE then restore the window height (for bug 14937) //this.Height = this.MinimumSize.Height; //m_needShrinkWindowHeight = false; } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } } else { ManagedPGRGuid guid; if (GetPGRGuidFromRowIndex(rowIndex, out guid) == false) { MessageBox.Show("Error getting camera information", "FlyCapture2", MessageBoxButtons.OK, MessageBoxIcon.Error); m_cameraInfoPanel.ClearInformation(); return; } InterfaceType ifType = m_busMgr.GetInterfaceTypeFromGuid(guid); ManagedCameraBase camera; if (ifType == InterfaceType.GigE) { camera = new ManagedGigECamera(); } else { camera = new ManagedCamera(); } using (camera) { if (ifType == InterfaceType.GigE) { ShowGigEInformation(); } else { HideGigEInformation(); } try { camera.Connect(guid); } catch (FC2Exception ex) { Debug.WriteLine("Unable to connect to camera."); Debug.WriteLine(ex.Message); return; } // cheeck for filter driver compatibility bool compatibleFilterDriverInstalled = true; string errorMessage = string.Empty; if (ifType == InterfaceType.GigE) { try { ManagedUtilities.CheckDriver(guid); } catch (FC2Exception ex) { compatibleFilterDriverInstalled = false; errorMessage = ex.Message; } } CameraInfo camInfo; try { camInfo = camera.GetCameraInfo(); } catch (FC2Exception ex) { Debug.WriteLine("Unable to get Camera Info. {0}", ex.Message); return; } m_cameraInfoPanel.Camera = camera; m_cameraInfoPanel.UpdateCameraInformation(camInfo); m_cameraInfoDisplayPanel.Height = m_cameraInfoPanel.MinimumSize.Height; m_cameraInfoDisplayPanel.Width = m_cameraInfoPanel.MinimumSize.Width; if (ifType == InterfaceType.GigE) { m_gigEInfoPanel.Camera = camera; m_gigEInfoPanel.UpdateGigECameraInformation(camInfo); m_gigeInfoDisplayPanel.Height = m_gigEInfoPanel.MinimumSize.Height; m_gigeInfoDisplayPanel.Width = m_gigEInfoPanel.MinimumSize.Width; m_needShrinkWindowHeight = true; if (!compatibleFilterDriverInstalled) { m_cameraInfoPanel.SetDriverCompatibilityStatus(compatibleFilterDriverInstalled, errorMessage); } } } AdjustWindowMinimumSize(); if (m_needShrinkWindowHeight == true && ifType != InterfaceType.GigE) { //if window shrink is needed and current interface //is not GigE then restore the window height (for bug 14937) this.Height = this.MinimumSize.Height; m_needShrinkWindowHeight = false; } } }
private void DisplayCameraInformationFromRowIndex(int rowIndex) { if (rowIndex == -1) { // Nothing is selected return; } bool badCamera = false; string cellContent = m_cameraDataGridView.Rows[rowIndex].Cells[0].Value.ToString(); if (m_badCameraInfo.ContainsKey(cellContent)) { badCamera = true; } if (badCamera) { try { CameraInfo camInfo; m_badCameraInfo.TryGetValue(m_cameraDataGridView.Rows[rowIndex].Cells[0].Value.ToString(), out camInfo); ShowGigEInformation(); m_cameraInfoPanel.Camera = null; m_cameraInfoPanel.UpdateBadCameraInformation(camInfo); m_cameraInfoDisplayPanel.Height = m_cameraInfoPanel.MinimumSize.Height; m_cameraInfoDisplayPanel.Width = m_cameraInfoPanel.MinimumSize.Width; m_gigEInfoPanel.Camera = null; m_gigEInfoPanel.UpdateBadGigECameraInformation(camInfo); m_gigeInfoDisplayPanel.Height = m_gigEInfoPanel.MinimumSize.Height; m_gigeInfoDisplayPanel.Width = m_gigEInfoPanel.MinimumSize.Width; m_needShrinkWindowHeight = true; AdjustWindowMinimumSize(); ////if window shrink is needed and current interface ////is not GigE then restore the window height (for bug 14937) //this.Height = this.MinimumSize.Height; //m_needShrinkWindowHeight = false; } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } } else { ManagedPGRGuid guid; if (GetPGRGuidFromRowIndex(rowIndex, out guid) == false) { MessageBox.Show("Error getting camera information", "FlyCapture2", MessageBoxButtons.OK, MessageBoxIcon.Error); m_cameraInfoPanel.ClearInformation(); return; } InterfaceType ifType = m_busMgr.GetInterfaceTypeFromGuid(guid); ManagedCameraBase camera; if (ifType == InterfaceType.GigE) { camera = new ManagedGigECamera(); } else { camera = new ManagedCamera(); } using (camera) { if (ifType == InterfaceType.GigE) { ShowGigEInformation(); } else { HideGigEInformation(); } try { camera.Connect(guid); } catch (FC2Exception ex) { Debug.WriteLine("Unable to connect to camera."); Debug.WriteLine(ex.Message); return; } CameraInfo camInfo; try { camInfo = camera.GetCameraInfo(); } catch (FC2Exception ex) { Debug.WriteLine("Unable to get Camera Info. {0}", ex.Message); return; } m_cameraInfoPanel.Camera = camera; m_cameraInfoPanel.UpdateCameraInformation(camInfo); m_cameraInfoDisplayPanel.Height = m_cameraInfoPanel.MinimumSize.Height; m_cameraInfoDisplayPanel.Width = m_cameraInfoPanel.MinimumSize.Width; if (ifType == InterfaceType.GigE) { m_gigEInfoPanel.Camera = camera; m_gigEInfoPanel.UpdateGigECameraInformation(camInfo); m_gigeInfoDisplayPanel.Height = m_gigEInfoPanel.MinimumSize.Height; m_gigeInfoDisplayPanel.Width = m_gigEInfoPanel.MinimumSize.Width; m_needShrinkWindowHeight = true; } } AdjustWindowMinimumSize(); if (m_needShrinkWindowHeight == true && ifType != InterfaceType.GigE) { //if window shrink is needed and current interface //is not GigE then restore the window height (for bug 14937) this.Height = this.MinimumSize.Height; m_needShrinkWindowHeight = false; } } }