示例#1
0
        internal void RunAndClosePreview()
        {
            if (_currentMainWindow.Visibility != Visibility.Visible)
            {
                return;
            }

            // if the current focus is in Desktop or explorer windows, just close the preview window and leave the task to System.
            var focus = NativeMethods.QuickLook.GetFocusedWindowType();

            if (focus != NativeMethods.QuickLook.FocusedWindowType.Invalid)
            {
                StopFocusMonitor();
                _currentMainWindow.BeginHide();
                return;
            }

            // if the focus is in the preview window, run it
            if (!WindowHelper.IsForegroundWindowBelongToSelf())
            {
                return;
            }

            StopFocusMonitor();
            _currentMainWindow.RunAndHide();
        }