Beispiel #1
0
        /// <summary>
        /// 完成新建对象,取得绘制的对象,并添加到图层中
        /// 建议在Map.DblClick或Map.MouseDown(Button = 2)事件中调用本方法
        /// </summary>
        public void NewFeatureEnd()
        {
            IGeometry        pGeom = null;
            IPointCollection pPointCollection;

            try
            {
                if (m_pFeedback is INewMultiPointFeedback)
                {
                    INewMultiPointFeedback pMPFeed = (INewMultiPointFeedback)m_pFeedback;
                    pMPFeed.Stop();
                    pGeom = (IGeometry)m_pPointCollection;
                }
                else if (m_pFeedback is INewLineFeedback)
                {
                    INewLineFeedback pLineFeed = (INewLineFeedback)m_pFeedback;

                    pLineFeed.AddPoint(m_pPoint);
                    IPolyline pPolyLine = pLineFeed.Stop();

                    pPointCollection = (IPointCollection)pPolyLine;
                    if (pPointCollection.PointCount < 2)
                    {
                        MessageBox.Show("至少输入两个节点");
                    }
                    else
                    {
                        pGeom = (IGeometry)pPointCollection;
                    }
                }
                else if (m_pFeedback is INewPolygonFeedback)
                {
                    INewPolygonFeedback pPolyFeed = (INewPolygonFeedback)m_pFeedback;
                    pPolyFeed.AddPoint(m_pPoint);

                    IPolygon pPolygon;
                    pPolygon = pPolyFeed.Stop();
                    if (pPolygon != null)
                    {
                        pPointCollection = (IPointCollection)pPolygon;
                        if (pPointCollection.PointCount < 3)
                        {
                            MessageBox.Show("至少输入三个节点");
                        }
                        else
                        {
                            pGeom = (IGeometry)pPointCollection;
                        }
                    }
                }

                CreateFeature(pGeom);
                m_pFeedback = null;
                m_bInUse    = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
            }
        }
        public void OnDblClick()
        {
            IGeometry pResultGeometry = null;

            if (m_EngineEditLayers == null)
            {
                return;
            }
            //获取编辑目标图层
            IFeatureLayer pFeatLyr = m_EngineEditLayers.TargetLayer;

            if (pFeatLyr == null)
            {
                return;
            }
            IFeatureClass pFeatCls = pFeatLyr.FeatureClass;

            if (pFeatCls == null)
            {
                return;
            }

            switch (pFeatCls.ShapeType)
            {
            case esriGeometryType.esriGeometryPoint:
                m_newMultPtFeedBack.Stop();
                pResultGeometry     = m_pointCollection as IGeometry;
                m_newMultPtFeedBack = null;
                break;

            case esriGeometryType.esriGeometryPolyline:
                IPolyline pPolyline = null;
                pPolyline         = m_newLineFeedBack.Stop();
                pResultGeometry   = pPolyline as IGeometry;
                m_newLineFeedBack = null;
                break;

            case esriGeometryType.esriGeometryPolygon:
                IPolygon pPolygon = null;
                pPolygon          = m_newPolyFeedBack.Stop();
                pResultGeometry   = pPolygon as IGeometry;
                m_newPolyFeedBack = null;
                break;
            }

            IZAware pZAware = pResultGeometry as IZAware;

            if (pZAware == null)
            {
                return;
            }
            pZAware.ZAware = true;
            //创建新要素
            CreateFeature(pResultGeometry);
        }
Beispiel #3
0
        public void OnDblClick()
        {
            IGeometry resultGeometry = null;

            if (engineEditLayers == null)
            {
                return;
            }
            //获取编辑目标图层
            IFeatureLayer featureLayer = engineEditLayers.TargetLayer;

            if (featureLayer == null)
            {
                return;
            }
            IFeatureClass featureClass = featureLayer.FeatureClass;

            if (featureClass == null)
            {
                return;
            }
            switch (featureClass.ShapeType)
            {
            case esriGeometryType.esriGeometryMultipoint:
                newMultiPointFeedback.Stop();
                resultGeometry        = pointCollection as IGeometry;
                newMultiPointFeedback = null;
                break;

            case esriGeometryType.esriGeometryPolyline:
                IPolyline polyline = null;
                polyline        = newLineFeedback.Stop();
                resultGeometry  = polyline as IGeometry;
                newLineFeedback = null;
                break;

            case esriGeometryType.esriGeometryPolygon:
                IPolygon polygon = null;
                polygon            = newPolygonFeedback.Stop();
                resultGeometry     = polygon as IGeometry;
                newPolygonFeedback = null;
                break;
            }
            IZAware zaware = resultGeometry as IZAware;

            zaware.ZAware = true;
            CreateFeature(resultGeometry);//创建新要素
        }
        public void EndSketch()
        {
            IGeometry        resGeometry = null;
            IPointCollection pointColl   = null;

            try
            {
                if ((MyfeedBack as INewMultiPointFeedback) != null)
                {
                    INewMultiPointFeedback multiPointFeedback = MyfeedBack as INewMultiPointFeedback;
                    multiPointFeedback.Stop();
                }
                else if ((MyfeedBack as INewLineFeedback) != null)
                {
                    INewLineFeedback lineFeedback = MyfeedBack as INewLineFeedback;
                    lineFeedback.AddPoint(MycurrentMousePosition);
                    IPolyline polyline = lineFeedback.Stop();
                    pointColl = polyline as IPointCollection;
                    if (pointColl.PointCount > 1)
                    {
                        resGeometry = pointColl as IGeometry;
                    }
                }
                else if ((MyfeedBack as INewPolygonFeedback) != null)
                {
                    INewPolygonFeedback polygonFeedback = MyfeedBack as INewPolygonFeedback;
                    polygonFeedback.AddPoint(MycurrentMousePosition);
                    IPolygon polygon = polygonFeedback.Stop();
                    if (polygon != null)
                    {
                        pointColl = polygon as IPointCollection;
                        if (pointColl.PointCount > 2)
                        {
                            resGeometry = pointColl as IGeometry;
                            ITopologicalOperator pTopo = resGeometry as ITopologicalOperator;
                            if (!pTopo.IsKnownSimple)
                            {
                                pTopo.Simplify();
                            }
                        }
                    }
                }
                MyfeedBack = null;
                If_isInUse = false;
            }
            catch { return; }
        }
Beispiel #5
0
        /// <summary>
        /// 完成新建对象,取得绘制的对象,并添加到图层中
        /// 建议在Map.DblClick或Map.MouseDown(Button = 2)事件中调用本方法
        /// </summary>
        public void NewFeatureEnd()
        {
            IGeometry        pGeom = null;
            IPointCollection pPointCollection;
            object           obj = Type.Missing;

            try
            {
                if (m_pFeedback is INewMultiPointFeedback)
                {
                    INewMultiPointFeedback pMPFeed = (INewMultiPointFeedback)m_pFeedback;
                    pMPFeed.Stop();
                    pGeom = (IGeometry)m_pPointCollection;

                    if (m_GeometryCollection == null)
                    {
                        m_GeometryCollection = new PointClass() as IGeometryCollection;
                    }

                    m_GeometryCollection.AddGeometryCollection(pGeom as IGeometryCollection);
                }
                else if (m_pFeedback is INewLineFeedback)
                {
                    INewLineFeedback pLineFeed = (INewLineFeedback)m_pFeedback;

                    if (m_GeometryCollection == null)
                    {
                        m_GeometryCollection = new PolylineClass() as IGeometryCollection;
                    }

                    IPolyline pPolyLine = pLineFeed.Stop();

                    pPointCollection = (IPointCollection)pPolyLine;
                    if (pPointCollection.PointCount < 2)
                    {
                        MessageBox.Show("至少输入两个节点");
                    }
                    else
                    {
                        pGeom = (IGeometry)pPointCollection;
                    }

                    m_GeometryCollection.AddGeometryCollection(pGeom as IGeometryCollection);
                }
                else if (m_pFeedback is INewPolygonFeedback)
                {
                    INewPolygonFeedback pPolyFeed = (INewPolygonFeedback)m_pFeedback;

                    if (m_GeometryCollection == null)
                    {
                        m_GeometryCollection = new PolygonClass() as IGeometryCollection;
                    }

                    IPolygon pPolygon;
                    pPolygon = pPolyFeed.Stop();
                    if (pPolygon != null)
                    {
                        pPointCollection = (IPointCollection)pPolygon;
                        if (pPointCollection.PointCount < 3)
                        {
                            MessageBox.Show("至少输入三个节点");
                        }
                        else
                        {
                            pGeom = (IGeometry)pPointCollection;
                        }

                        m_GeometryCollection.AddGeometryCollection(pGeom as IGeometryCollection);
                    }
                }
                if (pFeatureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                {
                    IPolyline pline = MyMapHelp.PolygonToPolyline(m_GeometryCollection as IPolygon);
                    CreateFeature(pline as IGeometry);
                }
                else
                {
                    CreateFeature(m_GeometryCollection as IGeometry);
                }
                m_pFeedback          = null;
                m_bInUse             = false;
                m_GeometryCollection = null;
            }
            catch (Exception e)
            {
                m_pFeedback          = null;
                m_bInUse             = false;
                m_GeometryCollection = null;
                Console.WriteLine(e.Message.ToString());
            }
        }