mirror of
https://github.com/2dust/v2rayN.git
synced 2025-04-19 21:52:25 +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"
|
x:Name="txtContent"
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
Width="300"
|
Width="300"
|
||||||
|
MaxHeight="100"
|
||||||
Margin="{StaticResource MarginTb8}"
|
Margin="{StaticResource MarginTb8}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
MaxLines="1" />
|
TextWrapping="WrapWithOverflow" />
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Media.Imaging;
|
using Avalonia.Media.Imaging;
|
||||||
|
using Avalonia.Threading;
|
||||||
|
|
||||||
namespace v2rayN.Desktop.Views
|
namespace v2rayN.Desktop.Views
|
||||||
{
|
{
|
||||||
|
@ -17,7 +18,7 @@ namespace v2rayN.Desktop.Views
|
||||||
txtContent.Text = url;
|
txtContent.Text = url;
|
||||||
imgQrcode.Source = GetQRCode(url);
|
imgQrcode.Source = GetQRCode(url);
|
||||||
|
|
||||||
// btnCancel.Click += (s, e) => this.Close();
|
txtContent.GotFocus += (_, _) => Dispatcher.UIThread.Post(() => { txtContent.SelectAll(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
private Bitmap? GetQRCode(string? url)
|
private Bitmap? GetQRCode(string? url)
|
||||||
|
@ -29,7 +30,9 @@ namespace v2rayN.Desktop.Views
|
||||||
private Bitmap? ByteToBitmap(byte[]? bytes)
|
private Bitmap? ByteToBitmap(byte[]? bytes)
|
||||||
{
|
{
|
||||||
if (bytes is null)
|
if (bytes is null)
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
using var ms = new MemoryStream(bytes);
|
using var ms = new MemoryStream(bytes);
|
||||||
return new Bitmap(ms);
|
return new Bitmap(ms);
|
||||||
|
|
Loading…
Reference in a new issue