Common CustomDataSourceCommon_CustomDataSource_VBNet\CustomDataSourceWebApp_VBNet\Default_TileMapData.aspx.vb
' Copyright 2007 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.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Collections
Imports ESRI.ArcGIS.ADF.Web.DataSources
Public Partial Class _Default
Inherits System.Web.UI.Page
Implements ICallbackEventHandler
Public sCallBackFunctionInvocation As String
Private returnstring As String = ""
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If (Not IsPostBack) Then
Session("GraphicColor") = "Red"
Session("GraphicType") = "Circle"
End If
DropDownList1.Attributes.Add("onchange", "ChangeDDLColor()")
DropDownList2.Attributes.Add("onchange", "ChangeDDLType()")
sCallBackFunctionInvocation = Page.ClientScript.GetCallbackEventReference(Me, "message", "HandleResponse", "context", "postBackError", True)
End Sub
#Region "ICallbackEventHandler Members"
Private Function GetCallbackResult() As String Implements ICallbackEventHandler.GetCallbackResult
Return returnstring
End Function
Private Sub RaiseCallbackEvent(ByVal eventArgs As String) Implements ICallbackEventHandler.RaiseCallbackEvent
Dim parser_char As Char() = { ","c }
If eventArgs.Contains("ddl_color") Then
Dim messages As String() = eventArgs.Split(parser_char)
Dim graphiccolor As String = messages(1)
Session("GraphicColor") = graphiccolor
ElseIf eventArgs.Contains("ddl_type") Then
Dim messages As String() = eventArgs.Split(parser_char)
Dim graphictype As String = messages(1)
Session("GraphicType") = graphictype
End If
End Sub
#End Region
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim MyFile As HttpPostedFile = FileUpload1.PostedFile
Dim FileLen As Integer
Dim MyStream As System.IO.Stream = Nothing
FileLen = MyFile.ContentLength
Dim input As Byte() = New Byte(FileLen - 1){}
MyStream = MyFile.InputStream
Dim reader As System.IO.StreamReader
reader = New System.IO.StreamReader(MyStream, System.Text.Encoding.ASCII)
Dim str As String
Dim alist As System.Collections.ArrayList = New System.Collections.ArrayList()
Dim parser_char As Char() = { ","c }
Do
str = reader.ReadLine()
If Not str Is Nothing Then
Dim messages As String() = str.Split(parser_char)
Dim x As Double = Double.Parse(messages(0))
Dim y As Double = Double.Parse(messages(1))
Dim point As ESRI.ArcGIS.ADF.Web.Geometry.Point = New ESRI.ArcGIS.ADF.Web.Geometry.Point(x, y)
alist.Add(point)
System.Diagnostics.Debug.WriteLine(str)
End If
Loop While Not str Is Nothing
Dim gfc As IEnumerable = Map1.GetFunctionalities()
Dim gResource As ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource = Nothing
For Each gfunc As IGISFunctionality In gfc
If TypeOf gfunc.Resource Is ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource Then
gResource = CType(gfunc.Resource, ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource)
Exit For
End If
Next gfunc
If gResource Is Nothing Then
Return
End If
Dim glayer As ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer = Nothing
If glayer Is Nothing Then
glayer = New ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer()
glayer.TableName = "Uploaded Points"
gResource.Graphics.Tables.Add(glayer)
End If
For Each pnt As ESRI.ArcGIS.ADF.Web.Geometry.Point In alist
Dim sms As ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleMarkerSymbol = New ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleMarkerSymbol()
sms.Color = System.Drawing.Color.FromName(CStr(Session("GraphicColor")))
Dim graphictype As String = CStr(Session("GraphicType"))
If graphictype = "Circle" Then
sms.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Circle
ElseIf DropDownList2.SelectedValue = "Square" Then
sms.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Square
Else
sms.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Star
End If
sms.Width = 14
sms.OutlineColor = System.Drawing.Color.Black
Dim ge As ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement = New ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(pnt, sms, Nothing)
glayer.Add(ge)
Next pnt
If Map1.ImageBlendingMode = ESRI.ArcGIS.ADF.Web.UI.WebControls.ImageBlendingMode.Browser Then
Map1.RefreshResource(gResource.Name)
Else
Map1.Refresh()
End If
Toc1.Refresh()
Map1.CallbackResults.CopyFrom(Toc1.CallbackResults)
End Sub
End Class