テキスト・ファイルをDownLoadして、複数のMapPolygon(6角形)を作成・MouseLeftButtonUpイベントを追加しました。
イベント先 Car_Click()でクリックしたcar()は何番目なのかを知る方法を教えてください。
Partial Public Class MainPage
Public car() As MapPolygon
Private Function GetPoints(ByVal count As Integer, ByVal centerX As Double, ByVal centerY As Double) As LocationCollection
Dim width As Double = BingMaps.ViewportSize.Width * 0.1
width = 0.00001
Dim points As LocationCollection = New LocationCollection()
For i As Integer = 0 To count - 1
Dim j As Double = i / count
points.Add(New Location(centerX + Math.Cos(j * 2.0 * Math.PI) * width, centerY + Math.Sin(j * 2.0 * Math.PI) * width))
Next
Return points
End Function
Private Sub wc_DownloadStringCompleted(ByVal sender As Object, ByVal e As DownloadStringCompletedEventArgs)
'* テキスト・ファイルをDownLoad完了
Dim s1 As String
Dim GYO() As String
Dim buf() As String
If IsNothing(e.Error) = True Then
s1 = e.Result
GYO = s1.Split(vbCrLf)
'* 配列の宣言
ReDim car(GYO.Length - 2)
For i As Integer = 0 To GYO.Length - 2
buf = GYO(i).Split(",")
'* エリアの確保
car(i) = New MapPolygon()
car(i).Locations = GetPoints(6, buf(1), buf(2))
car(i).StrokeThickness = 5
car(i).Stroke = New SolidColorBrush(Colors.Blue)
car(i).Fill = New SolidColorBrush(Colors.Blue)
'* 左ボタン・クリックのイベント追加
AddHandler car(i).MouseLeftButtonUp, AddressOf Car_Click
MyLayer.Children.Add(car(i))
Next
End If
End Sub
Private Sub Car_Click(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)
For i As Integer = 0 To car.Length
Next
End Sub
End Class