using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Windows.Forms;
|
using HalconDotNet;
|
|
namespace HalconTools
|
{
|
public partial class frmMain : Form
|
{
|
public HImage mainImage;
|
public HWndCtrl viewController;
|
|
public HalconTool ht = new HalconTool();
|
|
public frmMain()
|
{
|
InitializeComponent();
|
}
|
|
private void frmMain_Load(object sender, EventArgs e)
|
{
|
//mainImage = new HImage();
|
//viewController = new HWndCtrl(hWindowControl1);
|
//viewController.resetAll();
|
//viewController.setViewState(HWndCtrl.MODE_VIEW_NONE);
|
//viewController.addIconicVar(mainImage);
|
//viewController.repaint();
|
|
ht.resultCreater.ListenEvent += new EventHandler<ListenEventArgs>(resultCreater_ListenEvent);
|
}
|
|
void resultCreater_ListenEvent(object sender, ListenEventArgs e)
|
{
|
string str = e.IData.Data.ToString();
|
|
switch (str)
|
{
|
case "MatchDone":
|
MessageBox.Show("Match Successfully");
|
break;
|
|
case "FindLineDone":
|
MessageBox.Show("Fit Line Successfully");
|
break;
|
|
case "FindCircleDone":
|
MessageBox.Show("Fit Circle Successfully");
|
break;
|
}
|
}
|
|
private void button1_Click(object sender, EventArgs e)
|
{
|
frmFitCircleAndLine fitForm = new frmFitCircleAndLine(Language);
|
fitForm.ShowDialog();
|
}
|
|
private void button2_Click(object sender, EventArgs e)
|
{
|
frmMeasureAssistant measureForm = new frmMeasureAssistant();
|
measureForm.ShowDialog();
|
}
|
|
private void button3_Click(object sender, EventArgs e)
|
{
|
frmMatchingAssistant matchForm = new frmMatchingAssistant();
|
matchForm.ShowDialog();
|
}
|
|
string Language = "zh-CN";
|
private void rbChinese_CheckedChanged(object sender, EventArgs e)
|
{
|
Language = "zh-CN";
|
}
|
|
private void rbEnglish_CheckedChanged(object sender, EventArgs e)
|
{
|
Language = "en-US";
|
}
|
|
private void button4_Click(object sender, EventArgs e)
|
{
|
ht.LoadMatchingParameter(Application.StartupPath + "\\MatchingConfige\\MatchingConfige.xml");
|
ht.PatterMatchWithModule("test1", mainImage, ht.matchingPara, @"C:\Users\Swbuild\Desktop\1111.shm");
|
}
|
|
private void button5_Click(object sender, EventArgs e)
|
{
|
ht.LoadFitLineParameter(Application.StartupPath + "\\MeasureConfige\\MeasureConfige.xml");
|
|
//----------------------------------------------------------------------------------
|
MessageBox.Show("请画直线");
|
|
hWindowControl1.Focus();
|
HTuple hv_Row1 = null, hv_Column1 = null, hv_Row2 = null, hv_Column2 = null;
|
HOperatorSet.DrawLine(hWindowControl1.HalconWindow, out hv_Row1, out hv_Column1, out hv_Row2, out hv_Column2);
|
|
MessageBox.Show(hv_Row1.ToString() + "," + hv_Column1.ToString() + "," + hv_Row2.ToString() + "," + hv_Column2.ToString());
|
//-----------------------------------------------------------------------------------
|
|
ht.fitLinePara.hv_RowBegin = hv_Row1.D;
|
ht.fitLinePara.hv_RowEnd = hv_Row2.D;
|
ht.fitLinePara.hv_ColumnBegin = hv_Column1.D;
|
ht.fitLinePara.hv_ColumnEnd = hv_Column2.D;
|
|
ht.ThreadFindLine("test", mainImage, ht.fitLinePara);
|
|
}
|
|
private void button6_Click(object sender, EventArgs e)
|
{
|
ht.LoadFitCircleParameter(Application.StartupPath + "\\MeasureConfige\\MeasureConfige.xml");
|
|
//----------------------------------------------------------------------------------
|
MessageBox.Show("请画圆");
|
|
hWindowControl1.Focus();
|
HTuple hv_Row = null, hv_Column = null, hv_Radius = null;
|
HOperatorSet.DrawCircle(hWindowControl1.HalconWindow, out hv_Row, out hv_Column,out hv_Radius);
|
|
MessageBox.Show(hv_Row.ToString() + "," + hv_Column.ToString() + "," + hv_Radius.ToString());
|
//-----------------------------------------------------------------------------------
|
|
ht.fitCirclePara.hv_ColumnCenter = hv_Column;
|
ht.fitCirclePara.hv_RowCenter = hv_Row;
|
ht.fitCirclePara.hv_Radius = hv_Radius;
|
|
ht.FindCircle("test", mainImage, ht.fitCirclePara);
|
}
|
|
private void button7_Click(object sender, EventArgs e)
|
{
|
frmJobManager frmJob = new frmJobManager();
|
frmJob.ShowDialog();
|
}
|
|
private void button8_Click(object sender, EventArgs e)
|
{
|
frmContourAssistant frmContour = new frmContourAssistant();
|
frmContour.ShowDialog();
|
}
|
|
private void button9_Click(object sender, EventArgs e)
|
{
|
frmScrewAssistant frmScrew = new frmScrewAssistant();
|
frmScrew.ShowDialog();
|
}
|
|
private void btnCalibrationForm_Click(object sender, EventArgs e)
|
{
|
frmCalibration frmCalib = new frmCalibration();
|
frmCalib.ShowDialog();
|
}
|
}
|
}
|