This repository was archived by the owner on Nov 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainViewModel.cs
67 lines (60 loc) · 2.19 KB
/
MainViewModel.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
60
61
62
63
64
65
66
67
using System.Collections.Generic;
using System.Windows;
using OxyPlot;
using OxyPlot.Series;
namespace Simpson
{
public class MainViewModel
{
public MainViewModel()
{
Create();
}
public void SetPoints(List<Point> points)
{
PointsPlus.Clear();
PointsMinus.Clear();
foreach (Point p in points) //цикл пихания точек на график
{
if (p.Y == 0)
{
this.PointsPlus.Add(new DataPoint(p.X, p.Y));
this.PointsMinus.Add(new DataPoint(p.X, p.Y));
}
else if (p.Y > 0)
{
this.PointsPlus.Add(new DataPoint(p.X, p.Y));
}
else
{
this.PointsMinus.Add(new DataPoint(p.X, p.Y));
}
}
this.MyModel.ResetAllAxes();
this.MyModel.InvalidatePlot(true);
}
private void Create()
{
this.MyModel = new PlotModel { Title="График", PlotType = PlotType.Cartesian,}; // Юзается Декартова система координат.
this.PointsPlus = new List<DataPoint>();
this.PointsMinus = new List<DataPoint>();
MyModel.Series.Add(new AreaSeries //строим график на "положительной" части координат
{
Color = OxyColors.Green,
ItemsSource = PointsPlus,
LineStyle = LineStyle.None,
StrokeThickness = 0.1f
}) ;
MyModel.Series.Add(new AreaSeries //строим график на "отрицательной" части координат
{
Color = OxyColors.Blue,
ItemsSource = PointsMinus,
LineStyle = LineStyle.None,
StrokeThickness = 0.1f
}) ;
}
public IList<DataPoint> PointsPlus { get; private set; }
public IList<DataPoint> PointsMinus { get; private set; }
public PlotModel MyModel { get; private set; }
}
}