-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lines.cs
142 lines (126 loc) · 3.96 KB
/
Lines.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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace LabSystemDif
{
class Lines
{
public DrawingLine Drawing { get; private set; }
LinkedList<Line> lines;
public Line Last
{
get
{
return lines.Last.Value;
}
}
public Line this[int index]
{
get
{
if (index >= lines.Count) return null;
return lines.ElementAt(index);
}
}
public int Count
{
get
{
return lines.Count;
}
}
public Lines(DrawingLine drawing)
{
Drawing = drawing;
lines = new LinkedList<Line>();
}
public void Add(Func<float, float, float, float> dirivX, Func<float, float, float, float> dirivY, float stepH, PointF nullPoint, Color color, int count)
{
lines.AddLast(new Line(dirivX, dirivY, stepH, nullPoint, color, count, (list, col) =>
{
Drawing.NewColors(col);
Drawing.Drawing(list.ToArray());
}));
}
public void Add(Func<float, float, float, float> dirivX, Func<float, float, float, float> dirivY, float stepH, PointF nullPoint, Color color, string drawing, bool arrow, int across)
{
Action<LinkedList<PointF>, Color> draw = null;
Action<PointF[], Color> drawAll = null;
if (drawing == "points")
{
draw = (list, col) =>
{
Drawing.NewColors(col);
Drawing.PutPixelToScale(list.Last.Value);
};
drawAll = (points, col) =>
{
Drawing.NewColors(col);
Drawing.DrawingAllToPoints(points);
};
if (arrow)
drawAll = (points, col) =>
{
Drawing.NewColors(col);
Drawing.DrawingAllToPointsArrows(points);
};
}
else if (drawing == "lines")
{
draw = (list, col) =>
{
if (list.Count < 2) return;
Drawing.NewColors(col);
Drawing.DrawLineToScale(list.Last.Previous.Value, list.Last.Value);
};
drawAll = (points, col) =>
{
if (points.Length < 2) return;
Drawing.NewColors(col);
Drawing.DrawingAllToLines(points);
};
if (arrow)
drawAll = (points, col) =>
{
Drawing.NewColors(col);
Drawing.DrawingAllToLinesArrows(points);
};
}
else if (drawing == "curve")
{
draw = (list, col) =>
{
if (list.Count < 2) return;
Drawing.NewColors(col);
Drawing.DrawingAllToCurve(list.ToArray());
};
drawAll = (points, col) =>
{
if (points.Length < 2) return;
Drawing.NewColors(col);
Drawing.DrawingAllToCurve(points);
};
}
else return;
lines.AddLast(new Line(dirivX, dirivY, stepH, nullPoint, color, draw, drawAll, across));
}
public void DrawAll()
{
Drawing.DrawingNull();
foreach (var line in lines)
{
line.DrawingAll();
}
}
public void NullLines()
{
foreach (var line in lines)
{
line.NullPoints();
}
}
}
}