Displaying symbol-based MOLE graphics on a MapControl
MoleDisplay.vb
' Copyright 2010 ESRI
' 
' All rights reserved under the copyright laws of the United States
' and applicable international laws, treaties, and conventions.
' 
' You may freely redistribute and use this sample code, with or
' without modification, provided you include the original copyright
' notice and use restrictions.
' 
' See the use restrictions.
' 


Public Class MoleDisplay
    Dim COUNT As Int32
    Dim m_Random As New Random
    Dim sicArray() As String = {"SFAPC----------", "SFAPCF---------", "SFAPFH---------", "SFAPCL---------", "SFAPM----------"}
    Dim sd As ESRI.ArcGIS.Display.IScreenDisplay


#Region "class constructor"
    Public Sub New()
        ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Engine)
        InitializeComponent()
    End Sub
#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        COUNT = 5
        AxMapControl1.LoadMxFile(GetSdkDataPath() + "MilitaryOverlayEditor\MoleBasemap.mxd")
        ' drawSymbols()

    End Sub

    Private Sub drawSymbols()

        ' get screen display from active view

        sd = AxMapControl1.ActiveView.ScreenDisplay
        sd.StartDrawing(sd.hDC, ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache)


        Dim i As String
        For Each i In sicArray
            'create point
            Dim point As ESRI.ArcGIS.Geometry.IPoint
            point = CreateRandomPoint()

            'create marker symbol from mole marker symbol class
            Dim markerSym As ESRI.ArcGIS.DefenseSolutions.IMoleSymbol
            markerSym = New ESRI.ArcGIS.DefenseSolutions.MoleMarkerSymbolClass()

            'set the symbol id on the marker symbol
            markerSym.SymbolID = i

            'assign color to the symbol
            Dim m As ESRI.ArcGIS.Display.IMarkerSymbol
            m = markerSym
            m.Color = CreateRandomColor()

            'now that we have the symbol add it to screen display
            sd.SetSymbol(m)
            sd.DrawPoint(point)
        Next i
        sd.FinishDrawing()

    End Sub

    Public Function CreateRandomPoint() As ESRI.ArcGIS.Geometry.IPoint
        ' Create a new point and set its properties
        Dim point As ESRI.ArcGIS.Geometry.IPoint
        point = New ESRI.ArcGIS.Geometry.PointClass()
        point.PutCoords(m_Random.Next(-30, 30), m_Random.Next(-30, 30))
        Return point

    End Function

    Public Function CreateRandomColor() As ESRI.ArcGIS.Display.IColor

        Dim rgb As ESRI.ArcGIS.Display.IRgbColor
        rgb = New ESRI.ArcGIS.Display.RgbColorClass()
        rgb.Red = m_Random.Next(0, 255)
        rgb.Green = m_Random.Next(0, 255)
        rgb.Blue = m_Random.Next(0, 255)

        Return rgb

    End Function

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        drawSymbols()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        sd.Invalidate(AxMapControl1.Extent, True, ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache)

    End Sub

    Private Function GetSdkDataPath() As String
        'get the ArcGIS path from the registry
        Dim key As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\ESRI\ArcGIS_SXS_SDK")
        Dim path As String = Convert.ToString(key.GetValue("InstallDir"))

        'set the of the logo
        Dim str As String = System.IO.Path.Combine(path, "Samples\data\")
        If (Not System.IO.Directory.Exists(str)) Then
            MessageBox.Show("Path :" & str & " does not exist!")
            Return String.Empty
        End If

        Return str
    End Function

End Class