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); }
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; 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) { Close(); } 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); }
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")); 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; }
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); if (!string.IsNullOrEmpty(lParam)) { lParam = ResolveShortcut(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); } }
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}"); }
private void HotkeyEventHandler(object sender, KeyEventArgs e) { ViewWindowManager.GetInstance().InvokeRoutine(); }