|
|
|
|
using ESRI.ArcGIS.Carto;
|
|
|
|
|
using ESRI.ArcGIS.Controls;
|
|
|
|
|
using KGIS.Framework.AE.ExtensionMethod;
|
|
|
|
|
using KGIS.Framework.Commands;
|
|
|
|
|
using KGIS.Framework.Maps;
|
|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
using KGIS.Framework.Utils.Helper;
|
|
|
|
|
using Kingo.Plugin.DataLoad.Views;
|
|
|
|
|
using Kingo.PluginServiceInterface;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Kingo.Plugin.DataLoad.Commands
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 检测图斑加载
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class CmdLoadSurveyData : BaseMenuCommand
|
|
|
|
|
{
|
|
|
|
|
IEngineEditor m_pEditor;
|
|
|
|
|
private IHookHelper m_hookHelper = null;
|
|
|
|
|
public override void OnClick()
|
|
|
|
|
{
|
|
|
|
|
IEngineEditor pEditor = new EngineEditorClass();
|
|
|
|
|
if (pEditor.EditState == esriEngineEditState.esriEngineStateEditing)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("请先关闭编辑!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//导入的目标图斑
|
|
|
|
|
IFeatureLayer pTargetObj = MapsManager.Instance.MapService.GetFeatureLayerByName("JCTB");
|
|
|
|
|
FrmDataImport main = new FrmDataImport
|
|
|
|
|
{
|
|
|
|
|
TargetLayer = pTargetObj as IFeatureLayer,
|
|
|
|
|
Title = "监测数据加载",
|
|
|
|
|
WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
|
|
|
|
|
Left = 240,
|
|
|
|
|
Top = 110
|
|
|
|
|
};
|
|
|
|
|
main.ImpComplate += ImpComplate;
|
|
|
|
|
main.InitData();
|
|
|
|
|
main.ShowInMainWindow(true);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex.Message);
|
|
|
|
|
MessageHelper.ShowError("检测图斑初始化界面失败!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnCreate(object Hook)
|
|
|
|
|
{
|
|
|
|
|
if (m_hookHelper == null)
|
|
|
|
|
{
|
|
|
|
|
m_hookHelper = new HookHelperClass();
|
|
|
|
|
}
|
|
|
|
|
m_hookHelper.Hook = Hook;
|
|
|
|
|
m_pEditor = new EngineEditorClass();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ImpComplate(bool pIsComplate)
|
|
|
|
|
{
|
|
|
|
|
if (pIsComplate)
|
|
|
|
|
{
|
|
|
|
|
if (m_hookHelper.Hook is IMapControlDefault mapControl)
|
|
|
|
|
{
|
|
|
|
|
mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, mapControl.ActiveView.Extent);
|
|
|
|
|
if (m_hookHelper.GetCustomProperty() is IFeatureLayer)
|
|
|
|
|
{
|
|
|
|
|
mapControl.ActiveView.Extent = (m_hookHelper.GetCustomProperty() as ILayer).AreaOfInterest;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Enabled
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return JudgeIsHaveTargetPath();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool JudgeIsHaveTargetPath()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ProjectInfo prj = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo;
|
|
|
|
|
if (prj == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return !string.IsNullOrWhiteSpace(prj.BGDatabase) && m_pEditor.EditState == esriEngineEditState.esriEngineStateNotEditing;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("判定 检测数据加载 按钮是否有效时失败,异常原因: " + ex + " ; ");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|