From 2dd10cf5a19646494e970dc38064dee94c2ebf0e Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sat, 1 Mar 2025 19:56:52 +0800 Subject: [PATCH] Optimize QrcodeView --- v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml | 3 ++- v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml.cs | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml b/v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml index 984b0e4b..90d94685 100644 --- a/v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml +++ b/v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml @@ -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" /> diff --git a/v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml.cs index 64cdced5..8eec2726 100644 --- a/v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml.cs @@ -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);