Ejemplo n.º 1
0
        /// <summary>
        ///初始化控件image,和_halconWindow,及窗口设置的颜色
        /// </summary>
        /// <returns></returns>
        public bool init()
        {
            bool ok = false;

            exit_Image           = false;
            this._yunXingBiaoZhi = false;

            _halconWindow1  = hWindowControl1.HalconWindow;
            _hWindowControl = hWindowControl1;

            RepaintingROI += repaintingROI;

            _halconWindow1.SetColor("green");
            _halconWindow1.SetDraw("margin");

            HOperatorSet.GenEmptyObj(out _ho_Image);
            _ho_Image.Dispose();

            _roiControl = new ROIControl();
            _roiStatus  = ROIStatus.NoChioceROI;

            hWindowControl1.HMouseDown  += this.hWindowControl1_HMouseDown;
            hWindowControl1.HMouseMove  += this.hWindowControl1_HMouseMove;
            hWindowControl1.HMouseWheel += this.hWindowControl1_HMouseWheel;

            ok = true;
            return(ok);
        }
Ejemplo n.º 2
0
        private void hWindowControl1_HMouseDown(object sender, HMouseEventArgs e)
        {
            int temp_button_state;

            try
            {
                #region  无用代码
                //#region  记录鼠标状态
                //switch (e.Button)
                //{
                //    case MouseButtons.Left://鼠标左键按下检测
                //        this.Cursor = System.Windows.Forms.Cursors.Hand;//把鼠标显示为手型
                //        hWindowControl1.HalconWindow.GetMpositionSubPix(out _start_positionY, out _start_positionX, out temp_button_state);//得到亚像素组成 取得坐标,及鼠标的状态
                //        _b_leftButton = true;//记录鼠标的状态
                //        break;
                //    case MouseButtons.Right:
                //        _b_rightButton = true;//记录鼠标的状态
                //        this.Cursor = System.Windows.Forms.Cursors.Default;//把鼠标显示为手型
                //        break;
                //    case MouseButtons.Middle://鼠标中间按钮按下
                //        break;
                //    default:
                //        break;
                //}
                //#endregion
                #endregion

                #region  确定是否有选中ROI
                double col_x, row_y;
                hWindowControl1.HalconWindow.GetMpositionSubPix(out row_y, out col_x, out temp_button_state);//得到亚像素组成 取得坐标,及鼠标的状态

                this._start_positionX = col_x;
                this._start_positionY = row_y;

                int num_ = _roiControl.selectedROI(col_x, row_y);

                bool chioce_ = false;

                if (num_ == -1)
                {
                    chioce_ = false;
                }
                else
                {
                    chioce_ = true;
                }

                switch (chioce_)
                {
                case true:
                    _roiStatus = ROIStatus.ChioceROI;

                    this._roiControl.displayROI(this._halconWindow1);

                    break;

                case false:
                    _roiStatus = ROIStatus.NoChioceROI;
                    break;

                default:
                    break;
                }

                #endregion
            }
            catch (Exception ex)
            {
                StatusMessage.Text = ex.Message;//显示的运行错误
            }
        }