You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.8 KiB
C#

9 months ago
using POSV.Utils;
using QRCoder;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace POSV
{
public partial class AuthQRForm : BusinessForm
{
public AuthQRForm()
{
InitializeComponent();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
InstallQR();
}
private void InstallQR()
{
Dictionary<string, string> dic = new Dictionary<string, string>();
dic["tenantId"] = Global.Instance.Authc.TenantId;
dic["storeNo"] = Global.Instance.Authc.StoreNo;
dic["posNo"] = Global.Instance.Authc.PosNo;
dic["workerNo"] = Global.Instance.Worker.No;
var des = DesUtils.EncryptString(JsonUtils.Serialize(dic));
Bitmap bitmap = null;
QRCodeGenerator.ECCLevel eccLevel = QRCodeGenerator.ECCLevel.Q;
using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
{
using (QRCodeData qrCodeData = qrGenerator.CreateQrCode(des, eccLevel))
{
using (QRCode qrCode = new QRCode(qrCodeData))
{
bitmap = qrCode.GetGraphic(10, Color.Black, Color.White, false);
}
}
}
if(bitmap != null)
{
qrPanel.BackgroundImageLayout = ImageLayout.Zoom;
qrPanel.Style.BackgroundImage = bitmap;
qrPanel.Invalidate();
}
else
{
ShowToastNotify(this, "二维码生成失败!");
}
}
}
}