This document is archived and information here might be outdated.  Recommended version.


Draw Line on Dynamic Display Snippet (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference

Draw Line on Dynamic Display Snippet

Draws a line in screen coordinates using a given dynamic line glyph.

[C#]
///<summary>Draws a line in screen coordinates using a given dynamic line glyph.</summary>
///  
///<param name="dynamicDisplay">An IDynamicDisplay interface.</param>
///<param name="dynamicGlyph">An IDynamicGlyph interface that is the dynamic glyph line that will be used to draw the line.</param>
///<param name="fromPoint"> An IPoint interface that is starting point of the line in screen coordinates.</param>
///<param name="toPoint">An IPoint interface that is end point of the line in screen coordinates.</param>
///  
///<remarks></remarks>
public void DrawLineOnDynamicDisplay(ESRI.ArcGIS.Display.IDynamicDisplay dynamicDisplay, ESRI.ArcGIS.Display.IDynamicGlyph dynamicGlyph, ESRI.ArcGIS.Geometry.IPoint fromPoint, ESRI.ArcGIS.Geometry.IPoint toPoint)
{
  if (null == dynamicDisplay || null == fromPoint || null == toPoint)
    return;

  // cast the DynamicDisplay into DynamicSymbolProperties
  ESRI.ArcGIS.Display.IDynamicSymbolProperties dynamicSymbolProps=dynamicDisplay as ESRI.ArcGIS.Display.IDynamicSymbolProperties;

  // cast the DynamicDisplay into IDynamicDrawScreen
  ESRI.ArcGIS.Display.IDynamicDrawScreen dynamicDrawScreen=dynamicDisplay as ESRI.ArcGIS.Display.IDynamicDrawScreen;

  // set the line glyph
  dynamicSymbolProps.set_DynamicGlyph(ESRI.ArcGIS.Display.esriDynamicSymbolType.esriDSymbolLine, dynamicGlyph);

  // draw the line in screen coordinates
  dynamicDrawScreen.DrawScreenLine(fromPoint, toPoint);
}
[Visual Basic .NET]
'''<summary>Draws a line in screen coordinates using a given dynamic line glyph.</summary>
'''  
'''<param name="dynamicDisplay">An IDynamicDisplay interface.</param>
'''<param name="dynamicGlyph">An IDynamicGlyph interface that is the dynamic glyph line that will be used to draw the line.</param>
'''<param name="fromPoint"> An IPoint interface that is starting point of the line in screen coordinates.</param>
'''<param name="toPoint">An IPoint interface that is end point of the line in screen coordinates.</param>
'''  
'''<remarks></remarks>
Public Sub DrawLineOnDynamicDisplay(ByVal dynamicDisplay As ESRI.ArcGIS.Display.IDynamicDisplay, ByVal dynamicGlyph As ESRI.ArcGIS.Display.IDynamicGlyph, ByVal fromPoint As ESRI.ArcGIS.Geometry.IPoint, ByVal toPoint As ESRI.ArcGIS.Geometry.IPoint)

  If Nothing Is dynamicDisplay OrElse Nothing Is fromPoint OrElse Nothing Is toPoint OrElse dynamicGlyph Is Nothing Then
    Return
  End If

  ' cast the DynamicDisplay into DynamicSymbolProperties
  Dim dynamicSymbolProps As ESRI.ArcGIS.Display.IDynamicSymbolProperties=TryCast(dynamicDisplay, ESRI.ArcGIS.Display.IDynamicSymbolProperties) ' Dynamic Cast

  ' cast the DynamicDisplay into IDynamicDrawScreen
  Dim dynamicDrawScreen As ESRI.ArcGIS.Display.IDynamicDrawScreen=TryCast(dynamicDisplay, ESRI.ArcGIS.Display.IDynamicDrawScreen) ' Dynamic Cast

  ' set the line glyph
  dynamicSymbolProps.DynamicGlyph(ESRI.ArcGIS.Display.esriDynamicSymbolType.esriDSymbolLine)=dynamicGlyph

  ' draw the line in screen coordinates
  dynamicDrawScreen.DrawScreenLine(fromPoint, toPoint)

End Sub

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Display
  • ESRI.ArcGIS.Geometry