mirror of
https://github.com/eggplantlwj/VisionEdit.git
synced 2026-03-28 11:16:34 +08:00
版本初始化,建立主窗体页面
This commit is contained in:
6
VisionEditTest/App.config
Normal file
6
VisionEditTest/App.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
729
VisionEditTest/Job.cs
Normal file
729
VisionEditTest/Job.cs
Normal file
@@ -0,0 +1,729 @@
|
||||
using HalconDotNet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static VisionEditTest.ToolInfo;
|
||||
|
||||
namespace VisionEditTest
|
||||
{
|
||||
[Serializable]
|
||||
public class Job
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 工具对象集合
|
||||
/// </summary>
|
||||
public List<ToolInfo> L_toolList = new List<ToolInfo>();
|
||||
public TreeView tvw_job = null;
|
||||
|
||||
/// <summary>
|
||||
/// 当前流程树是否处于折叠状态
|
||||
/// </summary>
|
||||
private static bool jobTreeFold = true;
|
||||
/// <summary>
|
||||
/// 当前流程此次运行结果
|
||||
/// </summary>
|
||||
private JobRunStatu jobRunStatu = JobRunStatu.Fail;
|
||||
/// <summary>
|
||||
/// 工具输入项个数
|
||||
/// </summary>
|
||||
private int inputItemNum = 0;
|
||||
/// <summary>
|
||||
/// 工具输出项个数
|
||||
/// </summary>
|
||||
private int outputItemNum = 0;
|
||||
/// <summary>
|
||||
/// 指示图像窗口是否为第一次显示窗体,第一次显示时要初始化
|
||||
/// </summary>
|
||||
internal bool firstDisplayImage = true;
|
||||
/// <summary>
|
||||
/// 需要连线的节点对,不停的画连线,注意键值对中第一个为连线的结束节点,第二个为起始节点,一个输出可能连接多个输入,而键值对中的键不能重复,所以把源作为值,输入作为键
|
||||
/// </summary>
|
||||
internal Dictionary<TreeNode, TreeNode> D_itemAndSource = new Dictionary<TreeNode, TreeNode>();
|
||||
/// <summary>
|
||||
/// 本流程所绑定的图像窗口的句柄
|
||||
/// </summary>
|
||||
internal HTuple imageWindow = new HTuple();
|
||||
/// <summary>
|
||||
/// 本流程所绑定的生产窗口的名称
|
||||
/// </summary>
|
||||
internal string imageWindowName = "无";
|
||||
/// <summary>
|
||||
/// 流程结果图像所绑定的窗体
|
||||
/// </summary>
|
||||
internal string debugImageWindow = "图像";
|
||||
/// <summary>
|
||||
/// 流程运行结果图像
|
||||
/// </summary>
|
||||
internal HObject jobResultImage;
|
||||
/// <summary>
|
||||
/// 编辑节点前节点文本,用于修改工具名称
|
||||
/// </summary>
|
||||
private string nodeTextBeforeEdit = string.Empty;
|
||||
/// <summary>
|
||||
/// 流程编辑时的右击菜单
|
||||
/// </summary>
|
||||
private static ContextMenuStrip rightClickMenu = new ContextMenuStrip();
|
||||
/// <summary>
|
||||
/// 在空白除右击菜单
|
||||
/// </summary>
|
||||
private static ContextMenuStrip rightClickMenuAtBlank = new ContextMenuStrip();
|
||||
/// <summary>
|
||||
/// 流程名
|
||||
/// </summary>
|
||||
internal string jobName = string.Empty;
|
||||
/// <summary>
|
||||
/// 流程树中节点的最大长度
|
||||
/// </summary>
|
||||
private int maxLength = 130;
|
||||
/// <summary>
|
||||
/// 正在绘制输入输出指向线
|
||||
/// </summary>
|
||||
internal static bool isDrawing = false;
|
||||
/// <summary>
|
||||
/// 记录本工具执行完的耗时,用于计算各工具耗时
|
||||
/// </summary>
|
||||
private double recordElapseTime = 0;
|
||||
/// <summary>
|
||||
/// 标准图像字典,用于存储标准图像路径和图像对象
|
||||
/// </summary>
|
||||
internal static Dictionary<string, HObject> D_standardImage = new Dictionary<string, HObject>();
|
||||
/// <summary>
|
||||
/// 工具图标列表
|
||||
/// </summary>
|
||||
internal static ImageList imageList = new ImageList();
|
||||
/// <summary>
|
||||
/// 记录起始节点和此节点的列坐标值
|
||||
/// </summary>
|
||||
private static Dictionary<TreeNode, Color> startNodeAndColor = new Dictionary<TreeNode, Color>();
|
||||
/// <summary>
|
||||
/// 记录前面的划线所跨越的列段,
|
||||
/// </summary>
|
||||
private static Dictionary<int, Dictionary<TreeNode, TreeNode>> list = new Dictionary<int, Dictionary<TreeNode, TreeNode>>();
|
||||
/// <summary>
|
||||
/// 每一个列坐标值对应一种颜色
|
||||
/// </summary>
|
||||
private Dictionary<int, Color> colValueAndColor = new Dictionary<int, Color>();
|
||||
/// <summary>
|
||||
/// 输入输出指向线的颜色数组
|
||||
/// </summary>
|
||||
private static Color[] color = new Color[] { Color.Blue, Color.Orange, Color.Black, Color.Red, Color.Green, Color.Brown, Color.Blue, Color.Black, Color.Red, Color.Green, Color.Orange, Color.Brown, Color.Blue, Color.Black, Color.Red, Color.Green, Color.Orange, Color.Brown, Color.Blue, Color.Black, Color.Red, Color.Green, Color.Orange, Color.Brown, Color.Blue, Color.Black, Color.Red, Color.Green, Color.Orange, Color.Brown };
|
||||
|
||||
public Job()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 拖动工具节点
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
internal void tvw_job_ItemDrag(object sender, ItemDragEventArgs e)//左键拖动
|
||||
{
|
||||
try
|
||||
{
|
||||
if (((TreeView)sender).SelectedNode != null)
|
||||
{
|
||||
if (((TreeView)sender).SelectedNode.Level == 1) //输入输出不允许拖动
|
||||
{
|
||||
tvw_job.DoDragDrop(e.Item, DragDropEffects.Move);
|
||||
}
|
||||
|
||||
else if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
tvw_job.DoDragDrop(e.Item, DragDropEffects.Move);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 节点拖动
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
internal void tvw_job_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode"))
|
||||
{
|
||||
e.Effect = DragDropEffects.Move;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 释放被拖动的节点
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
internal void tvw_job_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 = tvw_job.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();
|
||||
tvw_job.Nodes.Insert(targeNode.Index, moveNode);
|
||||
|
||||
ToolInfo temp = new ToolInfo();
|
||||
for (int i = 0; i < L_toolList.Count; i++)
|
||||
{
|
||||
if (L_toolList[i].toolName == moveNode.Text)
|
||||
{
|
||||
temp = L_toolList[i];
|
||||
L_toolList.RemoveAt(i);
|
||||
L_toolList.Insert(targeNode.Index - 2, temp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
moveNode.Remove();
|
||||
tvw_job.Nodes.Insert(targeNode.Parent.Index + 1, moveNode);
|
||||
|
||||
ToolInfo temp = new ToolInfo();
|
||||
for (int i = 0; i < L_toolList.Count; i++)
|
||||
{
|
||||
if (L_toolList[i].toolName == moveNode.Text)
|
||||
{
|
||||
temp = L_toolList[i];
|
||||
L_toolList.RemoveAt(i);
|
||||
L_toolList.Insert(targeNode.Parent.Index, temp);
|
||||
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) != "<--")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//连线前要判断被拖动节点和目标节点的数据类型是否一致
|
||||
if ((DataType)moveNode.Tag != (DataType)targeNode.Tag)
|
||||
{
|
||||
// Frm_Main.Instance.OutputMsg("被拖动节点和目标节点数据类型不一致,不可关联", Color.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
string input = targeNode.Text;
|
||||
if (input.Contains("《")) //表示已经连接了源
|
||||
input = Regex.Split(input, "《")[0];
|
||||
else //第一次连接源就需要添加到输入输出集合
|
||||
D_itemAndSource.Add(targeNode, moveNode);
|
||||
GetToolInfoByToolName(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();
|
||||
}
|
||||
//更新当前拖动的节点选择
|
||||
tvw_job.SelectedNode = moveNode;
|
||||
//展开目标节点,便于显示拖放效果
|
||||
targeNode.Expand();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 流程树的双击事件
|
||||
/// </summary>
|
||||
internal void TVW_DoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
//判断是否在节点上双击
|
||||
TreeViewHitTestInfo test = tvw_job.HitTest(e.X, e.Y);
|
||||
if (test.Node == null || test.Location != TreeViewHitTestLocations.Label) //双击节点
|
||||
{
|
||||
if (jobTreeFold)
|
||||
{
|
||||
tvw_job.ExpandAll();
|
||||
jobTreeFold = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
tvw_job.CollapseAll();
|
||||
jobTreeFold = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
string toolName = tvw_job.SelectedNode.Text;
|
||||
// TestFrmIn myForm = new TestFrmIn()
|
||||
for (int i = 0; i < L_toolList.Count; i++)
|
||||
{
|
||||
if (L_toolList[i].toolName == toolName)
|
||||
{
|
||||
switch(toolName)
|
||||
{
|
||||
case "可输入工具":
|
||||
ShapeMatchTool shapeMatchTool = (ShapeMatchTool)(L_toolList[i].tool);
|
||||
TestFrmIn myTestFrmIn = new TestFrmIn();
|
||||
myTestFrmIn.shapeMatchTool = shapeMatchTool;
|
||||
myTestFrmIn.inputText = shapeMatchTool.text;
|
||||
myTestFrmIn.Show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region 绘制输入输出指向线
|
||||
internal void tvw_job_AfterSelect(object sender, TreeViewEventArgs e)
|
||||
{
|
||||
nodeTextBeforeEdit = tvw_job.SelectedNode.Text;
|
||||
}
|
||||
internal void Draw_Line(object sender, TreeViewEventArgs e)
|
||||
{
|
||||
tvw_job.Refresh();
|
||||
DrawLine();
|
||||
}
|
||||
internal void tbc_jobs_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
tvw_job.Refresh();
|
||||
DrawLine();
|
||||
}
|
||||
public void DrawLineWithoutRefresh(object sender, MouseEventArgs e)
|
||||
{
|
||||
tvw_job.Update();
|
||||
DrawLine();
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 通过工具名获取工具信息
|
||||
/// </summary>
|
||||
/// <param name="toolName">工具名</param>
|
||||
/// <returns>工具信息</returns>
|
||||
internal static ToolInfo GetToolInfoByToolName(string jobName, string toolName)
|
||||
{
|
||||
try
|
||||
{
|
||||
Job job = new Job();
|
||||
//for (int i = 0; i < Project.Instance.L_jobList.Count; i++)
|
||||
//{
|
||||
// if (Project.Instance.L_jobList[i].jobName == jobName)
|
||||
// {
|
||||
// job = Project.Instance.L_jobList[i];
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
job = TestForm.GetInstance().myJob;
|
||||
for (int i = 0; i < job.L_toolList.Count; i++)
|
||||
{
|
||||
if (job.L_toolList[i].toolName == toolName)
|
||||
{
|
||||
return job.L_toolList[i];
|
||||
}
|
||||
}
|
||||
return new ToolInfo();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ToolInfo();
|
||||
}
|
||||
}
|
||||
private static Graphics g;
|
||||
/// <summary>
|
||||
/// 绘制输入输出指向线
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
public void DrawLine()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!isDrawing)
|
||||
{
|
||||
isDrawing = true;
|
||||
Thread th = new Thread(() =>
|
||||
{
|
||||
tvw_job.MouseWheel += new MouseEventHandler(numericUpDown1_MouseWheel); //划线的时候不能滚动,否则画好了线,结果已经滚到其它地方了
|
||||
maxLength = 150;
|
||||
colValueAndColor.Clear();
|
||||
startNodeAndColor.Clear();
|
||||
list.Clear();
|
||||
TreeView tree = tvw_job;
|
||||
g = tree.CreateGraphics();
|
||||
tree.CreateGraphics().Dispose();
|
||||
|
||||
foreach (KeyValuePair<TreeNode, TreeNode> item in D_itemAndSource)
|
||||
{
|
||||
CreateLine(tree, item.Key, item.Value);
|
||||
}
|
||||
Application.DoEvents();
|
||||
tvw_job.MouseWheel -= new MouseEventHandler(numericUpDown1_MouseWheel);
|
||||
isDrawing = false;
|
||||
});
|
||||
th.IsBackground = true;
|
||||
th.ApartmentState = ApartmentState.STA; //此处要加一行,否则画线时会报错
|
||||
th.Start();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 画Treeview控件两个节点之间的连线
|
||||
/// </summary>
|
||||
/// <param name="treeview">要画连线的Treeview</param>
|
||||
/// <param name="startNode">结束节点</param>
|
||||
/// <param name="endNode">开始节点</param>
|
||||
private void CreateLine(TreeView treeview, TreeNode endNode, TreeNode startNode)
|
||||
{
|
||||
try
|
||||
{
|
||||
//得到起始与结束节点之间所有节点的最大长度 ,保证画线不穿过节点
|
||||
int startNodeParantIndex = startNode.Parent.Index;
|
||||
int endNodeParantIndex = endNode.Parent.Index;
|
||||
int startNodeIndex = startNode.Index;
|
||||
int endNodeIndex = endNode.Index;
|
||||
int max = 0;
|
||||
|
||||
if (!startNode.Parent.IsExpanded)
|
||||
{
|
||||
max = startNode.Parent.Bounds.X + startNode.Parent.Bounds.Width;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = startNodeIndex; i < startNode.Parent.Nodes.Count - 1; i++)
|
||||
{
|
||||
if (max < treeview.Nodes[startNodeParantIndex].Nodes[i].Bounds.X + treeview.Nodes[startNodeParantIndex].Nodes[i].Bounds.Width)
|
||||
max = treeview.Nodes[startNodeParantIndex].Nodes[i].Bounds.X + treeview.Nodes[startNodeParantIndex].Nodes[i].Bounds.Width;
|
||||
}
|
||||
}
|
||||
for (int i = startNodeParantIndex + 1; i < endNodeParantIndex; i++)
|
||||
{
|
||||
if (!treeview.Nodes[i].IsExpanded)
|
||||
{
|
||||
if (max < treeview.Nodes[i].Bounds.X + treeview.Nodes[i].Bounds.Width)
|
||||
max = treeview.Nodes[i].Bounds.X + treeview.Nodes[i].Bounds.Width;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = 0; j < treeview.Nodes[i].Nodes.Count; j++)
|
||||
{
|
||||
if (max < treeview.Nodes[i].Nodes[j].Bounds.X + treeview.Nodes[i].Nodes[j].Bounds.Width)
|
||||
max = treeview.Nodes[i].Nodes[j].Bounds.X + treeview.Nodes[i].Nodes[j].Bounds.Width;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!endNode.Parent.IsExpanded)
|
||||
{
|
||||
if (max < endNode.Parent.Bounds.X + endNode.Parent.Bounds.Width)
|
||||
max = endNode.Parent.Bounds.X + endNode.Parent.Bounds.Width;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < endNode.Index; i++)
|
||||
{
|
||||
if (max < treeview.Nodes[endNodeParantIndex].Nodes[i].Bounds.X + treeview.Nodes[endNodeParantIndex].Nodes[i].Bounds.Width)
|
||||
max = treeview.Nodes[endNodeParantIndex].Nodes[i].Bounds.X + treeview.Nodes[endNodeParantIndex].Nodes[i].Bounds.Width;
|
||||
}
|
||||
}
|
||||
max += 10; //箭头不能连着 节点,
|
||||
|
||||
if (!startNode.Parent.IsExpanded)
|
||||
startNode = startNode.Parent;
|
||||
if (!endNode.Parent.IsExpanded)
|
||||
endNode = endNode.Parent;
|
||||
|
||||
if (endNode.Bounds.X + endNode.Bounds.Width + 20 > max)
|
||||
max = endNode.Bounds.X + endNode.Bounds.Width + 20;
|
||||
if (startNode.Bounds.X + startNode.Bounds.Width + 20 > max)
|
||||
max = startNode.Bounds.X + startNode.Bounds.Width + 20;
|
||||
|
||||
//判断是否可以在当前处划线
|
||||
foreach (KeyValuePair<int, Dictionary<TreeNode, TreeNode>> item in list)
|
||||
{
|
||||
if (Math.Abs(max - item.Key) < 15)
|
||||
{
|
||||
foreach (KeyValuePair<TreeNode, TreeNode> item1 in item.Value)
|
||||
{
|
||||
if (startNode != item1.Value)
|
||||
{
|
||||
if ((item1.Value.Bounds.X < maxLength && item1.Key.Bounds.X < maxLength) || (item1.Value.Bounds.X < maxLength && item1.Key.Bounds.X < maxLength))
|
||||
{
|
||||
max += (15 - Math.Abs(max - item.Key));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary<TreeNode, TreeNode> temp = new Dictionary<TreeNode, TreeNode>();
|
||||
temp.Add(endNode, startNode);
|
||||
if (!list.ContainsKey(max))
|
||||
list.Add(max, temp);
|
||||
else
|
||||
list[max].Add(endNode, startNode);
|
||||
|
||||
if (!startNodeAndColor.ContainsKey(startNode))
|
||||
startNodeAndColor.Add(startNode, color[startNodeAndColor.Count]);
|
||||
|
||||
Pen pen = new Pen(startNodeAndColor[startNode], 1);
|
||||
Brush brush = new SolidBrush(startNodeAndColor[startNode]);
|
||||
|
||||
g.DrawLine(pen, startNode.Bounds.X + startNode.Bounds.Width,
|
||||
startNode.Bounds.Y + startNode.Bounds.Height / 2,
|
||||
max,
|
||||
startNode.Bounds.Y + startNode.Bounds.Height / 2);
|
||||
g.DrawLine(pen, max,
|
||||
startNode.Bounds.Y + startNode.Bounds.Height / 2,
|
||||
max,
|
||||
endNode.Bounds.Y + endNode.Bounds.Height / 2);
|
||||
g.DrawLine(pen, max,
|
||||
endNode.Bounds.Y + endNode.Bounds.Height / 2,
|
||||
endNode.Bounds.X + endNode.Bounds.Width,
|
||||
endNode.Bounds.Y + endNode.Bounds.Height / 2);
|
||||
g.DrawString("<", new Font("微软雅黑", 12F), brush, endNode.Bounds.X + endNode.Bounds.Width - 5,
|
||||
endNode.Bounds.Y + endNode.Bounds.Height / 2 - 12);
|
||||
Application.DoEvents();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
|
||||
//取消滚轮事件
|
||||
void numericUpDown1_MouseWheel(object sender, MouseEventArgs e)
|
||||
{
|
||||
HandledMouseEventArgs h = e as HandledMouseEventArgs;
|
||||
if (h != null)
|
||||
{
|
||||
h.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加输入
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Add_input(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string result = sender.ToString();
|
||||
|
||||
//首先检查是否已经有此输入项,若已添加,则返回
|
||||
foreach (var item in tvw_job.SelectedNode.Nodes)
|
||||
{
|
||||
string text;
|
||||
if (((TreeNode)item).Text.Contains("《"))
|
||||
{
|
||||
text = Regex.Split(((TreeNode)item).Text, "《")[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
text = ((TreeNode)item).Text;
|
||||
}
|
||||
if (text == "<--" + result)
|
||||
{
|
||||
//Frm_Main.Instance.OutputMsg(Configuration.language == Language.English ? "This input or output item already exists and cannot be added repeatedly" : "已存在此输入或输出项,不可重复添加", Color.Green);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int insertPos = GetInputItemNum(tvw_job.SelectedNode); //获取插入位置,要保证输入项在前,输出项在后
|
||||
TreeNode node = tvw_job.SelectedNode.Nodes.Insert(insertPos, "", "<--" + result, 26, 26);
|
||||
node.ForeColor = Color.DarkMagenta;
|
||||
tvw_job.SelectedNode.Expand();
|
||||
DataType ioType = (DataType)((ToolStripItem)sender).Tag;
|
||||
|
||||
//指定输入变量的类型
|
||||
//if (result == (Configuration.language == Language.English ? "InputImage" : "输入图像"))
|
||||
// node.Tag = DataType.Image;
|
||||
//else if (result == "BlobResult")
|
||||
// node.Tag = "BlobResult";
|
||||
//else
|
||||
node.Tag = ioType;
|
||||
node.Name = "<--" + result;
|
||||
GetToolInfoByToolName(jobName, tvw_job.SelectedNode.Text).input.Add(new ToolIO(result, "", ioType));
|
||||
|
||||
//如果是给输出工具添加输入,则需要连线
|
||||
if (GetToolInfoByToolName(jobName, tvw_job.SelectedNode.Text).toolType == ToolType.Output)
|
||||
{
|
||||
string toolNodeText = Regex.Split(sender.ToString(), " . ")[0];
|
||||
string toolIONodeText = Regex.Split(sender.ToString(), " . ")[1];
|
||||
D_itemAndSource.Add(GetToolIONodeByNodeText(tvw_job.SelectedNode.Text, "<--" + sender.ToString()), GetToolIONodeByNodeText(toolNodeText, toolIONodeText));
|
||||
|
||||
Draw_Line(null, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过TreeNode节点文本获取输入输出节点
|
||||
/// </summary>
|
||||
/// <param name="toolName">工具名称</param>
|
||||
/// <returns>IO名称</returns>
|
||||
internal TreeNode GetToolIONodeByNodeText(string toolName, string toolIOName)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (TreeNode toolNode in tvw_job.Nodes)
|
||||
{
|
||||
if (toolNode.Text == toolName)
|
||||
{
|
||||
foreach (TreeNode itemNode in ((TreeNode)toolNode).Nodes)
|
||||
{
|
||||
if (((TreeNode)itemNode).Text == toolIOName)
|
||||
{
|
||||
return itemNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加输出
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Add_output(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string result = sender.ToString();
|
||||
foreach (var item in tvw_job.SelectedNode.Nodes)
|
||||
{
|
||||
if (((TreeNode)item).Text == "-->" + result)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
TreeNode node = tvw_job.SelectedNode.Nodes.Add("", "-->" + result, 26, 26);
|
||||
node.ForeColor = Color.Blue;
|
||||
tvw_job.SelectedNode.Expand();
|
||||
DataType ioType = (DataType)((ToolStripItem)sender).Tag;
|
||||
|
||||
//指定输出变量的类型
|
||||
if (result == "输出图像")
|
||||
{
|
||||
// node.Tag = DataType.Image;
|
||||
node.ToolTipText = "图形变量不支持显示";
|
||||
}
|
||||
//else if (result == "BlobResult")
|
||||
// node.Tag = "BlobResult";
|
||||
//else
|
||||
node.Tag = ioType;
|
||||
|
||||
node.Name = "-->" + result;
|
||||
GetToolInfoByToolName(jobName, tvw_job.SelectedNode.Text).output.Add(new ToolIO(result, "", ioType));
|
||||
node.ToolTipText = "未运行";
|
||||
tvw_job.ShowNodeToolTips = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取工具输入项的个数
|
||||
/// </summary>
|
||||
private int GetInputItemNum(TreeNode toolNode)
|
||||
{
|
||||
try
|
||||
{
|
||||
int num = 0;
|
||||
foreach (TreeNode item in toolNode.Nodes)
|
||||
{
|
||||
if (item.Text.Substring(0, 3) == "<--")
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public enum JobRunStatu
|
||||
{
|
||||
Succeed,
|
||||
Fail,
|
||||
}
|
||||
}
|
||||
22
VisionEditTest/Program.cs
Normal file
22
VisionEditTest/Program.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace VisionEditTest
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// 应用程序的主入口点。
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new TestForm());
|
||||
}
|
||||
}
|
||||
}
|
||||
36
VisionEditTest/Properties/AssemblyInfo.cs
Normal file
36
VisionEditTest/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("VisionEditTest")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("VisionEditTest")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
//将 ComVisible 设置为 false 将使此程序集中的类型
|
||||
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("bf03a00c-35b5-470e-a335-0a78fd0478a6")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
||||
// 方法是按如下所示使用“*”: :
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
71
VisionEditTest/Properties/Resources.Designer.cs
generated
Normal file
71
VisionEditTest/Properties/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,71 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本: 4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能导致不正确的行为,如果
|
||||
// 重新生成代码,则所做更改将丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace VisionEditTest.Properties
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 强类型资源类,用于查找本地化字符串等。
|
||||
/// </summary>
|
||||
// 此类是由 StronglyTypedResourceBuilder
|
||||
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
||||
// 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
||||
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回此类使用的缓存 ResourceManager 实例。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("VisionEditTest.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 覆盖当前线程的 CurrentUICulture 属性
|
||||
/// 使用此强类型的资源类的资源查找。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
117
VisionEditTest/Properties/Resources.resx
Normal file
117
VisionEditTest/Properties/Resources.resx
Normal file
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
30
VisionEditTest/Properties/Settings.Designer.cs
generated
Normal file
30
VisionEditTest/Properties/Settings.Designer.cs
generated
Normal file
@@ -0,0 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace VisionEditTest.Properties
|
||||
{
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
VisionEditTest/Properties/Settings.settings
Normal file
7
VisionEditTest/Properties/Settings.settings
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
7
VisionEditTest/ShapeMatchTool.cs
Normal file
7
VisionEditTest/ShapeMatchTool.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace VisionEditTest
|
||||
{
|
||||
internal class ShapeMatchTool
|
||||
{
|
||||
public string text { get; set; } = null;
|
||||
}
|
||||
}
|
||||
98
VisionEditTest/TestForm.Designer.cs
generated
Normal file
98
VisionEditTest/TestForm.Designer.cs
generated
Normal file
@@ -0,0 +1,98 @@
|
||||
namespace VisionEditTest
|
||||
{
|
||||
partial class TestForm
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows 窗体设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要修改
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.tabControl1 = new System.Windows.Forms.TabControl();
|
||||
this.btnAddTree = new System.Windows.Forms.Button();
|
||||
this.AddNodeOutPut = new System.Windows.Forms.Button();
|
||||
this.AddInputNode = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tabControl1
|
||||
//
|
||||
this.tabControl1.Location = new System.Drawing.Point(12, 12);
|
||||
this.tabControl1.Name = "tabControl1";
|
||||
this.tabControl1.SelectedIndex = 0;
|
||||
this.tabControl1.Size = new System.Drawing.Size(434, 500);
|
||||
this.tabControl1.TabIndex = 0;
|
||||
//
|
||||
// btnAddTree
|
||||
//
|
||||
this.btnAddTree.Location = new System.Drawing.Point(462, 31);
|
||||
this.btnAddTree.Name = "btnAddTree";
|
||||
this.btnAddTree.Size = new System.Drawing.Size(91, 40);
|
||||
this.btnAddTree.TabIndex = 1;
|
||||
this.btnAddTree.Text = "添加JOB";
|
||||
this.btnAddTree.UseVisualStyleBackColor = true;
|
||||
this.btnAddTree.Click += new System.EventHandler(this.btnAddTree_Click);
|
||||
//
|
||||
// AddNodeOutPut
|
||||
//
|
||||
this.AddNodeOutPut.Location = new System.Drawing.Point(462, 101);
|
||||
this.AddNodeOutPut.Name = "AddNodeOutPut";
|
||||
this.AddNodeOutPut.Size = new System.Drawing.Size(90, 40);
|
||||
this.AddNodeOutPut.TabIndex = 2;
|
||||
this.AddNodeOutPut.Text = "添加输出节点";
|
||||
this.AddNodeOutPut.UseVisualStyleBackColor = true;
|
||||
this.AddNodeOutPut.Click += new System.EventHandler(this.AddNode_Click);
|
||||
//
|
||||
// AddInputNode
|
||||
//
|
||||
this.AddInputNode.Location = new System.Drawing.Point(462, 167);
|
||||
this.AddInputNode.Name = "AddInputNode";
|
||||
this.AddInputNode.Size = new System.Drawing.Size(91, 41);
|
||||
this.AddInputNode.TabIndex = 3;
|
||||
this.AddInputNode.Text = "添加输入节点";
|
||||
this.AddInputNode.UseVisualStyleBackColor = true;
|
||||
this.AddInputNode.Click += new System.EventHandler(this.AddInputNode_Click);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(645, 524);
|
||||
this.Controls.Add(this.AddInputNode);
|
||||
this.Controls.Add(this.AddNodeOutPut);
|
||||
this.Controls.Add(this.btnAddTree);
|
||||
this.Controls.Add(this.tabControl1);
|
||||
this.Name = "Form1";
|
||||
this.Text = "Form1";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TabControl tabControl1;
|
||||
private System.Windows.Forms.Button btnAddTree;
|
||||
private System.Windows.Forms.Button AddNodeOutPut;
|
||||
private System.Windows.Forms.Button AddInputNode;
|
||||
}
|
||||
}
|
||||
|
||||
175
VisionEditTest/TestForm.cs
Normal file
175
VisionEditTest/TestForm.cs
Normal file
@@ -0,0 +1,175 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static VisionEditTest.ToolInfo;
|
||||
|
||||
namespace VisionEditTest
|
||||
{
|
||||
public partial class TestForm : Form
|
||||
{
|
||||
private static TestForm instance = null;
|
||||
public Job myJob = null;
|
||||
public TestForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
instance = this;
|
||||
CheckForIllegalCrossThreadCalls = false;
|
||||
}
|
||||
|
||||
public static TestForm GetInstance()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
private void btnAddTree_Click(object sender, EventArgs e)
|
||||
{
|
||||
//string path = @"E:\VM Pro_0.0.0.3\VM Pro_0.0.0.3\Resources\Sample\OCR.job";
|
||||
//IFormatter formatter = new BinaryFormatter();
|
||||
//Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.None);
|
||||
//Job job = (Job)formatter.Deserialize(stream);
|
||||
//stream.Close();
|
||||
myJob = new Job();
|
||||
myJob.jobName = "test";
|
||||
|
||||
myJob.tvw_job = new TreeView();
|
||||
|
||||
myJob.tvw_job.Scrollable = true;
|
||||
|
||||
myJob.tvw_job.ItemHeight = 26;
|
||||
myJob.tvw_job.ShowLines = false;
|
||||
myJob.tvw_job.AllowDrop = true;
|
||||
myJob.tvw_job.ImageList = Job.imageList;
|
||||
|
||||
myJob.tvw_job.AfterSelect += myJob.tvw_job_AfterSelect;
|
||||
//tvw_job.AfterLabelEdit += new NodeLabelEditEventHandler(myJob.EditNodeText);
|
||||
//tvw_job.MouseClick += new MouseEventHandler(myJob.TVW_MouseClick);
|
||||
myJob.tvw_job.MouseDoubleClick += new MouseEventHandler(myJob.TVW_DoubleClick);
|
||||
|
||||
//节点间拖拽
|
||||
myJob.tvw_job.ItemDrag += new ItemDragEventHandler(myJob.tvw_job_ItemDrag);
|
||||
myJob.tvw_job.DragEnter += new DragEventHandler(myJob.tvw_job_DragEnter);
|
||||
myJob.tvw_job.DragDrop += new DragEventHandler(myJob.tvw_job_DragDrop);
|
||||
|
||||
//以下事件为画线事件
|
||||
myJob.tvw_job.MouseMove += myJob.DrawLineWithoutRefresh;
|
||||
myJob.tvw_job.AfterExpand += myJob.Draw_Line;
|
||||
myJob.tvw_job.AfterCollapse += myJob.Draw_Line;
|
||||
// Frm_Job.Instance.tbc_jobs.SelectedIndexChanged += myJob.tbc_jobs_SelectedIndexChanged;
|
||||
|
||||
myJob.tvw_job.Dock = DockStyle.Fill;
|
||||
myJob.tvw_job.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.tabControl1.TabPages.Add("test");
|
||||
this.tabControl1.TabPages[0].Controls.Add(myJob.tvw_job);
|
||||
//Frm_Job.Instance.tbc_jobs.TabPages.Add(jobName);
|
||||
//Frm_Job.Instance.tbc_jobs.TabPages[Frm_Job.Instance.tbc_jobs.TabPages.Count - 1].Controls.Add(tvw_job);
|
||||
//Frm_Job.Instance.tbc_jobs.SelectedIndex = Frm_Job.Instance.tbc_jobs.TabCount - 1;
|
||||
Application.DoEvents();
|
||||
}
|
||||
|
||||
private void AddNode_Click(object sender, EventArgs e)
|
||||
{
|
||||
int insertPos = -1;
|
||||
ToolInfo toolInfo = new ToolInfo();
|
||||
TreeNode toolNode = new TreeNode();
|
||||
HalconInterfaceTool halconInterfaceTool = new HalconInterfaceTool();
|
||||
toolInfo.toolType = ToolType.HalconInterface;
|
||||
toolInfo.tool = halconInterfaceTool;
|
||||
toolInfo.toolName = "可输出工具";
|
||||
|
||||
if (toolInfo.toolName == "Error") //此工具添加个数已达到上限,不让继续添加
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (insertPos == -1)
|
||||
{
|
||||
toolNode = myJob.tvw_job.Nodes.Add("", toolInfo.toolName, 1, 1);
|
||||
myJob.L_toolList.Add(toolInfo);
|
||||
}
|
||||
|
||||
|
||||
//添加必用项
|
||||
TreeNode itemNode = toolNode.Nodes.Add("","-->OutputImage", 26, 26);
|
||||
itemNode.ForeColor = Color.Blue;
|
||||
toolNode.ExpandAll();
|
||||
itemNode.Tag = DataType.Image;
|
||||
toolNode.ToolTipText = "it's tips";
|
||||
ToolIO outIO = new ToolIO();
|
||||
outIO.IOName = "outText";
|
||||
outIO.value = "i am output text";
|
||||
toolInfo.output.Add(outIO);
|
||||
|
||||
// myJob.output.Add(new ToolIO(Configuration.language == Language.English ? "OutputImage" : "输出图像", "", DataType.Image));
|
||||
myJob.tvw_job.ShowNodeToolTips = true;
|
||||
}
|
||||
|
||||
private void AddInputNode_Click(object sender, EventArgs e)
|
||||
{
|
||||
int insertPos = -1;
|
||||
ToolInfo toolInfo = new ToolInfo();
|
||||
TreeNode toolNode = new TreeNode();
|
||||
ShapeMatchTool shapeMatchTool = new ShapeMatchTool();
|
||||
toolInfo.toolType = ToolType.ShapeMatch;
|
||||
toolInfo.tool = shapeMatchTool;
|
||||
toolInfo.toolName = "可输入工具";
|
||||
if (toolInfo.toolName == "Error")
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (insertPos == -1)
|
||||
{
|
||||
toolNode = myJob.tvw_job.Nodes.Add("", toolInfo.toolName, 2, 2);
|
||||
myJob.L_toolList.Add(toolInfo);
|
||||
}
|
||||
|
||||
|
||||
//添加必用项
|
||||
TreeNode itemNode = toolNode.Nodes.Add("", "<--InputImage", 26, 26);
|
||||
itemNode.ForeColor = Color.DarkMagenta;
|
||||
toolNode.ExpandAll();
|
||||
itemNode.Tag = DataType.Image;
|
||||
shapeMatchTool.text = GetToolInfoByToolName("可输出工具").GetOutput("outText").value.ToString();
|
||||
|
||||
// Job.GetToolInfoByToolName(jobName, Configuration.language == Language.English ? "HalconAcqInterface" : toolInfo.toolName).input.Add(new ToolIO(Configuration.language == Language.English ? "OutputImage" : "输入图像", "", DataType.Image));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过工具名获取工具信息
|
||||
/// </summary>
|
||||
/// <param name="toolName">工具名</param>
|
||||
/// <returns>工具信息</returns>
|
||||
internal ToolInfo GetToolInfoByToolName(string toolName)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
for (int i = 0; i < myJob.L_toolList.Count; i++)
|
||||
{
|
||||
if (myJob.L_toolList[i].toolName == toolName)
|
||||
{
|
||||
return myJob.L_toolList[i];
|
||||
}
|
||||
}
|
||||
return new ToolInfo();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ToolInfo();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
internal class HalconInterfaceTool
|
||||
{
|
||||
}
|
||||
}
|
||||
120
VisionEditTest/TestForm.resx
Normal file
120
VisionEditTest/TestForm.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
60
VisionEditTest/TestFrmIn.Designer.cs
generated
Normal file
60
VisionEditTest/TestFrmIn.Designer.cs
generated
Normal file
@@ -0,0 +1,60 @@
|
||||
namespace VisionEditTest
|
||||
{
|
||||
partial class TestFrmIn
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.btnRun = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnRun
|
||||
//
|
||||
this.btnRun.Location = new System.Drawing.Point(33, 36);
|
||||
this.btnRun.Name = "btnRun";
|
||||
this.btnRun.Size = new System.Drawing.Size(83, 44);
|
||||
this.btnRun.TabIndex = 0;
|
||||
this.btnRun.Text = "btnRun";
|
||||
this.btnRun.UseVisualStyleBackColor = true;
|
||||
this.btnRun.Click += new System.EventHandler(this.btnRun_Click);
|
||||
//
|
||||
// TestFrm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(284, 261);
|
||||
this.Controls.Add(this.btnRun);
|
||||
this.Name = "TestFrm";
|
||||
this.Text = "TestFrm";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button btnRun;
|
||||
}
|
||||
}
|
||||
49
VisionEditTest/TestFrmIn.cs
Normal file
49
VisionEditTest/TestFrmIn.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace VisionEditTest
|
||||
{
|
||||
public partial class TestFrmIn : Form
|
||||
{
|
||||
public string inputText { get; set; } = null;
|
||||
/// <summary>
|
||||
/// 当前工具所对应的工具对象
|
||||
/// </summary>
|
||||
internal ShapeMatchTool shapeMatchTool = new ShapeMatchTool();
|
||||
/// <summary>
|
||||
/// 窗体对象实例
|
||||
/// </summary>
|
||||
private static TestFrmIn _instance;
|
||||
public static TestFrmIn Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
_instance = new TestFrmIn();
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public TestFrmIn()
|
||||
{
|
||||
InitializeComponent();
|
||||
//this.inputText = inputText;
|
||||
}
|
||||
|
||||
private void btnRun_Click(object sender, EventArgs e)
|
||||
{
|
||||
if(inputText != null)
|
||||
{
|
||||
MessageBox.Show(inputText);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
120
VisionEditTest/TestFrmIn.resx
Normal file
120
VisionEditTest/TestFrmIn.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
180
VisionEditTest/ToolInfo.cs
Normal file
180
VisionEditTest/ToolInfo.cs
Normal file
@@ -0,0 +1,180 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VisionEditTest
|
||||
{
|
||||
/// <summary>
|
||||
/// 工具信息类
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ToolInfo
|
||||
{
|
||||
public enum DataType
|
||||
{
|
||||
String,
|
||||
Region,
|
||||
Image,
|
||||
Point,
|
||||
Line,
|
||||
Circle,
|
||||
Pose,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工具的输入输出类
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ToolIO
|
||||
{
|
||||
public ToolIO() { }
|
||||
public ToolIO(string IOName1, object value1, DataType ioType1)
|
||||
{
|
||||
this.IOName = IOName1;
|
||||
this.value = value1;
|
||||
this.ioType = ioType1;
|
||||
}
|
||||
|
||||
public string IOName;
|
||||
public object value;
|
||||
public DataType ioType;
|
||||
}
|
||||
|
||||
public ToolInfo()
|
||||
{
|
||||
enable = true;
|
||||
toolType = ToolType.None;
|
||||
toolName = string.Empty;
|
||||
tool = new object();
|
||||
input = new List<ToolIO>();
|
||||
output = new List<ToolIO>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工具是否启用
|
||||
/// </summary>
|
||||
public bool enable;
|
||||
/// <summary>
|
||||
/// 工具名称
|
||||
/// </summary>
|
||||
public string toolName;
|
||||
/// <summary>
|
||||
/// 工具类型
|
||||
/// </summary>
|
||||
public ToolType toolType;
|
||||
/// <summary>
|
||||
/// 工具对象
|
||||
/// </summary>
|
||||
public object tool;
|
||||
/// <summary>
|
||||
/// 工具描述信息
|
||||
/// </summary>
|
||||
public string toolTipInfo = string.Empty;
|
||||
/// <summary>
|
||||
/// 工具输入字典集合
|
||||
/// </summary>
|
||||
public List<ToolIO> input;
|
||||
/// <summary>
|
||||
/// 工具输出字典集合
|
||||
/// </summary>
|
||||
public List<ToolIO> output;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 以IO名获取IO对象
|
||||
/// </summary>
|
||||
/// <param name="IOName"></param>
|
||||
/// <returns></returns>
|
||||
public ToolIO GetInput(string IOName)
|
||||
{
|
||||
for (int i = 0; i < input.Count; i++)
|
||||
{
|
||||
if (input[i].IOName == IOName)
|
||||
return input[i];
|
||||
}
|
||||
return new ToolIO();
|
||||
}
|
||||
/// <summary>
|
||||
/// 以IO名获取IO对象
|
||||
/// </summary>
|
||||
/// <param name="IOName"></param>
|
||||
/// <returns></returns>
|
||||
public ToolIO GetOutput(string IOName)
|
||||
{
|
||||
for (int i = 0; i < output.Count; i++)
|
||||
{
|
||||
if (output[i].IOName == IOName)
|
||||
return output[i];
|
||||
}
|
||||
return new ToolIO();
|
||||
}
|
||||
/// <summary>
|
||||
/// 移除工具输入项
|
||||
/// </summary>
|
||||
/// <param name="IOName"></param>
|
||||
public void RemoveInputIO(string IOName)
|
||||
{
|
||||
for (int i = 0; i < input.Count; i++)
|
||||
{
|
||||
if (input[i].IOName == toolName)
|
||||
input.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 移除工具输出项
|
||||
/// </summary>
|
||||
/// <param name="IOName"></param>
|
||||
public void RemoveOutputIO(string IOName)
|
||||
{
|
||||
for (int i = 0; i < output.Count; i++)
|
||||
{
|
||||
if (output[i].IOName == toolName)
|
||||
output.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工具类型
|
||||
/// </summary>
|
||||
public enum ToolType
|
||||
{
|
||||
None,
|
||||
HalconInterface,
|
||||
SDK_Basler,
|
||||
SDK_Congex,
|
||||
SDK_PointGray,
|
||||
SDK_IMAVision,
|
||||
SDK_MindVision,
|
||||
SDK_HIKVision,
|
||||
ShapeMatch,
|
||||
EyeHandCalibration,
|
||||
CircleCalibration,
|
||||
SubImage,
|
||||
BlobAnalyse,
|
||||
FindLine,
|
||||
FindCircle,
|
||||
CreateROI,
|
||||
CreatePosition,
|
||||
CoorTrans,
|
||||
OCR,
|
||||
Barcode,
|
||||
RegionFeature,
|
||||
RegionOperation,
|
||||
QRCode,
|
||||
KeyenceSR1000,
|
||||
DownCamAlign,
|
||||
ColorToRGB,
|
||||
DistancePL,
|
||||
DistanceSS,
|
||||
LLPoint,
|
||||
CodeEdit,
|
||||
Label,
|
||||
Logic,
|
||||
Output,
|
||||
CreateLine,
|
||||
}
|
||||
}
|
||||
106
VisionEditTest/VisionEditTest.csproj
Normal file
106
VisionEditTest/VisionEditTest.csproj
Normal file
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{BF03A00C-35B5-470E-A335-0A78FD0478A6}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>VisionEditTest</RootNamespace>
|
||||
<AssemblyName>VisionEditTest</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="DevComponents.DotNetBar2, Version=14.0.0.15, Culture=neutral, PublicKeyToken=c39c3242a43eee2b, processorArchitecture=MSIL" />
|
||||
<Reference Include="halcondotnet">
|
||||
<HintPath>E:\VisionAndMotionPro V0.0.0.3\VisionAndMotionPro V0.0.0.3\VisionAndMotion\bin\Debug\halcondotnet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="TestForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="TestForm.Designer.cs">
|
||||
<DependentUpon>TestForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Job.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ShapeMatchTool.cs" />
|
||||
<Compile Include="TestFrmIn.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="TestFrmIn.Designer.cs">
|
||||
<DependentUpon>TestFrmIn.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ToolInfo.cs" />
|
||||
<EmbeddedResource Include="TestForm.resx">
|
||||
<DependentUpon>TestForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="TestFrmIn.resx">
|
||||
<DependentUpon>TestFrmIn.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
BIN
VisionEditTest/bin/Debug/DevComponents.DotNetBar2.dll
Normal file
BIN
VisionEditTest/bin/Debug/DevComponents.DotNetBar2.dll
Normal file
Binary file not shown.
81015
VisionEditTest/bin/Debug/DevComponents.DotNetBar2.xml
Normal file
81015
VisionEditTest/bin/Debug/DevComponents.DotNetBar2.xml
Normal file
File diff suppressed because it is too large
Load Diff
BIN
VisionEditTest/bin/Debug/VisionEditTest.exe
Normal file
BIN
VisionEditTest/bin/Debug/VisionEditTest.exe
Normal file
Binary file not shown.
6
VisionEditTest/bin/Debug/VisionEditTest.exe.config
Normal file
6
VisionEditTest/bin/Debug/VisionEditTest.exe.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
BIN
VisionEditTest/bin/Debug/VisionEditTest.pdb
Normal file
BIN
VisionEditTest/bin/Debug/VisionEditTest.pdb
Normal file
Binary file not shown.
BIN
VisionEditTest/bin/Debug/VisionEditTest.vshost.exe
Normal file
BIN
VisionEditTest/bin/Debug/VisionEditTest.vshost.exe
Normal file
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
BIN
VisionEditTest/bin/Debug/halcondotnet.dll
Normal file
BIN
VisionEditTest/bin/Debug/halcondotnet.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
VisionEditTest/obj/Debug/VisionEditTest.TestForm.resources
Normal file
BIN
VisionEditTest/obj/Debug/VisionEditTest.TestForm.resources
Normal file
Binary file not shown.
BIN
VisionEditTest/obj/Debug/VisionEditTest.TestFrmIn.resources
Normal file
BIN
VisionEditTest/obj/Debug/VisionEditTest.TestFrmIn.resources
Normal file
Binary file not shown.
@@ -0,0 +1,13 @@
|
||||
F:\VSCode\VisionEditTest\VisionEditTest\bin\Debug\VisionEditTest.exe.config
|
||||
F:\VSCode\VisionEditTest\VisionEditTest\obj\Debug\VisionEditTest.Properties.Resources.resources
|
||||
F:\VSCode\VisionEditTest\VisionEditTest\obj\Debug\VisionEditTest.csproj.GenerateResource.Cache
|
||||
F:\VSCode\VisionEditTest\VisionEditTest\bin\Debug\VisionEditTest.exe
|
||||
F:\VSCode\VisionEditTest\VisionEditTest\bin\Debug\VisionEditTest.pdb
|
||||
F:\VSCode\VisionEditTest\VisionEditTest\bin\Debug\DevComponents.DotNetBar2.dll
|
||||
F:\VSCode\VisionEditTest\VisionEditTest\bin\Debug\halcondotnet.dll
|
||||
F:\VSCode\VisionEditTest\VisionEditTest\bin\Debug\DevComponents.DotNetBar2.xml
|
||||
F:\VSCode\VisionEditTest\VisionEditTest\obj\Debug\VisionEditTest.exe
|
||||
F:\VSCode\VisionEditTest\VisionEditTest\obj\Debug\VisionEditTest.pdb
|
||||
F:\VSCode\VisionEditTest\VisionEditTest\obj\Debug\VisionEditTest.TestFrmIn.resources
|
||||
F:\VSCode\VisionEditTest\VisionEditTest\obj\Debug\VisionEditTest.TestForm.resources
|
||||
F:\VSCode\VisionEditTest\VisionEditTest\obj\Debug\VisionEditTest.csprojResolveAssemblyReference.cache
|
||||
Binary file not shown.
Binary file not shown.
BIN
VisionEditTest/obj/Debug/VisionEditTest.exe
Normal file
BIN
VisionEditTest/obj/Debug/VisionEditTest.exe
Normal file
Binary file not shown.
BIN
VisionEditTest/obj/Debug/VisionEditTest.pdb
Normal file
BIN
VisionEditTest/obj/Debug/VisionEditTest.pdb
Normal file
Binary file not shown.
Reference in New Issue
Block a user