mirror of
https://github.com/2dust/v2rayN.git
synced 2025-04-19 13:42:24 +00:00
Optimize QrcodeView
This commit is contained in:
parent
96781a784b
commit
2dd10cf5a1
2 changed files with 6 additions and 2 deletions
|
@ -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>
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue