From 6b9f0d6bd993eed988a643918103099d8d021327 Mon Sep 17 00:00:00 2001 From: Ian C Date: Sat, 28 Apr 2012 23:13:45 +0000 Subject: Added box drawing and zoom. --- Native/EmuKeyboardDesigner/ImageControl.cs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'Native/EmuKeyboardDesigner/ImageControl.cs') diff --git a/Native/EmuKeyboardDesigner/ImageControl.cs b/Native/EmuKeyboardDesigner/ImageControl.cs index 06e4c74..02b37cd 100644 --- a/Native/EmuKeyboardDesigner/ImageControl.cs +++ b/Native/EmuKeyboardDesigner/ImageControl.cs @@ -44,6 +44,7 @@ namespace EmuKeyboardDesigner set { xUpDown.Value = value; + UpdateKeyOverlay(); } } @@ -56,6 +57,7 @@ namespace EmuKeyboardDesigner set { yUpDown.Value = value; + UpdateKeyOverlay(); } } @@ -68,6 +70,7 @@ namespace EmuKeyboardDesigner set { widthUpDown.Value = value; + UpdateKeyOverlay(); } } @@ -80,6 +83,7 @@ namespace EmuKeyboardDesigner set { heightUpDown.Value = value; + UpdateKeyOverlay(); } } @@ -87,6 +91,25 @@ namespace EmuKeyboardDesigner { if (image != null) { + Bitmap bmp = new Bitmap(image, image.Width * zoom.Value, image.Height * zoom.Value); + + using (Graphics g = Graphics.FromImage(bmp)) + { + using (Pen p = new Pen(Color.White, zoom.Value)) + { + g.DrawRectangle(p, (int)xUpDown.Value * zoom.Value, + (int)yUpDown.Value * zoom.Value, + (int)widthUpDown.Value * zoom.Value, + (int)heightUpDown.Value * zoom.Value); + } + } + + if (imageBox.Image != null) + { + imageBox.Image.Dispose(); + } + + imageBox.Image = bmp; } } @@ -124,7 +147,7 @@ namespace EmuKeyboardDesigner try { image = (Bitmap)Image.FromFile(fsel.FileName); - imageBox.Image = image; + UpdateKeyOverlay(); } catch (Exception ex) { @@ -134,5 +157,10 @@ namespace EmuKeyboardDesigner UpdateKeyOverlay(); } + + private void OnZoomChanged(object sender, EventArgs e) + { + UpdateKeyOverlay(); + } } } -- cgit v1.2.3