From 153e4a782d9c1e5d4ca617cc49c0b61d130b443c Mon Sep 17 00:00:00 2001 From: Mop1398 <46262900+Mop1398@users.noreply.github.com> Date: Mon, 5 Aug 2024 12:42:03 +0330 Subject: [PATCH 1/2] Mouse ContextFlyout (instead of ContextMenu) commands fix in AvaloniaEdit.Demo --- src/AvaloniaEdit.Demo/MainWindow.xaml | 12 ++++++++- src/AvaloniaEdit.Demo/MainWindow.xaml.cs | 5 ++-- .../ViewModels/MainWIndowViewModel.cs | 27 +++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/AvaloniaEdit.Demo/MainWindow.xaml b/src/AvaloniaEdit.Demo/MainWindow.xaml index 685a509f..916d7a5e 100644 --- a/src/AvaloniaEdit.Demo/MainWindow.xaml +++ b/src/AvaloniaEdit.Demo/MainWindow.xaml @@ -51,6 +51,16 @@ HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Visible" FontWeight="Light" - FontSize="14" /> + FontSize="14" > + + + + + + + + + + \ No newline at end of file diff --git a/src/AvaloniaEdit.Demo/MainWindow.xaml.cs b/src/AvaloniaEdit.Demo/MainWindow.xaml.cs index 696f0f5e..8881c4aa 100644 --- a/src/AvaloniaEdit.Demo/MainWindow.xaml.cs +++ b/src/AvaloniaEdit.Demo/MainWindow.xaml.cs @@ -51,7 +51,8 @@ public MainWindow() _textEditor.HorizontalScrollBarVisibility = Avalonia.Controls.Primitives.ScrollBarVisibility.Visible; _textEditor.Background = Brushes.Transparent; _textEditor.ShowLineNumbers = true; - _textEditor.ContextMenu = new ContextMenu + // The ContextMenu has been defined in MainWindow.xaml + /*_textEditor.ContextMenu = new ContextMenu { ItemsSource = new List { @@ -59,7 +60,7 @@ public MainWindow() new MenuItem { Header = "Paste", InputGesture = new KeyGesture(Key.V, KeyModifiers.Control) }, new MenuItem { Header = "Cut", InputGesture = new KeyGesture(Key.X, KeyModifiers.Control) } } - }; + };*/ _textEditor.TextArea.Background = this.Background; _textEditor.TextArea.TextEntered += textEditor_TextArea_TextEntered; _textEditor.TextArea.TextEntering += textEditor_TextArea_TextEntering; diff --git a/src/AvaloniaEdit.Demo/ViewModels/MainWIndowViewModel.cs b/src/AvaloniaEdit.Demo/ViewModels/MainWIndowViewModel.cs index 89095245..7eee32dc 100644 --- a/src/AvaloniaEdit.Demo/ViewModels/MainWIndowViewModel.cs +++ b/src/AvaloniaEdit.Demo/ViewModels/MainWIndowViewModel.cs @@ -1,4 +1,5 @@ using System.Collections.ObjectModel; +using AvaloniaEdit.Editing; using ReactiveUI; using TextMateSharp.Grammars; @@ -18,4 +19,30 @@ public ThemeViewModel SelectedTheme _textMateInstallation.SetTheme(_registryOptions.LoadTheme(value.ThemeName)); } } + + public void CopyMouseCommmand(TextArea textArea) + { + ApplicationCommands.Copy.Execute(null, textArea); + } + + public void CutMouseCommand(TextArea textArea) + { + ApplicationCommands.Cut.Execute(null, textArea); + } + + public void PasteMouseCommmand(TextArea textArea) + { + ApplicationCommands.Paste.Execute(null, textArea); + } + + public void SelectAllMouseCommmand(TextArea textArea) + { + ApplicationCommands.SelectAll.Execute(null, textArea); + } + + // Undo Status is not given back to disable it's item in ContextFlyout; therefore it's not being used yet. + public void UndoMouseCommmand(TextArea textArea) + { + ApplicationCommands.Undo.Execute(null, textArea); + } } \ No newline at end of file From 9f8d31d7718b729411b716358f625b68759d2ef8 Mon Sep 17 00:00:00 2001 From: Mop1398 <46262900+Mop1398@users.noreply.github.com> Date: Mon, 5 Aug 2024 13:52:56 +0330 Subject: [PATCH 2/2] comment removal --- src/AvaloniaEdit.Demo/MainWindow.xaml.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/AvaloniaEdit.Demo/MainWindow.xaml.cs b/src/AvaloniaEdit.Demo/MainWindow.xaml.cs index 8881c4aa..600d6bdc 100644 --- a/src/AvaloniaEdit.Demo/MainWindow.xaml.cs +++ b/src/AvaloniaEdit.Demo/MainWindow.xaml.cs @@ -51,16 +51,6 @@ public MainWindow() _textEditor.HorizontalScrollBarVisibility = Avalonia.Controls.Primitives.ScrollBarVisibility.Visible; _textEditor.Background = Brushes.Transparent; _textEditor.ShowLineNumbers = true; - // The ContextMenu has been defined in MainWindow.xaml - /*_textEditor.ContextMenu = new ContextMenu - { - ItemsSource = new List - { - new MenuItem { Header = "Copy", InputGesture = new KeyGesture(Key.C, KeyModifiers.Control) }, - new MenuItem { Header = "Paste", InputGesture = new KeyGesture(Key.V, KeyModifiers.Control) }, - new MenuItem { Header = "Cut", InputGesture = new KeyGesture(Key.X, KeyModifiers.Control) } - } - };*/ _textEditor.TextArea.Background = this.Background; _textEditor.TextArea.TextEntered += textEditor_TextArea_TextEntered; _textEditor.TextArea.TextEntering += textEditor_TextArea_TextEntering;