/// <summary>
        /// Initializes the image dimension, mouse delegation, and the
        /// graphical context setup of the instance.
        /// </summary>
        /// <param name="view"> HALCON window </param>
        #region 构造函数
        public HWndCtrl(HWindowControl view)
        {
            viewPort = view;
            //winHandle = viewPort.HalconWindow;
            view.HalconWindow.SetDraw("margin");
            view.HalconWindow.SetColor("blue");
            view.HalconWindow.SetLineWidth(1);
            //view.HalconWindow.SetWindowParam("flush", "true");

            timeMouseDoubleClick          = new Timer();
            timeMouseDoubleClick.Interval = 300;
            timeMouseDoubleClick.Tick    += TimerMouseDoubleClick_Tick;

            windowWidth  = viewPort.Size.Width;
            windowHeight = viewPort.Size.Height;

            ZoomWndFactor = (double)imageWidth / viewPort.Width;
            showMode      = ShowMode.IncludeROI;

            viewPort.HMouseUp   += new HalconDotNet.HMouseEventHandler(this.mouseUp);
            viewPort.HMouseDown += new HalconDotNet.HMouseEventHandler(this.mouseDown);
            viewPort.HMouseMove += new HalconDotNet.HMouseEventHandler(this.mouseMoved);
            //新添加滚轮事件
            viewPort.HMouseWheel += new HalconDotNet.HMouseEventHandler(this.mouseWheel);

            // graphical stack
            HObjList = new List <HObjectEntry>();
            mGC      = new GraphicsContext();

            fit_strip        = new ToolStripMenuItem("适应窗口");
            fit_strip.Click += new EventHandler((s, e) => DispImageFit());   //没有带(s,e)格式参数的函数,事件调用需要Lambd表达式形式。

            MoveWindowEnable_strip        = new ToolStripMenuItem("允许移动窗口");
            MoveWindowEnable_strip.Click += new EventHandler((s, e) =>
            {
                isMoveEnable = !isMoveEnable;
            });
            MoveWindowEnable_strip.CheckOnClick = true;

            fit_showImageOnly              = new ToolStripMenuItem("显示原图/所有");
            fit_showImageOnly.Click       += new EventHandler((s, e) => ShowImageOnly());
            fit_showImageOnly.CheckOnClick = true;

            saveImg_strip        = new ToolStripMenuItem("保存原始图像");
            saveImg_strip.Click += new EventHandler((s, e) => SaveImage());

            saveWindow_strip        = new ToolStripMenuItem("截图另存");
            saveWindow_strip.Click += new EventHandler((s, e) => SaveWindowDump());

            showCross_shrip              = new ToolStripMenuItem("显示/隐藏十字");
            showCross_shrip.Click       += new EventHandler((s, e) => ShowCross());
            showCross_shrip.CheckOnClick = true;

            showMessage_strip              = new ToolStripMenuItem("显示/隐藏文字");
            showMessage_strip.Click       += new EventHandler((s, e) => ShowMessage());
            showMessage_strip.CheckOnClick = true;

            ShowHistogram_strip        = new ToolStripMenuItem("灰度直方图");
            ShowHistogram_strip.Click += ShowHistogram_strip_Click;

            measureLine_strip        = new ToolStripMenuItem("距离测量");
            measureLine_strip.Click += MeasureLine_strip_Click;

            hv_MenuStrip = new ContextMenuStrip();
            hv_MenuStrip.Items.Add(fit_strip);
            hv_MenuStrip.Items.Add(MoveWindowEnable_strip);
            hv_MenuStrip.Items.Add(new ToolStripSeparator());
            hv_MenuStrip.Items.Add(fit_showImageOnly);
            hv_MenuStrip.Items.Add(showCross_shrip);
            hv_MenuStrip.Items.Add(showMessage_strip);
            hv_MenuStrip.Items.Add(measureLine_strip);
            hv_MenuStrip.Items.Add(ShowHistogram_strip);
            hv_MenuStrip.Items.Add(new ToolStripSeparator());
            hv_MenuStrip.Items.Add(saveImg_strip);
            hv_MenuStrip.Items.Add(saveWindow_strip);

            viewPort.ContextMenuStrip = hv_MenuStrip;
            //m_CtrlHStatusLabelCtrl.BringToFront();
            //viewPort.ResumeLayout(false);
            //viewPort.PerformLayout();
            //HOperatorSet.SetSystem("filename_encoding", "utf8");
        }