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.
106 lines
3.5 KiB
106 lines
3.5 KiB
using ESRI.ArcGIS.Carto; |
|
using ESRI.ArcGIS.Controls; |
|
using ESRI.ArcGIS.Geodatabase; |
|
using ESRI.ArcGIS.Geometry; |
|
using KGIS.Framework.EngineEditor; |
|
using KGIS.Framework.Maps; |
|
using KGIS.Framework.Platform; |
|
using KGIS.Framework.Utils; |
|
using KGIS.Framework.Utils.Helper; |
|
using KGIS.Framework.Utils.Interface; |
|
using System; |
|
using System.Collections.Generic; |
|
|
|
namespace Kingo.Plugin.EngineEditor.Commands.Tools |
|
{ |
|
public class CmdCopySelectData : BaseToolCmd |
|
{ |
|
private EngineEditorClass editor = new EngineEditorClass(); |
|
private IHookHelper m_hookHelper; |
|
private IFeatureLayer TargetLayer = null; |
|
|
|
public override void OnCreate(object hook) |
|
{ |
|
try |
|
{ |
|
base.OnCreate(hook); |
|
if (this.m_hookHelper == null) |
|
{ |
|
this.m_hookHelper = base.m_pHookHelper; |
|
} |
|
editor.OnStopEditing += Editor_OnStopEditing; |
|
base.OnCreate(hook); |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug("矢量复制图斑初始化OnCreate异常:" + ex.Message); |
|
} |
|
} |
|
|
|
private void Editor_OnStopEditing(bool saveChanges) |
|
{ |
|
try |
|
{ |
|
(m_hookHelper.Hook as IMapControl2).CurrentTool = null; |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug(ex); |
|
} |
|
} |
|
|
|
public override void OnClick() |
|
{ |
|
base.OnClick(); |
|
List<IFeature> addFeatures = new List<IFeature>(); |
|
try |
|
{ |
|
IFeature selectedFeature = null; |
|
if (m_hookHelper.FocusMap.FeatureSelection is IEnumFeature) |
|
{ |
|
IEnumFeature enumFeature = m_hookHelper.FocusMap.FeatureSelection as IEnumFeature; |
|
while ((selectedFeature = enumFeature.Next()) != null) |
|
{ |
|
if (((IDataset)selectedFeature.Class).Name.Equals("DLTBBG")) |
|
{ |
|
continue; |
|
} |
|
if (MessageHelper.ShowYesNoAndTips($"是否从“{((IDataset)selectedFeature.Class).Name}”图层中,提取图斑?") == System.Windows.Forms.DialogResult.Yes) |
|
{ |
|
addFeatures.Add(selectedFeature); |
|
} |
|
else |
|
{ |
|
selectedFeature = null; |
|
} |
|
} |
|
if (addFeatures.Count <= 0) |
|
{ |
|
return; |
|
} |
|
Platform.Instance.SendMsg(new NotifyMsgPackage() { MsgType = "CmdCopySelectData", Content = addFeatures }); |
|
} |
|
} |
|
catch (Exception) |
|
{ |
|
throw; |
|
} |
|
} |
|
|
|
public override bool Enabled |
|
{ |
|
get |
|
{ |
|
ILayer layer = (editor as EngineEditorClass).TargetLayer; |
|
if (editor.EditState == esriEngineEditState.esriEngineStateEditing && layer != null && (layer as IFeatureLayer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon) |
|
{ |
|
return Platform.Instance.SystemType == SystemTypeEnum.DTBJK; |
|
} |
|
else |
|
{ |
|
return false; |
|
} |
|
} |
|
} |
|
} |
|
}
|
|
|