This repository has been archived by the owner on Sep 25, 2023. It is now read-only.
/
Form1.vb
103 lines (88 loc) · 4.08 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Globalization
Imports System.Windows.Forms
Imports System.Xml.Linq
Imports DevExpress.TreeMap
Imports DevExpress.XtraTreeMap
Namespace SunburstDrillDown
Partial Public Class Form1
Inherits Form
Private dataStack As New Stack(Of DataSourceInfo)()
Private ReadOnly Property DataAdapter() As SunburstHierarchicalDataAdapter
Get
Return CType(sunburstControl1.DataAdapter, SunburstHierarchicalDataAdapter)
End Get
End Property
Public Sub New()
InitializeComponent()
DataAdapter.Mappings(0).Type = GetType(TypeInfo)
DataAdapter.DataSource = LoadDataFromXML()
End Sub
#Region "LoadData"
Private Sub LoadData(ByVal element As XElement, ByVal datas As List(Of TypeInfo))
Dim data As New TypeInfo() With { _
.NamespaceString = element.Element("Namespace").Value, _
.TypesCount = Convert.ToDouble(element.Element("TypesCount").Value, CultureInfo.InvariantCulture) _
}
datas.Add(data)
For Each item In element.Element("NestedNamespaces").Elements()
LoadData(item, data.NestedNamespaces)
Next item
End Sub
Private Function LoadDataFromXML() As List(Of TypeInfo)
Dim document As XDocument = XDocument.Load("..\..\Data\XtraBarsTypes.xml")
Dim datas As New List(Of TypeInfo)()
If document IsNot Nothing Then
For Each element As XElement In document.Element("ArrayOfTypeInfo").Elements()
LoadData(element, datas)
Next element
End If
Return datas
End Function
#End Region
#Region "Process DrillDown"
Private Sub sunburstControl1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles sunburstControl1.MouseUp
Dim shi As SunburstHitInfo = sunburstControl1.CalcHitInfo(e.Location)
If shi.InSunburstItem Then
dataStack.Push(New DataSourceInfo(DataAdapter.DataSource, sunburstControl1.CenterLabel.TextPattern))
Dim data As TypeInfo = CType(shi.SunburstItem.Tag, TypeInfo)
DataAdapter.DataSource = data
sunburstControl1.CenterLabel.TextPattern &= "." & data.NamespaceString
ElseIf shi.InCenterLabel AndAlso dataStack.Count > 0 Then
Dim sourceInfo As DataSourceInfo = dataStack.Pop()
DataAdapter.DataSource = sourceInfo.Source
sunburstControl1.CenterLabel.TextPattern = sourceInfo.Label
End If
End Sub
#End Region
Private Sub sunburstControl1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles sunburstControl1.MouseMove
Dim shi As SunburstHitInfo = sunburstControl1.CalcHitInfo(e.Location)
sunburstControl1.Cursor = If(shi.InCenterLabel AndAlso dataStack.Count > 0, Cursors.Hand, Cursors.Arrow)
End Sub
End Class
Public Class DataSourceInfo
Public ReadOnly Property Source() As Object
Public ReadOnly Property Label() As String
Public Sub New(ByVal source As Object, ByVal label As String)
Me.Source = source
Me.Label = label
End Sub
End Class
Public Class TypeInfo
Implements IListSource
Public Property NamespaceString() As String
Public Property TypesCount() As Double
Public ReadOnly Property NestedNamespaces() As New List(Of TypeInfo)()
Private ReadOnly Property IListSource_ContainsListCollection() As Boolean Implements IListSource.ContainsListCollection
Get
Return True
End Get
End Property
Private Function IListSource_GetList() As IList Implements IListSource.GetList
Return If(NestedNamespaces.Count > 0, NestedNamespaces, New List(Of TypeInfo)() From {Me})
End Function
End Class
End Namespace