/// <summary> /// 鼠标按下事件的处理函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void OnMouseDown(int button, double mapX, double mapY) { //窗体对象如果已经释放则不做任何操作 if (IsDisposed) return; //必须是左键按下 if (button != 1) return; //显示当前点击位置 DisplayCoordinates(mapX, mapY); //开始画框操作 IPoint mouseDownPoint = new PointClass(); mouseDownPoint.PutCoords(mapX, mapY); mouseDownPoint.SpatialReference = associateMapControl.SpatialReference; if (trackNewEnvelope == null) { //新建框选对象 trackNewEnvelope = new NewEnvelopeFeedbackClass(); trackNewEnvelope.Display = associateMapControl.ActiveView.ScreenDisplay; trackNewEnvelope.Start(mouseDownPoint); } }
/// <summary> /// 鼠标弹起的事件处理 /// </summary> public void OnMouseUp(double mapX, double mapY) { //必须在画框的过程中才调用鼠标弹起函数 if (trackNewEnvelope == null) return; //显示当前位置 DisplayCoordinates(mapX, mapY); //完成画框操作,获取矩形框/点 identifyEnvelope = trackNewEnvelope.Stop(); if (identifyEnvelope.IsEmpty) { IPoint mouseUpPoint = new PointClass(); mouseUpPoint.PutCoords(mapX, mapY); mouseUpPoint.SpatialReference = associateMapControl.SpatialReference; identifyEnvelope = mouseUpPoint; } identifyEnvelope.SpatialReference = associateMapControl.SpatialReference; //置空对象 trackNewEnvelope = null; //获取查询图层 List<LayerFilterProperties> searchLayers = SearchIdentifyLayers(); //没有图层时不进行任何操作返回 if (searchLayers == null || searchLayers.Count < 1) return; //显示查询信息 lblFeatureCount.Text = "正在查询..."; Application.DoEvents(); //对需查询的图层执行查询操作 ExecuteIdentify(searchLayers, identifyEnvelope); //显示查询结果 DisplayIdentifyResults(); //闪烁查询到的结果 flashObjects.FlashObjects(); }
/// <summary> /// 鼠标按下事件的处理函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { //窗体对象如果已经释放则不做任何操作 if (IsDisposed) return; //必须是左键按下 if (e.button != 1) return; //显示当前点击位置 DisplayCoordinates(e.mapX, e.mapY); //开始画框操作 IPoint mouseDownPoint = new PointClass(); mouseDownPoint.PutCoords(e.mapX, e.mapY); mouseDownPoint.SpatialReference = pAxMapControl.SpatialReference; if (trackNewEnvelope == null) { //新建框选对象 trackNewEnvelope = new NewEnvelopeFeedbackClass(); trackNewEnvelope.Display = pAxMapControl.ActiveView.ScreenDisplay; trackNewEnvelope.Start(mouseDownPoint); } }