-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
111 lines (100 loc) · 3.73 KB
/
Form1.cs
File metadata and controls
111 lines (100 loc) · 3.73 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
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
using System;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GTU_Tables_Windows
{
public partial class Form1 : Form
{
private Preferences prefs;
public Form1()
{
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.AcceptButton = this.fetchButton;
prefs = new Preferences("TablePrefs.json");
this.Telegram.Click += (s, e) =>
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
{
FileName = "https://t.me/s/NikkaGamesOfficial",
UseShellExecute = true
});
};
this.Facebook.Click += (s, e) =>
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
{
FileName = "https://facebook.com/sunflower.thrust",
UseShellExecute = true
});
};
this.Instagram.Click += (s, e) =>
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
{
FileName = "https://www.instagram.com/pmicdxe",
UseShellExecute = true
});
};
this.Github.Click += (s, e) =>
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
{
FileName = "https://github.com/NikkaGames",
UseShellExecute = true
});
};
}
private void Form1_Load(object sender, EventArgs e)
{
saveCheckbox.Checked = prefs.GetBool("checkbox", true);
if (prefs.GetBool("checkbox", true))
{
queryTextBox.Text = prefs.GetString("table_id", "");
}
fetchButton.Enabled = !string.IsNullOrEmpty(queryTextBox.Text);
}
private async void fetchButton_Click(object sender, EventArgs e)
{
loadingLabel.Visible = true;
fetchButton.Enabled = false;
string query = queryTextBox.Text;
bool save = saveCheckbox.Checked;
prefs.PutBool("checkbox", save);
if (!Utils.IsInternetAvailable())
{
MessageBox.Show("No Internet Connection!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
loadingLabel.Visible = false;
fetchButton.Enabled = true;
return;
}
try
{
string data = await Task.Run(() => Utils.SendAndReceiveAsync(query));
if (data == "NOT_FOUND")
{
MessageBox.Show($"Table {query} not found!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
//MessageBox.Show($"Table {query} found!", "Good", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (save)
prefs.PutString("table_id", query);
new Form2(data, query).Show();
}
}
catch (Exception ex)
{
MessageBox.Show($"Error fetching data: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
loadingLabel.Visible = false;
fetchButton.Enabled = true;
}
private void queryTextBox_TextChanged(object sender, EventArgs e)
{
fetchButton.Enabled = !string.IsNullOrEmpty(queryTextBox.Text);
}
}
}