|
|
|
|
using ESRI.ArcGIS.Carto;
|
|
|
|
|
using ESRI.ArcGIS.Controls;
|
|
|
|
|
using ESRI.ArcGIS.esriSystem;
|
|
|
|
|
using KGIS.Framework.Maps;
|
|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Kingo.Plugin.EngineEditor.Commands
|
|
|
|
|
{
|
|
|
|
|
public class BaseSnapCmd : ESRI.ArcGIS.SystemUI.ICommand
|
|
|
|
|
{
|
|
|
|
|
private IHookHelper m_hookHelper;
|
|
|
|
|
private EngineEditorClass m_editor = new EngineEditorClass();
|
|
|
|
|
private ISnappingEnvironment snapEnv = null;
|
|
|
|
|
private bool IsChecked = false;
|
|
|
|
|
public virtual esriSnappingType SnappingType { get { return esriSnappingType.esriSnappingTypeNone; } }
|
|
|
|
|
|
|
|
|
|
public bool Checked
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
IsChecked = (snapEnv.SnappingType & SnappingType) == SnappingType;
|
|
|
|
|
return IsChecked;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void OnCreate(object hook)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (hook == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (m_hookHelper == null)
|
|
|
|
|
{
|
|
|
|
|
m_hookHelper = new HookHelper();
|
|
|
|
|
m_hookHelper.Hook = hook;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_hookHelper.ActiveView == null)
|
|
|
|
|
{
|
|
|
|
|
m_hookHelper = null;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
IHookHelper2 hookHelper2 = m_hookHelper as IHookHelper2;
|
|
|
|
|
if (hookHelper2 != null)
|
|
|
|
|
{
|
|
|
|
|
IExtensionManager extensionManager = hookHelper2.ExtensionManager;
|
|
|
|
|
|
|
|
|
|
if (extensionManager != null)
|
|
|
|
|
{
|
|
|
|
|
IExtension extension = extensionManager.FindExtension(new UIDClass
|
|
|
|
|
{
|
|
|
|
|
Value = "{E07B4C52-C894-4558-B8D4-D4050018D1DA}"//捕捉
|
|
|
|
|
});
|
|
|
|
|
if (extension != null)
|
|
|
|
|
{
|
|
|
|
|
this.snapEnv = (extension as ISnappingEnvironment);
|
|
|
|
|
this.snapEnv.SnappingType = esriSnappingType.esriSnappingTypeIntersection | esriSnappingType.esriSnappingTypeEdge | esriSnappingType.esriSnappingTypeVertex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("加载 BaseSnap 类时失败,异常原因: " + ex + " ; ");
|
|
|
|
|
m_hookHelper = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IMapService _MapService;
|
|
|
|
|
|
|
|
|
|
public virtual void OnClick()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
this.IsChecked = !this.IsChecked;
|
|
|
|
|
if (this.IsChecked)
|
|
|
|
|
{
|
|
|
|
|
if (snapEnv != null)
|
|
|
|
|
{
|
|
|
|
|
if ((snapEnv.SnappingType & SnappingType) != SnappingType)
|
|
|
|
|
{
|
|
|
|
|
snapEnv.SnappingType = snapEnv.SnappingType | SnappingType;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (snapEnv != null && (snapEnv.SnappingType & SnappingType) == SnappingType)
|
|
|
|
|
{
|
|
|
|
|
if ((snapEnv.SnappingType ^ SnappingType) == esriSnappingType.esriSnappingTypeNone)
|
|
|
|
|
{
|
|
|
|
|
snapEnv.SnappingType = esriSnappingType.esriSnappingTypeNone;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (snapEnv != null && (snapEnv.SnappingType & SnappingType) == SnappingType)
|
|
|
|
|
{
|
|
|
|
|
snapEnv.SnappingType = snapEnv.SnappingType ^ SnappingType;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int Bitmap
|
|
|
|
|
{
|
|
|
|
|
get { return 0; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Caption
|
|
|
|
|
{
|
|
|
|
|
get { return ""; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Category
|
|
|
|
|
{
|
|
|
|
|
get { return ""; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Enabled
|
|
|
|
|
{
|
|
|
|
|
get { return m_editor.EditState == esriEngineEditState.esriEngineStateEditing; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int HelpContextID
|
|
|
|
|
{
|
|
|
|
|
get { return 0; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string HelpFile
|
|
|
|
|
{
|
|
|
|
|
get { return ""; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Message
|
|
|
|
|
{
|
|
|
|
|
get { return ""; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get { return ""; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual string Tooltip
|
|
|
|
|
{
|
|
|
|
|
get { return ""; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|