mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-27 16:44:53 +01:00
23 lines
741 B
C#
23 lines
741 B
C#
|
using System.Drawing;
|
||
|
using Microsoft.AspNetCore.Html;
|
||
|
using Microsoft.AspNetCore.Mvc;
|
||
|
using Microsoft.AspNetCore.Mvc.ViewComponents;
|
||
|
using QRCoder;
|
||
|
|
||
|
namespace BTCPayServer.Components.QRCode
|
||
|
{
|
||
|
public class QRCode : ViewComponent
|
||
|
{
|
||
|
private static QRCodeGenerator qrGenerator = new QRCodeGenerator();
|
||
|
|
||
|
|
||
|
public IViewComponentResult Invoke(string data)
|
||
|
{
|
||
|
|
||
|
QRCodeData qrCodeData = qrGenerator.CreateQrCode(data, QRCodeGenerator.ECCLevel.Q);
|
||
|
SvgQRCode qrCode = new SvgQRCode(qrCodeData);
|
||
|
return new HtmlContentViewComponentResult(new HtmlString(qrCode.GetGraphic(new Size(256,256), "#000", "#f5f5f7", true, SvgQRCode.SizingMode.ViewBoxAttribute)));
|
||
|
}
|
||
|
}
|
||
|
}
|