コード例 #1
0
        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;
                }
            }
        }
コード例 #2
0
        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;
                }
            }
        }