using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Controls; using ESRI.ArcGIS.Geodatabase; using KGIS.Framework.AE.ExtensionMethod; using KGIS.Framework.Maps; using KGIS.Framework.Utils; using KGIS.Framework.Utils.Helper; using Kingo.Plugin.DataLoad.Views; using System; namespace Kingo.Plugin.DataLoad.Commands { /// /// 图层右键数据导入 /// public class CmdLayerDataImport : BaseMapMenuCommand { private IEngineEditor editor = null; private new IHookHelper m_hookHelper = null; public override void OnClick()//OpenAttributeTableCommand { try { if (editor == null) { editor = new EngineEditorClass(); } object pTargetObj = m_hookHelper.GetCustomProperty(); if (pTargetObj is IFeatureLayer) { IFeatureLayer pFeatureLayer = pTargetObj as IFeatureLayer; if ((pFeatureLayer.FeatureClass as FeatureClass).Workspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace) { if (editor.EditState != esriEngineEditState.esriEngineStateEditing) { MessageHelper.ShowTips("请先开启编辑!"); return; } } else { if (editor.EditState == esriEngineEditState.esriEngineStateEditing) { MessageHelper.ShowTips("请先停止编辑!"); return; } } FrmDataImport main = new FrmDataImport { TargetLayer = pTargetObj as IFeatureLayer, Title = "数据导入", WindowStartupLocation = System.Windows.WindowStartupLocation.Manual, Left = 240, Top = 110 }; main.ImpComplate += ImpComplate; main.InitData(); main.ShowInMainWindow(true); } } catch (Exception ex) { MessageHelper.ShowTips("数据导入失败!"); LogAPI.Debug("数据导入异常:" + ex); } } public override void OnCreate(object Hook) { try { if (m_hookHelper == null) { m_hookHelper = new HookHelper(); m_hookHelper.Hook = Hook; } editor = new EngineEditorClass(); } catch (Exception ex) { LogAPI.Debug("加载 数据导入 命令时发生异常,异常信息如下:"); LogAPI.Debug(ex); LogAPI.Debug("异常信息结束"); } } private void ImpComplate(bool pIsComplate) { if (pIsComplate) { IMapControlDefault mapControl = m_hookHelper.Hook as IMapControlDefault; if (mapControl != null) { mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, mapControl.ActiveView.Extent); if ((m_hookHelper.GetCustomProperty() is IFeatureLayer)) { mapControl.ActiveView.Extent = (m_hookHelper.GetCustomProperty() as ILayer).AreaOfInterest; } } } } } }