Esempio n. 1
0
        public static bool PrepareExit()
        {
            bool readyToExit = true;

            foreach (BrowserController controller in new List <BrowserController>(Browsers))
            {
                if (controller.IsConnected())
                {
                    if (PreferencesFactory.get().getBoolean("browser.disconnect.confirm"))
                    {
                        controller.CommandBox(LocaleFactory.localizedString("Quit"),
                                              LocaleFactory.localizedString(
                                                  "You are connected to at least one remote site. Do you want to review open browsers?"),
                                              null,
                                              String.Format("{0}|{1}", LocaleFactory.localizedString("Review…"),
                                                            LocaleFactory.localizedString("Quit Anyway")), true,
                                              LocaleFactory.localizedString("Don't ask again", "Configuration"), TaskDialogIcon.Warning,
                                              delegate(int option, bool verificationChecked)
                        {
                            if (verificationChecked)
                            {
                                // Never show again.
                                PreferencesFactory.get().setProperty("browser.disconnect.confirm", false);
                            }
                            switch (option)
                            {
                            case -1:         // Cancel
                                             // Quit has been interrupted. Delete any saved sessions so far.
                                Application._sessions.clear();
                                readyToExit = false;
                                break;

                            case 0:         // Review
                                if (BrowserController.ApplicationShouldTerminate())
                                {
                                    break;
                                }
                                readyToExit = false;
                                break;

                            case 1:         // Quit
                                foreach (BrowserController c in
                                         new List <BrowserController>(Browsers))
                                {
                                    c.View.Dispose();
                                }
                                break;
                            }
                        });
                    }
                    else
                    {
                        controller.Unmount();
                    }
                }
            }
            return(readyToExit);
        }
Esempio n. 2
0
        public static void Exit()
        {
            foreach (BrowserController controller in new List <BrowserController>(Browsers))
            {
                if (controller.IsConnected())
                {
                    if (Preferences.instance().getBoolean("browser.confirmDisconnect"))
                    {
                        controller.CommandBox(Locale.localizedString("Quit"),
                                              Locale.localizedString(
                                                  "You are connected to at least one remote site. Do you want to review open browsers?"),
                                              null,
                                              String.Format("{0}|{1}",
                                                            Locale.localizedString("Review…"),
                                                            Locale.localizedString("Quit Anyway")),
                                              true,
                                              Locale.localizedString("Don't ask again", "Configuration"),
                                              SysIcons.Warning, delegate(int option, bool verificationChecked)
                        {
                            if (verificationChecked)
                            {
                                // Never show again.
                                Preferences.instance().setProperty(
                                    "browser.confirmDisconnect", false);
                            }
                            switch (option)
                            {
                            case -1:                                                 // Cancel
                                // Quit has been interrupted. Delete any saved sessions so far.
                                Application._sessions.clear();
                                return;

                            case 0:                                                 // Review
                                if (
                                    BrowserController.
                                    ApplicationShouldTerminate())
                                {
                                    break;
                                }
                                return;

                            case 1:                                                 // Quit
                                foreach (
                                    BrowserController c in
                                    new List <BrowserController>(
                                        Browsers))
                                {
                                    c.View.Dispose();
                                }
                                break;
                            }
                        });
                    }
                    else
                    {
                        controller.Unmount();
                    }
                }
            }
            ApplicationShouldTerminateAfterDonationPrompt();
            System.Windows.Forms.Application.Exit();
        }