private void AddCamBtn_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(CamNameTxt.Text)) { MessageHelper.ShowWarning("pls input the valid name of Cam"); return; } if (CamTypeComBox.SelectedItem == null) { MessageHelper.ShowWarning("pls select a type of this Cam"); return; } CameraManger.AddCameraInfo(CamNameTxt.Text.Trim(), CamTypeComBox.SelectedItem.ToString()); if (CameraManger.GetCameraInfoInstance(CamNameTxt.Text) != null) { DataGridViewRow newrow = new DataGridViewRow(); DataGridViewTextBoxCell namecell = new DataGridViewTextBoxCell(); namecell.Value = CamNameTxt.Text.Trim(); DataGridViewTextBoxCell TypecbCell = new DataGridViewTextBoxCell(); TypecbCell.Value = CamTypeComBox.SelectedItem.ToString(); newrow.Cells.Add(namecell); newrow.Cells.Add(TypecbCell); dataGridView1.Rows.Add(newrow); CamNameTxt.Clear(); } else { MessageHelper.ShowError("添加相机失败"); } }
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { int iRow = e.RowIndex; if (iRow >= 0) { if (dataGridView1.Rows[iRow].Cells[0].Value != null && dataGridView1.Rows[iRow].Cells[1].Value != null) { string camName = dataGridView1.Rows[iRow].Cells[0].Value.ToString(); formSetting = CreatingHelper <CameraSetting> .GetSingleObject(); IVisionCameraInfo info = CameraManger.GetCameraInfoInstance(camName); if (info != null) { formSetting.Info = info; formSetting.StartPosition = FormStartPosition.CenterScreen; if (formSetting.IsShowing) { formSetting.IsShowing = false; formSetting.Close(); System.Threading.Thread.Sleep(10); formSetting.Show(); formSetting.IsShowing = true; } else { formSetting.Show(); formSetting.IsShowing = true; } } } } }