How to create a dynamic glyph from a marker symbol
Development licensing
Deployment licensing
Engine Developer Kit
Engine Runtime
ArcView
ArcEditor
ArcInfo
Creating dynamic glyphs
Creation of dynamic glyphs must take place inside one of the dynamic drawing methods; either inside IDynamicLayer.DrawDynamicLayer or one of the DynamicDisplayEvents callbacks (IDynamicMapEvents.BeforeDraw and IDynamicMapEvents.AfterDraw). This is because the creation of a DynamicGlyph is done through the DynamicGlyphFactory, which is a property of the DynamicDisplay where the DynamicDisplay is a parameter of these methods.
Obtaining DynamicGlyphFactory and DynamicSymbolProperties from the DynamicDisplay
It is highly recommended to keep the DynamicGlyphFactory and DynamicSymbolProperties as class members and only get them once from the DynamicDisplay, since they will be used many times throughout the lifetime of the application. See the following:
[C#]
if (m_bOnce)
{
//Get the DynamicGlyphFactory from the DynamicDisplay.
m_dynamicGlyphFactory = DynamicDisplay.DynamicGlyphFactory;
//Cast the DynamicDisplay into DynamicSymbolProperties.
m_dynamicSymbolProps = DynamicDisplay as IDynamicSymbolProperties;
//Do other initializations here.//Call a method to create your glyph.
CreateMarkerGlyph();
m_bOnce = false;
}
[VB.NET]
If m_bOnce Then'Get the DynamicGlyphFactory from the DynamicDisplay.
m_dynamicGlyphFactory = DynamicDisplay.DynamicGlyphFactory
'Cast the DynamicDisplay into DynamicSymbolProperties.
m_dynamicSymbolProps = TryCast(DynamicDisplay, IDynamicSymbolProperties)
…
/ / Do other initializations here.
/ / Call a method To create your glyph.
CreateMarkerGlyph()
m_bOnce = FalseEndIf
Implementing the CreateMarkerGlyph method
The following goes through the required steps to implement the CreateMarkerGlyph() method.
At the bottom of your code, add a new CreateMarkerGlyph() private method. See the following:
[C#]
privatevoid CreateMarkerGlyph(){}
[VB.NET]
PrivateSub CreateMarkerGlyph()
EndSub
Set the color that will be used as a background by the DynamicGlyph. See the following:
[C#]
//Set the background color to white.
IRgbColor color = new RgbColorClass();
color.Red = 255;
color.Green = 255;
color.Blue = 255;
[VB.NET]
'Set the background color to white.Dim color As IRgbColor = New RgbColorClass()
color.Red = 255
color.Green = 255
color.Blue = 255
Create the marker symbol. In this example, create a character marker symbol. For convenience, use the ToStdFont() method, which converts a .NET font into stdole.IFontDisp. See the following:
Set the rotation alignment of the dynamic symbol. The symbol's rotation can be aligned in three positions: with the actual orientation of the element (set by the heading), with the window, or with the north direction (the element will always face north). See the following:
[C#]
//Set the symbol's alignment so that it will align with the symbol's heading.
m_dynamicSymbolProps.set_RotationAlignment
(esriDynamicSymbolType.esriDSymbolMarker,
esriDynamicSymbolRotationAlignment.esriDSRAHeading);
[VB.NET]
'Set the symbol's alignment so that it will align with the symbol's heading.
m_dynamicSymbolProps.RotationAlignment(esriDynamicSymbolType.esriDSymbolMarker) = esriDynamicSymbolRotationAlignment.esriDSRAHeading
Scale the symbol. Scaling refers to the scale relative to the original size of the active symbol. When scaling, you can use different scaling for x- and y-axis. See the following: