![]() |
This document is archived and information here might be outdated. Recommended version. |
Loads a FeatureClass as a MOLE Tactical Graphic Layer into the current IBasicMap (Map, Globe, or Scene).
///<summary>Loads a FeatureClass as a MOLE Tactical Graphic Layer into the current IBasicMap (Map, Globe, or Scene).</summary>
///
///<param name="featureClass">An IFeatureClass interface to load.</param>
///<param name="basicMap">An IBasicMap interface that is the Map, Scene, or Globe.</param>
///<param name="layerName">A System.String that the name to assign to the layer. Example: "Cities"</param>
///<param name="textSize">A System.Double that is the size of labels of graphics in the layer (in map units). Example: 0.5</param>
///<param name="symbolSize">A System.Double that is the size of graphics (primarily point graphics) in the layer (in map units). Example 0.5</param>
///<param name="useAffiliationColor">A System.Boolean that uses the affiliation color for graphic outline. Example: false</param>
///
///<returns>An ILayer interface.</returns>
///
///<remarks>Obtain a reference to the current IBasicMap. An IBasicMap is used because it is common between a Map, Globe, and Scene (and their corresponding Engine Controls).</remarks>
public ESRI.ArcGIS.Carto.ILayer LoadTacticalGraphicLayer(ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass, ESRI.ArcGIS.Carto.IBasicMap basicMap, System.String layerName, System.Double textSize, System.Double symbolSize, System.Boolean useAffiliationColor)
{
if ((featureClass == null) || (basicMap == null))
{
System.Diagnostics.Trace.WriteLine("Invalid parameter, aborting");
return null;
}
ESRI.ArcGIS.Carto.IFeatureLayer featureLayer=new ESRI.ArcGIS.Carto.FeatureLayerClass();
ESRI.ArcGIS.Carto.IGeoFeatureLayer geoFeatureLayer=featureLayer as ESRI.ArcGIS.Carto.IGeoFeatureLayer; // Dynamic Cast
geoFeatureLayer.FeatureClass=featureClass;
// Create a MOLE layer and attach the feature layer to it
ESRI.ArcGIS.DefenseSolutions.ICachedGraphicFeatureLayer cachedGraphicFeatureLayer=new ESRI.ArcGIS.DefenseSolutions.TacticalGraphicLayerClass() as ESRI.ArcGIS.DefenseSolutions.ICachedGraphicFeatureLayer;
cachedGraphicFeatureLayer.FeatureLayer=geoFeatureLayer;
// create a collection of cache renderers
ESRI.ArcGIS.DefenseSolutions.ICacheRendererCollection cachedRenderCollection=cachedGraphicFeatureLayer as ESRI.ArcGIS.DefenseSolutions.ICacheRendererCollection;
ESRI.ArcGIS.DefenseSolutions.ICacheRenderer cacheRenderer=new ESRI.ArcGIS.DefenseSolutions.TacticalGraphic2525BRendererClass();
cachedRenderCollection.AddRenderer(ref cacheRenderer, 0);
ESRI.ArcGIS.DefenseSolutions.ITacticalGraphicLayer tacticalGraphicLayer=cachedGraphicFeatureLayer as ESRI.ArcGIS.DefenseSolutions.TacticalGraphicLayer;
tacticalGraphicLayer.TextSize=textSize;
tacticalGraphicLayer.UseAffiliationColor=useAffiliationColor;
ESRI.ArcGIS.DefenseSolutions.ICachedGraphicLayer2 cachedGraphicLayer2=cachedGraphicFeatureLayer as ESRI.ArcGIS.DefenseSolutions.ICachedGraphicLayer2;
cachedGraphicLayer2.Size=symbolSize;
ESRI.ArcGIS.Carto.ILayer layer=cachedGraphicFeatureLayer as ESRI.ArcGIS.Carto.ILayer;
layer.Name=layerName;
basicMap.AddLayer(layer);
return layer;
}
'''<summary>Loads a FeatureClass as a MOLE Tactical Graphic Layer into the current IBasicMap (Map, Globe, or Scene).</summary>
'''
'''<param name="featureClass">An IFeatureClass interface to load.</param>
'''<param name="basicMap">An IBasicMap interface that is the Map, Scene, or Globe.</param>
'''<param name="layerName">A System.String that the name to assign to the layer. Example: "Cities"</param>
'''<param name="textSize">A System.Double that is the size of labels of graphics in the layer (in map units). Example: 0.5</param>
'''<param name="symbolSize">A System.Double that is the size of graphics (primarily point graphics) in the layer (in map units). Example 0.5</param>
'''<param name="useAffiliationColor">A System.Boolean that uses the affiliation color for graphic outline. Example: false</param>
'''
'''<returns>An ILayer interface.</returns>
'''
'''<remarks>Obtain a reference to the current IBasicMap. An IBasicMap is used because it is common between a Map, Globe, and Scene (and their corresponding Engine Controls).</remarks>
Public Function LoadTacticalGraphicLayer(ByVal featureClass As ESRI.ArcGIS.Geodatabase.IFeatureClass, ByVal basicMap As ESRI.ArcGIS.Carto.IBasicMap, ByVal layerName As System.String, ByVal textSize As System.Double, ByVal symbolSize As System.Double, ByVal useAffiliationColor As System.Boolean) As ESRI.ArcGIS.Carto.ILayer
If (featureClass Is Nothing) OrElse (basicMap Is Nothing) Then
System.Diagnostics.Trace.WriteLine("Invalid parameter, aborting")
Return Nothing
End If
Dim geoFeatureLayer As ESRI.ArcGIS.Carto.IGeoFeatureLayer=New ESRI.ArcGIS.Carto.FeatureLayerClass
geoFeatureLayer.FeatureClass=featureClass
' Create a MOLE layer and attach the feature layer to it
Dim cachedGraphicFeatureLayer As ESRI.ArcGIS.DefenseSolutions.ICachedGraphicFeatureLayer=New ESRI.ArcGIS.DefenseSolutions.TacticalGraphicLayerClass
cachedGraphicFeatureLayer.FeatureLayer=geoFeatureLayer
' create a collection of cache renderers
Dim cacheRendererCollection As ESRI.ArcGIS.DefenseSolutions.ICacheRendererCollection=CType(cachedGraphicFeatureLayer, ESRI.ArcGIS.DefenseSolutions.ICacheRendererCollection) ' Explicit Cast
Dim cacheRenderer As ESRI.ArcGIS.DefenseSolutions.ICacheRenderer=New ESRI.ArcGIS.DefenseSolutions.TacticalGraphic2525BRendererClass
cacheRendererCollection.AddRenderer(cacheRenderer, 0)
Dim tacticalGraphicLayer As ESRI.ArcGIS.DefenseSolutions.ITacticalGraphicLayer=CType(cachedGraphicFeatureLayer, ESRI.ArcGIS.DefenseSolutions.ITacticalGraphicLayer) ' Explicit Cast
tacticalGraphicLayer.TextSize=textSize
tacticalGraphicLayer.UseAffiliationColor=useAffiliationColor
Dim cachedGraphicLayer2 As ESRI.ArcGIS.DefenseSolutions.ICachedGraphicLayer2=CType(cachedGraphicFeatureLayer, ESRI.ArcGIS.DefenseSolutions.ICachedGraphicLayer2) ' Explicit Cast
cachedGraphicLayer2.Size=symbolSize
Dim layer As ESRI.ArcGIS.Carto.ILayer=CType(cachedGraphicFeatureLayer, ESRI.ArcGIS.Carto.ILayer) ' Explict Cast
layer.Name=layerName
basicMap.AddLayer(layer)
Return layer
End Function