private void btnSelect_Click(object sender, EventArgs e) { int index = lsbxTools.SelectedIndex; if (index > -1) { try { ToolsFactory.CreateTool(settingIndex, toolsTypeList[index]); this.DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show("添加工具异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
//工具名称显示 public void Init(string name, ToolBase tool) { lblCommToolsName.Text = name + ":"; this.tool = tool; txtCommMin.Text = tool.Min.ToString(); txtCommMax.Text = tool.Max.ToString(); //工具名称 txtCommNote.Text = tool.Note; //是否输出结果 chkIsOutputResults.Checked = tool.IsOutputResults; //图像工具不显示图像源 if (tool is CreateImage.CreateImageTool) { cmbImageSoure.Visible = false; labelCommImageSoure.Visible = false; txtCommNote.Enabled = false; } else { //显示图像源 List <ToolBase> tools = ToolsFactory.GetToolList(tool.SettingIndex); cmbImageSoure.Items.Clear(); foreach (ToolBase item in tools) { if (item == this.tool) { break; } if (item is ICreateImage) { cmbImageSoure.Items.Add(item.Name); } } cmbImageSoure.Text = tool.ImageSoureToolName; } if (tool.IsSubTool) { groupBoxCommSetting.Visible = false; } txtCommNote.ReadOnly = true; }
private void cmbMatchingToolSelect_SelectedIndexChanged(object sender, EventArgs e) { if (mat2dManger == null) { return; } int index = cmbMatchingToolSelect.SelectedIndex; if (index > -1) { mat2dManger.Mat2DToolName = mat2dTools[index]; IMatching matchingTool = ToolsFactory.GetToolList(mat2dManger.SettingIndex).Find( x => x.Name == mat2dTools[index]) as IMatching; if (matchingTool != null) { mat2dManger.Mat2DToolName = ((ToolBase)matchingTool).Name; if (mat2dManger.SelectMatchingToolObserver != null) { mat2dManger.SelectMatchingToolObserver(matchingTool); } } } }