-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
87 lines (61 loc) · 2.67 KB
/
Form1.cs
File metadata and controls
87 lines (61 loc) · 2.67 KB
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
using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraPivotGrid;
using DevExpress.XtraCharts;
namespace WindowsFormsApplication8 {
public partial class Form1 : Form {
#region Constants & Variables
static ImageList imgList = new ImageList();
static string[] seriesArguments = new string[] {
"FAR WEST", "GREAT LAKES", "MIDEAST", "NEW ENGLAND",
"PLAINS", "ROCKY MOUNTAIN", "SOUTHEAST", "SOUTHWEST" };
static Color[] seriesColors = new Color[] {
Color.Aqua, Color.Aquamarine, Color.BlueViolet, Color.Crimson,
Color.DarkOrange, Color.DarkSeaGreen, Color.Green, Color.Indigo };
#endregion
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
this.gSPTableAdapter.Fill(this.gspDataSet.GSP);
imgList.Images.AddRange(CreateImages(seriesColors));
pivotGridControl1.ValueImages = imgList;
}
private void pivotGridControl1_FieldValueImageIndex(object sender, PivotFieldImageIndexEventArgs e) {
if (e.Field == fieldRegion && e.ValueType == PivotGridValueType.Value)
e.ImageIndex = GetIndexByName(e.Value);
}
private void chartControl1_CustomDrawSeries(object sender, CustomDrawSeriesEventArgs e) {
UpdateDrawOptions((BarDrawOptions)e.SeriesDrawOptions);
UpdateDrawOptions((BarDrawOptions)e.LegendDrawOptions);
}
public static void UpdateDrawOptions(BarDrawOptions options) {
options.FillStyle.FillMode = FillMode.Hatch;
options.Shadow.Color = Color.Azure;
}
#region Auxilliary Methods
private Image[] CreateImages(Color[] colors) {
Image[] images = new Image[colors.Length];
for (int i = 0; i < colors.Length; i++) {
images[i] = CreateImage(16, 16, colors[i]);
}
return images;
}
private Image CreateImage(int width, int height, Color imageColor) {
Bitmap image = new Bitmap(width, height);
using (Graphics gfx = Graphics.FromImage(image))
using (SolidBrush brush = new SolidBrush(imageColor)) {
gfx.FillRectangle(brush, 0, 0, width, height);
}
return (Image)image;
}
private static int GetIndexByName(object name) {
if (name != null)
for (int i = 0; i < seriesArguments.Length; i++)
if (seriesArguments[i] == name.ToString()) return i;
return -1;
}
#endregion
}
}