2020-03-17 09:05:52 +13:00
|
|
|
|
using System;
|
2019-07-05 05:04:14 +12:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Windows.Forms;
|
2020-03-28 12:42:32 +13:00
|
|
|
|
using SystemTrayMenu.Utilities;
|
2019-07-05 05:04:14 +12:00
|
|
|
|
|
|
|
|
|
namespace SystemTrayMenu
|
|
|
|
|
{
|
2020-03-24 00:32:47 +13:00
|
|
|
|
internal static class Program
|
2019-07-05 05:04:14 +12:00
|
|
|
|
{
|
|
|
|
|
[STAThread]
|
2020-03-24 00:32:47 +13:00
|
|
|
|
private static void Main()
|
2019-07-05 05:04:14 +12:00
|
|
|
|
{
|
2020-03-17 02:45:19 +13:00
|
|
|
|
try
|
2019-07-05 05:04:14 +12:00
|
|
|
|
{
|
2020-03-17 02:45:19 +13:00
|
|
|
|
Log.Initialize();
|
|
|
|
|
SingleAppInstance.Initialize();
|
|
|
|
|
Language.Initialize();
|
2019-07-05 05:04:14 +12:00
|
|
|
|
|
2020-03-17 03:57:51 +13:00
|
|
|
|
Config.UpgradeIfNotUpgraded();
|
2020-03-17 02:45:19 +13:00
|
|
|
|
if (Config.LoadOrSetByUser())
|
|
|
|
|
{
|
|
|
|
|
Application.EnableVisualStyles();
|
|
|
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
|
|
|
Application.ThreadException += ThreadException;
|
|
|
|
|
void ThreadException(object s, ThreadExceptionEventArgs t)
|
|
|
|
|
{
|
|
|
|
|
AskUserSendError(t.Exception);
|
|
|
|
|
}
|
2019-07-05 05:04:14 +12:00
|
|
|
|
|
2020-03-17 02:45:19 +13:00
|
|
|
|
Scaling.Initialize();
|
2020-03-17 03:57:51 +13:00
|
|
|
|
FolderOptions.Initialize();
|
2019-07-05 05:04:14 +12:00
|
|
|
|
|
2020-03-17 02:45:19 +13:00
|
|
|
|
using (new SystemTrayMenu())
|
2019-07-05 05:04:14 +12:00
|
|
|
|
{
|
2020-03-17 09:05:52 +13:00
|
|
|
|
Log.WriteApplicationRuns();
|
2019-07-05 05:04:14 +12:00
|
|
|
|
Application.Run();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-03-30 06:26:45 +13:00
|
|
|
|
#pragma warning disable CA1031 // Do not catch general exception types
|
2019-07-05 05:04:14 +12:00
|
|
|
|
catch (Exception ex)
|
2020-03-30 06:26:45 +13:00
|
|
|
|
#pragma warning restore CA1031 // => Represents ThreadException during attached to process
|
2019-07-05 05:04:14 +12:00
|
|
|
|
{
|
2020-03-17 02:45:19 +13:00
|
|
|
|
AskUserSendError(ex);
|
2019-07-05 05:04:14 +12:00
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
2020-03-17 09:05:52 +13:00
|
|
|
|
Log.Close();
|
2019-07-05 05:04:14 +12:00
|
|
|
|
}
|
2020-03-24 00:24:16 +13:00
|
|
|
|
|
2020-03-17 02:45:19 +13:00
|
|
|
|
void AskUserSendError(Exception ex)
|
2020-03-15 22:27:05 +13:00
|
|
|
|
{
|
2020-03-17 02:45:19 +13:00
|
|
|
|
Log.Error("Application Crashed", ex);
|
2020-03-15 22:27:05 +13:00
|
|
|
|
|
2020-03-17 02:45:19 +13:00
|
|
|
|
#warning [Feature] When Error ask user to send us #47, todo own dialog, lines here too long
|
|
|
|
|
if (MessageBox.Show("A problem has been encountered and the application needs to restart. " +
|
|
|
|
|
"Reporting this error will help us make our product better. Press yes to open your standard email app.",
|
|
|
|
|
"SystemTrayMenu BugSplat", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
2019-07-05 05:04:14 +12:00
|
|
|
|
{
|
2020-03-30 06:26:45 +13:00
|
|
|
|
Log.ProcessStart("mailto:" + "markus@hofknecht.eu" +
|
2020-03-17 02:45:19 +13:00
|
|
|
|
"?subject=SystemTrayMenu Bug reported" +
|
|
|
|
|
"&body=" + ex.ToString());
|
2019-07-05 05:04:14 +12:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-17 09:05:52 +13:00
|
|
|
|
AppRestart.ByThreadException();
|
2019-07-05 05:04:14 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|