Fixed: minimize to try

This commit is contained in:
VladMordock
2021-02-17 13:25:34 +01:00
parent 385d1312e2
commit 10c2666e74
2 changed files with 17 additions and 9 deletions

View File

@@ -648,6 +648,7 @@
this.Text = "Perun for DCS"; this.Text = "Perun for DCS";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.form_Main_FormClosing); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.form_Main_FormClosing);
this.Load += new System.EventHandler(this.form_Main_Load); this.Load += new System.EventHandler(this.form_Main_Load);
this.Resize += new System.EventHandler(this.form_Main_Resize);
this.con_GroupBox_1.ResumeLayout(false); this.con_GroupBox_1.ResumeLayout(false);
this.con_GroupBox_1.PerformLayout(); this.con_GroupBox_1.PerformLayout();
this.con_GroupBox_2.ResumeLayout(false); this.con_GroupBox_2.ResumeLayout(false);

View File

@@ -356,6 +356,7 @@ namespace Perun_v1
// Changed close to try state // Changed close to try state
Properties.Settings.Default.CLOSE_TO_TRAY = con_check_minimize_to_tray.Checked; Properties.Settings.Default.CLOSE_TO_TRAY = con_check_minimize_to_tray.Checked;
} }
// ################################ Form state ################################ // ################################ Form state ################################
private void con_Button_Quit_Click(object sender, EventArgs e) private void con_Button_Quit_Click(object sender, EventArgs e)
{ {
@@ -407,13 +408,7 @@ namespace Perun_v1
if (e.CloseReason == CloseReason.UserClosing && !AppCanClose) if (e.CloseReason == CloseReason.UserClosing && !AppCanClose)
{ {
e.Cancel = true; e.Cancel = true;
if (Properties.Settings.Default.CLOSE_TO_TRAY) con_Button_Quit_Click(sender, e);
{
form_Main_SendToTray(); // Send app to system tray
} else
{
con_Button_Quit_Click(sender, e);
}
} }
} }
@@ -423,6 +418,17 @@ namespace Perun_v1
form_Main_BringFromTray(); // Bring app from system tray form_Main_BringFromTray(); // Bring app from system tray
} }
private void form_Main_Resize(object sender, EventArgs e)
{
// Form was minimised to try
if (WindowState == FormWindowState.Minimized)
{
if (con_check_minimize_to_tray.Checked)
{
form_Main_SendToTray();
}
}
}
// ################################ Timers ################################ // ################################ Timers ################################
private void Tim_GUI_Tick(object sender, EventArgs e) private void Tim_GUI_Tick(object sender, EventArgs e)
{ {
@@ -709,12 +715,13 @@ namespace Perun_v1
{ {
// Handle autostart parameter from command line // Handle autostart parameter from command line
TIM_Autostart.Enabled = false; // Disable timer TIM_Autostart.Enabled = false; // Disable timer
con_Button_Listen_ON_Click(sender,e); // Simulate button click con_Button_Listen_ON_Click(sender, e); // Simulate button click
} }
private void label16_Click(object sender, EventArgs e) private void label16_Click(object sender, EventArgs e)
{ {
} }
} }
} }