using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using static QuikDawEditor.EDITING.ShorcutKeys; using static QuikDawEditor.EDITING.StaticProperties; namespace QuikDawEditor; public partial class EditorWindow { UserCommandKeyPair ToggleMixerViewUCKP { get { return userCommandKeyPairs.Where(uckp => uckp.CommandName == "ToggleMixerView").FirstOrDefault(); } } UserCommandKeyPair TogglePianoRollViewUCKP { get { return userCommandKeyPairs.Where(uckp => uckp.CommandName == "TogglePianoRollView").FirstOrDefault(); } } UserCommandKeyPair ToggleShowSelectionRangeUCKP { get { return userCommandKeyPairs.Where(uckp => uckp.CommandName == "ToggleShowSelectionRange").FirstOrDefault(); } } UserCommandKeyPair ToggleLoopPlayOnUCKP { get { return userCommandKeyPairs.Where(uckp => uckp.CommandName == "ToggleLoopPlayOn").FirstOrDefault(); } } UserCommandKeyPair SetBookmarkUCKP { get { return userCommandKeyPairs.Where(uckp => uckp.CommandName == "SetBookmark").FirstOrDefault(); } } UserCommandKeyPair GoToBookmarkUCKP { get { return userCommandKeyPairs.Where(uckp => uckp.CommandName == "GoToBookmark").FirstOrDefault(); } } private void Window_PreviewKeyDown(object sender, KeyEventArgs e) { if (LoadingProject) return; if ((e.Key == Key.Escape) && CoverMessageLabel.IsVisible) CoverMessageHide(); if (HotKeysDisabled) return; //Check for shorcut keys ********************************** if (ToggleMixerViewUCKP?.shortcutKey == e.Key) if (ToggleMixerViewUCKP.modifierKeysMatch(Keyboard.Modifiers)) ToggleMixerView_Execute(); if (TogglePianoRollViewUCKP?.shortcutKey == e.Key) if (TogglePianoRollViewUCKP.modifierKeysMatch(Keyboard.Modifiers)) TogglePianoRollView_Execute(); if (ToggleShowSelectionRangeUCKP?.shortcutKey == e.Key) if (ToggleShowSelectionRangeUCKP.modifierKeysMatch(Keyboard.Modifiers)) ToggleShowSelectionRange_Execute(); if (ToggleLoopPlayOnUCKP?.shortcutKey == e.Key) if (ToggleLoopPlayOnUCKP.modifierKeysMatch(Keyboard.Modifiers)) ToggleLoopPlayOn_Execute(); if (SetBookmarkUCKP?.shortcutKey == e.Key) if (SetBookmarkUCKP.modifierKeysMatch(Keyboard.Modifiers)) SetBookmark_Execute(); if (GoToBookmarkUCKP?.shortcutKey == e.Key) if (GoToBookmarkUCKP.modifierKeysMatch(Keyboard.Modifiers)) GoToBookmark_Execute(); //***************************************************** if (e.Key == Key.Space && !CoverMessageLabel.IsVisible) { e.Handled = true; if (projPlayer.IsPianoRollPlaying) return; if (projPlayer.IsProjectRecording) RecordBut.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); else PlayBut.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); } if (e.Key == Key.R) if (RecordBut.IsEnabled && !projPlayer.IsProjectRecording) RecordBut.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); if (Keyboard.IsKeyDown(Key.LeftCtrl) && e.Key == Key.S) editingProject.Save(); //Range selection if (e.Key == Key.I) { editingProject.LoopRangeLeftMs = projPlayer.CurrentPlayingPosMS; editingProject.LoopRangeSelected = true; } if (e.Key == Key.O) editingProject.LoopRangeWidthMs = projPlayer.CurrentPlayingPosMS - editingProject.LoopRangeLeftMs; //Undo if (e.Key == Key.Z) { if (Keyboard.IsKeyDown(Key.LeftCtrl)) { e.Handled = true; if (projPlayer.IsProjectPlaying) { InfoText = "Cannot undo while playing!"; return; } MainEditor.PerformUndo(); } } } private void TogglePianoRollView_Execute() { if (editingProject.pianoRoll.myClip == null) return; if (projPlayer.IsPianoRollPlaying && editingProject.pianoRoll.IsVisible) return; editingProject.pianoRoll.IsVisible = !editingProject.pianoRoll.IsVisible; editingProject.NeedsSaving = true; } private void ToggleMixerView_Execute() { editingProject.IsMixerVisible = !editingProject.IsMixerVisible; editingProject.NeedsSaving = true; } private void ToggleShowSelectionRange_Execute() { editingProject.LoopRangeSelected = !editingProject.LoopRangeSelected; projPlayer.IsProjectLooped = false; editingProject.NeedsSaving = true; } private void ToggleLoopPlayOn_Execute() { if (!editingProject.LoopRangeSelected) return; projPlayer.IsProjectLooped = !projPlayer.IsProjectLooped; } private void SetBookmark_Execute() { editingProject.StartingBookmarkMs = (int)(projPlayer.CurrentPlayingPosMS); MainEditor.StartingBookmarkEllipse.Margin = new Thickness(MsecToPixels((double)editingProject.StartingBookmarkMs) * editingProject.ViewXZoomFac, 0, 0, 0); MainEditor.TracksContentSV.ScrollToHorizontalOffset(MsecToPixels((double)editingProject.StartingBookmarkMs) * editingProject.ViewXZoomFac - 350); } private void GoToBookmark_Execute() { MainEditor.TracksContentSV.ScrollToHorizontalOffset(MsecToPixels((double)editingProject.StartingBookmarkMs) * editingProject.ViewXZoomFac - 350); } }