diff --git a/SpriteLibrary/SpriteDatabase.cs b/SpriteLibrary/SpriteDatabase.cs index 455e686..44b316a 100644 --- a/SpriteLibrary/SpriteDatabase.cs +++ b/SpriteLibrary/SpriteDatabase.cs @@ -9,6 +9,7 @@ using System.Xml.Serialization; using System.Resources; using System.IO; using System.Collections; +using System.Windows.Forms; namespace SpriteLibrary { @@ -160,6 +161,68 @@ namespace SpriteLibrary /// Open a Sprite Edit Window. This window does not let you draw a sprite. What it does is to help /// you define your sprites and makes the process of using Sprites in your program a lot easier. /// + /// + /// This is an example of how to use a SpriteDatabase. + /// When you begin developing your project, you want to start by creating a SpriteDatabase and pointing + /// it to a file, and then opening up an EditorWindow. + /// + /// public partial class MyGameForm : Form + /// { + /// SpriteController mySpriteController = null; + /// SpriteDatabase mySpriteDatabase = null; + /// + /// public MyGameForm() + /// { + /// InitializeComponent(); + /// MainDrawingArea.BackgroundImage = Properties.Resources.Background; + /// MainDrawingArea.BackgroundImageLayout = ImageLayout.Stretch; + /// + /// string Desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); + /// string MyFile = Path.Combine(Desktop, "myFile.xml"); + /// mySpriteDatabase = new SpriteDatabase(Properties.Resources.ResourceManager, MyFile); + /// + /// mySpriteController = new SpriteController(MainDrawingArea, mySpriteDatabase); + /// + /// mySpriteDatabase.OpenEditWindow(); + /// mySpriteDatabase.Save(); + /// } + /// } + /// + /// The Editor Window will let you find the sprites that are contained in the various images you have + /// as resources in your program, and it will save a file with those sprite templates. Any SpriteController + /// that you have instantiated with a Sprite Database (see ) + /// will now be able to create named sprites from the templates defined in the database. After the first use, the + /// named sprites will be accessible from within that controller just like any other named sprites. + /// + /// After you have created your SpriteDatabase file, you will want to add your file to your program resources. + /// Then, you will change the SpriteDatabase to use the resource instead of a file. If we named the file + /// "MySpriteDatabase.xml", and it got added to your resources with the name "MySpriteDatabase", you would + /// pass "MySpriteDatabase" to the database instantiation. + /// + /// public partial class MyGameForm : Form + /// { + /// SpriteController mySpriteController = null; + /// SpriteDatabase mySpriteDatabase = null; + /// + /// public MyGameForm() + /// { + /// InitializeComponent(); + /// MainDrawingArea.BackgroundImage = Properties.Resources.Background; + /// MainDrawingArea.BackgroundImageLayout = ImageLayout.Stretch; + /// + /// //string Desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); + /// //string MyFile = Path.Combine(Desktop, "myFile.xml"); + /// //mySpriteDatabase = new SpriteDatabase(Properties.Resources.ResourceManager, MyFile); + /// mySpriteDatabase = new SpriteDatabase(Properties.Resources.ResourceManager, "MySpriteDatabase"); + /// + /// mySpriteController = new SpriteController(MainDrawingArea, mySpriteDatabase); + /// + /// //mySpriteDatabase.OpenEditWindow(); + /// //mySpriteDatabase.Save(); + /// } + /// } + /// + /// /// public void OpenEditWindow(int FirstItemIndex=-1) {