-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTriangleRadarItem.cs
131 lines (120 loc) · 3.36 KB
/
TriangleRadarItem.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
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace Interface_RADAR
{
public class TriangleRadarItem : RadarItem
{
int _id;
int _azimuth;
int _range;
int _width;
int _height;
DateTime _created = DateTime.Now;
GraphicsPath _gp;
public int ID
{
get
{
return _id;
}
}
public int Azimuth
{
get
{
return _azimuth;
}
set
{
_azimuth = value;
while (_azimuth < 0)
{
_azimuth += 360;
}
if (_azimuth >= 360)
_azimuth = _azimuth % 360;
}
}
public int Range
{
get
{
return _range;
}
set
{
_range = value;
if (_range > 90)
_range = 90;
else if (_range < 0)
_range = 0;
}
}
public int Height
{
get
{
return _height;
}
set
{
}
}
public int Width
{
get
{
return _width;
}
set
{
}
}
public DateTime Created
{
get
{
return _created;
}
}
public TriangleRadarItem(int id, int size, int az, int rg)
{
_id = id;
_width = size;
_height = size;
_azimuth = az;
_range = rg;
}
public void DrawItem(Radar radar, Graphics g)
{
Font drawFont = new Font("Arial", 8);
SolidBrush drawBrush = new SolidBrush(Color.Lime);
Font drawFont_risk = new Font("Wide Latin", 14);
SolidBrush drawBrush_risk = new SolidBrush(Color.Red);
PointF cp = radar.AzRg2XY(_azimuth, _range);
PointF _topLeft = new PointF(cp.X - ((float)_width / 2), cp.Y - ((float)_height / 2));
PointF p1 = new PointF(((float)_topLeft.X + ((float)_width / 2F)), (float)_topLeft.Y);
PointF p2 = new PointF((float)_topLeft.X, (float)_topLeft.Y + (float)_height);
PointF p3 = new PointF((float)_topLeft.X + (float)_width, (float)_topLeft.Y + (float)_height);
_gp = new GraphicsPath(FillMode.Winding);
_gp.AddPolygon(new PointF[] { p1, p2, p3 });
g.DrawString("V=10 m/s", drawFont, drawBrush, cp);
g.FillPath(new SolidBrush(radar.CustomLineColor), _gp);
// Zone à risque
if ((decimal)(_range) <= 5)
{
g.DrawString("!", drawFont_risk, drawBrush_risk, _topLeft);
}
// Zone tolérable
else if ((decimal)(_range) <= 15)
{
g.DrawString("└", drawFont_risk, drawBrush_risk, _topLeft);
}
}
public int CompareTo(RadarItem item)
{
return 0;
}
}
}