SpriteLibrary
SpriteLibrary
SpriteLibrary
SpriteDatabase Class
SpriteDatabase Methods
CloneByXMLSerializing(T) Method
GetImageFromName Method
GetImageNames Method
LoadObjectFromXmlFile(T) Method
OpenEditWindow Method
ReadFromXmlFile(T) Method
ReadFromXmlString(T) Method
Save Method
SetIcon Method
SetSnapGridSize Method
SpriteFromName Method
SpriteNames Method
WriteToXmlFile(T) Method
WriteToXMLString(T) Method

# SpriteDatabase OpenEditWindow Method

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.

Namespace: SpriteLibrary
Assembly: SpriteLibrary (in SpriteLibrary.dll) Version: 1.0.0.6 (1.0.0.6)
Syntax
C#
Copy

    public void OpenEditWindow(
    	int FirstItemIndex = -1
    )

#### Parameters

FirstItemIndex (Optional)
  Type: System
  Int32

Examples
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.
C#
Copy

    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 SpriteController(PictureBox, SpriteDatabase)) 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.
C#
Copy

    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();
        }
    }

See Also

#### Reference

SpriteDatabase Class
SpriteLibrary Namespace