From 72f1c3ac791a8bad3d60e46640726a01d51a8d20 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Fri, 15 Sep 2017 19:21:46 -0500 Subject: [PATCH] Define a grid size to snap onto. A grid of 1x1 gives us a pixel by pixel grid. But we usually want to have 5, 10, 50, 100 or something like that. --- SpriteLibrary/SpriteDatabase.cs | 11 ++++++++++- SpriteLibrary/SpriteEntryForm.cs | 6 +++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/SpriteLibrary/SpriteDatabase.cs b/SpriteLibrary/SpriteDatabase.cs index aca30d7..0e89309 100644 --- a/SpriteLibrary/SpriteDatabase.cs +++ b/SpriteLibrary/SpriteDatabase.cs @@ -26,6 +26,7 @@ namespace SpriteLibrary List TheImages = new List(); ResourceManager myResourceManager = null; string Filename = ""; + Size SnapGridSize = new Size(5, 5); public SpriteDatabase(ResourceManager theResourceManager, string filename) { @@ -39,6 +40,14 @@ namespace SpriteLibrary LoadSpriteInfo(); } + public void SetSnapGridSize(Size GridSize) + { + if (GridSize.Width <= 0) return; + if (GridSize.Height <= 0) return; + if (GridSize.Width > 500) return; + if (GridSize.Height > 500) return; + SnapGridSize = GridSize; + } //******************************* //**** Sprite Info Functions *** @@ -83,7 +92,7 @@ namespace SpriteLibrary public void OpenEditWindow(int FirstItemIndex=-1) { - SpriteEntryForm SEF = new SpriteEntryForm(myResourceManager, SpriteInfoList); + SpriteEntryForm SEF = new SpriteEntryForm(myResourceManager, SpriteInfoList, SnapGridSize); SEF.ShowDialog(); //Use the updated list returned from the form. SpriteInfoList.Clear(); diff --git a/SpriteLibrary/SpriteEntryForm.cs b/SpriteLibrary/SpriteEntryForm.cs index e3d3349..26bafcc 100644 --- a/SpriteLibrary/SpriteEntryForm.cs +++ b/SpriteLibrary/SpriteEntryForm.cs @@ -11,11 +11,9 @@ using System.Xml.Serialization; using System.IO; using System.Resources; using System.Windows.Forms; -using System.Windows; using System.Collections; - namespace SpriteLibrary { internal partial class SpriteEntryForm : Form @@ -23,12 +21,14 @@ namespace SpriteLibrary SpriteController MyController; ResourceManager myResources = null; List SpriteInformation = new List(); + Size SnapGridSize = new Size(5,5); - internal SpriteEntryForm(ResourceManager theResourceManager, List ListToWorkOn) + internal SpriteEntryForm(ResourceManager theResourceManager, List ListToWorkOn, Size GridSize) { InitializeComponent(); if (theResourceManager == null) throw new Exception("NullException: The ResourceManager passed to the SpriteEntryForm cannot be null. Pass it Properties.Resources.ResourceManager"); myResources = theResourceManager; + SnapGridSize = GridSize; LocalSetup(); SpriteInformation.AddRange(ListToWorkOn); }