Skip to content

Commit eda670d

Browse files
authored
Bug & Crash fixes
-The Loading screen didn't properly scale to the user's resolution. -Crash when trying to execute query in the db without having the proper configuration.
1 parent fb5db46 commit eda670d

File tree

3 files changed

+5661
-5649
lines changed

3 files changed

+5661
-5649
lines changed

AiPostgreWinForms/FrmAiPostgre.Designer.cs

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AiPostgreWinForms/FrmAiPostgre.cs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -234,20 +234,24 @@ private void btn_send_Click(object sender, EventArgs e)
234234
{ // You can't use it unless you have something written
235235
if (tb_userrequest.Text != "" && tb_userrequest.ForeColor != Color.Gray)
236236
{
237-
// Enables the loading screen
238-
gb_loading.Size = new Size(891, 709);
239-
gb_loading.Location = new Point(-10, -40);
240-
gb_loading.Visible = true;
241-
lbl_loadstatus.Text = "Mapping...";
242-
pb_loading.Value = 0; // Restart the bar value
243237
var thread = new Thread(() =>
244238
{
245239
// Connects to the database
246240
var connection = new NpgsqlConnection(database);
247241

248-
if (connection != null)
242+
if (connection != null && connection.ConnectionString != "")
249243
{
250244
connection.Open();
245+
246+
pb_loading.Invoke((MethodInvoker)(() =>
247+
{
248+
// Enables the loading screen
249+
gb_loading.Dock = DockStyle.Fill;
250+
gb_loading.Visible = true;
251+
lbl_loadstatus.Text = "Mapping...";
252+
pb_loading.Value = 0; // Restart the bar value
253+
}));
254+
251255
// If the database is already mapped, it skips the process
252256
if (json == "")
253257
{
@@ -402,8 +406,7 @@ private void btn_send_Click(object sender, EventArgs e)
402406
gb_loading.Invoke((MethodInvoker)(() =>
403407
{
404408
gb_loading.Visible = false;
405-
gb_loading.Size = new Size(1, 1);
406-
gb_loading.Location = new Point(0, 0);
409+
gb_loading.Dock = DockStyle.None;
407410
}));
408411
try
409412
{
@@ -432,6 +435,13 @@ private void btn_send_Click(object sender, EventArgs e)
432435
}));
433436
}
434437
}
438+
else {
439+
MessageBox.Show("You need to set up a proper Database connection first!", "No Database found", MessageBoxButtons.OK, MessageBoxIcon.Information);
440+
btn_dbsettings.Invoke((MethodInvoker)(() =>
441+
{
442+
btn_dbsettings_Click(sender, e);
443+
}));
444+
}
435445
});
436446
thread.Start();
437447
}
@@ -459,7 +469,7 @@ private void btn_tweak_Click(object sender, EventArgs e)
459469
{
460470
var connection = new NpgsqlConnection(database);
461471

462-
if (connection != null)
472+
if (connection != null && connection.ConnectionString != "")
463473
{
464474
connection.Open();
465475
try
@@ -478,6 +488,10 @@ private void btn_tweak_Click(object sender, EventArgs e)
478488
MessageBox.Show("An error was thrown while running the query (" + tb_aiquery.Text + ")", "The query failed to run in the PostgreSQL Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
479489
}
480490
}
491+
else {
492+
MessageBox.Show("You need to set up a proper Database connection first!", "No Database found", MessageBoxButtons.OK, MessageBoxIcon.Information);
493+
btn_dbsettings_Click(sender, e);
494+
}
481495
}
482496
}
483497

0 commit comments

Comments
 (0)