Dynamic logo layer
DynamicLogoLayerClass.vb
' Copyright 2006 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.
'
Imports Microsoft.VisualBasic
Imports System
Imports System.Drawing
Imports System.Runtime.InteropServices
Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.Geometry
Imports ESRI.ArcGIS.Display
Imports ESRI.ArcGIS.esriSystem
<Guid(DynamicLogoLayerClass.GUID), ClassInterface(ClassInterfaceType.None), ProgId("DynamicLogoLayer.DynamicLogoLayerClass")> _
Public NotInheritable Class DynamicLogoLayerClass
Inherits ESRI.ArcGIS.ADF.BaseClasses.BaseDynamicLayer
#Region "class members"
Public Const GUID As String = "7a78479c-fa89-4b31-9ef6-3b90002b9c0b"
Public m_bOnce As Boolean = True
Private m_logoGlyph As IDynamicGlyph = Nothing
Private m_dynamicGlyphFactory As IDynamicGlyphFactory = Nothing
Private m_dynamicSymbolProps As IDynamicSymbolProperties = Nothing
Private m_dynamicDrawScreen As IDynamicDrawScreen = Nothing
Private m_point As IPoint
Private m_logoSymbol As ISymbol = Nothing
Private m_logoPath As String = String.Empty
#End Region
#Region "class constructor"
Public Sub New()
MyBase.New()
MyBase.m_uid.Value = "DynamicLogoLayer.DynamicLogoLayerClass"
'search for the logo path
m_logoPath = GetLogoPath()
If String.Empty = m_logoPath Then
Throw New Exception("Cannot find logo bitmap!")
End If
End Sub
#End Region
#Region "overriden methods"
Public Overrides Sub DrawDynamicLayer(ByVal DynamicDrawPhase As ESRI.ArcGIS.Display.esriDynamicDrawPhase, ByVal Display As ESRI.ArcGIS.Display.IDisplay, ByVal DynamicDisplay As ESRI.ArcGIS.Display.IDynamicDisplay)
If m_bOnce Then
'cast the DynamicDisplay into DynamicGlyphFactory
m_dynamicGlyphFactory = DynamicDisplay.DynamicGlyphFactory
'cast the DynamicDisplay into DynamicSymbolProperties
m_dynamicSymbolProps = TryCast(DynamicDisplay, IDynamicSymbolProperties)
m_dynamicDrawScreen = TryCast(DynamicDisplay, IDynamicDrawScreen)
'create the dynamic glyph for the logo
m_logoGlyph = m_dynamicGlyphFactory.CreateDynamicGlyphFromFile(esriDynamicGlyphType.esriDGlyphMarker, m_logoPath, ESRI.ArcGIS.ADF.Converter.ToRGBColor(Color.White))
m_point = New PointClass()
m_point.PutCoords(120, 160)
m_bOnce = False
End If
m_dynamicSymbolProps.DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker) = m_logoGlyph
m_dynamicSymbolProps.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 0.5F, 0.5F)
m_dynamicDrawScreen.DrawScreenMarker(m_point)
MyBase.m_bIsImmediateDirty = True
End Sub
Public Overrides Sub Draw(ByVal drawPhase As esriDrawPhase, ByVal Display As IDisplay, ByVal trackCancel As ITrackCancel)
If esriDrawPhase.esriDPAnnotation <> drawPhase Then
Return
End If
If Nothing Is m_logoSymbol Then
m_logoSymbol = CreateStandardLogoSymbol()
End If
Dim r As tagRECT = Display.DisplayTransformation.DeviceFrame
Display.SetSymbol(m_logoSymbol)
Display.DrawPoint(Display.DisplayTransformation.ToMapPoint(120, r.bottom - 160))
End Sub
Public Overrides ReadOnly Property ID() As ESRI.ArcGIS.esriSystem.UID
Get
Return MyBase.m_uid
End Get
End Property
Public Overrides ReadOnly Property SupportedDrawPhases() As Integer
Get
Return CInt(Fix(esriDrawPhase.esriDPAnnotation))
End Get
End Property
#End Region
#Region "private methods"
Private Function GetLogoPath() As String
Dim str As String = System.IO.Path.GetFullPath("./../../ESRI_LOGO.bmp")
If (Not System.IO.File.Exists(str)) Then
Return String.Empty
End If
Return str
End Function
Private Function CreateStandardLogoSymbol() As ISymbol
Dim pictureMarkerSymbol As IPictureMarkerSymbol = New PictureMarkerSymbolClass()
pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, m_logoPath)
pictureMarkerSymbol.Size = 100
Return TryCast(pictureMarkerSymbol, ISymbol)
End Function
#End Region
End Class