mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-02 15:18:58 -05:00
Switched up QR Generation, change Number Padding
should be a little bit more reliable; old method via Control
This commit is contained in:
46
Misc/QR.cs
46
Misc/QR.cs
@@ -10,7 +10,7 @@ namespace PKHeX
|
||||
{
|
||||
public partial class QR : Form
|
||||
{
|
||||
public QR(byte[] data, Image preview, string top, string bottom, string left, string right)
|
||||
public QR(byte[] data, Image pkm, string top, string bottom, string left, string right)
|
||||
{
|
||||
InitializeComponent();
|
||||
string server = "http://loadcode.projectpokemon.org/b1s1.html#"; // Rehosted with permission from LC/MS -- massive thanks!
|
||||
@@ -19,14 +19,42 @@ public QR(byte[] data, Image preview, string top, string bottom, string left, st
|
||||
QRCodeGenerator qrGenerator = new QRCodeGenerator();
|
||||
QRCodeGenerator.QRCode qrCode = qrGenerator.CreateQrCode(server + qrdata, QRCodeGenerator.ECCLevel.L);
|
||||
Image qr = qrCode.GetGraphic(5);
|
||||
Image pic = Util.LayerImage(qr, preview, 2, 2, 1);
|
||||
Graphics g = Graphics.FromImage(pic);
|
||||
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
|
||||
g.DrawString(top, FontLabel.Font, Brushes.Black, new PointF(40, 4));
|
||||
g.DrawString(bottom, FontLabel.Font, Brushes.Black, new PointF(4, 350));
|
||||
g.DrawString(left, FontLabel.Font, Brushes.Black, new PointF(0, 60));
|
||||
g.DrawString(right, FontLabel.Font, Brushes.Black, new PointF(350, 60));
|
||||
PB_QR.BackgroundImage = pic;
|
||||
Font font = FontLabel.Font; // PKX.getPKXFont(8);
|
||||
Image preview = new Bitmap(45, 45);
|
||||
using (Graphics gfx = Graphics.FromImage(preview))
|
||||
{
|
||||
gfx.FillRectangle(new SolidBrush(Color.White), 0, 0, preview.Width, preview.Height);
|
||||
gfx.DrawImage(pkm, preview.Width / 2 - pkm.Width / 2, preview.Height / 2 - pkm.Height / 2);
|
||||
}
|
||||
Image pic = Util.LayerImage(qr, preview, qr.Width / 2 - preview.Width / 2, qr.Height / 2 - preview.Height / 2, 1); // Middle
|
||||
// Image pic = Util.LayerImage(qr, preview, 2, 2, 1); // Top Left
|
||||
// g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
|
||||
if (ModifierKeys == Keys.Control)
|
||||
{
|
||||
Graphics g = Graphics.FromImage(pic);
|
||||
g.DrawString(top, font, Brushes.Black, new PointF(20, 5));
|
||||
g.DrawString(bottom, font, Brushes.Black, new PointF(20, pic.Width - 15));
|
||||
g.DrawString(left, font, Brushes.Black, new PointF(0, 20));
|
||||
g.DrawString(right, font, Brushes.Black, new PointF(pic.Width - 15, 20), new System.Drawing.StringFormat(StringFormatFlags.DirectionVertical));
|
||||
|
||||
PB_QR.BackgroundImage = pic;
|
||||
}
|
||||
else
|
||||
{
|
||||
int stretch = 50;
|
||||
Height += stretch;
|
||||
Image newpic = new Bitmap(PB_QR.Width, PB_QR.Height);
|
||||
Graphics g = Graphics.FromImage(newpic);
|
||||
g.FillRectangle(new SolidBrush(Color.White), 0, 0, newpic.Width, newpic.Height);
|
||||
g.DrawImage(pic, 0, 0);
|
||||
|
||||
g.DrawString(top, font, Brushes.Black, new PointF(20, qr.Height - 5));
|
||||
g.DrawString(bottom, font, Brushes.Black, new PointF(20, qr.Height + 8));
|
||||
g.DrawString(left.Replace(Environment.NewLine.ToString(), "/").Replace("//", " ").Replace(":/", ": "), font, Brushes.Black, new PointF(20, qr.Height + 20));
|
||||
g.DrawString(right, font, Brushes.Black, new PointF(20, qr.Height + 32));
|
||||
|
||||
PB_QR.BackgroundImage = newpic;
|
||||
}
|
||||
}
|
||||
private void PB_QR_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
@@ -1581,7 +1581,7 @@ private void clickQR(object sender, EventArgs e)
|
||||
Environment.NewLine + data.SPA_EV.ToString("00"),
|
||||
Environment.NewLine + data.SPD_EV.ToString("00"),
|
||||
Environment.NewLine + data.SPE_EV.ToString("00"));
|
||||
new QR(ekx, dragout.Image, s1, s2, IVs, "").ShowDialog();
|
||||
new QR(ekx, dragout.Image, s1, s2, IVs, "ProjectPokemon.org & PKHeX").ShowDialog();
|
||||
}
|
||||
private void clickFriendship(object sender, EventArgs e)
|
||||
{
|
||||
@@ -2256,8 +2256,9 @@ private void update_ID(object sender, EventArgs e)
|
||||
TB_PID.Text = Util.getHEXval(TB_PID).ToString("X8");
|
||||
TB_EC.Text = Util.getHEXval(TB_EC).ToString("X8");
|
||||
|
||||
TB_TID.Text = Math.Min(Util.ToUInt32(TB_TID.Text), 65535).ToString(); // max TID/SID is 65535
|
||||
TB_SID.Text = Math.Min(Util.ToUInt32(TB_SID.Text), 65535).ToString();
|
||||
// Max TID/SID is 65535
|
||||
if (Util.ToUInt32(TB_TID.Text) > 65535) TB_TID.Text = "65535";
|
||||
if (Util.ToUInt32(TB_SID.Text) > 65535) TB_SID.Text = "65535";
|
||||
|
||||
setIsShiny();
|
||||
updateIVs(null, null); // If the PID is changed, PID%6 (Characteristic) might be changed.
|
||||
|
||||
Reference in New Issue
Block a user