-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
60 lines (53 loc) · 1.59 KB
/
MainWindow.xaml.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
58
59
using System;
using System.Windows;
using System.Windows.Media;
using DevExpress.Xpf.Charts;
namespace CustomDrawChart
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void chbCustomDraw_Checked(object sender, RoutedEventArgs e)
{
if (chart != null)
chart.UpdateData();
}
private void chbCustomDraw_Unchecked(object sender, RoutedEventArgs e)
{
if (chart != null)
chart.UpdateData();
}
private void chart_CustomDrawSeriesPoint(object sender, CustomDrawSeriesPointEventArgs e)
{
if ((bool)chbCustomDraw.IsChecked)
{
string color = CorrectDrawOptions(e.SeriesPoint.Value, e.DrawOptions);
if (!String.IsNullOrEmpty(color))
e.LabelText = color + ": " + e.LabelText;
}
}
string CorrectDrawOptions(double val, DrawOptions drawOptions)
{
if (drawOptions == null)
return "";
if (val < 1)
{
drawOptions.Color = Color.FromArgb(0xFF, 0x51, 0x89, 0x03);
return "Green";
}
else if (val < 2)
{
drawOptions.Color = Color.FromArgb(0xFF, 0xF9, 0xAA, 0x0F);
return "Yellow";
}
else
{
drawOptions.Color = Color.FromArgb(0xFF, 0xC7, 0x39, 0x0C);
return "Red";
}
}
}
}