|
|
|
|
namespace Kingo.Plugin.NYYP.Tool
|
|
|
|
|
{
|
|
|
|
|
using ESRI.ArcGIS.Carto;
|
|
|
|
|
using ESRI.ArcGIS.Controls;
|
|
|
|
|
using ESRI.ArcGIS.Display;
|
|
|
|
|
using ESRI.ArcGIS.Geometry;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
public class EngineSnapAgentClass
|
|
|
|
|
{
|
|
|
|
|
private EngineEditor m_editEnvironment = new EngineEditorClass();
|
|
|
|
|
private static EngineSnapAgentClass m_instance;
|
|
|
|
|
private bool m_isHasSnap = false;
|
|
|
|
|
private IMarkerSymbol m_snapMarkerSymbool;
|
|
|
|
|
private IPoint m_SnapPoint;
|
|
|
|
|
|
|
|
|
|
private EngineSnapAgentClass()
|
|
|
|
|
{
|
|
|
|
|
IEngineEditProperties editEnvironment = (IEngineEditProperties)this.m_editEnvironment;
|
|
|
|
|
this.m_snapMarkerSymbool = editEnvironment.SnapSymbol;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DrawSnapPoint(IActiveView activeView, IPoint point)
|
|
|
|
|
{
|
|
|
|
|
IScreenDisplay screenDisplay = activeView.ScreenDisplay;
|
|
|
|
|
screenDisplay.StartDrawing(screenDisplay.hDC, -1);
|
|
|
|
|
screenDisplay.SetSymbol((ISymbol)this.m_snapMarkerSymbool);
|
|
|
|
|
screenDisplay.DrawPoint(point);
|
|
|
|
|
screenDisplay.FinishDrawing();
|
|
|
|
|
screenDisplay = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Reset()
|
|
|
|
|
{
|
|
|
|
|
this.m_isHasSnap = false;
|
|
|
|
|
this.m_SnapPoint = null;
|
|
|
|
|
}
|
|
|
|
|
public void SetSnapTolerance(double pSnapTolerance)
|
|
|
|
|
{
|
|
|
|
|
((IEngineSnapEnvironment)this.m_editEnvironment).SnapTolerance = pSnapTolerance;
|
|
|
|
|
}
|
|
|
|
|
public bool SnapPoint(IActiveView activeView, IPoint inPoint)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (this.m_isHasSnap && (this.m_SnapPoint != null))
|
|
|
|
|
{
|
|
|
|
|
this.DrawSnapPoint(activeView, this.m_SnapPoint);
|
|
|
|
|
}
|
|
|
|
|
this.m_isHasSnap = ((IEngineSnapEnvironment)this.m_editEnvironment).SnapPoint(inPoint);
|
|
|
|
|
if (this.m_isHasSnap)
|
|
|
|
|
{
|
|
|
|
|
this.m_SnapPoint = inPoint;
|
|
|
|
|
this.DrawSnapPoint(activeView, this.m_SnapPoint);
|
|
|
|
|
}
|
|
|
|
|
return this.m_isHasSnap;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
KGIS.Framework.Utils.LogAPI.Debug(ex);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool HasSnapPoint
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this.m_isHasSnap;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static EngineSnapAgentClass Instance
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (m_instance == null)
|
|
|
|
|
{
|
|
|
|
|
m_instance = new EngineSnapAgentClass();
|
|
|
|
|
}
|
|
|
|
|
return m_instance;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IPoint SnapedPoint
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this.m_SnapPoint;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ClearSnapAgents()
|
|
|
|
|
{
|
|
|
|
|
((IEngineSnapEnvironment)this.m_editEnvironment).ClearSnapAgents();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddSnapAgent(IEngineSnapAgent SnapAgent)
|
|
|
|
|
{
|
|
|
|
|
IEngineSnapEnvironment snapEnv = (IEngineSnapEnvironment)this.m_editEnvironment;
|
|
|
|
|
//for (int i = 0; i < snapEnv.SnapAgentCount; i++)
|
|
|
|
|
//{
|
|
|
|
|
// IEngineSnapAgent agent = snapEnv.get_SnapAgent(i);
|
|
|
|
|
// if (agent == SnapAgent)
|
|
|
|
|
// {
|
|
|
|
|
// return agent;
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
snapEnv.AddSnapAgent(SnapAgent);
|
|
|
|
|
//return SnapAgent;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|