Private Sub AddRasterLayers(ByVal fileNames As IEnumerable(Of String)) For Each fileName As String In fileNames Try Dim layerName As String = New FileInfo(fileName).Name If Not DirectCast(WinformsMap1.Overlays(0), LayerOverlay).Layers.Contains(layerName) Then Dim rasterLayer As RasterLayer = Nothing Select Case Path.GetExtension(fileName).ToUpperInvariant() Case ".SID" rasterLayer = New MrSidRasterLayer(fileName) Exit Select Case ".ECW" rasterLayer = New EcwRasterLayer(fileName) Exit Select Case ".JP2" rasterLayer = New Jpeg2000RasterLayer(fileName) Exit Select Case ".BMP", ".JPG", ".JPEG", ".GIF", ".TIFF", ".TIF" rasterLayer = New GdiPlusRasterLayer(fileName) Exit Select Case Else Exit Select End Select If rasterLayer IsNot Nothing AndAlso ExplorerHelper.ValidateRasterLayer(rasterLayer) Then rasterLayer.Name = layerName WinformsMap1.Overlays(0).Lock.EnterWriteLock() Try DirectCast(WinformsMap1.Overlays(0), LayerOverlay).Layers.Add(layerName, rasterLayer) Finally WinformsMap1.Overlays(0).Lock.ExitWriteLock() End Try SetupThemeItem(rasterLayer) End If End If Catch ex As Exception MessageBox.Show(ex.Message, ex.[GetType]().ToString(), MessageBoxButtons.OK, MessageBoxIcon.[Error], MessageBoxDefaultButton.Button1, DirectCast(0, MessageBoxOptions)) End Try Next End Sub Public Shared Function ValidateRasterLayer(ByVal rasterLayer As RasterLayer) As Boolean Dim isValidate As Boolean = True Try rasterLayer.Open() Catch generatedExceptionName As Exception isValidate = False Finally If rasterLayer.IsOpen Then rasterLayer.Close() End If End Try Return isValidate End Function