Workaround for tray menu close issue

This commit is contained in:
Jaex 2016-03-17 11:25:43 +02:00
parent f23202d7ff
commit 1b51f42024
2 changed files with 12 additions and 7 deletions

View file

@ -1804,6 +1804,7 @@ private void InitializeComponent()
this.tsmiTrayExit.Image = global::ShareX.Properties.Resources.cross_button;
this.tsmiTrayExit.Name = "tsmiTrayExit";
resources.ApplyResources(this.tsmiTrayExit, "tsmiTrayExit");
this.tsmiTrayExit.Click += new System.EventHandler(this.tsmiTrayExit_Click);
this.tsmiTrayExit.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tsmiTrayExit_MouseDown);
//
// timerTraySingleClick

View file

@ -43,7 +43,7 @@ public partial class MainForm : HotkeyForm
{
public bool IsReady { get; private set; }
private bool forceClose, firstUpdateCheck = true;
private bool forceClose, trayMenuSaveSettings = true, firstUpdateCheck = true;
private UploadInfoManager uim;
private ToolStripDropDownItem tsmiImageFileUploaders, tsmiTrayImageFileUploaders, tsmiTextFileUploaders, tsmiTrayTextFileUploaders;
private System.Threading.Timer updateTimer;
@ -1317,19 +1317,23 @@ private void tsmiTrayShow_Click(object sender, EventArgs e)
private void tsmiTrayExit_MouseDown(object sender, MouseEventArgs e)
{
forceClose = true;
trayMenuSaveSettings = false;
}
private void cmsTray_Closed(object sender, ToolStripDropDownClosedEventArgs e)
{
if (forceClose)
{
Close();
}
else
if (trayMenuSaveSettings)
{
Program.SaveAllSettingsAsync();
}
trayMenuSaveSettings = true;
}
private void tsmiTrayExit_Click(object sender, EventArgs e)
{
forceClose = true;
Close();
}
#endregion Tray events