/// <summary> /// 向流程中添加工具,需要根据选择的工具名对工具类型等进行判断 /// </summary> /// <param name="tool">工具类型</param> /// <param name="isInsert">插入位置,当为-1时,表示在末尾插入,当不为-1时,表示被插入的工具索引</param> public void Add_Tool(ToolType tool, bool newAddTool = true, int insertPos = -1, int imageKey = 0) { string jobName = FormJobManage.Instance.tabJobUnion.SelectedTab.Text; string toolName = GetNewToolName(jobName, tool.ToString()); IToolInfo insertTool = VisionToolFactory.CreateToolVision(tool, toolName); TreeNode insertNode = new TreeNode(); insertNode = GetJobTree(jobName).Nodes.Add("", insertTool.toolName, (int)tool, (int)tool); // 该工具对应的节点 // 判断节点是否添加默认输入输出图 // 输入 for (int i = 0; i < insertTool.toolInput.Count; i++) { TreeNode childrenInputNode = insertNode.Nodes.Add("<--" + insertTool.toolInput[i].IOName); childrenInputNode.Tag = insertTool.toolInput[i].ioType; childrenInputNode.ForeColor = Color.DarkMagenta; } // 输出 for (int i = 0; i < insertTool.toolOutput.Count; i++) { TreeNode childrenOutputNode = insertNode.Nodes.Add("-->" + insertTool.toolOutput[i].IOName); childrenOutputNode.Tag = insertTool.toolOutput[i].ioType; childrenOutputNode.ForeColor = Color.Blue; } insertNode.Expand(); if (newAddTool) { VisionJobParams.pVisionProject.Project[jobName].L_toolList.Add(insertTool); } }
public ExceptionDialogViewModel(IToolInfo info, IUrlHelper urlHelper) { this.info = info; this.urlHelper = urlHelper; this.ShutdownCommand = new RelayCommand(this.ExecuteShutdownCommand); this.SubmitBugCommand = new RelayCommand(this.ExecuteSubmitBugCommand); }
public BlobTool(IToolInfo info, HImage image, DisplayControl window) { this.ToolName = info.ToolName; this.Info = info; this.Window = window; this.Image = image; }
/// <summary> /// 向流程中添加工具,需要根据选择的工具名对工具类型等进行判断 /// </summary> /// <param name="tool">工具类型</param> /// <param name="isInsert">插入位置,当为-1时,表示在末尾插入,当不为-1时,表示被插入的工具索引</param> public void Add_Tool(ToolType tool, int insertPos = -1, int imageKey = 0) { string toolName = GetNewToolName(tool.ToString()); IToolInfo insertTool = VisionToolFactory.CreateToolVision(tool, toolName); TreeNode insertNode = new TreeNode(); insertNode = VisionJobParams.myJobTreeView.Nodes.Add("", insertTool.toolName, (int)tool, (int)tool); // 该工具对应的节点 // 判断节点是否添加默认输入输出图 // 输入 for (int i = 0; i < insertTool.toolInput.Count; i++) { TreeNode childrenInputNode = insertNode.Nodes.Add("<--" + insertTool.toolInput[i].IOName); childrenInputNode.Tag = insertTool.toolInput[i].ioType; childrenInputNode.ForeColor = Color.DarkMagenta; } // 输出 for (int i = 0; i < insertTool.toolOutput.Count; i++) { TreeNode childrenOutputNode = insertNode.Nodes.Add("-->" + insertTool.toolOutput[i].IOName); childrenOutputNode.Tag = insertTool.toolOutput[i].ioType; childrenOutputNode.ForeColor = Color.Blue; } insertNode.Expand(); VisionJobParams.myVisionJob.L_toolList.Add(insertTool); }
public AboutDialogViewModel(IMessageBoxService messageBoxService, IToolInfo info) { this.messageBoxService = messageBoxService; this.Info = info; this.SubmitIssueCommand = new RelayCommand(ExecuteSubmitIssueCommand); this.CopyInfoCommand = new RelayCommand(this.ExecuteCopyInfoCommand); }
public FormCaliper(ref object caliper) { InitializeComponent(); myToolInfo = (IToolInfo)caliper; myCaliper = (Caliper)myToolInfo.tool; _instance = this; myCaliper.DispImage(); }
/// <summary> /// 交换List中的两个位置的值 /// </summary> /// <param name="inputList">要交换的List</param> /// <param name="souceIndex">原位置索引</param> /// <param name="targetIndex">现位置索引</param> /// <returns></returns> public static List <IToolInfo> SwapDataFun(List <IToolInfo> inputList, int souceIndex, int targetIndex) { IToolInfo temp = inputList[targetIndex]; inputList[targetIndex] = inputList[souceIndex]; inputList[souceIndex] = temp; return(inputList); }
public FormFindLine(ref object findLine) { InitializeComponent(); _instance = this; myToolInfo = (IToolInfo)findLine; myFindLine = (FindLine)myToolInfo.tool; //myFindLine.inputImage = ComGlobalParams.inputImageGlobal; // 暂时直接将图像传递给该工具 myFindLine.DispImage(); }
public bool InsertToolInfo(int index, IToolInfo info) { if (!TaskToolInfoDic.ContainsKey(info.ToolName)) { TaskToolInfoDic.Add(info.ToolName, info); TaskToolsInfo.Insert(index, info); return(true); } return(false); }
public bool AddToolInfo(IToolInfo info) { if (!TaskToolInfoDic.ContainsKey(info.ToolName)) { TaskToolInfoDic.Add(info.ToolName, info); TaskToolsInfo.Add(info); return(true); } return(false); }
public FormHalconTool(ref object halconTool) { InitializeComponent(); // 若窗体还未被初始化,则此时仍是object类型,就无法对类型强转 if (halconTool.GetType().FullName != "System.Object") { myToolInfo = (IToolInfo)halconTool; myHalconTool = (HalconTool)myToolInfo.tool; } _instance = this; }
public FormFindLine(ref object findLine) { InitializeComponent(); _instance = this; if (findLine.GetType().FullName != "System.Object") { myToolInfo = (IToolInfo)findLine; myFindLine = (FindLine)myToolInfo.tool; //myFindLine.inputImage = ComGlobalParams.inputImageGlobal; // 暂时直接将图像传递给该工具 myFindLine.DispImage(); } }
public GrayMatchTool(IToolInfo info, DisplayControl window) { this.Info = info; this.Window = window; this.ToolName = info.ToolName; try { Template = new HTemplate(); Template = ReadModelFromFile(info.ToolName); } catch (Exception e) { Template = null; WriteErrorLog("VisionTool", e.ToString()); } }
public NCCMatchTool(IToolInfo info, DisplayControl window) { this.Info = info; this.Window = window; this.ToolName = info.ToolName; try { NCCModel = new HNCCModel(); NCCModel = ReadModelFromFile(@".//ModelMatchFile/" + info.ToolName + ".ncm"); } catch (Exception e) { NCCModel = null; WriteErrorLog("VisionTool", e.ToString()); } }
public ShapeMatchTool(IToolInfo info, DisplayControl window) { this.Info = info; this.Window = window; this.ToolName = info.ToolName; try { ShapeModel = new HShapeModel(); ShapeModel = ReadModelFromFile(info.ToolName); ModelXLD = ShapeModel.GetShapeModelContours(1); } catch (Exception e) { ShapeModel = null; WriteErrorLog("VisionTool", e.ToString()); } }
public LineToolForm(IToolInfo info) { InitializeComponent(); #region Init Control and Tool displayForm = new DisplayControl(); displayForm.Size = panel2.Size; panel1.Controls.Add(displayForm); displayForm.Show(); displayForm.Rectangle2ROIEvent += DisplayForm_Rectangle2ROIEvent; this.parametersPropertyGrid.SelectedObject = info; if (info.GetType() == typeof(LineToolInfo)) { this.Info = (LineToolInfo)info; } Tool = new LineTool(this.Info, this.displayForm); #endregion }
private void tvw_ToolBox_AfterSelect(object sender, TreeViewEventArgs e) { if (e.Node.Level == 0) { this.richTextBoxEx1.Text = e.Node.Text; } else if (e.Node.Level == 1) { object selectTag = tvw_ToolBox.SelectedNode.Tag; if (selectTag != null) { IToolInfo insertTool = VisionToolFactory.CreateToolVision((ToolType)Enum.Parse(typeof(ToolType), selectTag.ToString())); this.richTextBoxEx1.Text = insertTool.toolDescription; } else { this.richTextBoxEx1.Text = "此工具尚未开发"; } } }
/// <summary> /// Overrides XMLToolboxManager to separate tools by scope. /// For this to work, we obviously override getToolboxContext as well. /// </summary> public override void AddTool(IToolInfo info) { if (info is DataInfo) { //add static data to the appTools map appTools[info.Key] = info.getInstance(null); } else if (info is ServletToolInfo) { ServletToolInfo stInfo = (ServletToolInfo)info; if (stInfo.Scope.ToUpper().Equals(ServletToolInfo.REQUEST_SCOPE.ToUpper())) { requestToolInfo.Add(stInfo); } else if (stInfo.Scope.ToUpper().Equals(ServletToolInfo.SESSION_SCOPE.ToUpper())) { sessionToolInfo.Add(stInfo); } else if (stInfo.Scope.ToUpper().Equals(ServletToolInfo.APPLICATION_SCOPE.ToUpper())) { //add application scoped tools to appTools and //initialize them with the ServletContext appTools[stInfo.Key] = stInfo.getInstance(httpContext); } else { log("Unknown scope: " + stInfo.Scope + " " + stInfo.Key + " will be request scoped."); requestToolInfo.Add(stInfo); } } else { //default is request scope requestToolInfo.Add(info); } }
// ------------------------------- ToolboxManager interface ------------ public virtual void AddTool(IToolInfo info) { toolinfo.Add(info); }
/// <summary> /// 释放被拖动的节点 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void TvwJob_DragDrop(object sender, DragEventArgs e)//拖动 { try { //获得拖放中的节点 TreeNode moveNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode"); //根据鼠标坐标确定要移动到的目标节点 System.Drawing.Point pt; TreeNode targeNode; // 目标节点 pt = ((TreeView)(sender)).PointToClient(new System.Drawing.Point(e.X, e.Y)); targeNode = tvwOnWorkJob.GetNodeAt(pt); //如果目标节点无子节点则添加为同级节点,反之添加到下级节点的未端 if (moveNode == targeNode) //若是把自己拖放到自己,不可,返回 { return; } if (targeNode == null) //目标节点为null,就是把节点拖到了空白区域,不可,直接返回 { return; } if (moveNode.Level == 1 && targeNode.Level == 1 && moveNode.Parent == targeNode.Parent) //都是输入输出节点,内部拖动排序 { moveNode.Remove(); targeNode.Parent.Nodes.Insert(targeNode.Index, moveNode); return; } if (moveNode.Level == 0) // 被拖动的是子节点,也就是工具节点 { if (targeNode.Level == 0) // 目标也是工具节点 { moveNode.Remove(); tvwOnWorkJob.Nodes.Insert(targeNode.Index, moveNode); IToolInfo temp = new IToolInfo(); for (int i = 0; i < L_toolList.Count; i++) { if (L_toolList[i].toolName == moveNode.Text) { SwapDataFun(L_toolList, i, targeNode.Index); break; } } } else { // 目标是子节点,则移动到该子节点的父节点的下一个节点上 moveNode.Remove(); tvwOnWorkJob.Nodes.Insert(targeNode.Parent.Index + 1, moveNode); for (int i = 0; i < L_toolList.Count; i++) { if (L_toolList[i].toolName == moveNode.Text) { SwapDataFun(L_toolList, i, targeNode.Parent.Index); break; } } } } else //被拖动的是输入输出节点 { if (targeNode.Level == 0 && GetToolInfoByToolName(JobName, targeNode.Text).toolType == ToolType.Output) { // 如果目标节点是工具节点,并且工具节点类型为可接收输入的节点,则直接将输出添加,先不考虑该情况 //string result = moveNode.Parent.Text + " . -->" + moveNode.Text.Substring(3); //GetToolInfoByToolName(jobName, targeNode.Text).input.Add(new ToolIO("<--" + result, "", DataType.String)); //TreeNode node = targeNode.Nodes.Add("", "<--" + result, 26, 26); //node.ForeColor = Color.DarkMagenta; //D_itemAndSource.Add(node, moveNode); //targeNode.Expand(); //DrawLine(); return; } else if (targeNode.Level == 0) { return; } //连线前首先要判断被拖动节点是否为输出项,目标节点是否为输入项 if (moveNode.Text.Substring(0, 3) != "-->" || targeNode.Text.Substring(0, 3) != "<--") { myFormLog.ShowLog("拖动类型不匹配!"); return; } //连线前要判断被拖动节点和目标节点的数据类型是否一致 if ((DataType)moveNode.Tag != (DataType)targeNode.Tag) { myFormLog.ShowLog("被拖动节点和目标节点数据类型不一致,不可关联"); return; } string input = targeNode.Text; if (input.Contains("《")) //表示已经连接了源 { input = Regex.Split(input, "《")[0]; } else //第一次连接源就需要添加到输入输出集合 { D_itemAndSource.Add(targeNode, moveNode); } GetToolInfoByToolName(this.JobName, targeNode.Parent.Text).GetInput(input.Substring(3)).value = "《- " + moveNode.Parent.Text + " . " + moveNode.Text.Substring(3); targeNode.Text = input + "《- " + moveNode.Parent.Text + " . " + moveNode.Text.Substring(3); DrawLine(); //移除拖放的节点 if (moveNode.Level == 0) { moveNode.Remove(); } } //更新当前拖动的节点选择 tvwOnWorkJob.SelectedNode = moveNode; //展开目标节点,便于显示拖放效果 targeNode.Expand(); } catch (Exception ex) { myFormLog.ShowLog("释放节点出错,原因: " + ex.Message + ex.StackTrace.ToString()); } }
public CircleTool(IToolInfo info, HImage image, DisplayControl window) { this.Info = info; this.Window = window; this.Image = image; }
public AboutDialogViewModel(IMessageBoxService messageBoxService, IToolInfo info, IUrlHelper urlHelper) { _messageBoxService = messageBoxService; Info = info; _urlHelper = urlHelper; }
public CircleTool(IToolInfo info, DisplayControl window) { this.Info = info; this.Window = window; }
/// <summary> /// Overrides XMLToolboxManager to separate tools by scope. /// For this to work, we obviously override getToolboxContext as well. /// </summary> public override void AddTool(IToolInfo info) { if (info is DataInfo) { //add static data to the appTools map appTools[info.Key] = info.getInstance(null); } else if (info is ServletToolInfo) { ServletToolInfo stInfo = (ServletToolInfo) info; if (stInfo.Scope.ToUpper().Equals(ServletToolInfo.REQUEST_SCOPE.ToUpper())) { requestToolInfo.Add(stInfo); } else if (stInfo.Scope.ToUpper().Equals(ServletToolInfo.SESSION_SCOPE.ToUpper())) { sessionToolInfo.Add(stInfo); } else if (stInfo.Scope.ToUpper().Equals(ServletToolInfo.APPLICATION_SCOPE.ToUpper())) { //add application scoped tools to appTools and //initialize them with the ServletContext appTools[stInfo.Key] = stInfo.getInstance(httpContext); } else { log("Unknown scope: " + stInfo.Scope + " " + stInfo.Key + " will be request scoped."); requestToolInfo.Add(stInfo); } } else { //default is request scope requestToolInfo.Add(info); } }
public ExceptionDialogViewModel(IToolInfo info, IUrlHelper urlHelper) { _info = info; _urlHelper = urlHelper; }
public GrabImageTool(IToolInfo info, DisplayControl window) { this.Info = info; this.Window = window; }