arcengine 捕捉笔记
来源:互联网 发布:路由器桥接后网络很慢 编辑:程序博客网 时间:2024/05/16 18:36
IEngineEditor pEngineEditor=new EngineEditor();
//Get the snap enviroment from editor
IEngineSnapEnviroment psnapEnvironment = pEngineEditor as IEngineSnapEnviorment();
if(pSnapEnvironment.SnapAgentCount==0)
{
IEngineFeatureSnapAgent pFeatureSnapAgent=new EngineFeatureAgent();
pFeatureSnapAgent.FeatureClass=pFeatureClass;
psnapEnvironment.AddSnapAgent(pFeatureSnapAgent);
}
psnapEnvironment.SnapToleranceUnits=esriEngineToleranceUnits.esriEngineTolerancePixels;
psnapEnviroment.SnapTolerance=10;
IEngineEditorProperties pEnginePro=pEngineEditor as IEngineEditProperties2;
pEginePro.SnapTips=true;
//用法 MoveMove下
IEngineSnapEnviroment psnapEnvironment = pEngineEditor as IEngineSnapEnviorment();
psnapEnvironment .SnapPoint(Point);
//0------------------------------------------------------简便高级的另外的一种捕捉 不需要打开编辑 效果同arcmap一致-----------------------------
using System;using System.Drawing;using System.Runtime.InteropServices;using ESRI.ArcGIS.ADF.BaseClasses;using ESRI.ArcGIS.ADF.CATIDs;using ESRI.ArcGIS.Controls;using System.Windows.Forms;using ESRI.ArcGIS.Geometry;using ESRI.ArcGIS.Display;using ESRI.ArcGIS.esriSystem;namespace WindowsFormsApplication1.tool{ /// <summary> /// Summary description for SnapTool. /// </summary> [Guid("192f72b4-5043-45cb-8e1a-743ea964fa97")] [ClassInterface(ClassInterfaceType.None)] [ProgId("WindowsFormsApplication1.tool.SnapTool")] public sealed class SnapTool : BaseTool { #region COM Registration Function(s) [ComRegisterFunction()] [ComVisible(false)] static void RegisterFunction(Type registerType) { // Required for ArcGIS Component Category Registrar support ArcGISCategoryRegistration(registerType); // // TODO: Add any COM registration code here // } [ComUnregisterFunction()] [ComVisible(false)] static void UnregisterFunction(Type registerType) { // Required for ArcGIS Component Category Registrar support ArcGISCategoryUnregistration(registerType); // // TODO: Add any COM unregistration code here // } #region ArcGIS Component Category Registrar generated code /// <summary> /// Required method for ArcGIS Component Category registration - /// Do not modify the contents of this method with the code editor. /// </summary> private static void ArcGISCategoryRegistration(Type registerType) { string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID); MxCommands.Register(regKey); ControlsCommands.Register(regKey); } /// <summary> /// Required method for ArcGIS Component Category unregistration - /// Do not modify the contents of this method with the code editor. /// </summary> private static void ArcGISCategoryUnregistration(Type registerType) { string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID); MxCommands.Unregister(regKey); ControlsCommands.Unregister(regKey); } #endregion #endregion private IHookHelper m_hookHelper = null; private IPoint m_snapPt; private ISnappingEnvironment m_SnapEnv; private IPointSnapper m_Snapper; private ISnappingFeedback m_SnapFeedback; private INewLineFeedback m_feedback; private ISnappingResult m_snapRst; public SnapTool() { // // TODO: Define values for the public properties // base.m_category = ""; //localizable text base.m_caption = ""; //localizable text base.m_message = "This should work in ArcMap/MapControl/PageLayoutControl"; //localizable text base.m_toolTip = ""; //localizable text base.m_name = ""; //unique id, non-localizable (e.g. "MyCategory_MyTool") try { // // TODO: change resource name if necessary // string bitmapResourceName = GetType().Name + ".bmp"; base.m_bitmap = new Bitmap(GetType(), bitmapResourceName); base.m_cursor = new System.Windows.Forms.Cursor(GetType(), GetType().Name + ".cur"); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap"); } } #region Overridden Class Methods /// <summary> /// Occurs when this tool is created /// </summary> /// <param name="hook">Instance of the application</param> public override void OnCreate(object hook) { try { m_hookHelper = new HookHelperClass(); m_hookHelper.Hook = hook; if (m_hookHelper.ActiveView == null) { m_hookHelper = null; } } catch { m_hookHelper = null; } if (m_hookHelper == null) base.m_enabled = false; else base.m_enabled = true; // TODO: Add other initialization code } /// <summary> /// Occurs when this tool is clicked /// </summary> public override void OnClick() { UID uid = new UIDClass(); uid.Value = "{E07B4C52-C894-4558-B804-D4050018D1DA}"; IExtensionManager extMar = (m_hookHelper as IHookHelper2).ExtensionManager; IExtension ext=extMar.FindExtension(uid); m_SnapEnv = ext as ISnappingEnvironment; m_Snapper = m_SnapEnv.PointSnapper; m_SnapFeedback = new SnappingFeedbackClass(); m_SnapFeedback.Initialize(m_hookHelper.Hook, m_SnapEnv, true); } public override void OnMouseDown(int Button, int Shift, int X, int Y) { IPoint ppt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); if (m_snapPt != null) { ppt = m_snapPt; } if (m_feedback != null) { m_feedback = new NewLineFeedbackClass(); m_feedback.Display = m_hookHelper.ActiveView.ScreenDisplay; m_feedback.Start(ppt); } else { m_feedback.AddPoint(ppt); } } public override void OnMouseMove(int Button, int Shift, int X, int Y) { IPoint ppt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); m_snapPt = ppt; m_snapRst = m_Snapper.Snap(m_snapPt); m_SnapFeedback.Update(m_snapRst, 0); if (m_snapRst != null) { m_snapPt = m_snapRst.Location; } if (m_feedback != null) { m_feedback.MoveTo(m_snapPt); } } public override void OnMouseUp(int Button, int Shift, int X, int Y) { // TODO: Add SnapTool.OnMouseUp implementation } #endregion }}
1 0
- arcengine 捕捉笔记
- Arcengine的工具中实现Snapping(捕捉)
- C#+ArcEngine开发笔记
- ArcEngine入门笔记1
- struts2学习笔记异常捕捉
- ArcEngine GP笔记(持续补充中......)
- IDA学习笔记--VS2008按钮事件捕捉
- AppleScript学习笔记(三)捕捉错误
- Android笔记:EditText失去焦点的捕捉
- 【STM32F103攻城笔记】输入捕捉实战
- cortex_m3_stm32嵌入式学习笔记(十):输入捕捉实验(定时器的输入捕捉)
- Directshow(SDK)学习笔记九_视频捕捉
- Directshow(SDK)学习笔记九_视频捕捉
- Directshow(SDK)学习笔记九_视频捕捉
- Shell编程笔记(日志文件、信号、trap捕捉信号、eval)
- 游戏数据的捕捉(郁金香学习笔记)
- Directshow(SDK)学习笔记九_视频捕捉
- webpy开发笔记01-调试模式下异常捕捉问题
- 微信硬件平台设备直连全讲解(1)开发前的准备
- 字节流-FileInputStream_FileOutputStream_BufferedInputStream_BufferedOutputStream
- Makefile详解——从入门到精通
- gitlib项目迁移到新Gitlab Server
- Android之Adapter的封装与抽象(二)
- arcengine 捕捉笔记
- 【转】一个十二年老程序猿的碎碎念
- SQL 字符串排序 (字符串为数字、字母、汉字)
- 查看Qt中可用的数据库插件
- Android 时间为隔天的九点、并且跳过周末
- spring配置详解-连接池配置(转载…
- Spring ApplicationContext.x…
- 51nod 1128 正整数分组 V 二分+贪心
- Android开发书籍推荐 & 学习路线图 & 资料汇整