PKHeX/PKHeX.Drawing.Misc/QR/QREncode.cs
Kurt fc754b346b
File scoped namespaces (#3529)
[Language Reference](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/file-scoped-namespaces)

Updates all the files, one less level of indentation.

Some small changes were made to API surfaces, renaming `PKM pkm` -> `PKM pk`, and `LegalityAnalysis.pkm` -> `LegalityAnalysis.Entity`
2022-06-18 11:04:24 -07:00

26 lines
885 B
C#

using System.Drawing;
using PKHeX.Core;
using QRCoder;
namespace PKHeX.Drawing.Misc;
public static class QREncode
{
public static Image GenerateQRCode(DataMysteryGift mg) => GenerateQRCode(QRMessageUtil.GetMessage(mg));
public static Image GenerateQRCode(PKM pk) => GenerateQRCode(QRMessageUtil.GetMessage(pk));
public static Image GenerateQRCode7(PK7 pk7, int box = 0, int slot = 0, int copies = 1)
{
byte[] data = QR7.GenerateQRData(pk7, box, slot, copies);
var msg = QRMessageUtil.GetMessage(data);
return GenerateQRCode(msg, ppm: 4);
}
private static Image GenerateQRCode(string msg, int ppm = 4)
{
using var generator = new QRCodeGenerator();
using var data = generator.CreateQrCode(msg, QRCodeGenerator.ECCLevel.Q);
using var code = new QRCode(data);
return code.GetGraphic(ppm);
}
}