mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-10 14:35:00 +03:00
csharp_style_namespace_declarations = file_scoped
This commit is contained in:
@@ -2,40 +2,39 @@ using Avalonia.Controls;
|
||||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Threading;
|
||||
|
||||
namespace v2rayN.Desktop.Views
|
||||
namespace v2rayN.Desktop.Views;
|
||||
|
||||
public partial class QrcodeView : UserControl
|
||||
{
|
||||
public partial class QrcodeView : UserControl
|
||||
public QrcodeView()
|
||||
{
|
||||
public QrcodeView()
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public QrcodeView(string? url)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
txtContent.Text = url;
|
||||
imgQrcode.Source = GetQRCode(url);
|
||||
|
||||
txtContent.GotFocus += (_, _) => Dispatcher.UIThread.Post(() => { txtContent.SelectAll(); });
|
||||
}
|
||||
|
||||
private Bitmap? GetQRCode(string? url)
|
||||
{
|
||||
var bytes = QRCodeHelper.GenQRCode(url);
|
||||
return ByteToBitmap(bytes);
|
||||
}
|
||||
|
||||
private Bitmap? ByteToBitmap(byte[]? bytes)
|
||||
{
|
||||
if (bytes is null)
|
||||
{
|
||||
InitializeComponent();
|
||||
return null;
|
||||
}
|
||||
|
||||
public QrcodeView(string? url)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
txtContent.Text = url;
|
||||
imgQrcode.Source = GetQRCode(url);
|
||||
|
||||
txtContent.GotFocus += (_, _) => Dispatcher.UIThread.Post(() => { txtContent.SelectAll(); });
|
||||
}
|
||||
|
||||
private Bitmap? GetQRCode(string? url)
|
||||
{
|
||||
var bytes = QRCodeHelper.GenQRCode(url);
|
||||
return ByteToBitmap(bytes);
|
||||
}
|
||||
|
||||
private Bitmap? ByteToBitmap(byte[]? bytes)
|
||||
{
|
||||
if (bytes is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var ms = new MemoryStream(bytes);
|
||||
return new Bitmap(ms);
|
||||
}
|
||||
using var ms = new MemoryStream(bytes);
|
||||
return new Bitmap(ms);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user