mirror of
https://github.com/2dust/v2rayN.git
synced 2025-07-01 20:42:10 +00:00
30 lines
753 B
C#
30 lines
753 B
C#
using QRCoder;
|
|
using QRCoder.Xaml;
|
|
using System.Windows.Media;
|
|
|
|
namespace v2rayN.Handler
|
|
{
|
|
/// <summary>
|
|
/// 含有QR码的描述类和包装编码和渲染
|
|
/// </summary>
|
|
public class QRCodeHelper
|
|
{
|
|
public static DrawingImage? GetQRCode(string strContent)
|
|
{
|
|
try
|
|
{
|
|
QRCodeGenerator qrGenerator = new();
|
|
QRCodeData qrCodeData = qrGenerator.CreateQrCode(strContent, QRCodeGenerator.ECCLevel.H);
|
|
XamlQRCode qrCode = new(qrCodeData);
|
|
DrawingImage qrCodeAsXaml = qrCode.GetGraphic(40);
|
|
return qrCodeAsXaml;
|
|
}
|
|
catch
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|