diff --git a/Mirivoice/ViewModels/MainViewModel.cs b/Mirivoice/ViewModels/MainViewModel.cs index cbbd0c2..84fcbf4 100644 --- a/Mirivoice/ViewModels/MainViewModel.cs +++ b/Mirivoice/ViewModels/MainViewModel.cs @@ -1,6 +1,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Input; using Avalonia.Platform.Storage; using global::Mirivoice.Views; using Mirivoice.Commands; @@ -26,6 +27,7 @@ namespace Mirivoice.ViewModels public class MainViewModel : VoicerSelectingViewModelBase { MainWindow mainWindow; + public static FilePickerFileType MiriVoiceProject { get; } = new("MiriVoice Project File") { Patterns = new[] { "*.mrp" }, @@ -729,6 +731,7 @@ public async void OnNewButtonClick() } + public MainViewModel(MainWindow window) : base(true) { @@ -740,6 +743,7 @@ public MainViewModel(MainWindow window) : base(true) LoadRecentFIles(); SetCommands(); + SetGestures(); SingleTextBoxEditorEnabled = false; IsVisibleProgressbar = false; @@ -940,6 +944,36 @@ public void LoadRecentFIles() } RecentFiles.UpdateUI(this); // update UI } + + // Key gestures + public KeyGesture UndoGesture { get; set; } + public KeyGesture RedoGesture { get; set; } + public KeyGesture OpenGesture { get; set; } + public KeyGesture SaveGesture { get; set; } + public KeyGesture SaveAsGesture { get; set; } + public KeyGesture NewGesture { get; set; } + + void SetGestures() + { + if (OS.IsWindows() || OS.IsLinux()) + { + UndoGesture = new KeyGesture(Key.Z, KeyModifiers.Control); + RedoGesture = new KeyGesture(Key.Y, KeyModifiers.Control); + OpenGesture = new KeyGesture(Key.O, KeyModifiers.Control); + SaveGesture = new KeyGesture(Key.S, KeyModifiers.Control); + SaveAsGesture = new KeyGesture(Key.S, KeyModifiers.Control | KeyModifiers.Shift); + NewGesture = new KeyGesture(Key.N, KeyModifiers.Control); + } + else // MacOS + { + UndoGesture = new KeyGesture(Key.Z, KeyModifiers.Meta); + RedoGesture = new KeyGesture(Key.Y, KeyModifiers.Meta); + OpenGesture = new KeyGesture(Key.O, KeyModifiers.Meta); + SaveGesture = new KeyGesture(Key.S, KeyModifiers.Meta); + SaveAsGesture = new KeyGesture(Key.S, KeyModifiers.Meta | KeyModifiers.Shift); + NewGesture = new KeyGesture(Key.N, KeyModifiers.Meta); + } + } // Commands public MCommand AddLineBoxCommand { get; set; } AddLineBoxReceiver addLineBoxReceiver; diff --git a/Mirivoice/Views/MainView.axaml b/Mirivoice/Views/MainView.axaml index d0736e6..5448c78 100644 --- a/Mirivoice/Views/MainView.axaml +++ b/Mirivoice/Views/MainView.axaml @@ -24,14 +24,14 @@ - + - + - - + + @@ -46,8 +46,8 @@ - - + + diff --git a/Mirivoice/Views/MainWindow.axaml b/Mirivoice/Views/MainWindow.axaml index 6551ee9..c0d6b7d 100644 --- a/Mirivoice/Views/MainWindow.axaml +++ b/Mirivoice/Views/MainWindow.axaml @@ -10,12 +10,12 @@ Icon="/Assets/mirivoice-logo.ico" Title="{Binding Title}"> - - - - - - + + + + + + \ No newline at end of file