Common_CustomDataSource_VBNet\TiledMapDataSource_VBNet\MapFunctionality.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. ' Imports Microsoft.VisualBasic Imports System Imports System.Collections.Generic Imports System.Text Imports System.Web.UI Imports ESRI.ArcGIS.ADF.Web.Geometry Imports ESRI.ArcGIS.ADF.Web.SpatialReference Imports ESRI.ArcGIS.ADF.Web.DataSources Imports System.Collections Imports ESRI.ArcGIS.ADF.Web.Display.Graphics Imports ESRI.ArcGIS.ADF.Web.Display.Drawing Imports ESRI.ArcGIS.ADF.Web Namespace TiledMapDataSource_VBNet Public Class MapFunctionality Implements IMapFunctionality #Region "Constructor" Public Sub New(ByVal name_Renamed As String, ByVal resource_Renamed As MapResource) Me.name_Renamed = name_Renamed Me.resource_Renamed = resource_Renamed End Sub Public ReadOnly Property MapResource() As MapResource Get Return TryCast(resource_Renamed, MapResource) End Get End Property #End Region #Region "IMapFunctionality implementation" #Region "Private Member Vars" Private displaySettings_Renamed As ESRI.ArcGIS.ADF.Web.DisplaySettings = Nothing Private webControl_Renamed As System.Web.UI.WebControls.WebControl = Nothing Private maintainsState_Renamed As Boolean = False Private spatialReference_Renamed As ESRI.ArcGIS.ADF.Web.SpatialReference.SpatialReference = Nothing Private layerVisibility_Renamed As Dictionary(Of String, Boolean) = Nothing #End Region #Region "Public Properties" Public Property MaintainsState() As Boolean Implements IMapFunctionality.MaintainsState Get Return maintainsState_Renamed End Get Set(ByVal value As Boolean) maintainsState_Renamed = Value End Set End Property Public Property WebControl() As System.Web.UI.WebControls.WebControl Implements IMapFunctionality.WebControl Get Return webControl_Renamed End Get Set(ByVal value As System.Web.UI.WebControls.WebControl) webControl_Renamed = Value End Set End Property Public ReadOnly Property Units() As ESRI.ArcGIS.ADF.Web.DataSources.Units Implements IMapFunctionality.Units Get Throw New NotImplementedException() End Get End Property Public Property DisplaySettings() As ESRI.ArcGIS.ADF.Web.DisplaySettings Implements IMapFunctionality.DisplaySettings Get If maintainsState_Renamed Then If displaySettings_Renamed Is Nothing Then displaySettings_Renamed = CType(MapResource.DisplaySettings.Clone(), DisplaySettings) End If Return displaySettings_Renamed Else Return MapResource.DisplaySettings End If End Get Set(ByVal value As ESRI.ArcGIS.ADF.Web.DisplaySettings) If maintainsState_Renamed Then displaySettings_Renamed = Value Else MapResource.DisplaySettings = Value End If End Set End Property Public ReadOnly Property LayerIDs() As Object() Get Dim ids As Object() = New Object(LayerVisibility.Count - 1) {} Dim i As Integer = 0 For Each kvp As KeyValuePair(Of String, Boolean) In LayerVisibility ids(i) = kvp.Key.ToString() i += 1 Next kvp Return ids End Get End Property Private extent_Renamed As Envelope Public Property Extent() As Envelope Get Return extent_Renamed End Get Set(ByVal value As Envelope) extent_Renamed = Value End Set End Property Public Property SpatialReference() As ESRI.ArcGIS.ADF.Web.SpatialReference.SpatialReference Implements IMapFunctionality.SpatialReference Get Return spatialReference_Renamed End Get Set(ByVal value As ESRI.ArcGIS.ADF.Web.SpatialReference.SpatialReference) spatialReference_Renamed = Value End Set End Property Public Function GetScale() As Double Return Double.NaN End Function Public ReadOnly Property Rotation() As Double Implements IMapFunctionality.Rotation Get Return Double.NaN End Get End Property #End Region #Region "Public Methods" Public Sub ApplyStateToDataSourceObjects() Implements IMapFunctionality.ApplyStateToDataSourceObjects Throw New NotImplementedException() End Sub Public Sub GetStateFromDataSourceObjects() Implements IMapFunctionality.GetStateFromDataSourceObjects Throw New NotImplementedException() End Sub Public Sub GetLayers(<System.Runtime.InteropServices.Out()> ByRef layerids As String(), <System.Runtime.InteropServices.Out()> ByRef layernames As String()) Implements ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality.GetLayers Throw New NotImplementedException() End Sub Public Sub GetVisibleScale(ByVal layerid As String, <System.Runtime.InteropServices.Out()> ByRef minscale As Double, <System.Runtime.InteropServices.Out()> ByRef maxscale As Double) Implements IMapFunctionality.GetVisibleScale Throw New NotImplementedException() End Sub Public Function GetScale(ByVal extent_Renamed As ESRI.ArcGIS.ADF.Web.Geometry.Envelope, ByVal mapWidth As Integer, ByVal mapHeight As Integer) As Double Implements IMapFunctionality.GetScale Throw New NotImplementedException() End Function Public Function GetCopyrightText() As System.Collections.Generic.Dictionary(Of String, String) Implements ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality.GetCopyrightText Throw New NotImplementedException() End Function Public Function DrawExtent(ByVal extentToDraw As ESRI.ArcGIS.ADF.Web.Geometry.Envelope) As ESRI.ArcGIS.ADF.Web.MapImage Implements IMapFunctionality.DrawExtent Throw New NotImplementedException() End Function Public ReadOnly Property LayerVisibility() As Dictionary(Of String, Boolean) Get If maintainsState_Renamed Then Return MapResource.layerVisibility Else Return layerVisibility_Renamed End If End Get End Property Public Function GetLayerVisibility(ByVal layerID As String) As Boolean Implements IMapFunctionality.GetLayerVisibility Return LayerVisibility(layerID) End Function Public Sub SetLayerVisibility(ByVal layerID As String, ByVal visible As Boolean) Implements IMapFunctionality.SetLayerVisibility LayerVisibility(layerID) = visible End Sub #End Region #End Region #Region "IGISFunctionality implementation" Private name_Renamed As String = String.Empty Private resource_Renamed As IGISResource = Nothing Private initialized_Renamed As Boolean = False Public Property Name() As String Implements IMapFunctionality.Name Get Return name_Renamed End Get Set(ByVal value As String) name_Renamed = Value End Set End Property Public Property Resource() As IGISResource Implements IMapFunctionality.Resource Get Return resource_Renamed End Get Set(ByVal value As IGISResource) resource_Renamed = Value End Set End Property Public ReadOnly Property Initialized() As Boolean Implements IMapFunctionality.Initialized Get Return initialized_Renamed End Get End Property Public Sub LoadState() Implements IMapFunctionality.LoadState If resource_Renamed.DataSource Is Nothing Then Return End If If resource_Renamed.DataSource.State Is Nothing Then Return End If Dim o As Object = resource_Renamed.DataSource.State(key) If Not o Is Nothing Then Dim mf As MapFunctionality = TryCast(o, MapFunctionality) layerVisibility_Renamed = mf.LayerVisibility End If End Sub Public Sub Initialize() Implements IMapFunctionality.Initialize initialized_Renamed = True If layerVisibility_Renamed Is Nothing Then layerVisibility_Renamed = New Dictionary(Of String, Boolean)() Dim mapRes As MapResource = TryCast(resource_Renamed, MapResource) For Each kvp As KeyValuePair(Of String, Boolean) In mapRes.layerVisibility layerVisibility_Renamed.Add(kvp.Key, kvp.Value) Next kvp End If End Sub Public Sub SaveState() Implements IMapFunctionality.SaveState If resource_Renamed.DataSource Is Nothing Then Return End If If resource_Renamed.DataSource.State Is Nothing Then Return End If resource_Renamed.DataSource.State(key) = Me End Sub Public Sub Dispose() Implements IMapFunctionality.Dispose initialized_Renamed = False End Sub Public Function Supports(ByVal operation As String) As Boolean Implements IMapFunctionality.Supports Return False End Function #End Region #Region "Private Properties" Private ReadOnly Property key() As String Get Dim szResource As String = CType(resource_Renamed, Object).GetType().ToString() & ":" & resource_Renamed.Name Dim szThis As String = Me.GetType().ToString() & ":" & name_Renamed Return (szResource & "," & szThis) End Get End Property #End Region End Class End Namespace