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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
using RealTimeGraphX.DataPoints;
using RealTimeGraphX.Renderers;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Media;
namespace RealTimeGraphX.WPF.Demo
{
public class MainWindowVM
{
public WpfGraphController<TimeSpanDataPoint, DoubleDataPoint> Controller { get; set; }
public WpfGraphController<TimeSpanDataPoint, DoubleDataPoint> MultiController { get; set; }
public MainWindowVM()
{
Controller = new WpfGraphController<TimeSpanDataPoint, DoubleDataPoint>();
Controller.Range.MinimumY = 0;
Controller.Range.MaximumY = 1080;
Controller.Range.MaximumX = TimeSpan.FromSeconds(10);
Controller.Range.AutoY = true;
Controller.DataSeriesCollection.Add(new WpfGraphDataSeries()
{
Name = "Series",
Stroke = Colors.DodgerBlue,
});
MultiController = new WpfGraphController<TimeSpanDataPoint, DoubleDataPoint>();
MultiController.Range.MinimumY = 0;
MultiController.Range.MaximumY = 1080;
MultiController.Range.MaximumX = TimeSpan.FromSeconds(10);
MultiController.Range.AutoY = true;
MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries()
{
Name = "Series 1",
Stroke = Colors.Red,
});
MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries()
{
Name = "Series 2",
Stroke = Colors.Green,
});
MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries()
{
Name = "Series 3",
Stroke = Colors.Blue,
});
MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries()
{
Name = "Series 4",
Stroke = Colors.Yellow,
});
MultiController.DataSeriesCollection.Add(new WpfGraphDataSeries()
{
Name = "Series 5",
Stroke = Colors.Gray,
});
Stopwatch watch = new Stopwatch();
watch.Start();
Task.Factory.StartNew(() =>
{
while (true)
{
var y = System.Windows.Forms.Cursor.Position.Y;
List<DoubleDataPoint> yy = new List<DoubleDataPoint>()
{
y,
y + 20,
y + 40,
y + 60,
y + 80,
};
var x = watch.Elapsed;
List<TimeSpanDataPoint> xx = new List<TimeSpanDataPoint>()
{
x,
x,
x,
x,
x
};
Controller.PushData(x, y);
MultiController.PushData(xx, yy);
Thread.Sleep(30);
}
});
}
}
}
|