more changes. Better viewing of preview
This commit is contained in:
parent
42b98b65db
commit
7ed9e548a8
21
SpriteLibrary/SpriteEntryForm.Designer.cs
generated
21
SpriteLibrary/SpriteEntryForm.Designer.cs
generated
@ -49,6 +49,7 @@
|
|||||||
this.lblCountSprites = new System.Windows.Forms.Label();
|
this.lblCountSprites = new System.Windows.Forms.Label();
|
||||||
this.TCTabPages = new System.Windows.Forms.TabControl();
|
this.TCTabPages = new System.Windows.Forms.TabControl();
|
||||||
this.tpFromImage = new System.Windows.Forms.TabPage();
|
this.tpFromImage = new System.Windows.Forms.TabPage();
|
||||||
|
this.lblAnimationNumber = new System.Windows.Forms.Label();
|
||||||
this.lblAnimationFwdBack = new System.Windows.Forms.Label();
|
this.lblAnimationFwdBack = new System.Windows.Forms.Label();
|
||||||
this.btnAnimBack = new System.Windows.Forms.Button();
|
this.btnAnimBack = new System.Windows.Forms.Button();
|
||||||
this.btnAnimFwd = new System.Windows.Forms.Button();
|
this.btnAnimFwd = new System.Windows.Forms.Button();
|
||||||
@ -69,7 +70,6 @@
|
|||||||
this.btnReset = new System.Windows.Forms.Button();
|
this.btnReset = new System.Windows.Forms.Button();
|
||||||
this.btnPreviewAnimFwd = new System.Windows.Forms.Button();
|
this.btnPreviewAnimFwd = new System.Windows.Forms.Button();
|
||||||
this.btnPreviewAnimBack = new System.Windows.Forms.Button();
|
this.btnPreviewAnimBack = new System.Windows.Forms.Button();
|
||||||
this.lblAnimationNumber = new System.Windows.Forms.Label();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pbImageField)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pbImageField)).BeginInit();
|
||||||
this.TCTabPages.SuspendLayout();
|
this.TCTabPages.SuspendLayout();
|
||||||
this.tpFromImage.SuspendLayout();
|
this.tpFromImage.SuspendLayout();
|
||||||
@ -283,6 +283,15 @@
|
|||||||
this.tpFromImage.Text = "From Image";
|
this.tpFromImage.Text = "From Image";
|
||||||
this.tpFromImage.UseVisualStyleBackColor = true;
|
this.tpFromImage.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
|
// lblAnimationNumber
|
||||||
|
//
|
||||||
|
this.lblAnimationNumber.AutoSize = true;
|
||||||
|
this.lblAnimationNumber.Location = new System.Drawing.Point(190, 91);
|
||||||
|
this.lblAnimationNumber.Name = "lblAnimationNumber";
|
||||||
|
this.lblAnimationNumber.Size = new System.Drawing.Size(16, 17);
|
||||||
|
this.lblAnimationNumber.TabIndex = 21;
|
||||||
|
this.lblAnimationNumber.Text = "0";
|
||||||
|
//
|
||||||
// lblAnimationFwdBack
|
// lblAnimationFwdBack
|
||||||
//
|
//
|
||||||
this.lblAnimationFwdBack.AutoSize = true;
|
this.lblAnimationFwdBack.AutoSize = true;
|
||||||
@ -463,6 +472,7 @@
|
|||||||
this.btnReset.TabIndex = 24;
|
this.btnReset.TabIndex = 24;
|
||||||
this.btnReset.Text = "Reset";
|
this.btnReset.Text = "Reset";
|
||||||
this.btnReset.UseVisualStyleBackColor = true;
|
this.btnReset.UseVisualStyleBackColor = true;
|
||||||
|
this.btnReset.Click += new System.EventHandler(this.btnReset_Click);
|
||||||
//
|
//
|
||||||
// btnPreviewAnimFwd
|
// btnPreviewAnimFwd
|
||||||
//
|
//
|
||||||
@ -486,15 +496,6 @@
|
|||||||
this.btnPreviewAnimBack.UseVisualStyleBackColor = true;
|
this.btnPreviewAnimBack.UseVisualStyleBackColor = true;
|
||||||
this.btnPreviewAnimBack.Click += new System.EventHandler(this.btnPreviewAnimBack_Click);
|
this.btnPreviewAnimBack.Click += new System.EventHandler(this.btnPreviewAnimBack_Click);
|
||||||
//
|
//
|
||||||
// lblAnimationNumber
|
|
||||||
//
|
|
||||||
this.lblAnimationNumber.AutoSize = true;
|
|
||||||
this.lblAnimationNumber.Location = new System.Drawing.Point(190, 91);
|
|
||||||
this.lblAnimationNumber.Name = "lblAnimationNumber";
|
|
||||||
this.lblAnimationNumber.Size = new System.Drawing.Size(16, 17);
|
|
||||||
this.lblAnimationNumber.TabIndex = 21;
|
|
||||||
this.lblAnimationNumber.Text = "0";
|
|
||||||
//
|
|
||||||
// SpriteEntryForm
|
// SpriteEntryForm
|
||||||
//
|
//
|
||||||
this.AcceptButton = this.btnApply;
|
this.AcceptButton = this.btnApply;
|
||||||
|
@ -170,23 +170,64 @@ namespace SpriteLibrary
|
|||||||
UpdateHighlightBox();
|
UpdateHighlightBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If multiple frames are selected, retrieve all of their rectangles
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private List<Rectangle> AnimationFrameAreas()
|
||||||
|
{
|
||||||
|
List<Rectangle> Frames = new List<Rectangle>();
|
||||||
|
Point start = ChosenArea.Location;
|
||||||
|
int animations;
|
||||||
|
int.TryParse(tbNumFrames.Text, out animations);
|
||||||
|
Frames.Add(ChosenArea);
|
||||||
|
Image tImage = myDatabase.GetImageFromName(cbStartingImage.SelectedItem.ToString(), true);
|
||||||
|
|
||||||
|
for (int i=1; i< animations; i++)
|
||||||
|
{
|
||||||
|
start = new Point(start.X + ChosenArea.Width, start.Y);
|
||||||
|
if(start.X >= tImage.Width)
|
||||||
|
{
|
||||||
|
start.X = 0;
|
||||||
|
start.Y += ChosenArea.Height;
|
||||||
|
}
|
||||||
|
Rectangle tRec = new Rectangle(start.X, start.Y, ChosenArea.Width, ChosenArea.Height);
|
||||||
|
Frames.Add(tRec);
|
||||||
|
}
|
||||||
|
return Frames;
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateHighlightBox()
|
private void UpdateHighlightBox()
|
||||||
{
|
{
|
||||||
int transparency = 50;
|
int transparency = 50;
|
||||||
Image NewFrontImage = new Bitmap(pbImageField.BackgroundImage.Width, pbImageField.BackgroundImage.Height);
|
Image NewFrontImage = new Bitmap(pbImageField.BackgroundImage.Width, pbImageField.BackgroundImage.Height);
|
||||||
Color FillColor = Color.Green;
|
Color FillColor = Color.Gray;
|
||||||
Brush brush = new SolidBrush(Color.FromArgb(transparency, FillColor.R, FillColor.G, FillColor.B));
|
Brush brush = new SolidBrush(Color.FromArgb(transparency, FillColor.R, FillColor.G, FillColor.B));
|
||||||
Brush nobrush = new SolidBrush(Color.FromArgb(0,0,0,0));
|
Brush nobrush = new SolidBrush(Color.FromArgb(0,0,0,0));
|
||||||
|
List<Rectangle> areas = AnimationFrameAreas();
|
||||||
using (Graphics G = Graphics.FromImage(NewFrontImage))
|
using (Graphics G = Graphics.FromImage(NewFrontImage))
|
||||||
{
|
{
|
||||||
G.FillRectangle(brush, 0,0,NewFrontImage.Width,NewFrontImage.Height);
|
G.FillRectangle(brush, 0,0,NewFrontImage.Width,NewFrontImage.Height);
|
||||||
GraphicsPath path = new GraphicsPath();
|
GraphicsPath path = new GraphicsPath();
|
||||||
path.AddRectangle(ChosenArea);
|
foreach (Rectangle one in areas)
|
||||||
|
{
|
||||||
|
path.AddRectangle(one);
|
||||||
|
}
|
||||||
G.SetClip(path);
|
G.SetClip(path);
|
||||||
G.Clear(Color.Transparent);
|
G.Clear(Color.Transparent);
|
||||||
G.ResetClip();
|
G.ResetClip();
|
||||||
// G.FillRectangle(nobrush, ChosenArea);
|
transparency = 50;
|
||||||
|
FillColor = Color.Green;
|
||||||
|
int increment = 10;
|
||||||
|
if (areas.Count > 7) increment = 5;
|
||||||
|
foreach (Rectangle one in areas)
|
||||||
|
{
|
||||||
|
transparency += increment;
|
||||||
|
if (transparency > 150) transparency = 160;
|
||||||
|
brush = new SolidBrush(Color.FromArgb(transparency, FillColor.R, FillColor.G, FillColor.B));
|
||||||
|
G.FillRectangle(brush, one);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
pbImageField.Image = NewFrontImage;
|
pbImageField.Image = NewFrontImage;
|
||||||
pbImageField.SizeMode = PictureBoxSizeMode.StretchImage;
|
pbImageField.SizeMode = PictureBoxSizeMode.StretchImage;
|
||||||
@ -209,14 +250,11 @@ namespace SpriteLibrary
|
|||||||
|
|
||||||
private void cbStartingImage_SelectedIndexChanged(object sender, EventArgs e)
|
private void cbStartingImage_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ResourceManager rm;
|
|
||||||
if (myResources != null) rm = myResources;
|
|
||||||
else rm = Properties.Resources.ResourceManager;
|
|
||||||
//We have a selected item
|
//We have a selected item
|
||||||
if (cbStartingImage.SelectedIndex >= 0)
|
if (cbStartingImage.SelectedIndex >= 0)
|
||||||
{
|
{
|
||||||
//Load in a new image into our background
|
//Load in a new image into our background
|
||||||
Image NewImage = (Bitmap)rm.GetObject(cbStartingImage.SelectedItem.ToString());
|
Image NewImage = myDatabase.GetImageFromName(cbStartingImage.SelectedItem.ToString(),true);
|
||||||
if (NewImage != null)
|
if (NewImage != null)
|
||||||
{
|
{
|
||||||
MyController.ReplaceOriginalImage(new Bitmap(NewImage));
|
MyController.ReplaceOriginalImage(new Bitmap(NewImage));
|
||||||
@ -571,5 +609,10 @@ namespace SpriteLibrary
|
|||||||
PreviewSprite.ChangeAnimation(NextAnim);
|
PreviewSprite.ChangeAnimation(NextAnim);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void btnReset_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SpriteInformationToForm();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user