zoukankan      html  css  js  c++  java
  • 用移动的element选择Features

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using ESRI.ArcGIS.DataSourcesGDB;
    using ESRI.ArcGIS.esriSystem;
    using ESRI.ArcGIS.Geodatabase;
    using ESRI.ArcGIS.Carto;
    using ESRI.ArcGIS.Geometry;
    using ESRI.ArcGIS.Display;

    namespace WindowsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }

            private void button1_Click(object sender, EventArgs e)
            {
                IPropertySet pPS = new PropertySetClass();
                IWorkspaceFactory pWF = new SdeWorkspaceFactoryClass();
                pPS.SetProperty("Server","8B63691CDAE4488");
                pPS.SetProperty("Instance", "5159");
                pPS.SetProperty("Database", "TestElementEdit");
                pPS.SetProperty("User", "sde");
                pPS.SetProperty("Password", "zhangjun1130");
                pPS.SetProperty("Version", "sde.default");
                IWorkspace pWs = pWF.Open(pPS, 0);
                IFeatureWorkspace pFWs=pWs as IFeatureWorkspace;


                IFeatureClass pFC = pFWs.OpenFeatureClass("ElementEdit");
                IFeatureLayer pFL = new FeatureLayerClass();
                pFL.FeatureClass = pFC;

                axMapControl1.AddLayer(pFL);


            }

            private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
            {

                if (radioButton3.Checked == true)
                {
                    IPolygon pPolygon = (IPolygon)axMapControl1.TrackPolygon();
                    IGraphicsContainer pGC = (IGraphicsContainer)axMapControl1.Map;
                    IActiveView pActiver = (IActiveView)axMapControl1.Map;
                    IPolygonElement pPolygonElement = new PolygonElementClass();
                    IElement pElement = (IElement)pPolygonElement;
                    IElementEditVertices pElementEditVertices = (IElementEditVertices)pPolygonElement;
                    pElement.Geometry = pPolygon;
                    pGC.AddElement(pElement, 0);
                    pActiver.Refresh();
                pElementEditVertices.MovingVertices = true;
                //ISelectionTracker pST=null;
                //pElementEditVertices.GetMoveVerticesSelectionTracker();
                }

            }

            private void axMapControl1_OnMouseUp(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseUpEvent e)
            {
                if (radioButton1.Checked == true)
                {
                    IGraphicsContainer pGC = (IGraphicsContainer)axMapControl1.Map;
                    IGraphicsContainerSelect pGCS = (IGraphicsContainerSelect)pGC;
                    IEnumElement pEE = pGCS.SelectedElements;
                    IElement pE = pEE.Next();
                    IElementEditVertices pEEV = pE as IElementEditVertices;
                    pEEV.MovingVertices = true;
                    ISpatialFilter pSF = new SpatialFilterClass();
                    pSF.GeometryField = "Shape";
                    pSF.Geometry = pE.Geometry;
                    pSF.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

                    IFeatureSelection pFS = axMapControl1.Map.get_Layer(0) as IFeatureSelection;
                    pFS.SelectFeatures(pSF, esriSelectionResultEnum.esriSelectionResultNew, false);
                    (axMapControl1.Map as IActiveView).Refresh();
                   
                    ISelection pS = axMapControl1.Map.FeatureSelection;
                    IEnumFeature pEF = (IEnumFeature)pS;
                    int i = 0;
                    IFeature pF = pEF.Next();
                    while (pF!= null)
                    {
                        i++;
                        pF=pEF.Next();
                    }
                    MessageBox.Show(i.ToString());


                }
            }
        }
    }
  • 相关阅读:
    使用Eclipse创建Maven的JSP项目
    MySQL远程访问
    IDEA创建web工程,不用Archetype(超简单)
    IDEA创建web工程(超简单)
    共享软件
    C语言讲义——链表完整代码
    base64图片显示问题
    JAVA 判断一个字符串是否是合法的日期格式?
    SpringBoot配置本地文件映射路径
    SpringBoot读取资源目录下的文件
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1454519.html
Copyright © 2011-2022 走看看