feat: upgrade to rc1.1

This commit is contained in:
rabbitism
2023-06-21 20:30:16 +08:00
parent e0c59799ad
commit 2e40bcf0f6
4 changed files with 16 additions and 16 deletions

View File

@@ -19,12 +19,12 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0-preview7" /> <PackageReference Include="Avalonia" Version="11.0.0-rc1.1" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview7" /> <PackageReference Include="Avalonia.Desktop" Version="11.0.0-rc1.1" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.--> <!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview7" /> <PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-rc1.1" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" /> <PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />
<PackageReference Include="Semi.Avalonia" Version="0.1.0-preview7" /> <PackageReference Include="Semi.Avalonia" Version="11.0.0-rc1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -8,7 +8,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0-preview7" /> <PackageReference Include="Avalonia" Version="11.0.0-rc1.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -120,7 +120,7 @@ public class IPv4Box: TemplatedControl
protected override void OnKeyDown(KeyEventArgs e) protected override void OnKeyDown(KeyEventArgs e)
{ {
if (_currentActivePresenter is null) return; if (_currentActivePresenter is null) return;
var keymap = AvaloniaLocator.Current.GetRequiredService<PlatformHotkeyConfiguration>(); var keymap = TopLevel.GetTopLevel(this)?.PlatformSettings?.HotkeyConfiguration;
bool Match(List<KeyGesture> gestures) => gestures.Any(g => g.Matches(e)); bool Match(List<KeyGesture> gestures) => gestures.Any(g => g.Matches(e));
if (e.Key == Key.Enter) if (e.Key == Key.Enter)
{ {
@@ -129,17 +129,17 @@ public class IPv4Box: TemplatedControl
base.OnKeyDown(e); base.OnKeyDown(e);
return; return;
} }
if (Match(keymap.SelectAll)) if (keymap is not null && Match(keymap.SelectAll))
{ {
_currentActivePresenter.SelectionStart = 0; _currentActivePresenter.SelectionStart = 0;
_currentActivePresenter.SelectionEnd = _currentActivePresenter.Text?.Length ?? 0; _currentActivePresenter.SelectionEnd = _currentActivePresenter.Text?.Length ?? 0;
return; return;
} }
else if (Match(keymap.Copy)) else if (keymap is not null && Match(keymap.Copy))
{ {
Copy(); Copy();
} }
else if (Match(keymap.Paste)) else if (keymap is not null && Match(keymap.Paste))
{ {
Paste(); Paste();
} }
@@ -494,17 +494,17 @@ public class IPv4Box: TemplatedControl
public async void Copy() public async void Copy()
{ {
string s = string.Join(".", _firstText?.Text, _secondText?.Text, _thirdText?.Text, _fourthText?.Text); string s = string.Join(".", _firstText?.Text, _secondText?.Text, _thirdText?.Text, _fourthText?.Text);
IClipboard? clipboard = AvaloniaLocator.Current.GetService<IClipboard>(); IClipboard? clipboard = TopLevel.GetTopLevel(this)?.Clipboard;
clipboard?.SetTextAsync(s); clipboard?.SetTextAsync(s);
} }
public static KeyGesture? CopyKeyGesture { get; } = AvaloniaLocator.Current.GetService<PlatformHotkeyConfiguration>()?.Copy.FirstOrDefault(); public static KeyGesture? CopyKeyGesture { get; } = Application.Current?.PlatformSettings?.HotkeyConfiguration.Copy.FirstOrDefault();
public static KeyGesture? PasteKeyGesture { get; } = AvaloniaLocator.Current.GetService<PlatformHotkeyConfiguration>()?.Paste.FirstOrDefault(); public static KeyGesture? PasteKeyGesture { get; } = Application.Current?.PlatformSettings?.HotkeyConfiguration.Paste.FirstOrDefault();
public static KeyGesture? CutKeyGesture { get; } = AvaloniaLocator.Current.GetService<PlatformHotkeyConfiguration>()?.Cut.FirstOrDefault(); public static KeyGesture? CutKeyGesture { get; } = Application.Current?.PlatformSettings?.HotkeyConfiguration.Cut.FirstOrDefault();
public async void Paste() public async void Paste()
{ {
IClipboard? clipboard = AvaloniaLocator.Current.GetService<IClipboard>(); IClipboard? clipboard = TopLevel.GetTopLevel(this)?.Clipboard;
if (clipboard is null) return; if (clipboard is null) return;
string s = await clipboard.GetTextAsync(); string s = await clipboard.GetTextAsync();
if (IPAddress.TryParse(s, out var address)) if (IPAddress.TryParse(s, out var address))
@@ -515,7 +515,7 @@ public class IPv4Box: TemplatedControl
public async void Cut() public async void Cut()
{ {
IClipboard? clipboard = AvaloniaLocator.Current.GetService<IClipboard>(); IClipboard? clipboard = TopLevel.GetTopLevel(this)?.Clipboard;
if(clipboard is null) return; if(clipboard is null) return;
string s = string.Join(".", _firstText?.Text, _secondText?.Text, _thirdText?.Text, _fourthText?.Text); string s = string.Join(".", _firstText?.Text, _secondText?.Text, _thirdText?.Text, _fourthText?.Text);
await clipboard.SetTextAsync(s); await clipboard.SetTextAsync(s);

View File

@@ -8,7 +8,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0-preview7" /> <PackageReference Include="Avalonia" Version="11.0.0-rc1.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>