我自己的编写环境
using Cognex.VisionPro.Implementation;
using myCogTool;
using System;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Windows.Forms;
namespace Cognex.VisionPro.ExtraTools
{
[Serializable]
[CogDefaultToolInputTerminal(0, "InputImage", "InputImage")]
[CogDefaultToolOutputTerminal(0, "MaskImage", "MaskImage")]
[Editor(typeof(myCogToolEdit), typeof(Control))]
public class myCogTool1:CogToolBase
{
/// <summary>
/// 用默认值初始化一个新对象
/// </summary>
public myCogTool1()
{
}
/// <summary>
/// 拷贝构造函数。用另一个对象的成员值初始化一个对象
/// </summary>
/// <param name="src">要复制的工具</param>
public myCogTool1(myCogTool1 src) : base(src)
{
}
/// <summary>
/// 克隆功能,使用复制构造函数将类克隆为新对象
/// </summary>
/// <returns></returns>
protected override object Clone()
{
Object newObj = new myCogTool1(this);
return newObj;
}
/// <summary>
/// Required for saving the tool. No code needed in this
/// function as it is handled by the base class
///保存工具时需要。此文件中不需要任何代码函数,因为它是由基类处理的
/// </summary>
/// <param name="info"></param>
/// <param name="context"></param>
private myCogTool1(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
/// <summary>
/// 由CreateCurrentRecord方法调用,用于创建包含工具当前状态的记录。
/// </summary>
/// <param name="newRecord">新创建的当前记录,派生工具可以向其添加新的子记录</param>
/// <param name="currentRecordEnable">CurrentRecordEnable属性的值</param>
protected override void InternalCreateCurrentRecord(ICogRecord newRecord, int currentRecordEnable)
{
}
/// <summary>
/// 由CreateLastRunRecord方法调用,用于创建包含工具在最后一次调用其Run方法后的状态的记录。
/// </summary>
/// <param name="newRecord">新创建的LastRun记录,派生工具可以向其添加新的子记录</param>
/// <param name="lastRunRecordEnable">lastunrecordenable属性在最后一次调用其Run方法时的值</param>
/// <param name="lastRunRecordDiagEnable">lastunrecorddiagenable属性在最后一次调用其Run方法时的值</param>
protected override void InternalCreateLastRunRecord(ICogRecord newRecord, int lastRunRecordEnable, int lastRunRecordDiagEnable)
{
}
/// <summary>
/// 由Run方法调用,以执行工具的主要处理
/// </summary>
/// <param name="message">可以在InternalRun函数中设置,以便在RunStatus对象中保存消息</param>
/// <returns></returns>
protected override CogToolResultConstants InternalRun(ref string message)
{
message = "消息已经弹出";
MessageBox.Show("这是由自定义控件myCogTool弹出的窗口");
return CogToolResultConstants.Accept;
}
}
}
public myCogTool1 Subject
{
get { return (Cognex.VisionPro.ExtraTools.myCogTool1)base.GetSubject(); }
set
{
if (base.GetSubject() != value)
{
base.SetSubject(value);
}
}
}
这里有点问题就是Cognex.VisionPro.ExtraTools这一段
public Form1()
{
InitializeComponent();
myCogTool1 mycogTool = new myCogTool1();
CogSerializer.SaveObjectToFile(mycogTool, Directory.GetCurrentDirectory() + "\\myCogTool.vtt");
}
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- hids.cn 版权所有 赣ICP备2024042780号-1
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务