/// <summary>Closes active window, removes it from list and activates another window</summary> public override void DevCloseWindow() { if (this.activeID.I == 0) { return; } HTuple htuple1 = HDevOpMultiWindowImpl.TupleFind2(this.fixedIDs, this.activeID); if (htuple1.Length > 0) { this.fixedUsed[htuple1[0].I] = (HTupleElements)0; } else { HOperatorSet.CloseWindow(this.activeID); } HTuple htuple2 = HDevOpMultiWindowImpl.TupleFind2(this.windowIDs, this.activeID); if (htuple2.Length > 0) { this.windowIDs = this.windowIDs.TupleRemove((HTuple)htuple2[0]); } if (this.windowIDs.Length > 0) { this.activeID = (HTuple)this.windowIDs[this.windowIDs.Length - 1]; } else { this.activeID = (HTuple)0; } }
private void WindowControl_Load(object sender, EventArgs e) { Window = WindowControl.HalconWindow; // initialize display Window.SetDraw("margin"); Window.SetLineWidth(4); // handler for display operators MyHDevOperatorImpl = new HDevOpMultiWindowImpl(Window); }
/// <summary>No action for fixed windows, adapt size otherwise</summary> public override void DevSetWindowExtents( HTuple row, HTuple column, HTuple width, HTuple height) { if (HDevOpMultiWindowImpl.TupleFind2(this.fixedIDs, this.activeID).Length != 0) { return; } HOperatorSet.SetWindowExtents(this.activeID, row, column, width, height); }
public void initialengine(string filename) { programPath = System.Environment.CurrentDirectory + @"\" + filename + ".hdev"; procedurePath = System.Environment.CurrentDirectory + @"\"; if (!HalconAPI.isWindows) { programPath = programPath.Replace("\\", "/"); procedurePath = procedurePath.Replace("\\", "/"); } engine.SetProcedurePath(procedurePath); // viewPort.HalconWindow.SetLineWidth(4); MyHDevOperatorImpl = new HDevOpMultiWindowImpl(viewPort.HalconWindow); engine.SetHDevOperators(MyHDevOperatorImpl); }
private void HalconTemplateCreator_ParentChanged(object sender, EventArgs e) { if (Parent != null) { ParentForm.Text = "GenTemplate"; ParentForm.AutoSize = true; ParentForm.FormClosing += new FormClosingEventHandler(ParentForm_FormClosing); try { lineGuageParam = (LineGuageParam)FastData.SaveStatic.ReadBin(guagepath); } catch (Exception exp) { MessageBox.Show("读取文件失败!" + guagepath + exp); } transCom.Items.AddRange(new object[3] { CalipTrans.all, CalipTrans.negtive, CalipTrans.positive }); heightTxt.Text = lineGuageParam.CalipHeight.ToString(); widthTxt.Text = lineGuageParam.CalipWidth.ToString(); calipNumTxt.Text = lineGuageParam.CalipNum.ToString(); thresholdTxt.Text = lineGuageParam.CalipThreshold.ToString(); IgnoreTxt.Text = lineGuageParam.CalipIgnore.ToString(); transCom.Text = lineGuageParam.calipTrans.ToString(); if (Image != null) { button1.Enabled = false; button2.Enabled = false; engine = new HDevEngine(); program = new HDevProgram(mPath); programCall = new HDevProgramCall(program); if (impl == null) { impl = new HDevOpMultiWindowImpl(hWindowControltemp.HalconWindow); } engine.SetHDevOperators(impl); //string di = new DirectoryInfo(string.Format("{0}../../../../", Application.StartupPath)).FullName; //string aa = di + "Template"; //if (!Directory.Exists(aa)) // Directory.CreateDirectory(aa); SetTemplateOriginImage(Image); Excute(); } } }
private void 加载一张图片ToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); string initdi = new DirectoryInfo(string.Format("{0}../../../../", Application.StartupPath)).FullName; //ofd.Filter = "Excel文件(*.xls;*.xlsx)|*.xls;*.xlsx|所有文件|*.*"; ofd.CheckPathExists = true; ofd.CheckFileExists = true; ofd.InitialDirectory = initdi + "SavePic"; if (ofd.ShowDialog() == DialogResult.OK) { string strFileName = ofd.FileName; HOperatorSet.ReadImage(out hObject, strFileName); HDevOpMultiWindowImpl impl = new HDevOpMultiWindowImpl(hSmartWindowControl1.HalconWindow); impl.DevDisplay(hObject); groupBox1.Enabled = true; } }
public void Excute() { if (task.Status == TaskStatus.Created || task.IsCompleted || task.IsFaulted || task.IsCanceled) { task = new Task(() => { engine = new HDevEngine(); program = new HDevProgram(Path); programCall = new HDevProgramCall(program); if (impl == null) { impl = new HDevOpMultiWindowImpl(hSmartWindowControlcamera.HalconWindow); } engine.SetHDevOperators(impl); programCall.Execute(); }, TaskCreationOptions.LongRunning); task.Start(); } }
/// <summary>Opens a window, appends window ID and sets active window</summary> public override void DevOpenWindow( HTuple row, HTuple column, HTuple width, HTuple height, HTuple background, out HTuple windowID) { HTuple htuple = HDevOpMultiWindowImpl.TupleFind2(this.fixedUsed, (HTuple)0); if (htuple.Length > 0) { this.activeID = (HTuple)this.fixedIDs[htuple[0].I]; this.fixedUsed[htuple[0].I] = (HTupleElements)1; } else { HOperatorSet.SetWindowAttr((HTuple)"background_color", background); HOperatorSet.OpenWindow(row, column, width, height, (HTuple)0, (HTuple)"visible", (HTuple)"", out this.activeID); } this.windowIDs[this.windowIDs.Length] = (HTupleElements)this.activeID; windowID = this.activeID.Clone(); }
private void 清除窗口ToolStripMenuItem_Click(object sender, EventArgs e) { HDevOpMultiWindowImpl impl = new HDevOpMultiWindowImpl(hSmartWindowControl1.HalconWindow); impl.DevClearWindow(); }
public HalconTemplateCreator(HDevOpMultiWindowImpl _impl) { InitializeComponent(); impl = _impl; hWindowControltemp.HMouseWheel += new HalconDotNet.HMouseEventHandler(hWindowControl1_HMouseWheel); }
public void button1_Click(object sender, EventArgs e) { button1.Enabled = false; if (GetTaskStatus() == 0) { OpenFileDialog ofd = new OpenFileDialog(); string initdi = new DirectoryInfo(string.Format("{0}../../../../", Application.StartupPath)).FullName; //ofd.Filter = "Excel文件(*.xls;*.xlsx)|*.xls;*.xlsx|所有文件|*.*"; ofd.CheckPathExists = true; ofd.CheckFileExists = true; ofd.InitialDirectory = initdi + "SavePic"; if (ofd.ShowDialog() == DialogResult.OK) { engine = new HDevEngine(); program = new HDevProgram(mPath); programCall = new HDevProgramCall(program); if (impl == null) { impl = new HDevOpMultiWindowImpl(hWindowControltemp.HalconWindow); } engine.SetHDevOperators(impl); //string di = new DirectoryInfo(string.Format("{0}../../../../", Application.StartupPath)).FullName; //string aa = di + "Template"; //if (!Directory.Exists(aa)) // Directory.CreateDirectory(aa); string strFileName = ofd.FileName; SetTemplateOriginPath(strFileName); Excute(); } } else//如已经在运行,将任务先停掉,然后再调用 { OpenFileDialog ofd = new OpenFileDialog(); //ofd.Filter = "Excel文件(*.xls;*.xlsx)|*.xls;*.xlsx|所有文件|*.*"; ofd.CheckPathExists = true; ofd.CheckFileExists = true; if (ofd.ShowDialog() == DialogResult.OK) { StopTask(); Thread.Sleep(500); engine = new HDevEngine(); program = new HDevProgram(mPath); programCall = new HDevProgramCall(program); if (impl == null) { impl = new HDevOpMultiWindowImpl(hWindowControltemp.HalconWindow); } engine.SetHDevOperators(impl); //string di = new DirectoryInfo(string.Format("{0}../../../../", Application.StartupPath)).FullName; //string aa = di + "Template"; //if (!Directory.Exists(aa)) // Directory.CreateDirectory(aa); //textBox1.Text = aa + "\\template.tif"; string strFileName = ofd.FileName; SetTemplateOriginPath(strFileName); Excute(); } } button1.Enabled = true; }
private void 切换到本窗口ToolStripMenuItem_Click(object sender, EventArgs e) { impl = new HDevOpMultiWindowImpl(hSmartWindowControlcamera.HalconWindow); engine.SetHDevOperators(impl); }
public Camera(HDevOpMultiWindowImpl _impl) { InitializeComponent(); impl = _impl; hSmartWindowControlcamera.MouseWheel += new MouseEventHandler(hSmartWindowControl1_MouseWheel); }