Common Custom controls
CustomControls_VBNet\ADFWebPart\Utility.vb
' Copyright 2011 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
Namespace ADFWebPart_VBNet
    ''' <summary>
    ''' Internal class containing methods shared by different classes within the ADFWebPart_VBNet assembly  
    ''' </summary>
    Friend Class Utility
        ' Adds the passed-in resource to the passed-in map resource manager
        Friend Shared Sub AddMapResourceItemToResourceManager(ByVal mapResourceManager As ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceManager, ByVal insertIntoBeginning As Boolean, ByVal mapResourceItem As ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem)
            If insertIntoBeginning Then
                mapResourceManager.ResourceItems.Insert(0, mapResourceItem)
            Else
                mapResourceManager.ResourceItems.Add(mapResourceItem)
            End If
        End Sub

        ' Creates a resource item with the passed-in name, the passed-in resource definition string, 
        ' and default settings
        Friend Shared Function CreateResourceItem(ByVal resourceName As String, ByVal gisResourceItemDefinition As ESRI.ArcGIS.ADF.Web.UI.WebControls.GISResourceItemDefinition) As ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem
            Dim mapResourceItem As ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem = New ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem()
            mapResourceItem.Definition = gisResourceItemDefinition
            mapResourceItem.Name = resourceName
            mapResourceItem.DisplaySettings = New ESRI.ArcGIS.ADF.Web.DisplaySettings()
            mapResourceItem.DisplaySettings.Visible = True
            Dim imageDescriptor As ESRI.ArcGIS.ADF.Web.ImageDescriptor = New ESRI.ArcGIS.ADF.Web.ImageDescriptor()
            imageDescriptor.ImageFormat = ESRI.ArcGIS.ADF.Web.ImageFormat.PNG8
            imageDescriptor.TransparentBackground = True
            imageDescriptor.TransparentColor = System.Drawing.Color.White
            imageDescriptor.ReturnMimeData = True
            mapResourceItem.DisplaySettings.ImageDescriptor = imageDescriptor
            mapResourceItem.DisplaySettings.Transparency = 0
            Return mapResourceItem
        End Function

        ' Creates a GISResourceItemDefinition with the passed-in parameters
        Friend Shared Function CreateGISResourceItemDefinition(ByVal dataSourceDefinition As String, ByVal dataSourceType As String, ByVal identity As String, ByVal resourceDefinition As String, ByVal dataSourceShared As Boolean) As ESRI.ArcGIS.ADF.Web.UI.WebControls.GISResourceItemDefinition
            Dim gisResourceItemDefinition As ESRI.ArcGIS.ADF.Web.UI.WebControls.GISResourceItemDefinition = New ESRI.ArcGIS.ADF.Web.UI.WebControls.GISResourceItemDefinition()
            gisResourceItemDefinition.DataSourceDefinition = dataSourceDefinition
            If (identity Is Nothing) Then
                gisResourceItemDefinition.Identity = String.Empty
            Else
                gisResourceItemDefinition.Identity = identity
            End If
            gisResourceItemDefinition.ResourceDefinition = resourceDefinition
            gisResourceItemDefinition.DataSourceShared = dataSourceShared
            gisResourceItemDefinition.DataSourceType = dataSourceType
            Return gisResourceItemDefinition
        End Function
    End Class

End Namespace