Ejemplo n.º 1
0
        private void App_OnExit(object sender, ExitEventArgs e)
        {
            if (!_cleanExit)
            {
                return;
            }

            _isRunning.ReleaseMutex();

            PipeServerManager.GetInstance().Dispose();

            //add by gh - 自动启动隐藏后台图标
            if (SettingHelper.Get("Visible", true))
            {
                TrayIconManager.GetInstance().Dispose();
            }
            //----------//

            //comment by gh
            //TrayIconManager.GetInstance().Dispose();
            //----------//

            KeystrokeDispatcher.GetInstance().Dispose();
            ViewWindowManager.GetInstance().Dispose();
        }
Ejemplo n.º 2
0
        private void CallViewWindowManagerInvokeRoutine(KeyEventArgs e, bool isKeyDown)
        {
            if (e.Modifiers != Keys.None)
            {
                return;
            }

            // set variable only when KeyDown
            if (isKeyDown)
            {
                _isKeyDownInDesktopOrShell = NativeMethods.QuickLook.GetFocusedWindowType() !=
                                             NativeMethods.QuickLook.FocusedWindowType.Invalid;
                _isKeyDownInDesktopOrShell |= WindowHelper.IsForegroundWindowBelongToSelf();
            }

            // call InvokeRoutine only when the KeyDown is valid
            if (_isKeyDownInDesktopOrShell)
            {
                Dispatcher.CurrentDispatcher.BeginInvoke(
                    new Action <bool>(down =>
                                      ViewWindowManager.GetInstance().InvokeRoutine(e, down)),
                    DispatcherPriority.ApplicationIdle,
                    isKeyDown);
            }

            // reset variable only when KeyUp
            if (!isKeyDown)
            {
                _isKeyDownInDesktopOrShell = false;
            }
        }
Ejemplo n.º 3
0
        internal MainWindowTransparent()
        {
            // this object should be initialized before loading UI components, because many of which are binding to it.
            ContextObject = new ContextObject();

            InitializeComponent();

            FontFamily = new FontFamily(TranslationHelper.GetString("UI_FontFamily", failsafe: "Segoe UI"));

            windowCaptionContainer.MouseLeftButtonDown += WindowDragMoveStart;
            windowCaptionContainer.MouseMove           += WindowDragMoving;
            windowCaptionContainer.MouseLeftButtonUp   += WindowDragMoveEnd;

            windowFrameContainer.PreviewMouseMove += ShowWindowCaptionContainer;

            buttonPin.Click += (sender, e) =>
            {
                if (Pinned)
                {
                    Topmost       = !Topmost;
                    buttonPin.Tag = Topmost ? "PinTop" : "Pin";
                    return;
                }
                Pinned        = true;
                buttonPin.Tag = "Pin";
                ViewWindowManager.GetInstance().ForgetCurrentWindow();
            };

            buttonCloseWindow.Click += (sender, e) =>
            {
                if (Pinned)
                {
                    BeginClose();
                }
                else
                {
                    ViewWindowManager.GetInstance().ClosePreview();
                }
            };

            buttonOpenWith.Click += (sender, e) =>
            {
                if (Pinned)
                {
                    RunAndClose();
                }
                else
                {
                    ViewWindowManager.GetInstance().RunAndClosePreview();
                }
            };

            buttonWindowStatus.Click += (sender, e) =>
                                        WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;

            buttonShare.Click +=
                (sender, e) => RunWith("rundll32.exe", $"shell32.dll,OpenAs_RunDLL {_path}");
        }
Ejemplo n.º 4
0
        private void App_OnExit(object sender, ExitEventArgs e)
        {
            if (_isFirstInstance)
            {
                _isRunning.ReleaseMutex();

                PipeServerManager.GetInstance().Dispose();
                TrayIconManager.GetInstance().Dispose();
                BackgroundListener.GetInstance().Dispose();
                ViewWindowManager.GetInstance().Dispose();
            }
        }
Ejemplo n.º 5
0
        private bool MessageReceived(string msg)
        {
            var split = msg.IndexOf('|');

            if (split == -1)
            {
                return(false);
            }

            var wParam = msg.Substring(0, split);
            var lParam = msg.Substring(split + 1, msg.Length - split - 1);

            switch (wParam)
            {
            case PipeMessages.RunAndClose:
                Application.Current.Dispatcher.BeginInvoke(
                    new Action(() => ViewWindowManager.GetInstance().RunAndClosePreview()),
                    DispatcherPriority.ApplicationIdle);
                return(false);

            case PipeMessages.Invoke:
                Application.Current.Dispatcher.BeginInvoke(
                    new Action(() => ViewWindowManager.GetInstance().InvokePreview(lParam)),
                    DispatcherPriority.ApplicationIdle);
                return(false);

            case PipeMessages.Switch:
                Application.Current.Dispatcher.BeginInvoke(
                    new Action(() => ViewWindowManager.GetInstance().SwitchPreview(lParam)),
                    DispatcherPriority.ApplicationIdle);
                return(false);

            case PipeMessages.Toggle:
                Application.Current.Dispatcher.BeginInvoke(
                    new Action(() => ViewWindowManager.GetInstance().TogglePreview(lParam)),
                    DispatcherPriority.ApplicationIdle);
                return(false);

            case PipeMessages.Close:
                Application.Current.Dispatcher.BeginInvoke(
                    new Action(() => ViewWindowManager.GetInstance().ClosePreview()),
                    DispatcherPriority.ApplicationIdle);
                return(false);

            case PipeMessages.Quit:
                return(true);

            default:
                return(false);
            }
        }
Ejemplo n.º 6
0
        private void App_OnExit(object sender, ExitEventArgs e)
        {
            if (!_isFirstInstance)
            {
                return;
            }

            _isRunning.ReleaseMutex();

            PipeServerManager.GetInstance().Dispose();
            TrayIconManager.GetInstance().Dispose();
            KeystrokeDispatcher.GetInstance().Dispose();
            ViewWindowManager.GetInstance().Dispose();
        }
Ejemplo n.º 7
0
        /* comment by gh
         * private void CheckUpdate()
         * {
         *  if (DateTime.Now.Ticks - SettingHelper.Get<long>("LastUpdateTicks") < TimeSpan.FromDays(7).Ticks)
         *      return;
         *
         *  Task.Delay(120 * 1000).ContinueWith(_ => Updater.CheckForUpdates(true));
         *  SettingHelper.Set("LastUpdateTicks", DateTime.Now.Ticks);
         * }
         *///----------//


        private void RunListener(StartupEventArgs e)
        {
            //comment by gh - 启动不显示启动提示
            //TrayIconManager.GetInstance();
            //if (!e.Args.Contains("/autorun") && !IsUWP)
            //TrayIconManager.ShowNotification("", TranslationHelper.Get("APP_START"));
            //if (e.Args.Contains("/first"))
            //AutoStartupHelper.CreateAutorunShortcut();
            //----------//

            //add by gh - 自动启动隐藏后台图标
            if (SettingHelper.Get("Visible", true))
            {
                TrayIconManager.GetInstance();
                if (!e.Args.Contains("/autorun") && !IsUWP)
                {
                    TrayIconManager.ShowNotification("", TranslationHelper.Get("APP_START"));
                }
            }
            else if (e.Args.Contains("/setvisible"))
            {
                SettingHelper.Set("Visible", true);
                TrayIconManager.GetInstance();
                if (!IsUWP)
                {
                    TrayIconManager.ShowNotification("", TranslationHelper.Get("APP_START"));
                }
            }
            //自己添加的功能,与quick look无关
            if (SettingHelper.Get("Watcher", false))
            {
                DesktopWatcher.GetInstance().WatcherStart();
            }

            if (e.Args.Contains("/first"))
            {
                AutoStartupHelper.CreateAutorunShortcut();
            }
            //----------//

            NativeMethods.QuickLook.Init();

            PluginManager.GetInstance();
            ViewWindowManager.GetInstance();
            KeystrokeDispatcher.GetInstance();
            PipeServerManager.GetInstance();
        }
Ejemplo n.º 8
0
        private void RunListener(StartupEventArgs e)
        {
            TrayIconManager.GetInstance();
            if (!e.Args.Contains("/autorun") && !IsUWP)
            {
                TrayIconManager.ShowNotification("", TranslationHelper.GetString("APP_START"));
            }
            if (e.Args.Contains("/first"))
            {
                AutoStartupHelper.CreateAutorunShortcut();
            }

            NativeMethods.QuickLook.Init();

            PluginManager.GetInstance();
            ViewWindowManager.GetInstance();
            BackgroundListener.GetInstance();
            PipeServerManager.GetInstance();
        }
Ejemplo n.º 9
0
        internal void BeginHide()
        {
            // reset custom window size
            _customWindowSize           = Size.Empty;
            _ignoreNextWindowSizeChange = true;

            UnloadPlugin();

            // if the this window is hidden in Max state, new show() will results in failure:
            // "Cannot show Window when ShowActivated is false and WindowState is set to Maximized"
            //WindowState = WindowState.Normal;

            Hide();
            //Dispatcher.BeginInvoke(new Action(Hide), DispatcherPriority.ApplicationIdle);

            ViewWindowManager.GetInstance().ForgetCurrentWindow();

            ProcessHelper.PerformAggressiveGC();
        }
Ejemplo n.º 10
0
        private void RunListener(StartupEventArgs e)
        {
            TrayIconManager.GetInstance();
            if (!e.Args.Contains("/autorun"))
            {
                TrayIconManager.GetInstance().ShowNotification("", "QuickLook is running in the background.");
            }
            if (e.Args.Contains("/first"))
            {
                AutoStartupHelper.CreateAutorunShortcut();
            }

            NativeMethods.QuickLook.Init();

            PluginManager.GetInstance();
            BackgroundListener.GetInstance();
            PipeServerManager.GetInstance().MessageReceived +=
                (msg, ea) => Dispatcher.BeginInvoke(
                    new Action(() => ViewWindowManager.GetInstance().InvokeViewer(msg as string, closeIfSame: true)),
                    DispatcherPriority.ApplicationIdle);
        }
Ejemplo n.º 11
0
        internal MainWindowTransparent()
        {
            // this object should be initialized before loading UI components, because many of which are binding to it.
            ContextObject = new ContextObject();

            InitializeComponent();

            SourceInitialized += (sender, e) =>
            {
                if (AllowsTransparency)
                {
                    BlurWindow.EnableWindowBlur(this);
                }
            };

            buttonCloseWindow.MouseLeftButtonUp += (sender, e) =>
                                                   ViewWindowManager.GetInstance().ClosePreview();

            buttonOpenWith.Click += (sender, e) =>
                                    ViewWindowManager.GetInstance().RunAndClosePreview();
        }
Ejemplo n.º 12
0
        internal ViewerWindow()
        {
            // this object should be initialized before loading UI components, because many of which are binding to it.
            ContextObject = new ContextObject();

            ContextObject.PropertyChanged += ContextObject_PropertyChanged;

            InitializeComponent();

            Icon = (App.IsWin10 ? Properties.Resources.app_white_png : Properties.Resources.app_png).ToBitmapSource();

            FontFamily = new FontFamily(TranslationHelper.Get("UI_FontFamily", failsafe: "Segoe UI"));

            SizeChanged += SaveWindowSizeOnSizeChanged;

            StateChanged += (sender, e) => _ignoreNextWindowSizeChange = true;

            windowFrameContainer.PreviewMouseMove += ShowWindowCaptionContainer;

            buttonTop.Click += (sender, e) =>
            {
                Topmost       = !Topmost;
                buttonTop.Tag = Topmost ? "Top" : "Auto";
            };

            buttonPin.Click += (sender, e) =>
            {
                if (Pinned)
                {
                    return;
                }

                ViewWindowManager.GetInstance().ForgetCurrentWindow();
            };

            buttonCloseWindow.Click += (sender, e) =>
            {
                if (Pinned)
                {
                    BeginClose();
                }
                else
                {
                    ViewWindowManager.GetInstance().ClosePreview();
                }
            };

            buttonOpenWith.Click += (sender, e) =>
            {
                if (Pinned)
                {
                    RunAndClose();
                }
                else
                {
                    ViewWindowManager.GetInstance().RunAndClosePreview();
                }
            };

            buttonWindowStatus.Click += (sender, e) =>
                                        WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;

            buttonShare.Click += Share;
        }
Ejemplo n.º 13
0
        internal ViewerWindow()
        {
            // this object should be initialized before loading UI components, because many of which are binding to it.
            ContextObject = new ContextObject();

            InitializeComponent();

            FontFamily = new FontFamily(TranslationHelper.GetString("UI_FontFamily", failsafe: "Segoe UI"));

            SizeChanged += SaveWindowSizeOnSizeChanged;

            StateChanged += (sender, e) => _ignoreNextWindowSizeChange = true;

            windowCaptionContainer.MouseLeftButtonDown += WindowDragMoveStart;
            windowCaptionContainer.MouseMove           += WindowDragMoving;
            windowCaptionContainer.MouseLeftButtonUp   += WindowDragMoveEnd;

            windowFrameContainer.PreviewMouseMove += ShowWindowCaptionContainer;

            buttonTop.Click += (sender, e) =>
            {
                Topmost       = !Topmost;
                buttonTop.Tag = Topmost ? "Top" : "Auto";
            };

            buttonPin.Click += (sender, e) =>
            {
                if (Pinned)
                {
                    return;
                }

                Pinned        = true;
                buttonPin.Tag = "Pin";
                ViewWindowManager.GetInstance().ForgetCurrentWindow();
            };

            buttonCloseWindow.Click += (sender, e) =>
            {
                if (Pinned)
                {
                    BeginClose();
                }
                else
                {
                    ViewWindowManager.GetInstance().ClosePreview();
                }
            };

            buttonOpenWith.Click += (sender, e) =>
            {
                if (Pinned)
                {
                    RunAndClose();
                }
                else
                {
                    ViewWindowManager.GetInstance().RunAndClosePreview();
                }
            };

            buttonWindowStatus.Click += (sender, e) =>
                                        WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;

            buttonShare.Click += Share;
        }
Ejemplo n.º 14
0
        internal MainWindowTransparent()
        {
            // this object should be initialized before loading UI components, because many of which are binding to it.
            ContextObject = new ContextObject();

            InitializeComponent();

            FontFamily = new FontFamily(TranslationHelper.GetString("UI_FontFamily", failsafe: "Segoe UI"));

            SourceInitialized += (sender, e) =>
            {
                if (AllowsTransparency)
                {
                    BlurWindow.EnableWindowBlur(this);
                }
            };

            buttonPin.MouseLeftButtonUp += (sender, e) =>
            {
                if (Pinned)
                {
                    buttonCloseWindow.RaiseEvent(
                        new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Left)
                    {
                        RoutedEvent = MouseLeftButtonUpEvent
                    });
                    return;
                }
                Pinned = true;
                ViewWindowManager.GetInstance().ForgetCurrentWindow();
            };

            buttonCloseWindow.MouseLeftButtonUp += (sender, e) =>
            {
                if (Pinned)
                {
                    BeginClose();
                }
                else
                {
                    ViewWindowManager.GetInstance().ClosePreview();
                }
            };

            buttonOpenWith.Click += (sender, e) =>
            {
                if (Pinned)
                {
                    RunAndClose();
                }
                else
                {
                    ViewWindowManager.GetInstance().RunAndClosePreview();
                }
            };

            buttonWindowStatus.MouseLeftButtonUp += (sender, e) =>
                                                    WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;

            buttonShare.MouseLeftButtonUp +=
                (sender, e) => RunWith("rundll32.exe", $"shell32.dll,OpenAs_RunDLL {Path}");
        }
Ejemplo n.º 15
0
        private bool MessageReceived(string msg)
        {
            var split = msg.IndexOf('|');

            if (split == -1)
            {
                return(false);
            }

            if (_lastOperation != null && _lastOperation.Status == DispatcherOperationStatus.Pending)
            {
                _lastOperation.Abort();
                Debug.WriteLine("Dispatcher task canceled");
            }

            var wParam = msg.Substring(0, split);
            var lParam = msg.Substring(split + 1, msg.Length - split - 1);

            lParam = ShellLinkHelper.GetTarget(lParam);

            switch (wParam)
            {
            case PipeMessages.RunAndClose:
                Application.Current.Dispatcher.BeginInvoke(
                    new Action(() => ViewWindowManager.GetInstance().RunAndClosePreview()),
                    DispatcherPriority.ApplicationIdle);
                return(false);

            case PipeMessages.Invoke:
                _lastOperation = Application.Current.Dispatcher.BeginInvoke(
                    new Action(() => ViewWindowManager.GetInstance().InvokePreview(lParam)),
                    DispatcherPriority.ApplicationIdle);
                return(false);

            case PipeMessages.Switch:
                _lastOperation = Application.Current.Dispatcher.BeginInvoke(
                    new Action(() => ViewWindowManager.GetInstance().SwitchPreview(lParam)),
                    DispatcherPriority.ApplicationIdle);
                return(false);

            case PipeMessages.Toggle:
                _lastOperation = Application.Current.Dispatcher.BeginInvoke(
                    new Action(() => ViewWindowManager.GetInstance().TogglePreview(lParam)),
                    DispatcherPriority.ApplicationIdle);
                return(false);

            case PipeMessages.Forget:
                Application.Current.Dispatcher.BeginInvoke(
                    new Action(() => ViewWindowManager.GetInstance().ForgetCurrentWindow()),
                    DispatcherPriority.ApplicationIdle);
                return(false);

            case PipeMessages.Close:
                Application.Current.Dispatcher.BeginInvoke(
                    new Action(() => ViewWindowManager.GetInstance().ClosePreview()),
                    DispatcherPriority.ApplicationIdle);
                return(false);

            case PipeMessages.Quit:
                return(true);

            default:
                return(false);
            }
        }
Ejemplo n.º 16
0
 internal static ViewWindowManager GetInstance()
 {
     return(_instance ?? (_instance = new ViewWindowManager()));
 }
Ejemplo n.º 17
0
        internal ViewerWindow()
        {
            // this object should be initialized before loading UI components, because many of which are binding to it.
            ContextObject = new ContextObject();

            ContextObject.PropertyChanged += ContextObject_PropertyChanged;

            InitializeComponent();

            Icon = (App.IsWin10 ? Properties.Resources.app_white_png : Properties.Resources.app_png).ToBitmapSource();

            FontFamily = new FontFamily(TranslationHelper.Get("UI_FontFamily", failsafe: "Segoe UI"));

            SizeChanged += SaveWindowSizeOnSizeChanged;

            StateChanged += (sender, e) => _ignoreNextWindowSizeChange = true;

            // bring the window to top when users click in the client area.
            // the non-client area is handled by the WndProc inside OnSourceInitialized().
            // This is buggy for Windows 7 and 8: https://github.com/QL-Win/QuickLook/issues/644#issuecomment-628921704
            if (App.IsWin10)
            {
                PreviewMouseDown += (sender, e) => this.BringToFront(false);
            }

            windowFrameContainer.PreviewMouseMove += ShowWindowCaptionContainer;

            Topmost       = SettingHelper.Get("Topmost", false);
            buttonTop.Tag = Topmost ? "Top" : "Auto";

            buttonTop.Click += (sender, e) =>
            {
                Topmost = !Topmost;
                SettingHelper.Set("Topmost", Topmost);
                buttonTop.Tag = Topmost ? "Top" : "Auto";
            };

            buttonPin.Click += (sender, e) =>
            {
                if (Pinned)
                {
                    return;
                }

                ViewWindowManager.GetInstance().ForgetCurrentWindow();
            };

            buttonCloseWindow.Click += (sender, e) =>
            {
                if (Pinned)
                {
                    BeginClose();
                }
                else
                {
                    ViewWindowManager.GetInstance().ClosePreview();
                }
            };

            buttonOpen.Click += (sender, e) =>
            {
                if (Pinned)
                {
                    RunAndClose();
                }
                else
                {
                    ViewWindowManager.GetInstance().RunAndClosePreview();
                }
            };

            buttonWindowStatus.Click += (sender, e) =>
                                        WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;

            buttonShare.Click    += (sender, e) => ShareHelper.Share(_path, this);
            buttonOpenWith.Click += (sender, e) => ShareHelper.Share(_path, this, true);
        }
Ejemplo n.º 18
0
 private void HotkeyEventHandler(object sender, KeyEventArgs e)
 {
     ViewWindowManager.GetInstance().InvokeRoutine();
 }