From 59bea020b685bfabad0a7b466bf5f246251dd481 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Wed, 20 Sep 2017 14:18:00 -0500 Subject: [PATCH] Choose a good image at the start of the window being opened. --- SpriteLibrary/SpriteDatabase.cs | 20 ++++++++++++++++++++ SpriteLibrary/SpriteEntryForm.cs | 12 ++++++++++++ 2 files changed, 32 insertions(+) diff --git a/SpriteLibrary/SpriteDatabase.cs b/SpriteLibrary/SpriteDatabase.cs index f253b48..c1339c5 100644 --- a/SpriteLibrary/SpriteDatabase.cs +++ b/SpriteLibrary/SpriteDatabase.cs @@ -8,6 +8,7 @@ using System.Xml; using System.Xml.Serialization; using System.Resources; using System.IO; +using System.Collections; namespace SpriteLibrary { @@ -203,6 +204,25 @@ namespace SpriteLibrary return MyImage; } + + /// + /// Return a list of the image names in the Properties.Resources + /// + /// + public List GetImageNames() + { + List Names = new List(); + if (myResourceManager == null) return Names; + ResourceSet Rs = myResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true); + foreach (DictionaryEntry entry in Rs) + { + string resourceKey = entry.Key.ToString(); //The name + object resource = entry.Value; //The object itself + if (resource is Image) Names.Add(resourceKey); + } + return Names; + } + /// /// This code is mostly handled by the sprite controller. If the SpriteController has a SpriteDatabase /// registered, then it will automatically ask the SpriteDatabase to create any sprite it does not already diff --git a/SpriteLibrary/SpriteEntryForm.cs b/SpriteLibrary/SpriteEntryForm.cs index 7f90650..b51ebd5 100644 --- a/SpriteLibrary/SpriteEntryForm.cs +++ b/SpriteLibrary/SpriteEntryForm.cs @@ -261,11 +261,23 @@ namespace SpriteLibrary private void SetUpEmptyInfo() { + string startingimage = cbStartingImage.Text; //grab whatever we were using last + Console.WriteLine("Setting up an empty info rec."); + if(startingimage == null || startingimage == "")//If we are not looking at anything yet + { + List ImageNames = myDatabase.GetImageNames(); + if (ImageNames.Count > 0) + startingimage = ImageNames[0]; + foreach(string name in ImageNames) + Console.WriteLine(" Name: " + name); + } + Console.WriteLine("NewName=" + startingimage); TempInformation = new SpriteInfo(); TempInformation.SpriteName = ""; TempInformation.ViewPercent = 100; AnimationInfo AI = new AnimationInfo(); AI.AnimSpeed = 200; + AI.ImageName = startingimage; AI.FieldsToUse = AnimationType.SpriteDefinition; AI.Height = 100; AI.Width = 100;