Пример #1
0
        /// <summary>
        ///     Runs when our global keyboard hook is triggered.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void KeyboardHook_OnPressed(object sender, KeyPressedEventArgs e)
        {
            // Ignore if quit in progress
            if (_eventShutdownRequested.WaitOne(0))
            {
                return;
            }

            // Ignore if already showing the tools form
            if (ShowingPasswordOrTools)
            {
                return;
            }

            // Ignore if there are no possible tabs enabled
            if (_userToolsEnabled == false && _taskSequenceVariablesEnabled == false)
            {
                return;
            }

            ShowingPasswordOrTools = true;

            // Hide the background window because it causes issues when the user clicks on it
            if (_customBackgroundEnabled)
            {
                Activate();
                BringToFront();
                Hide();
            }

            // Hide TS dialog
            TaskSequence.CloseProgressDialog();

            // Ask for password if needed
            PasswordMode passwordMode;

            using (var formPassword = new FormPassword(_options))
            {
                formPassword.ShowDialog();
                passwordMode = formPassword.PasswordMode;
            }

            // If password is ok, launch the tools
            if (passwordMode != PasswordMode.None)
            {
                _formTools = new FormTools(_options, passwordMode, _osdBackgroundDir);
                DialogResult result = _formTools.ShowDialog(this);
                _formTools.Dispose();
                _formTools = null;

                // Check if closed via the "Close App" button
                if (result == DialogResult.Abort)
                {
                    // Queue the quit signal
                    _eventShutdownRequested.Set();
                }
            }

            // Reshow the background and push it to the back again
            if (_customBackgroundEnabled)
            {
                Show();
            }

            // Push the Win7/Win10 progress screen to the bottom, then put our form on top of that
            BringToFrontOfWindowsSetupProgress();

            // Reshow TS progress
            TaskSequence.ShowTsProgress();

            ShowingPasswordOrTools = false;
        }