//-------------------------↑公共变量或参数↑--------------------------------------------// /// <summary> /// Initializes the image dimension, mouse delegation, /// and the graphical context setup of the instance. /// </summary> /// <param name="hwndctrl"></param> public HWndCtrller(HalconDotNet.HWindowControl hwndctrl) { this._hWindowControl = hwndctrl; this._viewMode = MODE_VIEW_NONE; this._windowWidth = this._hWindowControl.Size.Width; this._windowHeight = this._hWindowControl.Size.Height; this._zoomWndFactor = (double)this._imageWidth / this._hWindowControl.Width; this._zoomAddOn = System.Math.Pow(0.9, 5); this._zoomWndSize = 150; this._ROIDispMode = MODE_INCLUDE_ROI; this._hWindowControl.HMouseUp += new HalconDotNet.HMouseEventHandler(MouseUp); this._hWindowControl.HMouseDown += new HalconDotNet.HMouseEventHandler(MouseDown); this._hWindowControl.HMouseMove += new HalconDotNet.HMouseEventHandler(MouseMove); this._hWindowControl.HMouseWheel += new HalconDotNet.HMouseEventHandler(MouseWheel); this.NotifyInfo = new InformationDelegate(DummyS); this.NotifyIconic = new IconicDelegate(DummyI); /* Graphical Stack */ this._hObjList = new System.Collections.ArrayList(20); this._GC = new GraphicContext(); this._GC.NotifyGraphicContext += new GraphicContextDelegate(ExceptionGC); /*GUI绘制窗口用参数的初始值*/ this._compRangeX = new int[] { 0, 100 }; this._compRangeY = new int[] { 0, 100 }; this._prevCompX = this._prevCompY = 0; }
/// <summary> /// Initializes the image dimension, mouse delegation, /// and the graphical context setup of the instance. /// </summary> /// <param name="hwndctrl"></param> public HWndCtrller(HalconDotNet.HWindowControl hwndctrl) { _hWndCtrl = hwndctrl; _viewMode = HWndCtrller.VIEW_MODE_NONE; _windowWidth = _hWndCtrl.Size.Width; _windowHeight = _hWndCtrl.Size.Height; ZoomWndFactor = (double)_imageWidth / _hWndCtrl.Width; ZoomAddOn = System.Math.Pow(0.9, 5); _zoomWndSize = 150; _ROIPaintMode = HWndCtrller.PAINT_MODE_INCLUDE_ROI; NotifyInfoObserver = new InformationUpdatedDelegate(DummyS); IconicUpdatedEvt = new IconicUpdatedDelegate(OnIconicUpdated); /* Graphical Stack */ _hObjEntityList = new System.Collections.ArrayList(20); _grpCntx = new GraphicContext(); _grpCntx.NotifyGraphicContext = new GraphicContextDelegate(ExceptionGC); _msgLineList = new System.Collections.Generic.List <Communal.MessageLine>(); _defaultRowlEdge = 10; _rowlEdge = new HalconDotNet.HTuple(); /*GUI绘制窗口用参数的初始值*/ _compRangeX = new int[] { 0, 100 }; _compRangeY = new int[] { 0, 100 }; _prevCompX = _prevCompY = 0; }
private bool ConvertHWndCtrlMouseSingleToDoubleClick(object sender, HalconDotNet.HMouseEventArgs e) { HalconDotNet.HWindowControl hwdctrl = sender as HalconDotNet.HWindowControl; if (hwdctrl != null) { if (e.Button == MouseButtons.Left) { if (_isSingleClick) //左键单击,已记录单击一次 { if (_hWndTag == hwdctrl.Tag.ToString()) //再次单击时,同一个窗体 { TimeSpan span = DateTime.Now - _dateTimeLast; if (span.Milliseconds + 100 <= SystemInformation.DoubleClickTime) //与上次单击记录的时间间隔小于系统定义双击时间,则重置单击记录,判定为双击 { _isSingleClick = false; //左键单击记录复位 return(true); } else { return(false); } } else { return(false); } } //左键单击,未记录单击一次,则当前记录单击一次,判定为非双击 else { _isSingleClick = true; //单击一次 _dateTimeLast = DateTime.Now; _hWndTag = hwdctrl.Tag.ToString(); return(false); } }//非左键单击,判定为非双击 else { return(false); } } else { return(false); } }