Exemplo n.º 1
0
        private void m_timer_Tick(object sender, EventArgs e)
        {
            if (m_goodCameraInfo != null && !m_GigEEnumerationIsDisabled && m_goodCameraInfo.Count > 0)
            {
                foreach (KeyValuePair <ManagedPGRGuid, CameraInfo> pair in m_goodCameraInfo)
                {
                    bool isControlable = true;
                    try
                    {
                        isControlable = m_busMgr.IsCameraControlable(pair.Key);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message);
                        isControlable = false;
                    }

                    if (!isControlable)
                    {
                        // No CCP
                        foreach (DataGridViewRow row in m_cameraDataGridView.Rows)
                        {
                            if (row.Cells[0].Value.ToString().Contains(pair.Value.serialNumber.ToString()))
                            {
                                // Found the row for this camera
                                row.DefaultCellStyle.BackColor = NO_CCP;
                                foreach (DataGridViewTextBoxCell cell in row.Cells)
                                {
                                    cell.ToolTipText = "This camera cannot be controlled by FlyCapture2 because its CCP \n" +
                                                       "is not available)";
                                }

                                if (m_cameraDataGridView.SelectedRows.Contains(row))
                                {
                                    // Current row is selected. Let's update all controls
                                    UpdateControlStatus(m_cameraDataGridView.SelectedRows[0].Index);
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (DataGridViewRow row in m_cameraDataGridView.Rows)
                        {
                            if (row.Cells[0].Value.ToString().Contains(pair.Value.serialNumber.ToString()))
                            {
                                // Found the row for this camera
                                if (row.DefaultCellStyle.BackColor == NO_CCP)
                                {
                                    row.DefaultCellStyle.BackColor = HAS_CCP;
                                    foreach (DataGridViewTextBoxCell cell in row.Cells)
                                    {
                                        cell.ToolTipText = string.Empty;
                                    }
                                }

                                if (m_cameraDataGridView.SelectedRows.Contains(row))
                                {
                                    // Current row is selected. Let's update all controls
                                    UpdateControlStatus(m_cameraDataGridView.SelectedRows[0].Index);
                                }
                            }
                        }
                    }
                }
            }
            GC.Collect();
        }