From 23814be473d7b81ca2c2480f8e63b74bf03c1532 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Fri, 15 Sep 2017 19:15:37 -0500 Subject: [PATCH] Return a spriteinfo list from the entry form --- SpriteLibrary/SpriteDatabase.cs | 11 +++++++++++ SpriteLibrary/SpriteEntryForm.cs | 22 +++++++++++++++------- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/SpriteLibrary/SpriteDatabase.cs b/SpriteLibrary/SpriteDatabase.cs index 278d5a1..aca30d7 100644 --- a/SpriteLibrary/SpriteDatabase.cs +++ b/SpriteLibrary/SpriteDatabase.cs @@ -81,6 +81,17 @@ namespace SpriteLibrary return false; } + public void OpenEditWindow(int FirstItemIndex=-1) + { + SpriteEntryForm SEF = new SpriteEntryForm(myResourceManager, SpriteInfoList); + SEF.ShowDialog(); + //Use the updated list returned from the form. + SpriteInfoList.Clear(); + SpriteInfoList.AddRange(SEF.GetUpdatedList()); + } + #endregion + + #region General Functions public Image GetImageFromName(string Name, bool UseSmartImages) { Image MyImage = null; diff --git a/SpriteLibrary/SpriteEntryForm.cs b/SpriteLibrary/SpriteEntryForm.cs index a5514ad..e3d3349 100644 --- a/SpriteLibrary/SpriteEntryForm.cs +++ b/SpriteLibrary/SpriteEntryForm.cs @@ -18,33 +18,41 @@ using System.Collections; namespace SpriteLibrary { - public partial class SpriteEntryForm : Form + internal partial class SpriteEntryForm : Form { SpriteController MyController; ResourceManager myResources = null; + List SpriteInformation = new List(); - public SpriteEntryForm(ResourceManager theResourceManager) + internal SpriteEntryForm(ResourceManager theResourceManager, List ListToWorkOn) { InitializeComponent(); + if (theResourceManager == null) throw new Exception("NullException: The ResourceManager passed to the SpriteEntryForm cannot be null. Pass it Properties.Resources.ResourceManager"); myResources = theResourceManager; LocalSetup(); + SpriteInformation.AddRange(ListToWorkOn); } - public void LocalSetup() + private void LocalSetup() { pbImageField.BackgroundImageLayout = ImageLayout.Stretch; MyController = new SpriteController(pbImageField); PopulateMenu(); } - public void PopulateMenu() + internal List GetUpdatedList() { - ResourceManager rm = Properties.Resources.ResourceManager; - if (myResources != null) rm = myResources; + return SpriteInformation; + } + + private void PopulateMenu() + { + ResourceManager rm = myResources; PopulateMenu(rm); } - public void PopulateMenu(ResourceManager rm) + + private void PopulateMenu(ResourceManager rm) { if (myResources == null) myResources = rm; ResourceSet RS = rm.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true);