-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraphic.cs
98 lines (84 loc) · 2.58 KB
/
Graphic.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
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FPPWR_path_finding
{
class Graphic
{
private Graphics graphics;
public Graphic(Graphics graphics)
{
this.graphics = graphics;
}
public Graphic()
{
}
public void DrawMap(Size size)
{
int x = size.Width / 100 + 1;
int y = size.Height / 100 + 1;
for (int i = 0; i < x; i++)
{
graphics.DrawLine(new Pen(Color.Black) { Width = 1 }, new Point(i * 100, 1), new Point(i * 100, size.Height));
}
for (int i = 0; i < y; i++)
{
graphics.DrawLine(new Pen(Color.Black) { Width = 1 }, new Point(1, i * 100), new Point(size.Width, i * 100));
}
}
public void PAUSE(int pause = 100)
{
Thread.Sleep(pause); // set this value to set drawing speed
}
public void DrawLine(Point p1, Point p2, Color color)
{
Pen pen = new Pen(color);
pen.Width = 3;
graphics.DrawLine(pen, p1, p2);
}
public void DrawCircle(Point p, int radius, Color color, int pause = 30)
{
Pen pen = new Pen(color);
pen.Width = 2;
graphics.DrawEllipse(pen, p.X - radius, p.Y - radius, 2 * radius, 2 * radius);
PAUSE(pause);
}
public void DrawPoint(Point p, Brush brush)
{
graphics.FillRectangle(brush, p.X - 2, p.Y - 2, 4, 4);
}
public void DrawPointArray(Point[] points)
{
for (int i = 0; i < points.Length; i++)
{
DrawPoint(points[i], Brushes.Black);
}
}
public void DrawPointDictionary(Dictionary<Point, int> points)
{
foreach (KeyValuePair<Point, int> result in points)
DrawPoint(result.Key, Brushes.Black);
}
public void DrawPointList(List<Point> points)
{
foreach (Point point in points)
DrawPoint(point, Brushes.Black);
}
public void ClearImage()
{
graphics.Clear(Color.White);
}
public void DrawRoute(List<Point> points, Color color, int pause = 10)
{
for (int i = 1; i < points.Count; i++)
{
DrawLine(points[i - 1], points[i], color);
PAUSE(pause);
}
}
}
}