ArcObjects Library Reference

Create Force Element Snippet

Creates a DefenseSolutions Force Element as a Cached Graphic.

[C#]

///<summary>Creates a DefenseSolutions Force Element as a Cached Graphic.</summary>
///  
///<param name="feGraphicFactory">An IFEGraphicFactory interface that is used to create a graphic.</param>
///<param name="symbolIdCode">A System.String that is the MIL-STD-2525/APP6a Symbol ID Code for desirerd symbol. Example: "SFGP-----------"</param>
///<param name="propertySet">An IPropertySet interface that is the Property Set with desired symbol labels.</param>
///<param name="feGraphicStyle">An IFEGraphicStyle interface that is graphic style for the symbol.</param>
///<param name="point">An IPoint interface that is point ofr the symbol.</param>
///<param name="size">A System.Double that is the size in map units. Example: 0.5</param>
///  
///<returns>An ICachedGraphic interface or Nothing if unsuccessful.</returns>
///
///<remarks></remarks>
public ESRI.ArcGIS.DefenseSolutions.ICachedGraphic CreateForceElement(ESRI.ArcGIS.DefenseSolutions.IFEGraphicFactory feGraphicFactory, System.String symbolIdCode, ESRI.ArcGIS.esriSystem.IPropertySet propertySet, ESRI.ArcGIS.DefenseSolutions.IFEGraphicStyle feGraphicStyle, ESRI.ArcGIS.Geometry.IPoint point, System.Double size)
{
  ESRI.ArcGIS.DefenseSolutions.IFEGraphic feGraphic = feGraphicFactory.Make(symbolIdCode);

  if (feGraphic == null)
    return null;

  feGraphic.Style = feGraphicStyle;
  ESRI.ArcGIS.DefenseSolutions.IForceElement forceElement = new ESRI.ArcGIS.DefenseSolutions.ForceElementClass();

  forceElement.PropertySet = propertySet;
  forceElement.Shape = point;
  forceElement.MessageString = symbolIdCode;

  feGraphic.ForceElement = forceElement;

  ESRI.ArcGIS.DefenseSolutions.ICachedGraphic cachedGraphic = feGraphic as ESRI.ArcGIS.DefenseSolutions.ICachedGraphic; // Dynamic Cast
  ESRI.ArcGIS.Geometry.IGeometry geometry = point as ESRI.ArcGIS.Geometry.IGeometry; // Dynamic Cast
  cachedGraphic.Size = size;
  cachedGraphic.Geometry = geometry;

  return cachedGraphic;
}
[Visual Basic .NET]

'''<summary>Creates a DefenseSolutions Force Element as a Cached Graphic.</summary>
'''  
'''<param name="feGraphicFactory">An IFEGraphicFactory interface that is used to create a graphic.</param>
'''<param name="symbolIdCode">A System.String that is the MIL-STD-2525/APP6a Symbol ID Code for desirerd symbol. Example: "SFGP-----------"</param>
'''<param name="propertySet">An IPropertySet interface that is the Property Set with desired symbol labels.</param>
'''<param name="feGraphicStyle">An IFEGraphicStyle interface that is graphic style for the symbol.</param>
'''<param name="point">An IPoint interface that is point ofr the symbol.</param>
'''<param name="size">A System.Double that is the size in map units. Example: 0.5</param>
'''  
'''<returns>An ICachedGraphic interface or Nothing if unsuccessful.</returns>
'''
'''<remarks></remarks>
Public Function CreateForceElement(ByVal feGraphicFactory As ESRI.ArcGIS.DefenseSolutions.IFEGraphicFactory, ByVal symbolIdCode As System.String, ByVal propertySet As ESRI.ArcGIS.esriSystem.IPropertySet, ByVal feGraphicStyle As ESRI.ArcGIS.DefenseSolutions.IFEGraphicStyle, ByVal point As ESRI.ArcGIS.Geometry.IPoint, ByVal size As System.Double) As ESRI.ArcGIS.DefenseSolutions.ICachedGraphic

  Dim feGraphic As ESRI.ArcGIS.DefenseSolutions.IFEGraphic = feGraphicFactory.Make(symbolIdCode)

  If feGraphic Is Nothing Then
    Return Nothing
  End If

  feGraphic.Style = feGraphicStyle

  Dim forceElement As ESRI.ArcGIS.DefenseSolutions.IForceElement = New ESRI.ArcGIS.DefenseSolutions.ForceElementClass
  forceElement.PropertySet = propertySet
  forceElement.Shape = point
  forceElement.MessageString = symbolIdCode
  feGraphic.ForceElement = forceElement

  Dim cachedGraphic As ESRI.ArcGIS.DefenseSolutions.ICachedGraphic = CType(feGraphic, ESRI.ArcGIS.DefenseSolutions.ICachedGraphic) ' Explicit Cast
  Dim geometry As ESRI.ArcGIS.Geometry.IGeometry = point
  cachedGraphic.Size = size
  cachedGraphic.Geometry = geometry

  Return cachedGraphic

End Function


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