第一步,双击窗体创建加载窗体事件
cs
CogPMAlignTool pma = new CogPMAlignTool();
private void Form1_Load(object sender, EventArgs e)
{
string path = "1.vpp";
pma = CogSerializer.LoadObjectFromFile(path) as CogPMAlignTool;
pma.Ran+= Pma_Ran;
//获取查找概数
textBox1.Text = pma.RunParams.ApproximateNumberToFind.Tostring();
//获取接收阈值
munericUpDown1.Value = (decimal)pma.RunParams.AcceptThreshold;
}
其中 pma.Ran()是一个事件,代表pma执行时运行的事件,这里写的是创建一个圆
cs
private void Pma_Ran(object sender, EventArgs e)
{
//创建最近的记录,子记录索引值为0
cogRecordDisplay1.Fit();
for(int i = 0 ;i<pma.Results.Count ;i++)
{
CogPMAlignResults result = pma.Results[i];
CogCircle cir = new CogCircle();
cir.CenterX = results.GetPose().TranslationX;
cie.CenterY = results.GetPose().TranslationY;
cir.Radius = 20;
cir.LineWidthInScreenPixels = 5;//线宽
cogRecordDisplay1.StaticGraphics.Add(cir,"");
}
}
保存
cs
CogSerializer.SaveObjectToFile(pma,"1.vpp");