Mini Kabibi Habibi
Imports Microsoft.VisualBasic
Imports System
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Collections.Generic
Imports DevExpress.Utils
Imports System.Xml.Linq
Imports System.Globalization
Namespace DevExpress.XtraMap.Demos
Partial Public Class DataSource
Inherits MapTutorialControl
Private ReadOnly Property TilesLayer() As ImageTilesLayer
Get
Return CType(mapControl1.Layers(0), ImageTilesLayer)
End Get
End Property
Private ReadOnly Property ItemsLayer() As VectorItemsLayer
Get
Return CType(mapControl1.Layers(1), VectorItemsLayer)
End Get
End Property
Private toolTipFont As Font
Public Sub New()
InitializeComponent()
TilesLayer.DataProvider = CreateBingDataProvider(BingMapKind.Hybrid)
ItemsLayer.DataSource = LoadShipsFromXML()
Me.toolTipFont = New Font(AppearanceObject.DefaultFont.FontFamily, 12, FontStyle.Bold)
End Sub
Private Function LoadShipsFromXML() As List(Of ShipInfo)
Dim ships As New List(Of ShipInfo)()
Dim document As XDocument = DemoUtils.LoadXml("Ships.xml")
If document IsNot Nothing Then
For Each element As XElement In document.Element("Ships").Elements()
Dim latitude As Double = Convert.ToDouble(element.Element("Latitude").Value, CultureInfo.InvariantCulture)
Dim longitude As Double = Convert.ToDouble(element.Element("Longitude").Value, CultureInfo.InvariantCulture)
Dim name As String = element.Element("Name").Value
Dim description As String = element.Element("Description").Value
Dim year As String = element.Element("Year").Value
ships.Add(New ShipInfo() With {.Latitude = latitude, .Longitude = longitude, .Description = description, .Name = name, .Year = year})
Next element
End If
Return ships
End Function
Private Sub toolTipController1_BeforeShow(ByVal sender As Object, ByVal e As ToolTipControllerShowEventArgs) Handles toolTipController1.BeforeShow
Dim customElement As MapCustomElement = CType(e.SelectedObject, MapCustomElement)
Dim shipInfo As ShipInfo = CType(ItemsLayer.GetItemSourceObject(customElement), ShipInfo)
Dim titleItem1 As New ToolTipTitleItem() With {.Text = shipInfo.Header}
titleItem1.Appearance.ForeColor = SystemColors.GrayText
titleItem1.Appearance.Font = toolTipFont
Dim superToolTip As New SuperToolTip()
superToolTip.Items.Add(titleItem1)
Dim sepItem As New ToolTipSeparatorItem()
superToolTip.Items.Add(sepItem)
Dim textItem As New ToolTipItem() With {.Text = e.ToolTip}
superToolTip.Items.Add(textItem)
e.SuperTip = superToolTip
End Sub
End Class
Public Class ShipInfo
Private privateLatitude As Double
Public Property Latitude() As Double
Get
Return privateLatitude
End Get
Set(ByVal value As Double)
privateLatitude = value
End Set
End Property
Private privateLongitude As Double
Public Property Longitude() As Double
Get
Return privateLongitude
End Get
Set(ByVal value As Double)
privateLongitude = value
End Set
End Property
Private privateName As String
Public Property Name() As String
Get
Return privateName
End Get
Set(ByVal value As String)
privateName = value
End Set
End Property
Private privateYear As String
Public Property Year() As String
Get
Return privateYear
End Get
Set(ByVal value As String)
privateYear = value
End Set
End Property
Private privateDescription As String
Public Property Description() As String
Get
Return privateDescription
End Get
Set(ByVal value As String)
privateDescription = value
End Set
End Property
Public ReadOnly Property Header() As String
Get
Return Name & " (" & Year & ")"
End Get
End Property
End Class
End Namespace