Beispiel #1
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
            {
                return;
            }
            IFeatureLayer curLayer = getEditLayer.isExistLayer(m_MapControl.Map) as IFeatureLayer;

            if (curLayer == null)
            {
                return;
            }
            IFeatureSelection curLayerSn = curLayer as IFeatureSelection;

            IMapControl2 pMapCtl = m_hookHelper.Hook as IMapControl2;

            ESRI.ArcGIS.Geometry.IGeometry pGeometry = pMapCtl.TrackLine();
            if (pGeometry == null)
            {
                return;
            }
            if (pGeometry.GeometryType != esriGeometryType.esriGeometryPolyline)
            {
                return;
            }



            IFeature pFeatureCreated = IFeatureClass_Create(curLayer.FeatureClass, pGeometry);

            m_MapControl.ActiveView.Refresh();
            if (pFeatureCreated == null)
            {
                return;
            }
            frmAddPt = new frmAddPoint(pFeatureCreated, m_MapControl.Map as IActiveView, curLayer);
            frmAddPt.Show();
            pMapCtl.Map.FeatureSelection.Clear();
            curLayerSn.Add(pFeatureCreated);//选择刚创建的point
            m_MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
            //m_MapControl.Map.FeatureSelection.Clear();
            //m_MapControl.Map.FeatureSelection =curLayerSn as ISelection;

            //g = 3 + 7;
            //m_MapControl.ActiveView.Refresh();
        }
Beispiel #2
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
            {
                return;
            }
            IFeatureLayer curLayer = getEditLayer.isExistLayer(m_MapControl.Map) as IFeatureLayer;

            if (curLayer == null)
            {
                return;
            }
            IFeatureSelection curLayerSn = curLayer as IFeatureSelection;

            IMapControl2 pMapCtl = m_hookHelper.Hook as IMapControl2;

            ESRI.ArcGIS.Geometry.IGeometry pGeometry = null;
            if (curLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
            {
                pGeometry = pMapCtl.TrackPolygon();
                ITopologicalOperator iTO = pGeometry as ITopologicalOperator;
                iTO.Simplify();
            }
            else if (curLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
            {
                pGeometry = pMapCtl.TrackLine();
            }
            else if (curLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint)
            {
                pGeometry = m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            }
            if (pGeometry == null)
            {
                return;
            }



            IFeature pFeatureCreated = IFeatureClass_Create(curLayer.FeatureClass, pGeometry);

            m_MapControl.ActiveView.Refresh();
            if (pFeatureCreated == null)
            {
                return;
            }
            if (curLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint)
            {
                frmAddPt = new frmAddPoint(pFeatureCreated, m_MapControl.Map as IActiveView, curLayer);
                frmAddPt.Show();
            }
            m_MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
            curLayerSn.Clear();
            pMapCtl.Map.ClearSelection();
            curLayerSn.Add(pFeatureCreated);//选择刚创建的point
            m_MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
            //m_MapControl.Map.FeatureSelection.Clear();
            //m_MapControl.Map.FeatureSelection =curLayerSn as ISelection;

            //g = 3 + 7;
            //m_MapControl.ActiveView.Refresh();
        }