using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Controls; using ESRI.ArcGIS.Display; using KGIS.Framework.AE.ExtensionMethod; using KGIS.Framework.Maps; using KGIS.Framework.Utils; using System; namespace Kingo.Plugin.MapView.Commands { //[PathAttribute("Kingo.Plugin.MapView.Commands.CmdZoomToLayer")] public class CmdZoomToLayer : BaseMapMenuCommand { public override void OnClick() { if (m_hookHelper == null) return; object layer = m_hookHelper.GetCustomProperty(); if (layer is ILayer) { if (m_hookHelper.Hook is IPageLayoutControlDefault) { IActiveView activeView = m_hookHelper.ActiveView; IDisplayTransformation displayTransformation = activeView.ScreenDisplay.DisplayTransformation; displayTransformation.VisibleBounds = (layer as ILayer).AreaOfInterest; //activeView.Refresh(); m_hookHelper.ActiveView.Refresh(); } else { this.m_hookHelper.ActiveView.Extent = (layer as ILayer).AreaOfInterest; } this.m_hookHelper.ActiveView.Refresh(); } } public override void OnCreate(object Hook) { try { if (m_hookHelper == null) { m_hookHelper = new HookHelper(); m_hookHelper.Hook = Hook; } } catch (Exception ex) { LogAPI.Debug("加载 缩放至图层 命令时发生异常,异常信息如下:"); LogAPI.Debug(ex); LogAPI.Debug("异常信息结束"); } } } }