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.
97 lines
2.9 KiB
97 lines
2.9 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.AE.ExtensionMethod; |
|
using KGIS.Framework.Platform; |
|
using KGIS.Framework.Maps; |
|
|
|
namespace Kingo.Plugin.MapView.Commands |
|
{ |
|
[Guid("d6cf0401-78d0-4f87-b6e4-7b306f7d2014")] |
|
[ClassInterface(ClassInterfaceType.None)] |
|
[ProgId("KGIS.Commands.LayerSelectableCommand")] |
|
public class LayerSelectableOnlyOneCommand : BaseCommand, ICommandSubType |
|
{ |
|
//private IMapControl3 m_mapControl; |
|
public long m_subType = 1; |
|
private bool Selectable = true; |
|
private IHookHelper m_hookHelper = null; |
|
public void LayerSelectable() |
|
{ |
|
} |
|
public override void OnCreate(object hook) |
|
{ |
|
if (m_hookHelper == null) |
|
{ |
|
m_hookHelper = new HookHelper(); |
|
m_hookHelper.Hook = hook; |
|
} |
|
} |
|
public override void OnClick() |
|
{ |
|
IFeatureLayer layer = m_hookHelper.GetCustomProperty() as IFeatureLayer; |
|
if (layer == null) |
|
{ |
|
m_hookHelper.Hook = MapsManager.Instance.MapService.Hook; |
|
layer = m_hookHelper.GetCustomProperty() as IFeatureLayer; |
|
} |
|
if (layer != null) |
|
{ |
|
//if (m_subType == 1) |
|
//{ |
|
// layer.Selectable = true; |
|
//} |
|
//else if (m_subType == 2) |
|
//{ |
|
List<IFeatureLayer> allLayers = MapsManager.Instance.MapService.GetAllLayerInMap<IFeatureLayer>();//LayerHelper.GetAllLayerInMap<IFeatureLayer>(this.m_hookHelper.FocusMap); |
|
foreach (var item in allLayers) |
|
{ |
|
if (item != null) |
|
{ |
|
item.Selectable = !Selectable; |
|
} |
|
} |
|
layer.Selectable = Selectable; |
|
Selectable = !Selectable; |
|
//} |
|
//else if (m_subType == 3) |
|
//{ |
|
// layer.Selectable = false; |
|
//} |
|
} |
|
} |
|
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 (Selectable) |
|
return "将此图层设置成唯一可选图层"; |
|
else |
|
return "将此图层设置成唯一不可选图层"; |
|
|
|
} |
|
} |
|
} |
|
}
|
|
|