btcpayserver/BTCPayServer/Components/QRCode/QRCode.cs
Andrew Camilleri 5ca4e71c34
Introduce QR Code View component (#2125)
* Introduce QR Code View component

* more cleanup

* fix js clipboard

* Fix clipboard confirmation width calculation

* fix tests

Co-authored-by: Dennis Reimann <mail@dennisreimann.de>
2020-12-22 11:18:51 +09:00

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)));
}
}
}