public PreviewWindow(string file) { BrowseCommand = new BrowseCommand(this); RefreshCommand = new RefreshCommand(this); ExitCommand = new ExitCommand(this); InitializeComponent(); File = file; interop = new WindowInteropHelper(this); interop.EnsureHandle(); }
public bool TranslateAccelerator(ref MSG msg) { if (msg.message != 0x100) { return(false); } var vk = msg.wParam.ToInt64(); ModifierKeys modState = ModifierKeys.None; Dispatcher.Invoke(() => modState = Keyboard.Modifiers); Action action = null; try { switch (vk) { case 0x09: if ((modState & ModifierKeys.Shift) == ModifierKeys.Shift) { action = () => contentPresenter.MoveFocus(new TraversalRequest(FocusNavigationDirection.Previous)); } else { action = () => contentPresenter.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next)); } return(true); case 0x42: if ((modState & (ModifierKeys.Control | ModifierKeys.Alt | ModifierKeys.Shift)) == ModifierKeys.Control) { action = () => { BrowseCommand.Execute(null); contentPresenter.Focus(); }; return(true); } return(false); case 0x74: if ((modState & (ModifierKeys.Control | ModifierKeys.Alt | ModifierKeys.Shift | ModifierKeys.Windows)) == ModifierKeys.None) { action = () => { RefreshCommand.Execute(null); contentPresenter.Focus(); }; return(true); } return(false); case 0x1b: if ((modState & (ModifierKeys.Control | ModifierKeys.Alt | ModifierKeys.Shift | ModifierKeys.Windows)) == ModifierKeys.None) { action = () => ExitCommand.Execute(null); return(true); } return(false); default: return(false); } } finally { if (action != null) { Dispatcher.InvokeAsync(action, DispatcherPriority.Send); } } }