Optimize QrcodeView

This commit is contained in:
2dust 2025-03-01 19:56:52 +08:00
parent 96781a784b
commit 2dd10cf5a1
2 changed files with 6 additions and 2 deletions

View file

@ -17,10 +17,11 @@
x:Name="txtContent"
Grid.Row="1"
Width="300"
MaxHeight="100"
Margin="{StaticResource MarginTb8}"
VerticalAlignment="Center"
IsReadOnly="True"
MaxLines="1" />
TextWrapping="WrapWithOverflow" />
</Grid>
</UserControl>

View file

@ -1,5 +1,6 @@
using Avalonia.Controls;
using Avalonia.Media.Imaging;
using Avalonia.Threading;
namespace v2rayN.Desktop.Views
{
@ -17,7 +18,7 @@ namespace v2rayN.Desktop.Views
txtContent.Text = url;
imgQrcode.Source = GetQRCode(url);
// btnCancel.Click += (s, e) => this.Close();
txtContent.GotFocus += (_, _) => Dispatcher.UIThread.Post(() => { txtContent.SelectAll(); });
}
private Bitmap? GetQRCode(string? url)
@ -29,7 +30,9 @@ namespace v2rayN.Desktop.Views
private Bitmap? ByteToBitmap(byte[]? bytes)
{
if (bytes is null)
{
return null;
}
using var ms = new MemoryStream(bytes);
return new Bitmap(ms);