Return a spriteinfo list from the entry form

This commit is contained in:
Tim Young 2017-09-15 19:15:37 -05:00
parent 846d4b569f
commit 23814be473
2 changed files with 26 additions and 7 deletions

View File

@ -81,6 +81,17 @@ namespace SpriteLibrary
return false; 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) public Image GetImageFromName(string Name, bool UseSmartImages)
{ {
Image MyImage = null; Image MyImage = null;

View File

@ -18,33 +18,41 @@ using System.Collections;
namespace SpriteLibrary namespace SpriteLibrary
{ {
public partial class SpriteEntryForm : Form internal partial class SpriteEntryForm : Form
{ {
SpriteController MyController; SpriteController MyController;
ResourceManager myResources = null; ResourceManager myResources = null;
List<SpriteInfo> SpriteInformation = new List<SpriteInfo>();
public SpriteEntryForm(ResourceManager theResourceManager) internal SpriteEntryForm(ResourceManager theResourceManager, List<SpriteInfo> ListToWorkOn)
{ {
InitializeComponent(); InitializeComponent();
if (theResourceManager == null) throw new Exception("NullException: The ResourceManager passed to the SpriteEntryForm cannot be null. Pass it Properties.Resources.ResourceManager");
myResources = theResourceManager; myResources = theResourceManager;
LocalSetup(); LocalSetup();
SpriteInformation.AddRange(ListToWorkOn);
} }
public void LocalSetup() private void LocalSetup()
{ {
pbImageField.BackgroundImageLayout = ImageLayout.Stretch; pbImageField.BackgroundImageLayout = ImageLayout.Stretch;
MyController = new SpriteController(pbImageField); MyController = new SpriteController(pbImageField);
PopulateMenu(); PopulateMenu();
} }
public void PopulateMenu() internal List<SpriteInfo> GetUpdatedList()
{ {
ResourceManager rm = Properties.Resources.ResourceManager; return SpriteInformation;
if (myResources != null) rm = myResources; }
private void PopulateMenu()
{
ResourceManager rm = myResources;
PopulateMenu(rm); PopulateMenu(rm);
} }
public void PopulateMenu(ResourceManager rm)
private void PopulateMenu(ResourceManager rm)
{ {
if (myResources == null) myResources = rm; if (myResources == null) myResources = rm;
ResourceSet RS = rm.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true); ResourceSet RS = rm.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true);