|
|
|
|
using ESRI.ArcGIS.Carto;
|
|
|
|
|
using ESRI.ArcGIS.Controls;
|
|
|
|
|
using KGIS.Framework.Commands;
|
|
|
|
|
using KGIS.Framework.Core.Attributes;
|
|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
using KGIS.Framework.Utils.Helper;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Kingo.Plugin.MapView.Commands
|
|
|
|
|
{
|
|
|
|
|
//[PathAttribute("Kingo.Plugin.MapView.Commands.ClearAllGraphicsCommand")]
|
|
|
|
|
public class ClearAllGraphicsCommand : BaseMenuCommand
|
|
|
|
|
{
|
|
|
|
|
public IHookHelper m_hookHelper = null;//获取地图控件和主窗体
|
|
|
|
|
|
|
|
|
|
public override void OnClick()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (m_hookHelper != null)
|
|
|
|
|
{
|
|
|
|
|
IGraphicsContainer graphics = m_hookHelper.ActiveView.GraphicsContainer;
|
|
|
|
|
if (graphics == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
graphics.Reset();
|
|
|
|
|
IElement ele = null;
|
|
|
|
|
while ((ele = graphics.Next()) != null)
|
|
|
|
|
{
|
|
|
|
|
IElementProperties eleProp = ele as IElementProperties;
|
|
|
|
|
if (eleProp.Name == "BaseElement")
|
|
|
|
|
continue;
|
|
|
|
|
(ele as IGroupElement).ClearElements();
|
|
|
|
|
}
|
|
|
|
|
//graphics.DeleteAllElements();
|
|
|
|
|
if (this.m_hookHelper != null && this.m_hookHelper.Hook != null && (this.m_hookHelper.Hook as IMapControl4) != null)
|
|
|
|
|
{
|
|
|
|
|
//在地图上测量,画一条线或者图形,离开绘制图形界面,功能有错误
|
|
|
|
|
IMapControl4 currentMap = this.m_hookHelper.Hook as IMapControl4;
|
|
|
|
|
currentMap.CurrentTool = null;
|
|
|
|
|
//刷新地图
|
|
|
|
|
(this.m_hookHelper.Hook as IMapControl4).ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, (this.m_hookHelper.Hook as IMapControl4).ActiveView.Extent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.Show("hookHelper获取失败");
|
|
|
|
|
//return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("点击 清除图形 时异常,异常信息如下:");
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
LogAPI.Debug("点击 清除图形 时异常信息结束");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnCreate(object Hook)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (Hook != null)
|
|
|
|
|
{
|
|
|
|
|
if (m_hookHelper == null)
|
|
|
|
|
{
|
|
|
|
|
m_hookHelper = new HookHelper();
|
|
|
|
|
m_hookHelper.Hook = Hook;
|
|
|
|
|
}
|
|
|
|
|
//m_hookHelper.Hook = hook;
|
|
|
|
|
if (m_hookHelper.ActiveView == null)
|
|
|
|
|
{
|
|
|
|
|
m_hookHelper = null;
|
|
|
|
|
//return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
m_hookHelper = new HookHelper();
|
|
|
|
|
m_hookHelper.Hook = null;
|
|
|
|
|
//return;
|
|
|
|
|
|
|
|
|
|
LogAPI.Debug("初始化 清除图形 时异常,异常信息如下:");
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
LogAPI.Debug("初始化 清除图形 时异常信息结束");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|