windowsforms-devexpress-dot-xtramap-96d949b1.md
Represents the linear distribution of color ranges in a colorizer.
Namespace : DevExpress.XtraMap
Assembly : DevExpress.XtraMap.v25.2.dll
NuGet Package : DevExpress.Win.Map
public class LinearRangeDistribution :
RangeDistributionBase
Public Class LinearRangeDistribution
Inherits RangeDistributionBase
The following members return LinearRangeDistribution objects:
Set the LinearRangeDistribution, LogarithmicRangeDistribution or ExponentialRangeDistribution object to the ChoroplethColorizer.RangeDistribution property. Note that if the ChoroplethColorizer.ApproximateColors property value equals false , shapes with values inside one range interval have the same color.
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
}
}
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
Object RangeDistributionBase LinearRangeDistribution
See Also