mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-20 02:28:31 +01:00
5ca4e71c34
* 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>
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)));
|
|
}
|
|
}
|
|
}
|