From 1361a46b7c90b73955cf4c20c9c75ab01342c3e6 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Sun, 17 Sep 2017 17:36:57 -0500 Subject: [PATCH] initial drag and drop visual (shows there is a bug to figure out) --- SpriteLibrary/SpriteEntryForm.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/SpriteLibrary/SpriteEntryForm.cs b/SpriteLibrary/SpriteEntryForm.cs index 6c49cfc..353e7ec 100644 --- a/SpriteLibrary/SpriteEntryForm.cs +++ b/SpriteLibrary/SpriteEntryForm.cs @@ -12,6 +12,7 @@ using System.IO; using System.Resources; using System.Windows.Forms; using System.Collections; +using System.Drawing.Drawing2D; namespace SpriteLibrary @@ -120,6 +121,30 @@ namespace SpriteLibrary private void UpdateChosenAreaLabel() { lblChosenArea.Text = ChosenArea.X + "," + ChosenArea.Y + "," + ChosenArea.Width + "," + ChosenArea.Height; + UpdateHighlightBox(); + } + + private void UpdateHighlightBox() + { + int transparency = 200; + Image NewFrontImage = new Bitmap(pbImageField.BackgroundImage.Width, pbImageField.BackgroundImage.Height); + Color FillColor = Color.Green; + Brush brush = new SolidBrush(Color.FromArgb(transparency, FillColor.R, FillColor.G, FillColor.B)); + Brush nobrush = new SolidBrush(Color.FromArgb(0,0,0,0)); + using (Graphics G = Graphics.FromImage(NewFrontImage)) + { + G.FillRectangle(brush, 0,0,NewFrontImage.Width,NewFrontImage.Height); + GraphicsPath path = new GraphicsPath(); + path.AddRectangle(ChosenArea); + G.SetClip(path); + G.Clear(Color.Transparent); + G.ResetClip(); + // G.FillRectangle(nobrush, ChosenArea); + + } + pbImageField.Image = NewFrontImage; + pbImageField.SizeMode = PictureBoxSizeMode.StretchImage; + pbImageField.Invalidate(); } private void SetUpEmptyInfo()