public override void OnMapControlMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { base.OnMapControlMouseDown(button, shift, x, y, mapX, mapY); if (m_mapCtrl != null && button == 1) { if (m_identifyResult == null) { m_identifyResult = new EsriMapIdentifyResults(m_mapCtrl); } if (m_identifyResult != null) { IGeometry idGeo = null; switch (shift) { case 0: idGeo = m_mapCtrl.ToMapPoint(x, y); double mapLen = Units.ConvertScreenPixelsToMapUnits(m_mapCtrl.ActiveView.ScreenDisplay, 10.0); idGeo = TopologicalOperator.Buffer(idGeo, mapLen); break; case 1: idGeo = m_mapCtrl.TrackPolygon(); break; case 2: idGeo = m_mapCtrl.TrackRectangle(); break; case 4: idGeo = m_mapCtrl.TrackCircle(); break; default: idGeo = m_mapCtrl.ToMapPoint(x, y); break; } if (idGeo != null & !idGeo.IsEmpty) { idGeo.SpatialReference = m_mapCtrl.Map.SpatialReference; m_identifyResult.DoEsriMapIdentify(idGeo); } m_app.AddToInfoPanel(m_identifyResult, "信息查看", true, true, true, true); } } }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { m_mapControl.MousePointer = esriControlsMousePointer.esriPointerCrosshair; if (Button == 1) { IGeometry pGeo; pGeo = m_mapControl.TrackRectangle(); m_mapControl.Map.ClearSelection(); m_mapControl.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null); m_mapControl.Map.SelectByShape(pGeo, null, false); m_mapControl.CustomProperty = m_mapControl.Map.FeatureSelection; m_mapControl.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null); } }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { if (Button != 1) { return; } //设置点选择容差 ISelectionEnvironment pSelectEnv = new SelectionEnvironmentClass(); double Length = ModPublic.ConvertPixelsToMapUnits(m_hookHelper.ActiveView, pSelectEnv.SearchTolerance); IPoint pPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); IGeometry pGeometry = pPoint as IGeometry; ITopologicalOperator pTopo = pGeometry as ITopologicalOperator; IGeometry pBuffer = pTopo.Buffer(Length); //仅与框架别界相交地物会被选取 pGeometry = m_MapControl.TrackRectangle() as IGeometry; bool bjustone = true; if (pGeometry != null) { if (pGeometry.IsEmpty) { pGeometry = pBuffer; } else { bjustone = false; } } else { pGeometry = pBuffer; } UID pUID = new UIDClass(); pUID.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}"; //UID for IFeatureLayer IEnumLayer pEnumLayer = m_MapControl.Map.get_Layers(pUID, true); pEnumLayer.Reset(); ILayer pLayer = pEnumLayer.Next(); while (pLayer != null) { if (pLayer.Visible == false) { pLayer = pEnumLayer.Next(); continue; } IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer; if (pFeatureLayer.Selectable == false) { pLayer = pEnumLayer.Next(); continue; } GetSelctionSet(pFeatureLayer, pGeometry, bjustone, Shift); pLayer = pEnumLayer.Next(); } //触发Map选择发生变化事件 ISelectionEvents pSelectionEvents = m_hookHelper.FocusMap as ISelectionEvents; pSelectionEvents.SelectionChanged(); //刷新 m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, m_hookHelper.ActiveView.Extent); AttributeShow(); }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { if (Button != 1) { return; } //设置点选择容差 ISelectionEnvironment pSelectEnv = new SelectionEnvironmentClass(); double Length = ModPublic.ConvertPixelsToMapUnits(m_hookHelper.ActiveView, pSelectEnv.SearchTolerance); IPoint pPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); IGeometry pGeometry = pPoint as IGeometry; ITopologicalOperator pTopo = pGeometry as ITopologicalOperator; IGeometry pBuffer = pTopo.Buffer(Length); //仅与框架别界相交地物会被选取 pGeometry = m_MapControl.TrackRectangle() as IGeometry; bool bjustone = true; if (pGeometry != null) { if (pGeometry.IsEmpty) { pGeometry = pBuffer; } else { bjustone = false; } } else { pGeometry = pBuffer; } UID pUID = new UIDClass(); pUID.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}"; //UID for IFeatureLayer IEnumLayer pEnumLayer = m_MapControl.Map.get_Layers(pUID, true); pEnumLayer.Reset(); ILayer pLayer = pEnumLayer.Next(); while (pLayer != null) { IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer; IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; if (pFeatureClass.ObjectClassID != ControlsAttribute.m_CurFeatCls.ObjectClassID) { pLayer = pEnumLayer.Next(); continue; } switch (Shift) { case 1: //增加选择结果集 ModPublic.GetSelctionSet(pFeatureLayer, pGeometry, pFeatureClass, esriSelectionResultEnum.esriSelectionResultAdd, bjustone); break; case 4: //减少选择结果集 ModPublic.GetSelctionSet(pFeatureLayer, pGeometry, pFeatureClass, esriSelectionResultEnum.esriSelectionResultSubtract, bjustone); break; case 2: ModPublic.GetSelctionSet(pFeatureLayer, pGeometry, pFeatureClass, esriSelectionResultEnum.esriSelectionResultXOR, bjustone); break; default: //新建选择结果集 ModPublic.GetSelctionSet(pFeatureLayer, pGeometry, pFeatureClass, esriSelectionResultEnum.esriSelectionResultNew, bjustone); break; } pLayer = pEnumLayer.Next(); } //刷新 m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, m_hookHelper.ActiveView.Extent); }