ArcGIS Pro配置中删除已有所有TAB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using System.Threading.Tasks;
using ArcGIS.Core.CIM;
using ArcGIS.Core.Data;
using ArcGIS.Core.Geometry;
using ArcGIS.Desktop.Catalog;
using ArcGIS.Desktop.Core;
using ArcGIS.Desktop.Editing;
using ArcGIS.Desktop.Extensions;
using ArcGIS.Desktop.Framework;
using ArcGIS.Desktop.Framework.Contracts;
using ArcGIS.Desktop.Framework.Dialogs;
using ArcGIS.Desktop.Framework.Threading.Tasks;
using ArcGIS.Desktop.Mapping;
using System.Xml.Linq;


namespace ProConfiguration2
{
    internal class Module1 : Module
    {
        private static Module1 _this = null;

        /// 
        /// Retrieve the singleton instance to this module here
        /// 
        public static Module1 Current
        {
            get
            {
                return _this ?? (_this = (Module1)FrameworkApplication.FindModule("ProConfiguration2_Module"));
            }
        }

        #region Overrides
        /// 
        /// Called by Framework when ArcGIS Pro is closing
        /// 
        /// False to prevent Pro from closing, otherwise True
        protected override bool CanUnload()
        {
            //TODO - add your business logic
            //return false to ~cancel~ Application close
            return true;
        }
//by gisoracle
        protected  void OnUpdateDatabase(System.Xml.Linq.XDocument database)
        {
            var nsp = database.Root.Name.Namespace;
            var tabElements = from seg in database.Root.Descendants(nsp + "tab") select seg;
            var elements = new HashSet();
            foreach (var tabElement in tabElements)
            {
                if (tabElement.Parent == null
                    || tabElement.Parent.Name.LocalName.StartsWith("backstage"))
                    continue;
                var id = tabElement.Attribute("id");
                if (id == null) continue;

                if (id.Value.StartsWith("esri"))
                    elements.Add(tabElement);
            }

            foreach (var element in elements)
            {
                element.Remove();
            }
        }
        #endregion Overrides

    }
}

 

你可能感兴趣的:(ArcGIS Pro配置中删除已有所有TAB)