-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form3.cs
141 lines (122 loc) · 5.27 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
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 SortedList<int, SortedList<string, string>> z_layers_player = new SortedList<int, SortedList<string, string>>();
public SortedList<int, SortedList<string, string>> z_layers_gps = new SortedList<int, SortedList<string, string>>();
public SortedList<int, SortedList<string, string>> z_layers_map = new SortedList<int, SortedList<string, string>>();
public KeyValuePair<int, KeyValuePair<int, int>> initial_coords;
public Form3()
{
InitializeComponent();
PaintPanel();
toolTip1.ShowAlways = true;
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
private void timer1_Tick(object sender, EventArgs e)
{
PaintPanel();
}
private void PaintPanel()
{
Graphics g = panel1.CreateGraphics();
g.Clear(Color.Black);
PaintPoints(g, z_layers_map, 1, false);
PaintPoints(g, z_layers_player, 0.5);
PaintPoints(g, z_layers_gps, 1, false);
float coef = panel1.Width / 11;
for (float i = 1; i < panel1.Width; i += coef)
{
g.DrawLine(new Pen(new SolidBrush(Color.DarkGreen)), 0, i, panel1.Width, i);
g.DrawLine(new Pen(new SolidBrush(Color.DarkGreen)), i, 0, i, panel1.Width);
}
}
public void PaintPoints(Graphics g, SortedList<int, SortedList<string, string>> z_layers, double coef_scale = 1, bool connect = true)
{
int z = Convert.ToInt32(initial_coords.Key);
if (!z_layers.ContainsKey(z))
return;
int width = panel1.Width;
int height = panel1.Height;
int coef_X = width / 11;
int coef_y = height / 11;
int[] last = new int[2]
{
-1,
-1,
};
for (int i = -5; i <= 5; i++)
{
for (int o = -5; o <= 5; o++)
{
string key = String.Format("{0}:{1}", initial_coords.Value.Key + i, initial_coords.Value.Value + o);
if (z_layers[z].Keys.Contains(key))
{
int[] point = new int[2]
{
((i + 5) * coef_X),
(height - ((o + 6) * coef_y))
};
Color clr = ColorTranslator.FromHtml(z_layers[z][key]);
Brush color = new SolidBrush(clr);
g.FillRectangle(color, point[0], point[1], float.Parse((coef_X * coef_scale).ToString()), float.Parse((coef_y * coef_scale).ToString()));
if (last[0] != -1 && last[1] != -1 && connect)
g.DrawLine(new Pen(color), last[0], last[1], point[0], point[1]);
last = point;
}
}
}
/*foreach (KeyValuePair<int, int> coords in z_layers[z])
{
int[] point = new int[2]
{
(coords.Key * coef_X),
(height - (coords.Value * coef_y))
};
g.FillRectangle(color, point[0], point[1], float.Parse((coef_X * coef_scale).ToString()), float.Parse((coef_y * coef_scale).ToString()));
if (last[0] != -1 && last[1] != -1 && connect)
g.DrawLine(new Pen(color), last[0], last[1], point[0], point[1]);
last = point;
}*/
}
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
float coef = panel1.Width / 11;
int x = initial_coords.Value.Key - 5 + Convert.ToInt32(Math.Round((e.X - coef / 2) / coef, MidpointRounding.ToEven));
int y = initial_coords.Value.Value + 5 - Convert.ToInt32(Math.Round((e.Y - coef / 2) / coef, MidpointRounding.ToEven));
int z = Convert.ToInt32(initial_coords.Key);
string coords = String.Format("{0} {1} {2}", x, y, z);
StreamWriter writer = new StreamWriter("open_wormhole.txt", false);
writer.WriteLine(coords);
writer.Close();
this.Close();
}
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
float coef = panel1.Width / 11;
int x = initial_coords.Value.Key - 5 + Convert.ToInt32(Math.Round((e.X - coef / 2) / coef, MidpointRounding.ToEven));
int y = initial_coords.Value.Value + 5 - Convert.ToInt32(Math.Round((e.Y - coef / 2) / coef, MidpointRounding.ToEven));
int z = Convert.ToInt32(initial_coords.Key);
string coords_text = String.Format("{0} {1} {2}", x, y, z);
toolTip1.SetToolTip(panel1, coords_text);
}
private void Form3_Load(object sender, EventArgs e)
{
}
}
}