예제 #1
0
        /// <summary>
        /// Callback detecting application idle time.
        /// </summary>
        static void Application_Idle(object sender, EventArgs e)
        {
            Application.Idle -= _handlerIdleUpdater;

            Update = new UpdateManager(_mainForm);
            Update.UpdateCheckCompleted += new EventHandler<UpdateCheckCompletedEventArgs>(UpdateManager_CheckCompleted);
            Update.CheckForUpdate();
        }
예제 #2
0
        static void Main(string[] args)
        {
            //Hook fatal abort handler
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            //Initialize and check for platform support
            Platform = PlatformSupport.Create();
            if (!Platform.CheckCompatibility())
                return;
            Platform.PreHandleFormInit();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //Update settings if needed
            if (Settings.Default.MustUpdate) {
                Settings.Default.Upgrade();
                Settings.Default.MustUpdate = false;
            }

            //Load startup options
            var options = StartupOptions.Factory.CreateOptions(args);
            string optionsMessage = options.DebugMessage;
            if (!string.IsNullOrEmpty(optionsMessage)) { //show dialog if debug message present or if parsing failed
                var dlg = new CommandLineReportForm(options.Status, optionsMessage);
                dlg.ShowDialog();
            }
            if (options.Status == CliStatus.Information || options.Status == CliStatus.Error)
                return;

            //Load language
            Thread.CurrentThread.CurrentUICulture = Settings.Default.Language;

            //Show form
            using (_mainForm = new MainForm(options)) {
                //Start up update manager
                Update = new UpdateManager(_mainForm);
                Update.UpdateCheckCompleted += new EventHandler<UpdateCheckCompletedEventArgs>(UpdateManager_CheckCompleted);
                bool doneCheck = false;
                _mainForm.Shown += delegate {
                    if (doneCheck) return;
                    doneCheck = true;

                    //Delay first update check to when form is visible
                    Update.CheckForUpdate();
                };

                //Enter GUI loop
                Application.Run(_mainForm);

                //Persist settings
                Settings.Default.RestoreLastPosition = _mainForm.Location;
                Settings.Default.RestoreLastSize = _mainForm.ClientSize;
                Settings.Default.Save();
            }
        }