PKHeX/Misc/QR.cs

44 lines
2 KiB
C#
Raw Normal View History

using System;
using System.Drawing;
using System.Windows.Forms;
namespace PKHeX
{
public partial class QR : Form
{
2015-02-26 07:12:38 +00:00
public QR(Image qr, Image pkm, string top, string bottom, string left, string right)
{
InitializeComponent();
Font font = Main.unicode ? FontLabel.Font : PKX.getPKXFont((float)8.25);
2015-02-26 07:12:38 +00:00
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);
}
2015-03-14 02:59:51 +00:00
// Layer on Preview Image
Image pic = Util.LayerImage(qr, preview, qr.Width / 2 - preview.Width / 2, qr.Height / 2 - preview.Height / 2, 1);
2015-02-27 01:22:53 +00:00
// Layer on Text
2015-03-14 02:59:51 +00:00
const 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);
2015-03-14 02:59:51 +00:00
g.DrawString(top, font, Brushes.Black, new PointF(18, qr.Height - 5));
g.DrawString(bottom, font, Brushes.Black, new PointF(18, qr.Height + 8));
g.DrawString(left.Replace(Environment.NewLine, "/").Replace("//", " ").Replace(":/", ": "), font, Brushes.Black, new PointF(18, qr.Height + 20));
g.DrawString(right, font, Brushes.Black, new PointF(18, qr.Height + 32));
2015-03-14 02:59:51 +00:00
PB_QR.BackgroundImage = newpic;
}
2015-02-25 04:42:05 +00:00
private void PB_QR_Click(object sender, EventArgs e)
{
if (DialogResult.Yes != Util.Prompt(MessageBoxButtons.YesNo, "Copy QR Image to Clipboard?")) return;
try { Clipboard.SetImage(PB_QR.BackgroundImage); }
catch { Util.Alert("Failed to set Image to Clipboard"); }
}
}
}