From a3243991348c802b78b2e6899c8de1ecbd8e355b Mon Sep 17 00:00:00 2001 From: rabbitism Date: Sat, 25 Feb 2023 14:25:11 +0800 Subject: [PATCH] feat: add menu flyout. --- src/Ursa.Themes.Semi/Controls/IPv4Box.axaml | 22 ++++++++++++++++ src/Ursa/Controls/IPv4Box.cs | 28 +++++++++++++++++---- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/Ursa.Themes.Semi/Controls/IPv4Box.axaml b/src/Ursa.Themes.Semi/Controls/IPv4Box.axaml index 2f5095b..4a55d21 100644 --- a/src/Ursa.Themes.Semi/Controls/IPv4Box.axaml +++ b/src/Ursa.Themes.Semi/Controls/IPv4Box.axaml @@ -8,6 +8,27 @@ + + + + + + @@ -20,6 +41,7 @@ + (); clipboard?.SetTextAsync(s); } + + public static KeyGesture? CopyKeyGesture { get; } = AvaloniaLocator.Current.GetService()?.Copy.FirstOrDefault(); + public static KeyGesture? PasteKeyGesture { get; } = AvaloniaLocator.Current.GetService()?.Paste.FirstOrDefault(); + public static KeyGesture? CutKeyGesture { get; } = AvaloniaLocator.Current.GetService()?.Cut.FirstOrDefault(); - public async void OnPaste() + public async void Paste() { IClipboard? clipboard = AvaloniaLocator.Current.GetService(); if (clipboard is null) return; - string? s = await clipboard.GetTextAsync(); + string s = await clipboard.GetTextAsync(); if (IPAddress.TryParse(s, out var address)) { IPAddress = address; } } + + public async void Cut() + { + IClipboard? clipboard = AvaloniaLocator.Current.GetService(); + if(clipboard is null) return; + string s = string.Join(".", _firstText?.Text, _secondText?.Text, _thirdText?.Text, _fourthText?.Text); + await clipboard.SetTextAsync(s); + Clear(); + } } public static class TextPresenterHelper