2013-08-07 05:32:22 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Windows.Forms;
|
2021-11-06 20:44:26 +00:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
2013-08-30 22:55:01 +00:00
|
|
|
|
using NLog;
|
2013-08-13 05:08:37 +00:00
|
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
2013-08-31 01:42:30 +00:00
|
|
|
|
using NzbDrone.Common.Instrumentation;
|
2013-08-16 02:20:54 +00:00
|
|
|
|
using NzbDrone.Host;
|
2013-08-07 05:32:22 +00:00
|
|
|
|
using NzbDrone.SysTray;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone
|
|
|
|
|
{
|
|
|
|
|
public static class WindowsApp
|
|
|
|
|
{
|
2014-12-17 07:12:26 +00:00
|
|
|
|
private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(WindowsApp));
|
2013-08-30 22:55:01 +00:00
|
|
|
|
|
2013-08-07 05:32:22 +00:00
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
{
|
2021-12-11 04:30:12 +00:00
|
|
|
|
Application.EnableVisualStyles();
|
|
|
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
|
|
|
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
|
|
|
|
|
2013-08-07 05:32:22 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2013-11-26 06:53:36 +00:00
|
|
|
|
var startupArgs = new StartupContext(args);
|
2013-08-31 01:42:30 +00:00
|
|
|
|
|
2014-12-17 07:12:26 +00:00
|
|
|
|
NzbDroneLogger.Register(startupArgs, false, true);
|
2013-08-31 01:42:30 +00:00
|
|
|
|
|
2021-12-11 04:30:12 +00:00
|
|
|
|
Bootstrap.Start(args, e => { e.ConfigureServices((_, s) => s.AddSingleton<IHostedService, SystemTrayApp>()); });
|
2013-08-16 02:20:54 +00:00
|
|
|
|
}
|
2013-08-07 05:32:22 +00:00
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
2017-01-05 22:33:40 +00:00
|
|
|
|
Logger.Fatal(e, "EPIC FAIL");
|
2021-12-11 04:30:12 +00:00
|
|
|
|
var message = string.Format("{0}: {1}", e.GetType().Name, e.ToString());
|
2023-07-30 16:41:00 +00:00
|
|
|
|
|
|
|
|
|
if (RuntimeInfo.IsUserInteractive)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show($"{e.GetType().Name}: {e.Message}", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error, caption: "Epic Fail!");
|
|
|
|
|
}
|
2013-08-07 05:32:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-08-31 01:42:30 +00:00
|
|
|
|
}
|