private void MainWindow_Closing(object sender, CancelEventArgs e)
        {
            if (!already_exiting && !suppress_exit_warning)
            {
                if (ConfigurationManager.Instance.ConfigurationRecord.GUI_AskOnExit)
                {
                    LogoutWindow logout_window = new LogoutWindow();
                    if (false == logout_window.ShowDialog())
                    {
                        e.Cancel = true;
                        Logging.Info("User has requested not to quit Qiqqa on window close");
                        return;
                    }
                }
            }

            if (ConfigurationManager.Instance.ConfigurationRecord.GUI_RestoreWindowsAtStartup)
            {
                RestoreDesktopManager.SaveDesktop();
            }

            // Close all windows
            DockingManager.CloseAllContent();

            MainEntry.SignalShutdown();

            // If we get this far, they want out
            already_exiting = true;
        }
        private void PostStartupWork()
        {
            WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread();

            if (ConfigurationManager.Instance.ConfigurationRecord.GUI_RestoreWindowsAtStartup)
            {
                RestoreDesktopManager.RestoreDesktop();
            }
            else
            {
                // Open the most recently accessed web library
                List <WebLibraryDetail> web_libary_details = WebLibraryManager.Instance.WebLibraryDetails_WorkingWebLibrariesWithoutGuest;
                WebLibraryManager.Instance.SortWebLibraryDetailsByLastAccessed(web_libary_details);
                if (0 < web_libary_details.Count)
                {
                    WPFDoEvents.InvokeInUIThread(() => MainWindowServiceDispatcher.Instance.OpenLibrary(web_libary_details[0].library));
                }

                // Also open guest under some circumstances
                bool should_open_guest = false;

                // No web libraries
                if (0 == web_libary_details.Count)
                {
                    should_open_guest = true;
                }
                // Web library is small compared to guest library
                if (0 < web_libary_details.Count && WebLibraryManager.Instance.Library_Guest.PDFDocuments_IncludingDeleted_Count > 2 * web_libary_details[0].library.PDFDocuments_IncludingDeleted_Count)
                {
                    should_open_guest = true;
                }

                if (should_open_guest)
                {
                    WPFDoEvents.InvokeInUIThread(() => MainWindowServiceDispatcher.Instance.OpenLibrary(WebLibraryManager.Instance.Library_Guest));
                }

                // Make sure the start page is selected
                WPFDoEvents.InvokeInUIThread(() => MainWindowServiceDispatcher.Instance.OpenStartPage());
            }

            WPFDoEvents.InvokeInUIThread(() =>
            {
                if (ConfigurationManager.Instance.ConfigurationRecord.GUI_RestoreLocationAtStartup)
                {
                    SetupConfiguredDimensions();
                }
                else
                {
                    if (!RegistrySettings.Instance.IsSet(RegistrySettings.StartNotMaximized))
                    {
                        WindowState = WindowState.Maximized;
                    }
                }

                // Install the global keyboard and mouse hooks
                if (!RegistrySettings.Instance.IsSet(RegistrySettings.DisableGlobalKeyHook))
                {
                    keyboard_hook          = new KeyboardHook();
                    keyboard_hook.KeyDown += keyboard_hook_KeyDown;
                    keyboard_hook.Start();
                }
                else
                {
                    Logging.Warn("DisableGlobalKeyHook is set!");
                }
            });

            {
                // Start listening for other apps
                ipc_server = new IPCServer();
                ipc_server.IPCServerMessage += ipc_server_IPCServerMessage;

                ipc_server.Start();
            }

            StartBackgroundWorkerDaemon();
        }
Beispiel #3
0
        private void PostStartupWork()
        {
            if (ConfigurationManager.Instance.ConfigurationRecord.GUI_RestoreWindowsAtStartup)
            {
                RestoreDesktopManager.RestoreDesktop();
            }
            else
            {
                // Open the most recently accessed web library
                List <WebLibraryDetail> web_libary_details = WebLibraryManager.Instance.WebLibraryDetails_WorkingWebLibrariesWithoutGuest;
                WebLibraryManager.Instance.SortWebLibraryDetailsByLastAccessed(web_libary_details);
                if (0 < web_libary_details.Count)
                {
                    MainWindowServiceDispatcher.Instance.OpenLibrary(web_libary_details[0].library);
                }

                // Also open guest under some circumstances
                bool should_open_guest = false;

                // No web libraries
                if (0 == web_libary_details.Count)
                {
                    should_open_guest = true;
                }
                // Web library is small compared to guest library
                if (0 < web_libary_details.Count && WebLibraryManager.Instance.Library_Guest.PDFDocuments_IncludingDeleted_Count > 2 * web_libary_details[0].library.PDFDocuments_IncludingDeleted_Count)
                {
                    should_open_guest = true;
                }

                if (should_open_guest)
                {
                    MainWindowServiceDispatcher.Instance.OpenLibrary(WebLibraryManager.Instance.Library_Guest);
                }

                // Make sure the start page is selected
                MainWindowServiceDispatcher.Instance.OpenStartPage();
            }

            if (ConfigurationManager.Instance.ConfigurationRecord.GUI_RestoreLocationAtStartup)
            {
                SetupConfiguredDimensions();
            }
            else
            {
                if (!RegistrySettings.Instance.IsSet(RegistrySettings.StartNotMaximized))
                {
                    WindowState = WindowState.Maximized;
                }
            }

            // Install the global keyboard and mouse hooks
            if (!RegistrySettings.Instance.IsSet(RegistrySettings.DisableGlobalKeyHook))
            {
                keyboard_hook          = new KeyboardHook();
                keyboard_hook.KeyDown += keyboard_hook_KeyDown;
                keyboard_hook.Start();
            }
            else
            {
                Logging.Warn("DisableGlobalKeyHook is set!");
            }

            if (true)
            {
                // Start listening for other apps
                ipc_server = new IPCServer();
                ipc_server.IPCServerMessage += ipc_server_IPCServerMessage;

                ipc_server.Start();
            }

            if (ConfigurationManager.Instance.ConfigurationRecord.TermsAndConditionsAccepted)
            {
                StartBackgroundWorkerDaemon();
            }
            else
            {
                // TODO: nothing to do any more; user hasn't accepted the Terms & Conditions... Allow update via UI maybe? Nah, just quit!
                WPFDoEvents.ResetHourglassCursor();

                MessageBoxes.Info("You have not accepted the Qiqqa Terms and Conditions. Consequently, no service can be provided. The application will terminate now.\n\nYou may want to re-install the software and check&accept the Terms & Conditions, which are shown during the installation procedure.");

                MainWindowServiceDispatcher.Instance.ShutdownQiqqa(suppress_exit_warning: true);
            }
        }