This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
/
Form1.cs
57 lines (45 loc) · 2.25 KB
/
Form1.cs
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
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using DevExpress.Map;
using DevExpress.XtraMap;
namespace RangeDistributions {
public partial class Form1 : Form {
const string filepath = "../../Data/Countries.shp";
List<RangeDistributionBase> distributions = new List<RangeDistributionBase>{
new LinearRangeDistribution(),
new LogarithmicRangeDistribution(),
new ExponentialRangeDistribution()
};
VectorItemsLayer MapLayer { get { return (VectorItemsLayer)mapControl1.Layers["MapLayer"]; } }
ChoroplethColorizer Colorizer { get { return (ChoroplethColorizer)MapLayer.Colorizer; } }
ShapefileDataAdapter Adapter { get { return (ShapefileDataAdapter)MapLayer.Data; } }
public Form1() {
InitializeComponent();
cbRangeDistribution.DataSource = distributions;
Uri baseUri = new Uri(System.Reflection.Assembly.GetEntryAssembly().Location);
Adapter.FileUri = new Uri(baseUri, filepath);
}
private void cbRangeDistribution_SelectedIndexChanged(object sender, EventArgs e) {
RangeDistributionBase selectedDistribution = cbRangeDistribution.SelectedItem as RangeDistributionBase;
if (selectedDistribution == null) return;
if (selectedDistribution.Equals(distributions[0])) seFactor.Enabled = false;
else {
seFactor.Enabled = true;
EquationRangeDistribution eqDistribution = selectedDistribution as EquationRangeDistribution;
eqDistribution.Factor = (double)seFactor.Value;
}
Colorizer.RangeDistribution = selectedDistribution;
}
private void seFactor_EditValueChanged(object sender, EventArgs e) {
EquationRangeDistribution distribution = Colorizer.RangeDistribution as EquationRangeDistribution;
if (distribution == null) return;
distribution.Factor = (double)seFactor.Value;
}
#region #ApproximateColors
private void cbApproximateColors_CheckedChanged(object sender, EventArgs e) {
Colorizer.ApproximateColors = cbApproximateColors.Checked;
}
#endregion #ApproximateColors
}
}