diff --git a/demo/Ursa.Demo/Ursa.Demo.csproj b/demo/Ursa.Demo/Ursa.Demo.csproj
index 08bc7d1..328116c 100644
--- a/demo/Ursa.Demo/Ursa.Demo.csproj
+++ b/demo/Ursa.Demo/Ursa.Demo.csproj
@@ -19,12 +19,12 @@
-
-
+
+
-
+
-
+
diff --git a/src/Ursa.Themes.Semi/Ursa.Themes.Semi.csproj b/src/Ursa.Themes.Semi/Ursa.Themes.Semi.csproj
index ff84eee..414c03f 100644
--- a/src/Ursa.Themes.Semi/Ursa.Themes.Semi.csproj
+++ b/src/Ursa.Themes.Semi/Ursa.Themes.Semi.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/src/Ursa/Controls/IPv4Box.cs b/src/Ursa/Controls/IPv4Box.cs
index b7c6d43..228771f 100644
--- a/src/Ursa/Controls/IPv4Box.cs
+++ b/src/Ursa/Controls/IPv4Box.cs
@@ -120,7 +120,7 @@ public class IPv4Box: TemplatedControl
protected override void OnKeyDown(KeyEventArgs e)
{
if (_currentActivePresenter is null) return;
- var keymap = AvaloniaLocator.Current.GetRequiredService();
+ var keymap = TopLevel.GetTopLevel(this)?.PlatformSettings?.HotkeyConfiguration;
bool Match(List gestures) => gestures.Any(g => g.Matches(e));
if (e.Key == Key.Enter)
{
@@ -129,17 +129,17 @@ public class IPv4Box: TemplatedControl
base.OnKeyDown(e);
return;
}
- if (Match(keymap.SelectAll))
+ if (keymap is not null && Match(keymap.SelectAll))
{
_currentActivePresenter.SelectionStart = 0;
_currentActivePresenter.SelectionEnd = _currentActivePresenter.Text?.Length ?? 0;
return;
}
- else if (Match(keymap.Copy))
+ else if (keymap is not null && Match(keymap.Copy))
{
Copy();
}
- else if (Match(keymap.Paste))
+ else if (keymap is not null && Match(keymap.Paste))
{
Paste();
}
@@ -494,17 +494,17 @@ public class IPv4Box: TemplatedControl
public async void Copy()
{
string s = string.Join(".", _firstText?.Text, _secondText?.Text, _thirdText?.Text, _fourthText?.Text);
- IClipboard? clipboard = AvaloniaLocator.Current.GetService();
+ IClipboard? clipboard = TopLevel.GetTopLevel(this)?.Clipboard;
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 static KeyGesture? CopyKeyGesture { get; } = Application.Current?.PlatformSettings?.HotkeyConfiguration.Copy.FirstOrDefault();
+ public static KeyGesture? PasteKeyGesture { get; } = Application.Current?.PlatformSettings?.HotkeyConfiguration.Paste.FirstOrDefault();
+ public static KeyGesture? CutKeyGesture { get; } = Application.Current?.PlatformSettings?.HotkeyConfiguration.Cut.FirstOrDefault();
public async void Paste()
{
- IClipboard? clipboard = AvaloniaLocator.Current.GetService();
+ IClipboard? clipboard = TopLevel.GetTopLevel(this)?.Clipboard;
if (clipboard is null) return;
string s = await clipboard.GetTextAsync();
if (IPAddress.TryParse(s, out var address))
@@ -515,7 +515,7 @@ public class IPv4Box: TemplatedControl
public async void Cut()
{
- IClipboard? clipboard = AvaloniaLocator.Current.GetService();
+ IClipboard? clipboard = TopLevel.GetTopLevel(this)?.Clipboard;
if(clipboard is null) return;
string s = string.Join(".", _firstText?.Text, _secondText?.Text, _thirdText?.Text, _fourthText?.Text);
await clipboard.SetTextAsync(s);
diff --git a/src/Ursa/Ursa.csproj b/src/Ursa/Ursa.csproj
index b09fce8..e99c156 100644
--- a/src/Ursa/Ursa.csproj
+++ b/src/Ursa/Ursa.csproj
@@ -8,7 +8,7 @@
-
+