WPF Globe Gallery
Application.xaml.vb
' Copyright 2012 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.Windows
Imports System.Windows.Data
Imports System.Xml
Imports System.Configuration
Imports ESRI.ArcGIS.esriSystem

Class Application

 Protected Overrides Sub OnStartUp(ByVal e As System.Windows.StartupEventArgs)

    MyBase.OnStartup(e)

    Dim galleryWindow As Gallery = New Gallery()
    galleryWindow.mapGallery = CType(Me.Resources("Maps"), ObjectDataProvider).Data
    galleryWindow.mapGallery = CType((TryCast(Me.Resources("Maps"), ObjectDataProvider)).Data, MapCollection)
    galleryWindow.mapGallery.Path = data.GetLocalDataPath() & "\GlobeImages"

    'bind to ArcGIS Engine installation
    ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Engine)

    If (Not InitializeEngineLicense()) Then
            MessageBox.Show("ArcGIS Engine License or Globe Extension could not be initialized.  Closing...")
    End If
 End Sub


 Private Function InitializeEngineLicense() As Boolean
    Dim aoi As AoInitialize = New AoInitializeClass()

    'more license choices could be included here
    Dim productCode As ESRI.ArcGIS.esriSystem.esriLicenseProductCode = ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeEngine
    Dim extensionCode As esriLicenseExtensionCode = esriLicenseExtensionCode.esriLicenseExtensionCode3DAnalyst

    If aoi.IsProductCodeAvailable(productCode) = ESRI.ArcGIS.esriSystem.esriLicenseStatus.esriLicenseAvailable Then
      If aoi.IsExtensionCodeAvailable(productCode, extensionCode) = ESRI.ArcGIS.esriSystem.esriLicenseStatus.esriLicenseAvailable Then
        aoi.Initialize(productCode)
        aoi.CheckOutExtension(extensionCode)
        Return True
      Else
        Return False
      End If
    End If
  End Function
End Class