Ionite
1 year ago
4 changed files with 45 additions and 27 deletions
@ -0,0 +1,16 @@
|
||||
using AvaloniaEdit; |
||||
using CommunityToolkit.Mvvm.Input; |
||||
|
||||
namespace StabilityMatrix.Avalonia.Controls; |
||||
|
||||
public static class EditorCommands |
||||
{ |
||||
public static RelayCommand<TextEditor> CopyCommand { get; } = |
||||
new(editor => editor?.Copy(), editor => editor?.CanCopy ?? false); |
||||
|
||||
public static RelayCommand<TextEditor> CutCommand { get; } = |
||||
new(editor => editor?.Cut(), editor => editor?.CanCut ?? false); |
||||
|
||||
public static RelayCommand<TextEditor> PasteCommand { get; } = |
||||
new(editor => editor?.Paste(), editor => editor?.CanPaste ?? false); |
||||
} |
@ -0,0 +1,27 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia" |
||||
xmlns:avaloniaEdit="https://github.com/avaloniaui/avaloniaedit" |
||||
xmlns:controls="clr-namespace:StabilityMatrix.Avalonia.Controls"> |
||||
<!-- Context menu for editors --> |
||||
<ui:FAMenuFlyout x:Key="EditorContextFlyout"> |
||||
<ui:MenuFlyoutItem |
||||
Text="Paste" |
||||
IconSource="Paste" |
||||
HotKey="Ctrl+V" |
||||
Command="{x:Static controls:EditorCommands.PasteCommand}" |
||||
CommandParameter="{Binding $parent[avaloniaEdit:TextEditor]}"/> |
||||
<ui:MenuFlyoutItem |
||||
Text="Copy" |
||||
IconSource="Copy" |
||||
HotKey="Ctrl+C" |
||||
Command="{x:Static controls:EditorCommands.CopyCommand}" |
||||
CommandParameter="{Binding $parent[avaloniaEdit:TextEditor]}"/> |
||||
<ui:MenuFlyoutItem |
||||
Text="Cut" |
||||
IconSource="Cut" |
||||
HotKey="Ctrl+X" |
||||
Command="{x:Static controls:EditorCommands.CutCommand}" |
||||
CommandParameter="{Binding $parent[avaloniaEdit:TextEditor]}"/> |
||||
</ui:FAMenuFlyout> |
||||
</ResourceDictionary> |
Loading…
Reference in new issue