在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
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 = 11; timer.Interval = 15; timer.Tick += timer_Tick; timer.Enabled = true; TransparenyColor = MapElement.SetColor(255, 255, 255, 64); } 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 > 1) { pPointCollection.RemovePoints(0, pPointCollection.PointCount); } if (pPointCollection.PointCount > 0) { if (IsMoved) { Radius = CircleRadius(pPointCollection.Point[0], MouseMvePoint); } points = CirclePointCollection(pPointCollection.Point[0], Radius, 80); } 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); }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论