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 taskName = dataGridView1.Rows[iRow].Cells[0].Value.ToString(); formSetting = CreatingHelper <TaskToolManager> .GetSingleObject(); VisionTaskInfo info = VisionTaskManger.GetTaskInfoInstance(taskName); if (info != null) { formSetting.Info = info; formSetting.StartPosition = FormStartPosition.CenterScreen; if (formSetting.IsShowing) { formSetting.IsShowing = false; formSetting.Close(); System.Threading.Thread.Sleep(5); formSetting.Show(); formSetting.IsShowing = true; } else { formSetting.Show(); formSetting.IsShowing = true; } } } } }
private void AddBtn_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(TaskNameTxt.Text)) { MessageHelper.ShowWarning("请输入任务名称!"); return; } if (TaskRunFormCombox.SelectedItem == null) { MessageHelper.ShowWarning("请选择任务显示界面!"); return; } VisionTaskInfo info = new VisionTaskInfo() { TaskName = TaskNameTxt.Text.Trim(), TaskRunFormName = TaskRunFormCombox.SelectedItem.ToString() }; if (!string.IsNullOrEmpty(TaskDescriptionTxt.Text)) { info.TaskDescription = TaskDescriptionTxt.Text.Trim(); } if (!VisionTaskManger.AddTaskInfo(info)) { MessageHelper.ShowWarning("已存在相同名称的任务!"); return; } if (VisionTaskManger.GetTaskInfoInstance(TaskNameTxt.Text) != null) { DataGridViewRow newrow = new DataGridViewRow(); DataGridViewTextBoxCell namecell = new DataGridViewTextBoxCell(); namecell.Value = TaskNameTxt.Text.Trim(); DataGridViewTextBoxCell runFormCell = new DataGridViewTextBoxCell(); runFormCell.Value = TaskRunFormCombox.SelectedItem.ToString(); DataGridViewTextBoxCell dsCell = new DataGridViewTextBoxCell(); dsCell.Value = TaskDescriptionTxt.ToString(); newrow.Cells.Add(namecell); newrow.Cells.Add(runFormCell); newrow.Cells.Add(dsCell); dataGridView1.Rows.Add(newrow); } else { MessageHelper.ShowError("添加任务失败"); } TaskNameTxt.Clear(); TaskDescriptionTxt.Clear(); }