• 大小: 6KB
    文件类型: .cs
    金币: 1
    下载: 0 次
    发布日期: 2021-05-16
  • 语言: C#
  • 标签: ArcMap  Add-I  

资源简介

提供ArcMap Add-In tool 工具开发的示例,调用方法,on_actived

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.framework;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Editor;
using System.Windows.Forms;
using System.IO;

namespace validatechange
{
    public class ChangeType00_Tool : ESRI.ArcGIS.Desktop.AddIns.Tool
    {
        IMap pMap = null;
        //IFeaturelayer pFtlyr = null; //待操作的图层  
        IEditor _Editor;

        public ChangeType00_Tool()
        {
            UID eUID = new UIDClass();
            eUID.Value = “esriEditor.Editor“;
            _Editor = ArcMap.Application.FindExtensionByCLSID(eUID) as IEditor;

            if (_Editor.EditState != esriEditState.esriStateEditing)
            {
                Enabled = false;
                return;
            }
            else
            {
                Enabled = true;
            }
        }
        protected override void OnUpdate()
        {
            if (ArcMap.Application != null)
            {
                UID eUID = new UIDClass();
                eUID.Value = “esriEditor.Editor“;
                _Editor = ArcMap.Application.FindExtensionByCLSID(eUID) as IEditor;

                if (_Editor.EditState != esriEditState.esriStateEditing)
                {
                    Enabled = false;
                    return;
                }
                else
                {
                    Enabled = true;
                }
            }  
        }
          protected override void onkeyup(KeyEventArgs arg)  
        {  
            //if (arg.KeyCode == System.Windows.Forms.Keys.Escape)  
            //    ArcMap.Application.CurrentTool = null;  
        }  
  
        protected override void onmousedown(MouseEventArgs arg)  
        {
           // MessageBox.Show(“aa“);
        }
        protected override void onactivate()
        {
            //对手工修改过的要素要临时标记
            string TempFolder = @“C:\ChangeTypeTempData“;
            if (!Directory.Exists(TempFolder))
            {
                Directory.CreateDirectory(TempFolder);
            }
            string Recprdfilepath = TempFolder + “\\temprecord.txt“;
           
           // MessageBox.Show(“aba“);
            IEnumFeature getselfeatures = getSelectedFeature(); //判断是否有选取的要素
            if (getselfeatures != null)
            { 
                //首先判断是否含有changetype字段
                IFeature feature = getselfeatures.Next();
                if (feature == null)
                    return;
                IFeatureClass pfeacls = feature.Class as IFeatureClass;
                if (pfeacls.FindField(“ChangeType“) < 0) //如果没有changetype字段,返回
                    return;
                _Editor.StartOperation();
                //IDataset dataset = (IDataset)pfeacls;
                //IWorkspace workspace = dat

评论

共有 条评论

相关资源