-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm3.cs
164 lines (145 loc) · 5.12 KB
/
Form3.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GPSTracker
{
public partial class Form3 : Form
{
public Form1 Form;
public Map Map;
public MapPoint InitialCoords;
private TransparentPanel _panel;
private PictureBox _map;
public Form3()
{
InitializeComponent();
toolTip1.ShowAlways = true;
CreateComponents();
Shown += (sender, args) =>
{
Map.InitStaticMap(_panel.Width, _panel.Height, 1, 1);
_map.Image = Map.GetStaticMap();
};
}
private void CreateComponents()
{
_map = new PictureBox
{
Size = new Size(330, 330),
Location = new Point(10, 10),
SizeMode = PictureBoxSizeMode.Zoom,
};
// Прозрачная панель
_panel = new TransparentPanel
{
Size = _map.Size,
Location = _map.Location,
Parent = _map.Parent,
BackColor = Color.Transparent,
};
_panel.MouseMove += panel1_MouseMove;
_panel.MouseDown += panel1_MouseDown;
_panel.Paint += display_Paint;
// Добавление на форму
Controls.Add(_map);
Controls.Add(_panel);
_panel.BringToFront();
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
private void timer1_Tick(object sender, EventArgs e)
{
_map.Invalidate();
_panel.Invalidate();
}
private void display_Paint(object sender, PaintEventArgs e)
{
MapPoint nullPoint = new MapPoint()
{
X = InitialCoords.X - 5,
Y = InitialCoords.Y - 6,
Z = InitialCoords.Z
};
if (Form.PlayerGps == null)
{
return;
}
MapPoint pointPlayer = new MapPoint()
{
X = Form.PlayerGps.X - nullPoint.X,
Y = Form.PlayerGps.Y + 1 - nullPoint.Y,
Z = Form.PlayerGps.Z,
Tag = Form.PlayerGps.Tag
};
if (Form.PlayerGps.Z == InitialCoords.Z)
{
// Отрисовка игрока
Map.DrawPoint(
_map.Width,
_map.Height,
g : e.Graphics,
pointPlayer,
entityColor : Color.Red,
textBrush : Brushes.White
);
}
Form.SignalsGps ??= new List<MapPoint>();
foreach (MapPoint signalsGps in Form.SignalsGps)
{
if (signalsGps.Z != InitialCoords.Z)
{
continue;
}
MapPoint point = new MapPoint()
{
X = signalsGps.X - nullPoint.X,
Y = signalsGps.Y + 1 - nullPoint.Y,
Z = signalsGps.Z,
Tag = signalsGps.Tag
};
Map.DrawPoint(
_map.Width,
_map.Height,
g : e.Graphics,
point,
entityColor : Color.Red,
textBrush : Brushes.White
);
}
}
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
float coef = _panel.Width / 11f;
int x = InitialCoords.X - 5 + Convert.ToInt32(Math.Round((e.X - coef / 2) / coef, MidpointRounding.ToEven));
int y = InitialCoords.Y + 5 - Convert.ToInt32(Math.Round((e.Y - coef / 2) / coef, MidpointRounding.ToEven));
int z = Convert.ToInt32(InitialCoords.Z);
string coords = String.Format("{0} {1} {2}", x, y, z);
StreamWriter writer = new StreamWriter(Config.PathOpenWormhole, false);
writer.WriteLine(coords);
writer.Close();
this.Close();
}
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
float coef = _panel.Width / 11f;
int x = InitialCoords.X - 5 + Convert.ToInt32(Math.Round((e.X - coef / 2) / coef, MidpointRounding.ToEven));
int y = InitialCoords.Y + 5 - Convert.ToInt32(Math.Round((e.Y - coef / 2) / coef, MidpointRounding.ToEven));
int z = Convert.ToInt32(InitialCoords.Z);
string coords_text = String.Format("{0} {1} {2}", x, y, z);
toolTip1.SetToolTip(_panel, coords_text);
}
private void Form3_Load(object sender, EventArgs e)
{
}
}
}