private void EnableShellCheck_CheckedChanged(object sender, EventArgs e)
        {
            ProgressWindowCheck.Enabled = OpenUiCheck.Enabled = EnableShellCheck.Checked;

            if (EnableShellCheck.Checked)
            {
                if (!_isStartup)
                {
                    ShellIntegration.Create();
                }
            }
            else
            {
                if (!_isStartup)
                {
                    ShellIntegration.Remove();
                }

                OpenUiCheck.Checked         = Settings.Default.ShowUiFromShell = false;
                ProgressWindowCheck.Checked = Settings.Default.ShowProgressWindow = false;
            }
        }
Exemple #2
0
        private static void Main(params string[] folders)
        {
            if (folders != null && folders.Length == 1)
            {
                var command = folders[0].Trim('/', '-');
                if (string.Compare(command, "uninstall", StringComparison.OrdinalIgnoreCase) == 0 ||
                    string.Compare(command, "remove", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    ShellIntegration.Remove();
                    Environment.Exit(0);
                    return;
                }
            }

            if (Settings.Default.EnableShellIntegration)
            {
                Task.Run(() => ShellIntegration.Create());
            }

            Application.ApplicationExit += (sender, args) => History.Default.Save();

            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            Application.ThreadException += (sender, args) =>
                                           LogUnhandledException(args.Exception, "Uncaught thread exception");

            AppDomain.CurrentDomain.UnhandledException += (sender, args) => LogUnhandledException(
                args.ExceptionObject as Exception,
                $"Uncaught exception: {sender}, terminating: {args.IsTerminating}");

            TaskScheduler.UnobservedTaskException += (sender, args) =>
            {
                LogUnhandledException(args.Exception,
                                      $"Uncaught task exception: {sender}");
                args.SetObserved();
            };

            Mediator.Run(folders);
        }