You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							94 lines
						
					
					
						
							3.1 KiB
						
					
					
				
			
		
		
	
	
							94 lines
						
					
					
						
							3.1 KiB
						
					
					
				using System; | 
						|
using System.Collections.Generic; | 
						|
using System.Linq; | 
						|
using System.Runtime.InteropServices; | 
						|
using ESRI.ArcGIS.ADF.BaseClasses; | 
						|
using ESRI.ArcGIS.SystemUI; | 
						|
using ESRI.ArcGIS.Controls; | 
						|
using ESRI.ArcGIS.Carto; | 
						|
using KGIS.Framework.AE.ExtensionMethod; | 
						|
using KGIS.Framework.Platform; | 
						|
using KGIS.Framework.Maps; | 
						|
using UIShell.OSGi; | 
						|
using Kingo.PluginServiceInterface; | 
						|
 | 
						|
namespace Kingo.Plugin.MapView.Commands | 
						|
{ | 
						|
    [Guid("d6cf0401-78d0-4f87-b6e4-7b306f7d2014")] | 
						|
    [ClassInterface(ClassInterfaceType.None)] | 
						|
    [ProgId("KGIS.Commands.LayerSelectableCommand")] | 
						|
    public class LayerSelectableCommand : BaseCommand, ICommandSubType | 
						|
    { | 
						|
        public long m_subType = 2; | 
						|
        private IHookHelper m_hookHelper = null; | 
						|
        private IDataCatalogService _DataCatalog = null; | 
						|
        private IFeatureLayer FeatureLayer = null; | 
						|
        private LayerCfg layerCfg = null; | 
						|
        public override void OnCreate(object hook) | 
						|
        { | 
						|
            if (m_hookHelper == null) | 
						|
            { | 
						|
                m_hookHelper = new HookHelper | 
						|
                { | 
						|
                    Hook = hook | 
						|
                }; | 
						|
            } | 
						|
        } | 
						|
        public override void OnClick() | 
						|
        { | 
						|
            if (layerCfg != null && FeatureLayer != null) | 
						|
            { | 
						|
                if (layerCfg.Selectable) | 
						|
                { | 
						|
                    FeatureLayer.Selectable = false; | 
						|
                } | 
						|
                else | 
						|
                { | 
						|
                    FeatureLayer.Selectable = true; | 
						|
                } | 
						|
                Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "SaveProject" }); | 
						|
                if (_DataCatalog != null) | 
						|
                    _DataCatalog.UpdateTree(); | 
						|
            } | 
						|
        } | 
						|
        public override bool Enabled | 
						|
        { | 
						|
            get | 
						|
            { | 
						|
                return true; | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        public int GetCount() | 
						|
        { | 
						|
            return 3; | 
						|
        } | 
						|
        public void SetSubType(int SubType) | 
						|
        { | 
						|
            m_subType = SubType; | 
						|
        } | 
						|
        public override string Caption | 
						|
        { | 
						|
            get | 
						|
            { | 
						|
                if (_DataCatalog == null) | 
						|
                    _DataCatalog = BundleRuntime.Instance.GetFirstOrDefaultService<IDataCatalogService>(); | 
						|
                if (_DataCatalog.CurrentLayers == null) return "图层不可选"; | 
						|
                LayerCfg layerInfo = _DataCatalog.CurrentLayers as LayerCfg; | 
						|
                List<LayerCfg> lists = layerInfo.GetAllItem(); | 
						|
                FeatureLayer = m_hookHelper.GetCustomProperty() as IFeatureLayer; | 
						|
                if (!(m_hookHelper.GetCustomProperty() is FeatureLayer)) | 
						|
                { | 
						|
                    m_hookHelper.Hook = MapsManager.Instance.MapService.Hook; | 
						|
                    FeatureLayer = m_hookHelper.GetCustomProperty() as IFeatureLayer; | 
						|
                } | 
						|
                if (FeatureLayer == null) return "图层不可选"; | 
						|
                layerCfg = lists.FirstOrDefault(x => x.LayerName == FeatureLayer.Name); | 
						|
                if (layerCfg != null && !layerCfg.Selectable) | 
						|
                    return "图层可选"; | 
						|
                else | 
						|
                    return "图层不可选"; | 
						|
            } | 
						|
        } | 
						|
    } | 
						|
}
 | 
						|
 |