private void LoadingParams(string CameraLabelText, string LineDetectName, string filePath) { CameraLabel.Text = CameraLabelText; LineDetect.SaveLineDataName = LineDetectName; ho_Image = new HImage(filePath); LineDetect.ho_Image = ho_Image; if (!LineDetect.ReadParams(LineDetect.SaveLineDataName)) { MessageBox.Show("读取默认参数失败"); } //生成ROI roiController.ROIList.Clear(); roiController.roiMode = ROIRectangle2; ROIRectangle2.midR = (LineDetect.hv_MeasureRow1 + LineDetect.hv_MeasureRow2) / 2; ROIRectangle2.midC = (LineDetect.hv_MeasureColumn1 + LineDetect.hv_MeasureColumn2) / 2; HOperatorSet.AngleLx(LineDetect.hv_MeasureRow1, LineDetect.hv_MeasureColumn1, LineDetect.hv_MeasureRow2, LineDetect.hv_MeasureColumn2, out HTuple AngleL); ROIRectangle2.phi = -Convert.ToDouble(AngleL.ToString()); HOperatorSet.DistancePp(LineDetect.hv_MeasureRow1, LineDetect.hv_MeasureColumn1, LineDetect.hv_MeasureRow2, LineDetect.hv_MeasureColumn2, out HTuple LengthL); ROIRectangle2.length1 = Convert.ToDouble(LengthL.ToString()) / 2; ROIRectangle2.length2 = LineDetect.hv_MeasureLength1; roiController.roiMode.createROI(ROIRectangle2.midC, ROIRectangle2.midR); LineDetect.RefreshParams(); ReDraw(); roiController.ROIList.Add(roiController.roiMode); roiController.activeROIidx = -1; HWndCtrl.addIconicVar(ho_Image); HWndCtrl.resetAll(); HWndCtrl.repaint(); SendMessage(this.TLPanel_Bottom.Handle, WM_SETREDRAW, 0, IntPtr.Zero);//禁止重绘 TLPCheckParam.Controls.Clear(); TLPCheckParam.Controls.Add(LineDetect); LineDetect.Show(); SendMessage(TLPanel_Bottom.Handle, WM_SETREDRAW, 1, IntPtr.Zero); //取消禁止 TLPanel_Bottom.Refresh(); //刷新控件 }
private void checkBox1_CheckedChanged(object sender, EventArgs e) { SendMessage(this.TLPanel_Bottom.Handle, WM_SETREDRAW, 0, IntPtr.Zero);//禁止重绘 if (this.checkBox1.Checked == true) { this.label1.Visible = false; this.TLPanel_Frame1.SetColumnSpan(this.TLPanel_BGM1, 10); this.TLPanel_Frame2.SetColumnSpan(this.TLPanel_BGM2, 10); } else if (this.checkBox1.Checked == false) { this.TLPanel_Frame1.SetColumnSpan(this.TLPanel_BGM1, 8); this.TLPanel_Frame2.SetColumnSpan(this.TLPanel_BGM2, 8); this.label1.Visible = true; } SendMessage(TLPanel_Bottom.Handle, WM_SETREDRAW, 1, IntPtr.Zero);//取消禁止 TLPanel_Bottom.Refresh(); }
///<summary> ///程序初始化 ///</summary> public void Initialization() { //实例化:检测画面子菜单 LineDetect = new LineDetect(); LineDetect.TopLevel = false; LineDetect.Dock = DockStyle.Fill; LineDetect.FormBorderStyle = FormBorderStyle.None; LineDetect.Size = TLPCheckParam.Size; ROIRectangle2 = new ROIRectangle2(); ho_Image = null; hv_ImageWindow = HWControl1.HalconID; InspectionStandard = new InspectionStandard(); InspectionStandard.TopLevel = false; InspectionStandard.Dock = DockStyle.Fill; InspectionStandard.FormBorderStyle = FormBorderStyle.None; InspectionStandard.Size = TLPCheckParam.Size; SendMessage(this.TLPanel_Bottom.Handle, WM_SETREDRAW, 0, IntPtr.Zero);//禁止重绘 TLPCheckParam.Controls.Clear(); TLPCheckParam.Controls.Add(InspectionStandard); InspectionStandard.Show(); SendMessage(TLPanel_Bottom.Handle, WM_SETREDRAW, 1, IntPtr.Zero); //取消禁止 TLPanel_Bottom.Refresh(); //刷新控件 // //画面缩放 roiController = new ROIController(); HWndCtrl = new HWndCtrl(HWControl1); HWndCtrl.useROIController(roiController); HWndCtrl.setViewState(HWndCtrl.MODE_VIEW_ZOOM); HWndCtrl.setViewState(HWndCtrl.MODE_VIEW_MOVE); HWndCtrl.ReDrawEvent += new HWndCtrl.ReDrawDelegate(ReDraw); //更改测量矩形,重绘直线 LineDetect.ReviewLineEvent += new LineDetect.ReviewLineDelegate(ReviewLine); //参数更改,重绘直线 HWndCtrl.ImageProcessingEvent += HWndCtrl_ImageProcessingEvent; if (ho_Image != null) { HWndCtrl.addIconicVar(ho_Image); HWndCtrl.repaint(); } // }
private void Button_Standard_Click(object sender, EventArgs e) { SendMessage(this.TLPanel_Bottom.Handle, WM_SETREDRAW, 0, IntPtr.Zero);//禁止重绘 TLPCheckParam.Controls.Clear(); TLPCheckParam.Controls.Add(InspectionStandard); InspectionStandard.Show(); SendMessage(TLPanel_Bottom.Handle, WM_SETREDRAW, 1, IntPtr.Zero); //取消禁止 TLPanel_Bottom.Refresh(); //刷新控件 //按钮点击效果 this.Button_Standard.BackgroundImage = global::通用架构.Properties.Resources.PicChangeParam_Gray; Task Button_Standards_Active = new Task(() => { Delay(100); this.Button_Standard.BackgroundImage = global::通用架构.Properties.Resources.PicChangeParam_White; }); Button_Standards_Active.Start(); // }