2015-02-25 04:10:47 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
2017-01-08 07:54:09 +00:00
|
|
|
|
using PKHeX.Core;
|
2019-09-29 16:47:06 +00:00
|
|
|
|
using PKHeX.Drawing;
|
2015-02-25 04:10:47 +00:00
|
|
|
|
|
2018-04-07 04:23:09 +00:00
|
|
|
|
using static PKHeX.Core.MessageStrings;
|
|
|
|
|
|
2017-01-08 07:54:09 +00:00
|
|
|
|
namespace PKHeX.WinForms
|
2015-02-25 04:10:47 +00:00
|
|
|
|
{
|
|
|
|
|
public partial class QR : Form
|
|
|
|
|
{
|
2016-11-29 07:02:25 +00:00
|
|
|
|
private readonly PKM pkm;
|
|
|
|
|
private readonly Image icon;
|
|
|
|
|
private Image qr;
|
2016-11-17 03:47:41 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private readonly string[] Lines;
|
2016-11-29 07:02:25 +00:00
|
|
|
|
private string extraText;
|
2016-11-17 03:47:41 +00:00
|
|
|
|
|
2019-09-29 16:47:06 +00:00
|
|
|
|
public QR(Image qr, Image icon, params string[] lines)
|
2015-02-26 07:12:38 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2019-09-29 16:47:06 +00:00
|
|
|
|
this.qr = qr;
|
|
|
|
|
this.icon = icon;
|
|
|
|
|
Lines = lines;
|
2016-11-17 03:47:41 +00:00
|
|
|
|
|
|
|
|
|
const int stretch = 50;
|
|
|
|
|
Height += stretch;
|
2019-09-29 16:47:06 +00:00
|
|
|
|
RefreshImage();
|
|
|
|
|
}
|
2016-11-17 03:47:41 +00:00
|
|
|
|
|
2019-09-29 16:47:06 +00:00
|
|
|
|
public QR(Image qr, Image icon, PKM pk, params string[] lines)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2016-11-17 03:47:41 +00:00
|
|
|
|
this.qr = qr;
|
|
|
|
|
this.icon = icon;
|
2017-06-18 01:37:19 +00:00
|
|
|
|
Lines = lines;
|
2016-11-17 03:47:41 +00:00
|
|
|
|
|
2019-09-29 16:47:06 +00:00
|
|
|
|
const int stretch = 50;
|
|
|
|
|
Height += stretch;
|
2016-11-17 03:47:41 +00:00
|
|
|
|
|
2019-09-29 16:47:06 +00:00
|
|
|
|
pkm = pk;
|
|
|
|
|
// Layer on Text
|
|
|
|
|
if (pkm.Format == 7 && pkm is PK7 pk7)
|
2016-03-12 02:40:08 +00:00
|
|
|
|
{
|
2019-09-29 16:47:06 +00:00
|
|
|
|
Height += 40;
|
|
|
|
|
ReloadQRData(pk7);
|
2016-03-12 02:40:08 +00:00
|
|
|
|
}
|
2019-09-29 16:47:06 +00:00
|
|
|
|
RefreshImage();
|
2015-02-25 04:42:05 +00:00
|
|
|
|
}
|
2018-05-12 15:13:39 +00:00
|
|
|
|
|
2019-09-29 16:47:06 +00:00
|
|
|
|
private void ReloadQRData(PK7 pk7)
|
2016-06-20 04:22:43 +00:00
|
|
|
|
{
|
2019-09-29 16:47:06 +00:00
|
|
|
|
var box = (int)NUD_Box.Value - 1;
|
|
|
|
|
var slot = (int)NUD_Slot.Value - 1;
|
|
|
|
|
var copies = (int)NUD_Copies.Value;
|
|
|
|
|
extraText = $" (Box {box + 1}, Slot {slot + 1}, {copies} cop{(copies > 1 ? "ies" : "y")})";
|
|
|
|
|
qr = QREncode.GenerateQRCode7(pk7, box, slot, copies);
|
2017-08-13 07:21:42 +00:00
|
|
|
|
}
|
2018-07-22 02:20:11 +00:00
|
|
|
|
|
2019-09-29 16:47:06 +00:00
|
|
|
|
private void RefreshImage()
|
2017-08-13 07:21:42 +00:00
|
|
|
|
{
|
2019-09-29 16:47:06 +00:00
|
|
|
|
SuspendLayout();
|
|
|
|
|
ResumeLayout();
|
2019-10-27 06:14:00 +00:00
|
|
|
|
Font font = !Main.Unicode ? Font : FontUtil.GetPKXFont(8.25f);
|
2019-09-29 16:47:06 +00:00
|
|
|
|
PB_QR.BackgroundImage = QRImageUtil.GetQRImageExtended(font, qr, icon, PB_QR.Width, PB_QR.Height, Lines, extraText);
|
2016-06-20 04:22:43 +00:00
|
|
|
|
}
|
2017-08-13 07:21:42 +00:00
|
|
|
|
|
2019-09-29 16:47:06 +00:00
|
|
|
|
private void PB_QR_Click(object sender, EventArgs e)
|
2016-06-20 04:22:43 +00:00
|
|
|
|
{
|
2019-10-05 03:10:50 +00:00
|
|
|
|
if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgQRClipboardImage))
|
2019-09-29 16:47:06 +00:00
|
|
|
|
return;
|
|
|
|
|
try { Clipboard.SetImage(PB_QR.BackgroundImage); }
|
|
|
|
|
catch { WinFormsUtil.Alert(MsgQRClipboardFail); }
|
2016-06-20 04:22:43 +00:00
|
|
|
|
}
|
2016-11-17 03:47:41 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void UpdateBoxSlotCopies(object sender, EventArgs e)
|
2016-11-17 03:47:41 +00:00
|
|
|
|
{
|
2019-09-29 16:47:06 +00:00
|
|
|
|
if (!(pkm is PK7 pk7))
|
2016-11-17 03:47:41 +00:00
|
|
|
|
throw new ArgumentException("Can't update QR7 if pkm isn't a PK7!");
|
2019-09-29 16:47:06 +00:00
|
|
|
|
ReloadQRData(pk7);
|
2016-11-17 03:47:41 +00:00
|
|
|
|
RefreshImage();
|
2017-01-12 01:55:42 +00:00
|
|
|
|
}
|
2015-02-25 04:10:47 +00:00
|
|
|
|
}
|
2017-05-15 20:07:07 +00:00
|
|
|
|
}
|