示例#1
0
        private static void Main(params string[] folders)
        {
            if (folders?.Length == 1)
            {
                var command = folders[0].Trim('/', '-');
                if (string.Equals(command, "uninstall", StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(command, "remove", StringComparison.OrdinalIgnoreCase))
                {
                    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);
        }
        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;
            }
        }