diff --git a/SpriteLibrary/Properties/Resources.Designer.cs b/SpriteLibrary/Properties/Resources.Designer.cs
index 527b3a7..076841d 100644
--- a/SpriteLibrary/Properties/Resources.Designer.cs
+++ b/SpriteLibrary/Properties/Resources.Designer.cs
@@ -61,15 +61,23 @@ namespace SpriteLibrary.Properties {
}
///
- /// Looks up a localized string similar to {\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
- ///{\colortbl ;\red0\green0\blue255;}
- ///{\*\generator Riched20 10.0.10586}\viewkind4\uc1
- ///\pard\sa200\sl276\slmult1\f0\fs22\lang9 This is the Running Demo, which was created to test out the SpriteController: {{\field{\*\fldinst{HYPERLINK http://www.codeproject.com/Articles/1085446/Using-Sprites-Inside-Windows-Forms }}{\fldrslt{http://www.codeproject.com/Articles/1085446/Using-Sprites-Inside-Windows-Forms\ul0\cf0}}}}\f0 [rest of string was truncated]";.
+ /// Looks up a localized string similar to {\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31505\stshfloch31506\stshfhich31506\stshfbi31507\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f34\fbidi \froman\fcharset1\fprq2{\*\panose 02040503050406030204}Cambria Math;}
+ ///{\f39\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}{\f40\fbidi \fmodern\fcharset0\fprq1{\*\panose 020b0609020204030204}Consolas;}{\ [rest of string was truncated]";.
///
internal static string ChangeLog {
get {
return ResourceManager.GetString("ChangeLog", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
+ ///
+ internal static System.Drawing.Icon SLIcon {
+ get {
+ object obj = ResourceManager.GetObject("SLIcon", resourceCulture);
+ return ((System.Drawing.Icon)(obj));
+ }
+ }
}
}
diff --git a/SpriteLibrary/Properties/Resources.resx b/SpriteLibrary/Properties/Resources.resx
index eb0b268..e81f0a2 100644
--- a/SpriteLibrary/Properties/Resources.resx
+++ b/SpriteLibrary/Properties/Resources.resx
@@ -121,4 +121,7 @@
..\Resources\ChangeLog.rtf;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
+
+ ..\Resources\SLIcon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
\ No newline at end of file
diff --git a/SpriteLibrary/Resources/SLIcon.ico b/SpriteLibrary/Resources/SLIcon.ico
new file mode 100644
index 0000000..89c1b63
Binary files /dev/null and b/SpriteLibrary/Resources/SLIcon.ico differ
diff --git a/SpriteLibrary/SpriteController.cs b/SpriteLibrary/SpriteController.cs
index de1d7c1..7a7d28b 100644
--- a/SpriteLibrary/SpriteController.cs
+++ b/SpriteLibrary/SpriteController.cs
@@ -146,6 +146,12 @@ namespace SpriteLibrary
private SpriteAdjustmentRatio _AdjustmentRatio;
+ ///
+ /// The Sprite Database has tools to load and save sprite definitions, as well as a tool to help
+ /// developers create sprite definitions.
+ ///
+ private SpriteDatabase myDatabase = null;
+
///
/// If your sprite images need substantial growing or shrinking when displayed, you can try setting this to "true"
/// to see if it makes it run any faster. What it does is to resize the image once, and keep a cached copy of that
@@ -183,6 +189,39 @@ namespace SpriteLibrary
Local_Setup();
}
+ ///
+ /// Create a sprite controller, specifying the picturebox on which the sprites
+ /// will be displayed. You want to have the PictureBox already defined, and a background image
+ /// already set for the PictureBox. This constructor also uses a , which
+ /// loads sprite definitions at construction time, and has tools for making and storing sprites.
+ ///
+ ///
+ /// This is an example of a Form class that defines a SpriteController. The MainDrawingArea is a
+ /// PictureBox.
+ ///
+ /// public partial class ShootingFieldForm : Form
+ /// {
+ /// public ShootingFieldForm()
+ /// {
+ /// InitializeComponent();
+ /// MainDrawingArea.BackgroundImage = Properties.Resources.Background;
+ /// MainDrawingArea.BackgroundImageLayout = ImageLayout.Stretch;
+ /// MySpriteDatabase = new SpriteDatabase(Properties.Resources.ResourceManager, "MySpriteDefinitions");
+ /// MySpriteController = new SpriteController(MainDrawingArea, MySpriteDatabase);
+ /// }
+ /// }
+ ///
+ ///
+ /// The PictureBox.
+ /// that the sprites will be drawn in
+ /// A SpriteDatabase to use
+ public SpriteController(PictureBox Area, SpriteDatabase DatabaseToUse)
+ {
+ myDatabase = DatabaseToUse;
+ DrawingArea = Area;
+ Local_Setup();
+ }
+
///
/// Create a sprite controller, specifying the picturebox on which the sprites
/// will be displayed.
@@ -980,6 +1019,11 @@ namespace SpriteLibrary
return Found;
}
}
+ //If we are here, we have not yet found a sprite. Now we can check our database and see if we have one defined
+ if(myDatabase != null)
+ {
+ return myDatabase.SmartDuplicateSprite(this, Name, true);
+ }
return null;
}
diff --git a/SpriteLibrary/SpriteDatabase.cs b/SpriteLibrary/SpriteDatabase.cs
index c9475c4..29c0da4 100644
--- a/SpriteLibrary/SpriteDatabase.cs
+++ b/SpriteLibrary/SpriteDatabase.cs
@@ -36,6 +36,7 @@ namespace SpriteLibrary
ResourceManager myResourceManager = null;
string Filename = "";
Size SnapGridSize = new Size(5, 5);
+ System.Drawing.Icon LibIcon = null;
///
/// The sprite database instantiation function. The filename can either be a file on the computer or it
@@ -86,6 +87,15 @@ namespace SpriteLibrary
}
}
+ ///
+ /// Change the Icon for the SpriteEntryForm
+ ///
+ /// An icon image
+ public void SetIcon(System.Drawing.Icon toSet)
+ {
+ LibIcon = toSet;
+ }
+
///
/// The SnapGrid is the block-size that your sprite will be. For example, I will often have sprites with
/// a snapgrid of 50,50. This means that the sprite can be 50x50, 100x50, or anything with a step-size
@@ -155,11 +165,25 @@ namespace SpriteLibrary
{
SpriteEntryForm SEF = new SpriteEntryForm(this, SpriteInfoList, SnapGridSize);
SEF.SetInitialSprite(FirstItemIndex);
+ if (LibIcon != null) SEF.SetIcon(LibIcon);
SEF.ShowDialog();
//Use the updated list returned from the form.
SpriteInfoList.Clear();
SpriteInfoList.AddRange(SEF.GetUpdatedList());
}
+
+ ///
+ /// Generate a new, named sprite from a sprite template stored in the database. Most of the time you do
+ /// not want to use this yourself. SpriteControllers that are defined with a database will automatically
+ /// look up sprite templates that they do not have sprites for. This function is just a wrapper for SmartDuplicateSprite.
+ ///
+ /// The name of the sprite to load. Names are case-sensitive.
+ /// The sprite controller that will store the sprite in its cache
+ /// A new, named sprite, or null if no such template is found.
+ public Sprite SpriteFromName(string Name, SpriteController ControllerToUse)
+ {
+ return SmartDuplicateSprite(ControllerToUse, Name, true);
+ }
#endregion
#region General Functions
diff --git a/SpriteLibrary/SpriteEntryForm.cs b/SpriteLibrary/SpriteEntryForm.cs
index d17e286..c245eb5 100644
--- a/SpriteLibrary/SpriteEntryForm.cs
+++ b/SpriteLibrary/SpriteEntryForm.cs
@@ -87,6 +87,8 @@ namespace SpriteLibrary
myToolTip.SetToolTip(btnNewSprite, "Create a new sprite.");
myToolTip.SetToolTip(btnDeleteAnim, "Delete the current animation you are looking at.");
myToolTip.SetToolTip(btnDelSprite, "Delete the current sprite you are looking at.");
+
+ Icon = Properties.Resources.SLIcon;
}
internal List GetUpdatedList()
@@ -94,6 +96,11 @@ namespace SpriteLibrary
return SpriteInformation;
}
+ internal void SetIcon(Icon IconImage)
+ {
+ Icon = IconImage;
+ }
+
private void PopulateMenu()
{
ResourceManager rm = myResources;
diff --git a/SpriteLibrary/SpriteLibrary.csproj b/SpriteLibrary/SpriteLibrary.csproj
index eda7b56..3371803 100644
--- a/SpriteLibrary/SpriteLibrary.csproj
+++ b/SpriteLibrary/SpriteLibrary.csproj
@@ -85,6 +85,9 @@
+
+
+