-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddWorld.cs
97 lines (83 loc) · 2.82 KB
/
AddWorld.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
using KPreisser.UI;
using MagmaMc.BetterForms;
using MagmaMc.JEF;
using MagmaMc.UAS;
using MagmaMC.SharedLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TaskDialog = KPreisser.UI.TaskDialog;
namespace VRCWMT;
public partial class AddWorld : Form
{
public AddWorld()
{
InitializeComponent();
}
private void CreateWorld_Load(object sender, EventArgs e)
{
}
private void CreateButton_Click(object sender, EventArgs e)
{
if (WorldName_Input.Text.Length < 3)
{
MessageBox.Show("World Name Invalid Length", "VRCWEditor", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
gifPlayer1.Visible = true;
CreateWorldButton.Enabled = false;
WarningText.Text = "";
Task<string> addworld = API.AddWorldAsync(WorldName_Input.Text, Description_Input.Text, GithubRepo_Input.Text, File.ReadAllBytes(ImagePath.Text), Path.GetExtension(ImagePath.Text));
new Thread(() =>
{
string Success = addworld.GetResult();
Invoke((MethodInvoker)delegate
{
gifPlayer1.Visible = false;
CreateWorldButton.Enabled = true;
if (string.IsNullOrWhiteSpace(Success))
WarningText.Text = "Failed";
else
{
Clipboard.SetText(Success);
TaskDialog.Show(text: "World Created Successfully, Copied WorldID To Clip Board",
title: "VRCWMT",
buttons: TaskDialogButtons.OK,
icon: TaskDialogStandardIcon.Information);
Close();
Config.WorldID = Success;
Config.WriteConfig();
Application.Restart();
Dispose();
return;
}
});
}).Start();
}
private void Description_Input_TextChanged(object sender, EventArgs e)
{
}
private DateTime? lastClickTime = null;
private void SelectImage(object sender, MouseEventArgs e)
{
if (lastClickTime != null && (DateTime.Now - lastClickTime.Value).TotalMilliseconds < 250)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Image Files (*.png; *.jpeg; *.jpg)|*.png;*.jpeg;*.jpg";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
ImagePath.Text = openFileDialog.FileName;
}
}
lastClickTime = DateTime.Now;
}
private void BannerImagePath_TextChanged(object sender, EventArgs e)
{
}
}