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
76 lines (63 loc) · 2.9 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
Imports System
Imports System.Collections.Generic
Imports System.Windows.Forms
Imports DevExpress.Map
Imports DevExpress.XtraMap
Namespace RangeDistributions
Partial Public Class Form1
Inherits Form
Private Const filepath As String = "../../Data/Countries.shp"
Private distributions As New List(Of RangeDistributionBase)() From { _
New LinearRangeDistribution(), _
New LogarithmicRangeDistribution(), _
New ExponentialRangeDistribution() _
}
Private ReadOnly Property MapLayer() As VectorItemsLayer
Get
Return CType(mapControl1.Layers("MapLayer"), VectorItemsLayer)
End Get
End Property
Private ReadOnly Property Colorizer() As ChoroplethColorizer
Get
Return CType(MapLayer.Colorizer, ChoroplethColorizer)
End Get
End Property
Private ReadOnly Property Adapter() As ShapefileDataAdapter
Get
Return CType(MapLayer.Data, ShapefileDataAdapter)
End Get
End Property
Public Sub New()
InitializeComponent()
cbRangeDistribution.DataSource = distributions
Dim baseUri As New Uri(System.Reflection.Assembly.GetEntryAssembly().Location)
Adapter.FileUri = New Uri(baseUri, filepath)
End Sub
Private Sub cbRangeDistribution_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles cbRangeDistribution.SelectedIndexChanged
Dim selectedDistribution As RangeDistributionBase = TryCast(cbRangeDistribution.SelectedItem, RangeDistributionBase)
If selectedDistribution Is Nothing Then
Return
End If
If selectedDistribution.Equals(distributions(0)) Then
seFactor.Enabled = False
Else
seFactor.Enabled = True
Dim eqDistribution As EquationRangeDistribution = TryCast(selectedDistribution, EquationRangeDistribution)
eqDistribution.Factor = CDbl(seFactor.Value)
End If
Colorizer.RangeDistribution = selectedDistribution
End Sub
Private Sub seFactor_EditValueChanged(ByVal sender As Object, ByVal e As EventArgs) Handles seFactor.EditValueChanged
Dim distribution As EquationRangeDistribution = TryCast(Colorizer.RangeDistribution, EquationRangeDistribution)
If distribution Is Nothing Then
Return
End If
distribution.Factor = CDbl(seFactor.Value)
End Sub
#Region "#ApproximateColors"
Private Sub cbApproximateColors_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) Handles cbApproximateColors.CheckedChanged
Colorizer.ApproximateColors = cbApproximateColors.Checked
End Sub
#End Region ' #ApproximateColors
End Class
End Namespace