This repository was archived by the owner on Jan 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainForm.cs
More file actions
71 lines (65 loc) · 2.13 KB
/
MainForm.cs
File metadata and controls
71 lines (65 loc) · 2.13 KB
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
using Microsoft.Extensions.Configuration;
using PixelPilot.PixelGameClient;
using PixelPilot;
using EELVL;
using PixelPilot.PixelGameClient.Messages.Received;
using PixelPilot.PixelGameClient.Messages.Send;
namespace EEtoPWGUI
{
public partial class MainForm : Form
{
public string FileName { get { return txtbFileName.Text; } }
private static Thread? thread;
private static PixelPilotClient? client_;
private bool stopthread = false;
public MainForm()
{
InitializeComponent();
}
private void btnImport_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "EELVL *.eelvl|*.eelvl";
if (ofd.ShowDialog() == DialogResult.OK)
{
txtbFileName.Text = ofd.FileName;
}
}
private void StartThread(object data)
{
thread = new Thread(() => RunThread());
thread.Start();
}
private void RunThread()
{
BlockUploader.PlaceBlocks(client_, txtbFileName.Text);
if (stopthread) { return; }
}
private async void button1_Click(object sender, EventArgs e)
{
if (button1.Text == "Upload")
{
button1.Text = "Stop";
// Create a client.
if (!string.IsNullOrEmpty(txtbAuthTokenOrEmail.Text) && !string.IsNullOrEmpty(txtbWorldId.Text))
{
client_ = new PixelPilotClient(txtbAuthTokenOrEmail.Text, false);
client_.OnClientConnected += StartThread;
await client_.Connect(txtbWorldId.Text);
}
}
if (button1.Text == "Stop")
{
if (client_ != null && client_.IsConnected)
{
client_?.Disconnect();
if (thread != null && thread.IsAlive)
{
stopthread = true;
}
button1.Text = "Upload";
}
}
}
}
}