This repository has been archived by the owner on Sep 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomColorizer.cs
46 lines (39 loc) · 1.5 KB
/
CustomColorizer.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
#region #CustomColorizerImplementation
using DevExpress.TreeMap;
using DevExpress.XtraTreeMap;
using System;
using System.Drawing;
namespace CustomColorizerSample {
class CustomColorizer : ITreeMapColorizer {
Palette palette = Palette.Office2016Palette;
public Palette Palette {
get { return palette; }
set {
if(palette.Equals(value)) return;
palette = value;
RaiseColorizerChanged();
}
}
public event ColorizerChangedEventHandler ColorizerChanged;
public Color GetItemColor(ITreeMapItem item, TreeMapItemGroupInfo group) {
if(item.Children.Count == 0) {
Color itemColor = Palette[group.ItemIndex % Palette.Count];
double itemWeight = (item.Value - group.MinValue) / (group.MaxValue - group.MinValue);
if(Double.IsNaN(itemWeight)) itemWeight = 1;
return Color.FromArgb(
(int)(itemWeight * 255),
itemColor.R,
itemColor.G,
itemColor.B
);
}
else
return Palette[Palette.Count - 1 - (group.GroupIndex + group.GroupLevel + group.ItemIndex) % Palette.Count];
}
void RaiseColorizerChanged() {
if(ColorizerChanged == null) return;
ColorizerChanged.Invoke(this, new ColorizerChangedEventArgs());
}
}
}
#endregion #CustomColorizerImplementation