private void CamParaDgv_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { try { if (e.RowIndex < 0) { return; } if (this.CamParaDgv.Columns[e.ColumnIndex].Name.Equals("isOpen")) { if (e.RowIndex < CameraParaManager.Instance.CameraParaList.Count()) { CameraPara item = CameraParaManager.Instance.CameraParaList[e.RowIndex]; if (item == null) { e.Value = this.imageList1.Images[3]; } else if (item.IsOpen) { e.Value = (item.IsActive == true) ? this.imageList1.Images[2] : this.imageList1.Images[2]; } else { e.Value = this.imageList1.Images[1]; } } } } catch { } }
private void CamParaDgv_CellContentClick(object sender, DataGridViewCellEventArgs e) { try{ if (e.RowIndex >= 0) { //当前行对应的相机参数 CameraPara CurCamPara = (CameraPara)this.CamParaDgv.CurrentRow.DataBoundItem; if (CurCamPara == null) { return; } switch (CamParaDgv.Columns[e.ColumnIndex].Name) { case "DeleteBtnDgvCol": if (MessageBox.Show("是否删除该项设备? ", "删除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } CameraParaManager.Instance.CameraParaList.Remove(CurCamPara); break; case "OpenCamBtnDgvCol": CameraPara camParaI; for (int i = 0; i < CameraParaManager.Instance.CameraParaList.Count() - 1; i++) { camParaI = CameraParaManager.Instance.CameraParaList[i]; if (CurCamPara.CameraName == camParaI.CameraName) { MessageBox.Show("相机已经示教,请重新选择相机"); break; } } CameraCtrl.Instance.Init(); break; case "GrabImgDgvCol": ImgOut.Dispose(); CameraCtrl.Instance.GrabImg(CurCamPara.CameraName, out ImgOut); view.ResetView(); view.AddViewImage(ImgOut); //view.Refresh(); view.Repaint(); break; } this.CamParaDgv.Refresh(); } } catch { } }
public void SetCamPara(CameraPara camParaIn) { this.myCamPara = camParaIn; }