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.
103 lines
3.3 KiB
103 lines
3.3 KiB
using System; |
|
using System.Collections.Generic; |
|
using System.Linq; |
|
using System.Text; |
|
using System.Runtime.InteropServices; |
|
using ESRI.ArcGIS.ADF.BaseClasses; |
|
using ESRI.ArcGIS.SystemUI; |
|
using ESRI.ArcGIS.Controls; |
|
using ESRI.ArcGIS.Carto; |
|
using KGIS.Framework.Platform; |
|
using KGIS.Framework.Maps; |
|
|
|
namespace Kingo.Plugin.MapView.Commands |
|
{ |
|
public class AllLayerSelectableCommand : BaseCommand, ICommandSubType |
|
{ |
|
private IHookHelper m_hookHelper = null;// Env.Instance.KMap.HookHelper; |
|
public long m_subType = 2; |
|
private bool Selectable = true; |
|
|
|
public AllLayerSelectableCommand() |
|
{ |
|
} |
|
public override void OnCreate(object hook) |
|
{ |
|
if (m_hookHelper == null) |
|
{ |
|
m_hookHelper = new HookHelper(); |
|
m_hookHelper.Hook = hook; |
|
} |
|
} |
|
public override void OnClick() |
|
{ |
|
List<IFeatureLayer> allLayers = MapsManager.Instance.MapService.GetAllLayerInMap<IFeatureLayer>();// LayerHelper.GetAllLayerInMap<IFeatureLayer>(m_hookHelper.FocusMap); |
|
Selectable = !Selectable; |
|
foreach (var layer in allLayers) |
|
{ |
|
if (layer == null) |
|
continue; |
|
if (!Selectable) |
|
{ |
|
layer.Selectable = false; |
|
} |
|
else |
|
{ |
|
layer.Selectable = true; |
|
} |
|
} |
|
} |
|
public override bool Enabled |
|
{ |
|
get |
|
{ |
|
//int canSelectCount = 0; |
|
//int notCanSelectCount = 0; |
|
//List<IFeatureLayer> allLayers = Platform.Instance.MapsService.GetAllLayerInMap<IFeatureLayer>();//LayerHelper.GetAllLayerInMap<IFeatureLayer>(m_hookHelper.FocusMap); |
|
//foreach (var layer in allLayers) |
|
//{ |
|
// if (layer != null) |
|
// { |
|
// if (layer.Selectable == false) |
|
// { |
|
// notCanSelectCount++; |
|
// } |
|
// else |
|
// { |
|
// canSelectCount++; |
|
// } |
|
// } |
|
//} |
|
//if (m_subType == 1) |
|
//{ |
|
// //所有图层可选菜单 只有一种情况下不可点击(所有都已经选择上) |
|
// return !(notCanSelectCount == 0 && canSelectCount > 0); |
|
//} |
|
//else |
|
//{ |
|
// //所有图层不可选菜单只有一种情况下不可点击(所有都没选择上) |
|
// return !(canSelectCount == 0 && notCanSelectCount > 0); |
|
//} |
|
return true; |
|
} |
|
} |
|
public int GetCount() |
|
{ |
|
return 2; |
|
} |
|
public void SetSubType(int SubType) |
|
{ |
|
m_subType = SubType; |
|
} |
|
public override string Caption |
|
{ |
|
get |
|
{ |
|
if (!Selectable) |
|
return "设置所有图层可选"; |
|
else |
|
return "设置所有图层不可选"; |
|
} |
|
} |
|
} |
|
}
|
|
|