private void Window_PreviewKeyDown(object sender, KeyEventArgs e) { if (_sheetController.State.Mode == SheetMode.TextEditor) { return; } bool none = Keyboard.Modifiers == ModifierKeys.None; bool onlyCtrl = Keyboard.Modifiers == ModifierKeys.Control; bool onlyShift = Keyboard.Modifiers == ModifierKeys.Shift; bool ctrlShift = Keyboard.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift); switch (e.Key) { // Ctrl+0: Zoom to Page Level case Key.D0: case Key.NumPad0: if (onlyCtrl) { _sheetController.State.ZoomController.AutoFit(); } break; // Ctrl+1: Actual Size case Key.D1: case Key.NumPad1: if (onlyCtrl) { _sheetController.State.ZoomController.ActualSize(); } break; // N: Mode None // Ctrl+N: New Page case Key.N: if (none) { _sheetController.State.Mode = SheetMode.None; UpdateModeMenu(); } if (onlyCtrl) { _sheetController.NewPage(); } break; // Ctrl+O: Open Page case Key.O: if (onlyCtrl) { _sheetController.OpenPage(); } break; // Ctrl+S: Save Page // S: Mode Selection case Key.S: if (onlyCtrl) { _sheetController.SavePage(); } else if (none) { _sheetController.State.Mode = SheetMode.Selection; UpdateModeMenu(); } break; // E: Mode Ellipse case Key.E: if (none) { _sheetController.State.Mode = SheetMode.Ellipse; UpdateModeMenu(); } break; // Ctrl+L: Library // L: Mode Line case Key.L: if (onlyCtrl) { _sheetController.LoadLibrary(); } else if (none) { _sheetController.State.Mode = SheetMode.Line; UpdateModeMenu(); } break; // Ctrl+D: Database // D: Mode Image case Key.D: if (onlyCtrl) { OpenDatabase(); } else if (none) { _sheetController.State.Mode = SheetMode.Image; UpdateModeMenu(); } break; // Ctrl+Z: Undo case Key.Z: if (onlyCtrl) { _sheetController.State.HistoryController.Undo(); } break; // Ctrl+Y: Redo case Key.Y: if (onlyCtrl) { _sheetController.State.HistoryController.Redo(); } break; // Ctrl+X: Cut // Ctrl+Shift+X: Cut as Json case Key.X: if (onlyCtrl) { _sheetController.CutText(); } else if (ctrlShift) { _sheetController.CutJson(); } break; // Ctrl+C: Copy // Ctrl+Shift+C: Copy as Json case Key.C: if (onlyCtrl) { _sheetController.CopyText(); } else if (ctrlShift) { _sheetController.CopyJson(); } break; // Ctrl+V: Paste // Ctrl+Shift+V: Paste as Json case Key.V: if (onlyCtrl) { _sheetController.PasteText(); } break; // Del: Delete // Ctrl+Del: Reset case Key.Delete: if (onlyCtrl) { _sheetController.State.HistoryController.Register("Reset"); _sheetController.ResetPage(); } else if (none) { _sheetController.Delete(); } break; // Ctrl+A: Select All case Key.A: if (onlyCtrl) { _sheetController.SelecteAll(); } break; // B: Create Block // Ctrl+B: Break Block case Key.B: if (onlyCtrl) { _sheetController.BreakBlock(); } else if (none) { e.Handled = true; _sheetController.CreateBlock(); } break; // Up: Move Up case Key.Up: if (none && _sheetController.State.View.IsFocused) { _sheetController.MoveUp(); e.Handled = true; } break; // Down: Move Down case Key.Down: if (none && _sheetController.State.View.IsFocused) { _sheetController.MoveDown(); e.Handled = true; } break; // Left: Move Left case Key.Left: if (none && _sheetController.State.View.IsFocused) { _sheetController.MoveLeft(); e.Handled = true; } break; // Right: Move Right case Key.Right: if (none && _sheetController.State.View.IsFocused) { _sheetController.MoveRight(); e.Handled = true; } break; // F: Toggle Fill case Key.F: if (none) { _sheetController.ToggleFill(); } break; // I: Mode Insert case Key.I: if (none) { _sheetController.State.Mode = SheetMode.Insert; UpdateModeMenu(); } break; // P: Mode Point case Key.P: if (none) { _sheetController.State.Mode = SheetMode.Point; UpdateModeMenu(); } break; // R: Mode Rectangle case Key.R: if (none) { _sheetController.State.Mode = SheetMode.Rectangle; UpdateModeMenu(); } break; // T: Mode Text case Key.T: if (none) { _sheetController.State.Mode = SheetMode.Text; UpdateModeMenu(); } break; } }