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());


                }
            }
        }
    }
  • 相关阅读:
    python应用之文件属性浏览
    python进阶之路之文件处理
    magento安装时的数据库访问错误
    magento麦进斗客户地址属性不保存在sales_flat_order_address
    自动填写麦进斗Magento进货地址字段
    麦进斗magentoRequireJs回调失败
    如何在麦进斗magento2中调用站外的JS?
    在magento1.9结账地址中删除验证
    麦进斗:在windows系统里面刷新magento2的缓存
    如何安装麦进斗Magento2
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1454519.html
Copyright © 2011-2022 走看看