This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
87 lines (77 loc) · 3.1 KB
/
Form1.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Imports DevExpress.XtraMap
Imports System
Imports System.Collections.Generic
Imports System.Windows.Forms
Namespace CustomSearchProvider
Partial Public Class Form1
Inherits Form
Private ReadOnly Property Layer() As InformationLayer
Get
Return CType(mapControl1.Layers(1), InformationLayer)
End Get
End Property
Public Sub New()
InitializeComponent()
Dim provider As New SearchProvider()
Layer.DataProvider = provider
End Sub
End Class
Public Class SearchProvider
Inherits InformationDataProviderBase
Implements ISearchPanelRequestSender
Protected Shadows ReadOnly Property Data() As SearchData
Get
Return CType(MyBase.Data, SearchData)
End Get
End Property
Private ReadOnly Property Addresses As IEnumerable(Of LocationInformation) Implements ISearchPanelRequestSender.Addresses
Get
Return Data.Addresses
End Get
End Property
Protected Overrides Function CreateData() As IInformationData
Return New SearchData()
End Function
Private Sub SearchByString(keyword As String) Implements ISearchPanelRequestSender.SearchByString
Data.Search(keyword)
End Sub
End Class
Public Class SearchData
Implements IInformationData
Private ReadOnly addresses_Renamed As New List(Of LocationInformation)()
Public ReadOnly Property Addresses() As IEnumerable(Of LocationInformation)
Get
Return addresses_Renamed
End Get
End Property
Private Event OnDataResponse As EventHandler(Of RequestCompletedEventArgs) Implements IInformationData.OnDataResponse
Private Function CreateEventArgs() As RequestCompletedEventArgs
Dim items(addresses_Renamed.Count - 1) As MapItem
For i As Integer = 0 To items.Length - 1
items(i) = New MapCallout() With {.Location = addresses_Renamed(i).Location, .Text = addresses_Renamed(i).Address.FormattedAddress}
Next i
Return New RequestCompletedEventArgs(items, Nothing, False, Nothing)
End Function
Protected Sub RaiseChanged()
RaiseEvent OnDataResponse(Me, CreateEventArgs())
End Sub
Public Sub Search(ByVal keyword As String)
Dim rnd As New Random(Date.Now.Millisecond)
addresses_Renamed.Clear()
Dim length As Integer = keyword.Length
For i As Integer = 0 To length - 1
Dim info As New LocationInformation()
info.Address = New Address(keyword & " " & i.ToString())
info.Location = New GeoPoint(rnd.Next(180) - 90, rnd.Next(360) - 180)
addresses_Renamed.Add(info)
Next i
RaiseChanged()
End Sub
End Class
Public Class Address
Inherits AddressBase
Public Sub New(ByVal address As String)
Me.FormattedAddress = address
End Sub
End Class
End Namespace