Creating a new desktop app with avaloniaui
This commit is contained in:
26
v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml.cs
Normal file
26
v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Media.Imaging;
|
||||
|
||||
namespace v2rayN.Desktop.Views
|
||||
{
|
||||
public partial class QrcodeView : Window
|
||||
{
|
||||
public QrcodeView(string? url)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
txtContent.Text = url;
|
||||
imgQrcode.Source = GetQRCode(url);
|
||||
|
||||
btnCancel.Click += (s, e) => this.Close();
|
||||
}
|
||||
|
||||
private Bitmap? GetQRCode(string? url)
|
||||
{
|
||||
var qrCodeImage = QRCodeHelper.GenQRCode(url);
|
||||
if (qrCodeImage is null) return null;
|
||||
var ms = new MemoryStream(qrCodeImage);
|
||||
return new Bitmap(ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user