-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.vb
53 lines (45 loc) · 1.39 KB
/
MainWindow.xaml.vb
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
Imports System
Imports System.Windows
Imports System.Windows.Media
Imports DevExpress.Xpf.Charts
Namespace CustomDrawChart
Partial Public Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
End Sub
Private Sub chbCustomDraw_Checked(ByVal sender As Object, ByVal e As RoutedEventArgs)
If chart IsNot Nothing Then
chart.UpdateData()
End If
End Sub
Private Sub chbCustomDraw_Unchecked(ByVal sender As Object, ByVal e As RoutedEventArgs)
If chart IsNot Nothing Then
chart.UpdateData()
End If
End Sub
Private Sub chart_CustomDrawSeriesPoint(ByVal sender As Object, ByVal e As CustomDrawSeriesPointEventArgs)
If CBool(chbCustomDraw.IsChecked) Then
Dim color As String = CorrectDrawOptions(e.SeriesPoint.Value, e.DrawOptions)
If Not String.IsNullOrEmpty(color) Then
e.LabelText = color & ": " & e.LabelText
End If
End If
End Sub
Private Function CorrectDrawOptions(ByVal val As Double, ByVal drawOptions As DrawOptions) As String
If drawOptions Is Nothing Then
Return ""
End If
If val < 1 Then
drawOptions.Color = Color.FromArgb(&HFF, &H51, &H89, &H3)
Return "Green"
ElseIf val < 2 Then
drawOptions.Color = Color.FromArgb(&HFF, &HF9, &HAA, &HF)
Return "Yellow"
Else
drawOptions.Color = Color.FromArgb(&HFF, &HC7, &H39, &HC)
Return "Red"
End If
End Function
End Class
End Namespace