ArcEngine搭载C#进行GIS的二次开发,关于目标显示的问题,由于考虑到设置定时器刷新目标位置和方向,因此在显示图层上采用的是动态图层DynamicLayer,主要用到的dll文件是ESRI.ArcGIS.ADF.BaseClasses,通过继承BaseDynamicLayer设计一个自己的动态图层基类,这样在加载其他图层时可以很方便的调用。先上基类的代码

using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Geometry;
using System;
using System.Windows.Forms; namespace GIS
{
public abstract class myDynamicLayer : BaseDynamicLayer
{
protected IDynamicGlyph DynamicGlyph; private readonly Timer timer = new Timer();
private bool isUpdate; public IColor TransparenyColor { get; set; } public int Level { get; set; } public double Scale
{
get { return MapElement.GetScale(Level); }
} public IPoint MouseMvePoint { get; set; } public string LayerName
{
get { return m_sName; }
set { m_sName = value; }
} public int TimerInterval
{
get { return timer.Interval; }
set
{
timer.Enabled = false;
timer.Interval = value;
timer.Enabled = true;
}
} public void BeginUpdate()
{
isUpdate = true;
} public void EndUpdate()
{
isUpdate = false;
} protected FisDynamicLayer()
{
Level = ;
timer.Interval = ;
timer.Tick += timer_Tick;
timer.Enabled = true;
TransparenyColor = MapElement.SetColor(, , , );
} public override void DrawDynamicLayer(esriDynamicDrawPhase DynamicDrawPhase, IDisplay Display, IDynamicDisplay DynamicDisplay)
{
if (!m_bIsImmediateDirty) return; if (DynamicDrawPhase != esriDynamicDrawPhase.esriDDPImmediate)
{
return;
} if (!m_bValid || !m_visible)
{
return;
} if (isUpdate)
{
return;
} IDynamicSymbolProperties2 DynamicSymbolProps = DynamicDisplay as IDynamicSymbolProperties2;
IDynamicGlyphFactory2 DynamicGlyphFactory2 = DynamicDisplay.DynamicGlyphFactory as IDynamicGlyphFactory2; if (DynamicSymbolProps == null || DynamicGlyphFactory2 == null)
{
return;
} DrawDynamicLayerEx(DynamicDisplay, DynamicGlyphFactory2, DynamicSymbolProps); m_bIsImmediateDirty = false;
}
private void timer_Tick(object sender, EventArgs e)
{
if (!m_bIsImmediateDirty)
m_bIsImmediateDirty = true;
}
}
}

此外需要在动态图层基类中创建一个abstract方法以方便继承时写入不同图层的需要

public abstract void DrawDynamicLayerEx(IDynamicDisplay DynamicDisplay, IDynamicGlyphFactory2 DynamicGlyphFactory2, IDynamicSymbolProperties2 DynamicSymbolProps);

  这样你就有了一个可以继承的动态图层基类了,生成新图层时重写上面的抽象方法即可,例如:

public override void DrawDynamicLayerEx(IDynamicDisplay DynamicDisplay, IDynamicGlyphFactory2 DynamicGlyphFactory2, IDynamicSymbolProperties2 DynamicSymbolProps)
{
if (MouseMvePoint == null)
{
return;
} if (!IsClicked)
{
return;
} if (pPointCollection.PointCount > )
{
pPointCollection.RemovePoints(, pPointCollection.PointCount);
} if (pPointCollection.PointCount > )
{
if (IsMoved)
{
Radius = CircleRadius(pPointCollection.Point[], MouseMvePoint); } points = CirclePointCollection(pPointCollection.Point[], Radius, );
} DynamicSymbolProps.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 6.0f, 6.0f);
DynamicSymbolProps.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 255.0f, 0.0f, 0.0f, 1.0f);
DynamicDisplay.DrawMarker(CenterPoint); DynamicSymbolProps.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 1.0f, 1.0f);
DynamicSymbolProps.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 255.0f, 0.0f, 0.0f, 1.0f);
DynamicDisplay.DrawPolyline(points); DynamicSymbolProps.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 1.0f, 1.0f);
DynamicSymbolProps.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 255.0f, 0.0f, 0.0f, 0.5f);
DynamicDisplay.DrawPolygon(points);
}

C# ArcEngine二次开发之动态图层的更多相关文章

  1. Arcengine 二次开发添加右键菜单

    最近在搞arcengine 二次开发,遇到了好多问题,也通过网上查资料试着慢慢解决了,把解决的步骤记录下来,有需要帮助的可以看一下,也欢迎各位来批评指正. 想给自己的map application在图 ...

  2. Qt+QGis二次开发:矢量图层的显示样式

    原文链接:QGis二次开发基础 -- 矢量图层的显示样式

  3. Arcengine 二次开发得到点shapefile的坐标

    做二次开发的时候,想要得到Point shapfile的坐标和相应的属性,也就是Point 的(x,y)和某个属性,在网上查了一些资料,做总结如下 首先,你要确定自己要操作的图层,一般来说,得到当前操 ...

  4. [ArcEngine二次开发]为Feature的属性赋值

    在创建FeatureClass之后,需要为FeatureClass添加Features,在为Feature的字段赋值时,代码大致如下: 在这里赋值的时候,出现了一个错误: The operation ...

  5. ArcEngine二次开发,TOCControl控件上使用contextMenuStrip

    右键菜单,在二次开发中很实用,以前没用过,最近通过一本书了解到,一直想找这么一个控件来用. 一般的控件,将contextMenuStrip控件拖到所依托的控件上,然后输入自己想要的几个功能.  在所依 ...

  6. ArcEngine二次开发错误编码对照表(转)

    阅读数:3323 每当我们在进行AE开发,出现错误时经常会出现错误代码,但是我们并不知道它到底代表什么意思,这里的而错误编码我们可以对照着找到我们需要的时候常详细信息(问题是,经常还是会出现没有错误编 ...

  7. 转载:ArcEngine二次开发界面基本设置

    转自:https://blog.csdn.net/weixin_42032107/article/details/80644991 1.   在form窗体中添加菜单栏和状态栏控件 2.   添加li ...

  8. AUTOCAD二次开发-----删除一个图层里面的所有对象

    https://blog.csdn.net/aasswwe/article/details/40899759 private void Test() { // 获取当前文档和数据库 Document ...

  9. ArcEngine二次开发之提取外包矩

    1.通过ITopologicalOperator接口,此方法适用于需要获得包含几个或多个要素的最小外包矩形 public IEnvelope GetEnvelope(IGeometryCollecti ...

随机推荐

  1. Spring Cloud 微服务架构全链路实践

    阅读目录: 1. 网关请求流程 2. Eureka 服务治理 3. Config 配置中心 4. Hystrix 监控 5. 服务调用链路 6. ELK 日志链路 7. 统一格式返回 Java 微服务 ...

  2. 依赖注入[5]: 创建一个简易版的DI框架[下篇]

    为了让读者朋友们能够对.NET Core DI框架的实现原理具有一个深刻而认识,我们采用与之类似的设计构架了一个名为Cat的DI框架.在<依赖注入[4]: 创建一个简易版的DI框架[上篇]> ...

  3. Linux中搭建Maven私服

    linux安装maven 先解压maven的压缩包apache-maven-3.5.4-bin.tar.gz   命令: tar -zavf pache-maven-3.5.4-bin.tar.gz ...

  4. [Bash]LeetCode192. 统计词频 | Word Frequency

    Write a bash script to calculate the frequency of each word in a text file words.txt. For simplicity ...

  5. [Swift]LeetCode303. 区域和检索 - 数组不可变 | Range Sum Query - Immutable

    Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive ...

  6. qcharts编译

    编译环境vs2013+qt5.5.1+perl5 qchart源码在git上自己下载,或者在此下载,参考文档:Qt Charts 5.7.0 安装教程,这篇文章是使用mingw的方式编译qcharts ...

  7. 『Balancing Act 树的重心』

    树的重心 我们先来认识一下树的重心. 树的重心也叫树的质心.找到一个点,其所有的子树中最大的子树节点数最少,那么这个点就是这棵树的重心,删去重心后,生成的多棵树尽可能平衡. 根据树的重心的定义,我们可 ...

  8. IdentityServer4之Implicit(隐式许可)

    IdentityServer4之Implicit(隐式许可) 参考 官方文档:3_interactive_login .7_javascript_client 概念:隐式许可 认证服务端配置 认证服务 ...

  9. jxa快速入门,Javascript已加入AppleScript全家桶

    因为工作环境基本是以跨平台为主,所以纯mac本地化的AppleScript一直关注是不够的,前几天找资料发现AppleScript也在迅速的进步着,目前已经对Javascript做了比较好的支持--- ...

  10. Solr 05 - Solr Web管理界面的基本使用

    目录 1 Dashboard - 仪表盘 2 Logging - 日志信息 3 CoreAdmin - Solr核心 4 Java Properties - Java参数 5 Thread Dump ...