Team Up

Team Up
This is the project our small team worked on at Full Sail University for our Structure of Game Production class.

Four of us made a side scrolling brawler game over two months.

Here is our dev blog from the project.

 

Here are some code samples from the Animation Editor tool I made for Team Up.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SGP;

namespace Animation_Editor
{
    [Serializable]
    public class Animation
    {
        // ImageID, only for loading it in the renderer of the editor
        int ImageID;
        public int ImageID1
        {
            get { return ImageID; }
            set { ImageID = value; }
        }

        // animation speed (only for editing)
        decimal animSpeed;
        public decimal AnimSpeed
        {
            get { return animSpeed; }
            set { animSpeed = value; }
        }

        string AnimName;
        public string AnimName1
        {
            get { return AnimName; }
            set { AnimName = value; }
        }

        string sheetFilename;
        public string SheetFilename
        {
            get { return sheetFilename; }
            set { sheetFilename = value; }
        }

        // list of frames for each animation
        List<Frame> frames = new List<Frame>();
        public List<Frame> Frames
        {
            get { return frames; }
            set { frames = value; }
        }

        // add a frame to the list
        public void AddFrame(Frame frame)
        {
            frames.Add(frame);
        }
        public void RemoveFrame(Frame frame)
        {
            frames.Remove(frame);
        }
        public override string ToString()
        {
            return AnimName1;
        }
    }

    [Serializable]
    public class BinaryData
    {
        List<Animation> animList;

        public List<Animation> AnimList
        {
            get { return animList; }
            set { animList = value; }
        }
    }

    [Serializable]
    public class Frame
    {
        // frame number
        int frameNum;
        public int FrameNum
        {
            get { return frameNum; }
            set { frameNum = value; }
        }

        // trigger event name
        string triggerName;
        public string TriggerName
        {
            get { return triggerName; }
            set { triggerName = value; }
        }

        // duration that the frame plays for
        float frameDuration;
        public float FrameDuration
        {
            get { return frameDuration; }
            set { frameDuration = value; }
        }

        // the rect for drawing the frame
        Rectangle drawRect;
        public Rectangle DrawRect
        {
            get { return drawRect; }
            set { drawRect = value; }
        }

        // the rect used for attack collision
        Rectangle attackRect;
        public Rectangle AttackRect
        {
            get { return attackRect; }
            set { attackRect = value; }
        }

        // the rect used for taking damage
        Rectangle colRect;
        public Rectangle ColRect
        {
            get { return colRect; }
            set { colRect = value; }
        }

        // the point around which the frame animates
        Point anchorpoint;
        public Point Anchor
        {
            get { return anchorpoint; }
            set { anchorpoint = value; }
        }

        // the point at which triggered events will spawn if needed (ie projectiles)
        Point triggerpoint;
        public Point Triggerpoint
        {
            get { return triggerpoint; }
            set { triggerpoint = value; }
        }

        public override string ToString()
        {
            return "Frame " + frameNum;
        }
    }
}

And Here’s the non Designer portion of the Form for the window.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Xml.Linq;
using System.Xml.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using SGP;

namespace Animation_Editor
{
    public enum drawType { FRAME, ATTACK, COLLISION, ANCHOR, TRIGGER };
    public partial class FormAnimationEditor : Form
    {
        XNAWrapped d3d;
        XNATextureManager tm;
        string sheetFile = string.Empty;
        string animFile = string.Empty;
        Rectangle FrameRect = Rectangle.Empty;
        Rectangle AttackRect = Rectangle.Empty;
        Rectangle CollisionRect = Rectangle.Empty;
        Rectangle tmpRect = Rectangle.Empty;
        Point AnchorPoint = Point.Empty;
        Point TriggerPoint = Point.Empty;
        int drawtype = -1;
        List<Frame> framesList;
        List<Animation> animList;
        Point rectStartPos;
        Point mouse;
        Size pointSize = new Size(6, 6);
        bool mouseIsDown = false;
        bool readyToDraw = false;
        bool isPlaying = false;
        bool isLooping = false;
        bool modified = false;
        int counter = 0;
        float animSpeed = 0;

        // for sheet panel
        float sheetScale = 1.0f;
        int sheetID = -1;

        // animation panel constants
        float scaleofFrame = 1.0f;

        static float fTimeStep = 0;

        public FormAnimationEditor()
        {
            Looping = true;
            InitializeComponent();
            d3d = XNAWrapped.Instance;
            tm = XNATextureManager.Instance;
            d3d.InitXNA(panelSheet, true);
            d3d.InitRenderWindow(panelAnimation, true);
            tm.InitXNATextureManager(d3d.Device, d3d.Sprite);
            framesList = new List<Frame>();
            animList = new List<Animation>();
            string dir = Application.StartupPath.ToString();
            System.IO.Directory.SetCurrentDirectory(dir);
#if DEBUG
            System.IO.Directory.SetCurrentDirectory("../../../");
            sheetID = tm.LoadTexture("spritesheet for powerups.png");
            if (tm.GetTextureWidth(sheetID) > panelSheet.Width ||
                    tm.GetTextureHeight(sheetID) > panelSheet.Height)
            {
                hScrollBar1.Maximum = tm.GetTextureWidth(sheetID) - panelSheet.Width + 15;
                vScrollBar1.Maximum = tm.GetTextureHeight(sheetID) - panelSheet.Height + 15;
            }
            else
            {
                hScrollBar1.Maximum = 0;
                vScrollBar1.Maximum = 0;
            }
            // maximums
            numericUpDownRectX.Maximum = tm.GetTextureWidth(sheetID) + 1000 ;
            numericUpDownRectY.Maximum = tm.GetTextureHeight(sheetID) + 1000;
            numericUpDownRectWidth.Maximum = tm.GetTextureWidth(sheetID) + 1000;
            numericUpDownRectHeight.Maximum = tm.GetTextureHeight(sheetID) + 1000;
            numericUpDownPointX.Maximum = tm.GetTextureWidth(sheetID) + 1000;
            numericUpDownPointY.Maximum = tm.GetTextureHeight(sheetID) + 1000;
            // minimums
            numericUpDownRectX.Minimum = -tm.GetTextureWidth(sheetID);
            numericUpDownRectY.Minimum = -tm.GetTextureHeight(sheetID);
            numericUpDownRectWidth.Minimum = -tm.GetTextureWidth(sheetID);
            numericUpDownRectHeight.Minimum = -tm.GetTextureHeight(sheetID);
            numericUpDownPointX.Minimum = -tm.GetTextureWidth(sheetID);
            numericUpDownPointY.Minimum = -tm.GetTextureHeight(sheetID);
#endif
            // initial values
            numericUpDownFrameDuration.Value = 0.30M;
            numericUpDownAnimSpeed.Value = 1.0M;
            animSpeed = (float)numericUpDownAnimSpeed.Value;
            comboBoxZoom.SelectedIndex = 1;
            checkBoxLooping.Checked = true;
            modified = false;
        }

        private void importSheetToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // make dialog object
            OpenFileDialog dlg = new OpenFileDialog();
            // set image filter
            dlg.Filter = "image files (*.bmp,*.jpg...)|*.bmp;*.jpg;*.jpeg;*.gif;*.png|All Files (*.*)|*.*";
            // show the dialog box to the user
            if (DialogResult.OK == dlg.ShowDialog())
            {
                // import tilesheet
                string filepath = Path.GetDirectoryName(dlg.FileName);
                dlg.FileName = Path.GetFileName(dlg.FileName);
                string tmp = System.IO.Directory.GetCurrentDirectory();
                if (System.IO.Directory.GetCurrentDirectory() != filepath)
                {
                    MessageBox.Show("You are trying to load outside your workspace", "Animation Editor - Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);

                    return;
                }
                sheetID = tm.LoadTexture(dlg.FileName);

                // TODO: set up the scrollbars better
                if (tm.GetTextureWidth(sheetID) > panelSheet.Width ||
                    tm.GetTextureHeight(sheetID) > panelSheet.Height)
                {
                    hScrollBar1.Maximum = tm.GetTextureWidth(sheetID) - panelSheet.Width + 15;
                    vScrollBar1.Maximum = tm.GetTextureHeight(sheetID) - panelSheet.Height + 15;
                }
                else
                {
                    hScrollBar1.Maximum = 0;
                    vScrollBar1.Maximum = 0;
                }
                // maximums
                numericUpDownRectX.Maximum = tm.GetTextureWidth(sheetID) + 1000;
                numericUpDownRectY.Maximum = tm.GetTextureHeight(sheetID) + 1000;
                numericUpDownRectWidth.Maximum = tm.GetTextureWidth(sheetID) + 1000;
                numericUpDownRectHeight.Maximum = tm.GetTextureHeight(sheetID) + 1000;
                numericUpDownPointX.Maximum = tm.GetTextureWidth(sheetID) + 1000;
                numericUpDownPointY.Maximum = tm.GetTextureHeight(sheetID) + 1000;
                // minimums
                numericUpDownRectX.Minimum = -tm.GetTextureWidth(sheetID);
                numericUpDownRectY.Minimum = -tm.GetTextureHeight(sheetID);
                numericUpDownRectWidth.Minimum = -tm.GetTextureWidth(sheetID);
                numericUpDownRectHeight.Minimum = -tm.GetTextureHeight(sheetID);
                numericUpDownPointX.Minimum = -tm.GetTextureWidth(sheetID);
                numericUpDownPointY.Minimum = -tm.GetTextureHeight(sheetID);
                
                sheetFile = dlg.FileName;
            }
            modified = true;
        }
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // TODO: relative paths

            // make a dialog object
            OpenFileDialog dlg = new OpenFileDialog();
            //set the filters
            dlg.Filter = "XML files|*.xml|Binary|*.anim*";
            dlg.FilterIndex = 1;
            // show dialog box to user
            if (DialogResult.OK == dlg.ShowDialog())
            {
                if (dlg.FilterIndex == 1)
                {
                    BinaryData bd = new BinaryData();
                    StreamReader reader = new StreamReader(dlg.FileName);

                    XmlSerializer xms = new XmlSerializer(typeof(BinaryData));

                    bd = (BinaryData)xms.Deserialize(reader);

                    reader.Close();

                    animList.Clear();
                    listBoxAnimations.Items.Clear();

                    animList = bd.AnimList;

                    foreach (Animation a in animList)
                    {
                        listBoxAnimations.Items.Add(a);
                    }
                    animFile = dlg.FileName;
                }
                else if (dlg.FilterIndex == 2)
                {
                    BinaryReader br = new BinaryReader(File.Open(dlg.FileName, FileMode.Open));

                    animList.Clear();
                    listBoxAnimations.Items.Clear();
                    int count = br.ReadInt32();
                    for(int i = 0; i < count; ++i)
                    {
                        Animation anim = new Animation();
                        int length = br.ReadInt32();
                        anim.AnimName1 = new string(br.ReadChars(length));
                        length = br.ReadInt32();
                        anim.SheetFilename = new string(br.ReadChars(length));
                        anim.AnimSpeed = (decimal)br.ReadSingle();
                        int frCount = br.ReadInt32();
                        for (int j = 0; j < frCount; ++j)
                        {
                            Frame fr = new Frame();
                            fr.FrameNum = br.ReadInt32();
                            fr.FrameDuration = br.ReadSingle();
                            // DrawRect
                            int X, Y, W, H;
                            X = br.ReadInt32();
                            Y = br.ReadInt32();
                            W = br.ReadInt32();
                            H = br.ReadInt32();
                            fr.DrawRect = new Rectangle(X, Y, W, H);
                            // Anchor Point
                            X = br.ReadInt32();
                            Y = br.ReadInt32();
                            fr.Anchor = new Point(X, Y);
                            // Col Rect
                            X = br.ReadInt32();
                            Y = br.ReadInt32();
                            W = br.ReadInt32();
                            H = br.ReadInt32();
                            fr.ColRect = new Rectangle(X, Y, W, H);
                            // Att Rect
                            X = br.ReadInt32();
                            Y = br.ReadInt32();
                            W = br.ReadInt32();
                            H = br.ReadInt32();
                            fr.AttackRect = new Rectangle(X, Y, W, H);
                            // Trigger Point
                            length = br.ReadInt32();
                            fr.TriggerName = new string(br.ReadChars(length));
                            X = br.ReadInt32();
                            Y = br.ReadInt32();
                            fr.Triggerpoint = new Point(X, Y);

                            anim.AddFrame(fr);
                        }
                        animList.Add(anim);
                    }
                    foreach (Animation a in animList)
                    {
                        listBoxAnimations.Items.Add(a);
                    }
                    animFile = dlg.FileName;
                }
            }
        }
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // if file has no name, call the SaveAs function
            // else, just overwrite the filename it already has.
            if (animFile == string.Empty)
            {
                saveAsToolStripMenuItem_Click(sender, e);
            }
            else
            {
                BinaryData bd = new BinaryData();
                //bd.AnimList = new List<Animation>();
                bd.AnimList = animList;
                XmlSerializer xsw = new XmlSerializer(typeof(BinaryData));
                StreamWriter writer = new StreamWriter(animFile);
                xsw.Serialize(writer, bd);

                writer.Close();

               modified = false;
            }
        }
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // TODO: relative paths
            SaveFileDialog dlg = new SaveFileDialog();
            dlg.Filter = "XML file|*.xml|All Files (*.*)|*.*";
            dlg.DefaultExt = ".xml";

            if (DialogResult.OK == dlg.ShowDialog())
            {
                BinaryData bd = new BinaryData();
                //bd.AnimList = new List<Animation>();
                bd.AnimList = animList;
                XmlSerializer xsw = new XmlSerializer(typeof(BinaryData));
                StreamWriter writer = new StreamWriter(dlg.FileName);
                xsw.Serialize(writer, bd);

                writer.Close();

                animFile = dlg.FileName;
                modified = false;
            }
            else
                return;
        }
        private void exportToGameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // load all the info into one object
            //BinaryData data = new BinaryData();
            //data.AnimList = animList;
            SaveFileDialog dlg = new SaveFileDialog();
            dlg.Filter = "Binary File|*.anim";
            dlg.DefaultExt = ".anim";
            if (DialogResult.OK == dlg.ShowDialog())
            {
                // save as binary for game      
                BinaryWriter bw = new BinaryWriter(File.Open(dlg.FileName,FileMode.Create));
                // for animation count
                bw.Write(animList.Count);
                foreach (Animation a in animList)
                {
                    bw.Write(a.AnimName1.Length);
                    bw.Write(a.AnimName1.ToCharArray(0,a.AnimName1.Length));
                    bw.Write(a.SheetFilename.Length);
                    bw.Write(a.SheetFilename.ToCharArray(0, a.SheetFilename.Length));
                    bw.Write((float)a.AnimSpeed);
                    // for frame count
                    bw.Write(a.Frames.Count);
                    foreach (Frame f in a.Frames)
                    {
                        bw.Write(f.FrameNum);
                        bw.Write(f.FrameDuration);
                        //Draw Rect
                        bw.Write(f.DrawRect.X);
                        bw.Write(f.DrawRect.Y);
                        bw.Write(f.DrawRect.Width);
                        bw.Write(f.DrawRect.Height);
                        // AnchorPoint
                        bw.Write(f.Anchor.X);
                        bw.Write(f.Anchor.Y);
                        //ColRect
                        bw.Write(f.ColRect.X);
                        bw.Write(f.ColRect.Y);
                        bw.Write(f.ColRect.Width);
                        bw.Write(f.ColRect.Height);
                        // AttRect
                        bw.Write(f.AttackRect.X);
                        bw.Write(f.AttackRect.Y);
                        bw.Write(f.AttackRect.Width);
                        bw.Write(f.AttackRect.Height);
                        // Trigger point
                        bw.Write(f.TriggerName.Length);
                        bw.Write(f.TriggerName.ToCharArray(0, f.TriggerName.Length));
                        bw.Write(f.Triggerpoint.X);
                        bw.Write(f.Triggerpoint.Y);
                    }
                }
            }
        }
        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Created by Aaron Schie\nFull Sail University", "Author");
        }
        internal Rectangle NormRect(Point one, Point two)
        {
            Rectangle rect = Rectangle.Empty;
            if (one.X < two.X && one.Y < two.Y)
            {
                // point one is top left
                rect = new Rectangle(one.X, one.Y, Math.Abs(two.X - one.X),
                    Math.Abs(two.Y - one.Y));
            }
            else if (one.X < two.X && one.Y > two.Y)
            {
                // point one is bottom left
                rect = new Rectangle(one.X, two.Y, Math.Abs(two.X - one.X),
                    Math.Abs(one.Y - two.Y));
            }
            else if (one.X > two.X && one.Y < two.Y)
            {
                // point one is top right
                rect = new Rectangle(two.X, one.Y, Math.Abs(one.X - two.X),
                    Math.Abs(two.Y - one.Y));
            }
            else if (one.X > two.X && one.Y > two.Y)
            {
                // point one is bottom right
                rect = new Rectangle(two.X, two.Y, Math.Abs(one.X - two.X),
                    Math.Abs(one.Y - two.Y));
            }

            return rect;
        }
        internal void Render()
        {
            // spritesheet panel
            d3d.Clear(255, 255, 255);
            d3d.SpriteBegin();
            if (sheetID > -1)
                tm.Draw(sheetID, -hScrollBar1.Value, -vScrollBar1.Value, sheetScale,
                    sheetScale, Rectangle.Empty, 0, 0, 0, Color.White);
            d3d.SpriteEnd();

            if (!FrameRect.IsEmpty)
                d3d.DrawRectEmpty(new Rectangle(FrameRect.X - hScrollBar1.Value,
                    FrameRect.Y - vScrollBar1.Value,
                    FrameRect.Width, FrameRect.Height), Color.Blue);
            if (!AttackRect.IsEmpty)
                d3d.DrawRectEmpty(new Rectangle((AttackRect.X + (FrameRect.X + AnchorPoint.X)) - hScrollBar1.Value,
                    (AttackRect.Y + (FrameRect.X + AnchorPoint.X)) - vScrollBar1.Value,
                    AttackRect.Width, AttackRect.Height), Color.Red);
            if (!CollisionRect.IsEmpty)
                d3d.DrawRectEmpty(new Rectangle((CollisionRect.X + (FrameRect.X + AnchorPoint.X)) - hScrollBar1.Value,
                    (CollisionRect.Y + (FrameRect.Y + AnchorPoint.Y)) - vScrollBar1.Value,
                    CollisionRect.Width, CollisionRect.Height), Color.Black);
            
            if (!AnchorPoint.IsEmpty)
                d3d.DrawRect(new Rectangle( (FrameRect.X + (AnchorPoint.X - pointSize.Width/2)) - hScrollBar1.Value,
                        (FrameRect.Y + (AnchorPoint.Y - pointSize.Height/2)) - vScrollBar1.Value,
                        pointSize.Width, pointSize.Height), Color.DarkGreen);

            if (!TriggerPoint.IsEmpty)
                d3d.DrawRect(new Rectangle((FrameRect.X + (TriggerPoint.X - pointSize.Width / 2)) - hScrollBar1.Value,
                        (FrameRect.Y + (TriggerPoint.Y - pointSize.Height / 2)) - vScrollBar1.Value,
                        pointSize.Width, pointSize.Height), Color.Purple);
            d3d.Present(panelSheet);

            // animation panel playing
            // should draw the rects for the other stuff and the points too
            // to make sure they are accurate
            d3d.Clear(255, 255, 255);
            d3d.SpriteBegin();
            Point panel = new Point(panelAnimation.Width / 2, panelAnimation.Height - panelAnimation.Height / 4);
            if (sheetID > -1)
            {
                if (!isPlaying && FrameRect != Rectangle.Empty && AnchorPoint != Point.Empty)
                {
                    if (framesList.Count != 0)
                    {
                        if (listBoxFramesList.SelectedIndex > -1)
                        {
                            if (framesList[listBoxFramesList.SelectedIndex].DrawRect != Rectangle.Empty &&
                                framesList[listBoxFramesList.SelectedIndex].Anchor != Point.Empty)
                            {
                                Rectangle tmpFrameRect = framesList[listBoxFramesList.SelectedIndex].DrawRect;
                                Point tmpAnchor = framesList[listBoxFramesList.SelectedIndex].Anchor;
                                tm.Draw(sheetID, panel.X - tmpAnchor.X, panel.Y - tmpAnchor.Y, scaleofFrame,
                                    scaleofFrame, tmpFrameRect, 0, 0, 0, Color.White);
                            }
                            else
                                tm.Draw(sheetID, panel.X - AnchorPoint.X, panel.Y - AnchorPoint.Y, scaleofFrame, scaleofFrame, FrameRect, 0, 0, 0, Color.White);
                        }
                        else
                            tm.Draw(sheetID, panel.X - AnchorPoint.X, panel.Y - AnchorPoint.Y, scaleofFrame, scaleofFrame, FrameRect, 0, 0, 0, Color.White);
                    }
                    else
                        tm.Draw(sheetID, panel.X - AnchorPoint.X, panel.Y - AnchorPoint.Y, scaleofFrame, scaleofFrame, FrameRect, 0, 0, 0, Color.White);
                }
                else
                {
                    if (framesList.Count != 0)
                    {
                        Rectangle drawRect = framesList[counter].DrawRect;
                        Point anchor = framesList[counter].Anchor;
                        tm.Draw(sheetID, panel.X - (anchor.X * (int)scaleofFrame),
                            panel.Y - (anchor.Y * (int)scaleofFrame), scaleofFrame,
                            scaleofFrame, drawRect, 0, 0, 0, Color.White);
                    }
                }
            }
            d3d.SpriteEnd();
            // TODO: right here we need to make sure we're drawing per frame the rects
            // based on the frameslist index... Collision, Attack, and Trigger Point
            // Attack Rect has right values, but not rendering properly in the sheet panel
            // Trigger point is having the same issues.
            if (AnchorPoint != Point.Empty)
            {
                d3d.DrawRect(new Rectangle(panel.X - pointSize.Width / 2,
                    panel.Y - pointSize.Height / 2, pointSize.Width, pointSize.Height),
                    Color.DarkGreen);
            }
            if (TriggerPoint != Point.Empty)
            {
                d3d.DrawRect(new Rectangle(panel.X + (TriggerPoint.X - pointSize.Width/2),
                    panel.Y + (TriggerPoint.Y - pointSize.Height/2), pointSize.Width,
                    pointSize.Height), Color.Purple);
            }
            if (CollisionRect != Rectangle.Empty)
            {
                Rectangle tmp = new Rectangle(panel.X - CollisionRect.X, panel.Y - CollisionRect.Y,
                    CollisionRect.Width, CollisionRect.Height);
                d3d.DrawRectEmpty(new Rectangle(panel.X + CollisionRect.X,panel.Y + CollisionRect.Y,
                    CollisionRect.Width,CollisionRect.Height), Color.Black);
            }
            if (AttackRect != Rectangle.Empty)
            {
                d3d.DrawRectEmpty(new Rectangle(panel.X + AttackRect.X, panel.Y + AttackRect.Y,
                    AttackRect.Width, AttackRect.Height), Color.Red);
            }

            d3d.Present(panelAnimation);
        }
        internal void Update(float fElapsedTime)
        {
            fTimeStep += fElapsedTime * animSpeed;

            // showing buttons
            if (sheetID > -1)
            {
                buttonFrameRect.Enabled = true;
            }
            else
                buttonFrameRect.Enabled = false;
            if (FrameRect != Rectangle.Empty)
            {
                buttonAnchorPoint.Enabled = true;
            }
            else
                buttonAnchorPoint.Enabled = false;
            if (AnchorPoint != Point.Empty)
            {
                buttonCollisionRect.Enabled = true;
                buttonAttackRect.Enabled = true;
                buttonTriggerPoint.Enabled = true;
            }
            else
            {
                buttonCollisionRect.Enabled = false;
                buttonAttackRect.Enabled = false;
                buttonTriggerPoint.Enabled = false;
            }
            
            // for animation timing
            // elapsedtime > frame duration of list[counter]
            // then increment counter
            if (isPlaying)
            {
                if (framesList.Count > 0 && fTimeStep >= framesList[counter].FrameDuration)
                {
                    counter++;
                    if (!isLooping && counter >= framesList.Count)
                    {
                        isPlaying = false;
                        counter = 0;
                    }
                    if (counter >= framesList.Count)
                        counter = 0;
                    listBoxFramesList.SelectedIndex = counter;
                    fTimeStep = 0;
                }
            }
        }
        private void buttonAddFrame_Click(object sender, EventArgs e)
        {
            if (FrameRect != Rectangle.Empty && AnchorPoint != Point.Empty)
            {
                Frame fr = new Frame();
                fr.Anchor = AnchorPoint;
                fr.Triggerpoint = TriggerPoint;
                fr.AttackRect = AttackRect;
                fr.ColRect = CollisionRect;
                fr.DrawRect = FrameRect;
                fr.FrameDuration = (float)numericUpDownFrameDuration.Value;
                fr.TriggerName = textBoxTriggerName.Text.ToString();

                // TODO: frame num should change based on where it is in the list...
                // that way I wont ever have two of the same number frame // see notes
                fr.FrameNum = framesList.Count + 1;
                framesList.Add(fr);
                listBoxFramesList.Items.Add(fr);

                textBoxTriggerName.Text = string.Empty;
            }
            else
            {
                if (FrameRect == Rectangle.Empty)
                    MessageBox.Show("Frame must have a Draw Rect", "Error");
                else
                    MessageBox.Show("Frame must have an Anchor Point", "Error");
            }
        }
        private void buttonDeleteFrame_Click(object sender, EventArgs e)
        {
            // TODO: need to make this update the frame number of all subsequent frames
            // Loop through the frameslist to do it
            if (listBoxFramesList.Items.Count != 0 && listBoxFramesList.SelectedIndex != -1)
            {
                framesList.RemoveAt(listBoxFramesList.SelectedIndex);
                for (int i = listBoxFramesList.SelectedIndex; i < framesList.Count; ++i)
                {
                    framesList&#91;i&#93;.FrameNum--;
                }
                listBoxFramesList.Items.Clear();
                for (int i = 0; i < framesList.Count; ++i)
                {
                    listBoxFramesList.Items.Add(framesList&#91;i&#93;);
                }
                listBoxFramesList.Invalidate();
                counter = 0;
            }
        }
        private void buttonEditFrame_Click(object sender, EventArgs e)
        {
            // update
            if (listBoxFramesList.SelectedIndex > -1)
            {
                framesList[listBoxFramesList.SelectedIndex].Anchor = AnchorPoint;
                framesList[listBoxFramesList.SelectedIndex].AttackRect = AttackRect;
                framesList[listBoxFramesList.SelectedIndex].ColRect = CollisionRect;
                framesList[listBoxFramesList.SelectedIndex].DrawRect = FrameRect;
                framesList[listBoxFramesList.SelectedIndex].FrameDuration = (float)numericUpDownFrameDuration.Value;
                framesList[listBoxFramesList.SelectedIndex].Triggerpoint = TriggerPoint;
                framesList[listBoxFramesList.SelectedIndex].TriggerName = textBoxTriggerName.Text;
            }
        }
        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private void FormAnimationEditor_FormClosing(object sender, FormClosingEventArgs e)
        {
            // TODO: ask if want to save, then exit.
            if (modified)
            {
                DialogResult result = MessageBox.Show("Would you like to save before exit?", "Exit",
                    MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    saveToolStripMenuItem_Click(sender, e);
                }
                tm.ShutdownXNATextureManager();
                Looping = false;
            }
            else
            {
                tm.ShutdownXNATextureManager();
                Looping = false;
            }
        }
        private void listBoxFramesList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBoxFramesList.SelectedIndex > -1)
            {
                Frame fr = (Frame)listBoxFramesList.Items[listBoxFramesList.SelectedIndex];
                FrameRect = fr.DrawRect;
                AttackRect = fr.AttackRect;
                CollisionRect = fr.ColRect;
                AnchorPoint = fr.Anchor;
                TriggerPoint = fr.Triggerpoint;
                numericUpDownFrameDuration.Value = (decimal)fr.FrameDuration;
                textBoxTriggerName.Text = fr.TriggerName;
            }
        }
        private void comboBoxZoom_SelectedIndexChanged(object sender, EventArgs e)
        {
            // TODO: make this work so that it scales properly... an option for later 
            // if I have the time
            if (comboBoxZoom.SelectedIndex == 0)
            {
                sheetScale = 1.0f * .5f;
            }
            else if (comboBoxZoom.SelectedIndex == 1)
            {
                sheetScale = 1.0f * 1.0f;
            }
            else if (comboBoxZoom.SelectedIndex == 2)
            {
                sheetScale = 1.0f * 1.5f;
            }
            else if (comboBoxZoom.SelectedIndex == 3)
            {
                sheetScale = 1.0f * 2.0f;
            }
            else if (comboBoxZoom.SelectedIndex == 4)
            {
                sheetScale = 1.0f * 2.5f;
            }
        }
        private void panelSheet_MouseMove(object sender, MouseEventArgs e)
        {
            if (mouseIsDown)
            {
                mouse = e.Location;
                readyToDraw = true;
            }
            switch (drawtype)
            {
                case (int)drawType.FRAME:
                    {
                        if (mouseIsDown && readyToDraw)
                        {
                            Point offset = new Point(0, 0);
                            offset.X += hScrollBar1.Value;
                            offset.Y += vScrollBar1.Value;

                            FrameRect = NormRect(new Point(mouse.X + offset.X, mouse.Y + offset.Y),
                                new Point(rectStartPos.X + offset.X, rectStartPos.Y + offset.Y));
                        }

                        numericUpDownRectX.Value = FrameRect.X;
                        numericUpDownRectY.Value = FrameRect.Y;
                        numericUpDownRectWidth.Value = FrameRect.Width;
                        numericUpDownRectHeight.Value = FrameRect.Height;

                        break;
                    }
                case (int)drawType.ATTACK:
                    {
                        if (mouseIsDown && readyToDraw)
                        {
                            Point offset = new Point(0, 0);
                            offset.X += hScrollBar1.Value;// *(int)sheetScale;
                            offset.Y += vScrollBar1.Value;// *(int)sheetScale;

                            Rectangle tmpRect = NormRect(new Point(mouse.X + offset.X, mouse.Y + offset.Y),
                                new Point(rectStartPos.X + offset.X, rectStartPos.Y + offset.Y));

                            AttackRect = new Rectangle(tmpRect.X - (FrameRect.X + AnchorPoint.X),
                                tmpRect.Y - (FrameRect.Y + AnchorPoint.Y), tmpRect.Width, tmpRect.Height);
                        }

                        numericUpDownRectX.Value = AttackRect.X;
                        numericUpDownRectY.Value = AttackRect.Y;
                        numericUpDownRectWidth.Value = AttackRect.Width;
                        numericUpDownRectHeight.Value = AttackRect.Height;

                        break;
                    }
                case (int)drawType.COLLISION:
                    {
                        if (mouseIsDown && readyToDraw)
                        {
                            Point offset = new Point(0,0);
                            offset.X += hScrollBar1.Value;// *(int)sheetScale;
                            offset.Y += vScrollBar1.Value;// *(int)sheetScale;

                            Rectangle tmpRect = NormRect(new Point(mouse.X + offset.X, mouse.Y + offset.Y),
                                new Point(rectStartPos.X + offset.X, rectStartPos.Y + offset.Y));

                            CollisionRect = new Rectangle(tmpRect.X - (FrameRect.X + AnchorPoint.X),
                                tmpRect.Y - (FrameRect.Y + AnchorPoint.Y), tmpRect.Width, tmpRect.Height);
                        }
                        numericUpDownRectX.Value = CollisionRect.X;
                        numericUpDownRectY.Value = CollisionRect.Y;
                        numericUpDownRectWidth.Value = CollisionRect.Width;
                        numericUpDownRectHeight.Value = CollisionRect.Height;
                      
                        break;
                    }
            }            
        }
        private void panelSheet_MouseDown_1(object sender, MouseEventArgs e)
        {
            if (!mouseIsDown)
            {
                rectStartPos = e.Location;
            }
            mouseIsDown = true;
        }
        private void panelSheet_MouseUp(object sender, MouseEventArgs e)
        {
            if (mouseIsDown)
            {
                mouseIsDown = false;
            }
        }
        private void buttonFrameRect_Click(object sender, EventArgs e)
        {
            drawtype = (int)drawType.FRAME;
            if (FrameRect != Rectangle.Empty)
            {
                numericUpDownRectX.Value = FrameRect.X;
                numericUpDownRectY.Value = FrameRect.Y;
                numericUpDownRectWidth.Value = FrameRect.Width;
                numericUpDownRectHeight.Value = FrameRect.Height;
            }
        }
        private void buttonAttackRect_Click(object sender, EventArgs e)
        {
            drawtype = (int)drawType.ATTACK;
            if (AttackRect != Rectangle.Empty)
            {
                numericUpDownRectX.Value = AttackRect.X;
                numericUpDownRectY.Value = AttackRect.Y;
                numericUpDownRectWidth.Value = AttackRect.Width;
                numericUpDownRectHeight.Value = AttackRect.Height;
            }
        }
        private void buttonCollisionRect_Click(object sender, EventArgs e)
        {
            drawtype = (int)drawType.COLLISION;
            if (CollisionRect != Rectangle.Empty)
            {
                numericUpDownRectX.Value = CollisionRect.X;
                numericUpDownRectY.Value = CollisionRect.Y;
                numericUpDownRectWidth.Value = CollisionRect.Width;
                numericUpDownRectHeight.Value = CollisionRect.Height;
            }
        }
        private void buttonAnchorPoint_Click(object sender, EventArgs e)
        {
            drawtype = (int)drawType.ANCHOR;
            if (AnchorPoint != Point.Empty)
            {
                numericUpDownPointX.Value = AnchorPoint.X;
                numericUpDownPointY.Value = AnchorPoint.Y;
            }
        }
        private void buttonTriggerPoint_Click(object sender, EventArgs e)
        {
            drawtype = (int)drawType.TRIGGER;
            if (TriggerPoint != Point.Empty)
            {
                numericUpDownPointX.Value = TriggerPoint.X;
                numericUpDownPointY.Value = TriggerPoint.Y;
            }
        }
        private void numericUpDownRectLeft_ValueChanged(object sender, EventArgs e)
        {
            if (drawtype == (int)drawType.FRAME)
                FrameRect.X = (int)numericUpDownRectX.Value;
            else if (drawtype == (int)drawType.COLLISION)
                CollisionRect.X = (int)numericUpDownRectX.Value;
            else if (drawtype == (int)drawType.ATTACK)
                AttackRect.X = (int)numericUpDownRectX.Value;
        }
        private void numericUpDownRectTop_ValueChanged(object sender, EventArgs e)
        {
            if (drawtype == (int)drawType.FRAME)
                FrameRect.Y = (int)numericUpDownRectY.Value;
            else if (drawtype == (int)drawType.COLLISION)
                CollisionRect.Y = (int)numericUpDownRectY.Value;
            else if (drawtype == (int)drawType.ATTACK)
                AttackRect.Y = (int)numericUpDownRectY.Value;
        }
        private void numericUpDownRectRight_ValueChanged(object sender, EventArgs e)
        {
            if (drawtype == (int)drawType.FRAME)
                FrameRect.Width = (int)numericUpDownRectWidth.Value;
            else if (drawtype == (int)drawType.COLLISION)
                CollisionRect.Width = (int)numericUpDownRectWidth.Value;
            else if (drawtype == (int)drawType.ATTACK)
                AttackRect.Width = (int)numericUpDownRectWidth.Value;
        }
        private void numericUpDownRectBottom_ValueChanged(object sender, EventArgs e)
        {
            if (drawtype == (int)drawType.FRAME)
                FrameRect.Height = (int)numericUpDownRectHeight.Value;
            else if (drawtype == (int)drawType.COLLISION)
                CollisionRect.Height = (int)numericUpDownRectHeight.Value;
            else if (drawtype == (int)drawType.ATTACK)
                AttackRect.Height = (int)numericUpDownRectHeight.Value;
        }
        private void numericUpDownPointX_ValueChanged(object sender, EventArgs e)
        {
            switch (drawtype)
            {
                case (int)drawType.ANCHOR:
                    AnchorPoint.X = (int)numericUpDownPointX.Value;
                    break;
                case (int)drawType.TRIGGER:
                    TriggerPoint.X = (int)numericUpDownPointX.Value;
                    break;
            }
        }
        private void numericUpDownPointY_ValueChanged(object sender, EventArgs e)
        {
            switch (drawtype)
            {
                case (int)drawType.ANCHOR:
                    AnchorPoint.Y = (int)numericUpDownPointY.Value;
                    break;
                case (int)drawType.TRIGGER:
                    TriggerPoint.Y = (int)numericUpDownPointY.Value;
                    break;
            }
        }
        private void buttonAnimPlay_Click(object sender, EventArgs e)
        {
            // dont forget looping
            counter = 0;
            isPlaying = true;
        }
        private void buttonAnimStop_Click(object sender, EventArgs e)
        {
            isPlaying = false;
        }
        private void buttonAnimReset_Click(object sender, EventArgs e)
        {
            counter = 0;
            if(listBoxFramesList.SelectedIndex > -1)
                listBoxFramesList.SelectedIndex = 0;
        }
        private void checkBoxLooping_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBoxLooping.Checked == true)
                isLooping = true;
            else
                isLooping = false;
        }
        private void numericUpDownAnimSpeed_ValueChanged(object sender, EventArgs e)
        {
            animSpeed = (float)numericUpDownAnimSpeed.Value;
            modified = true;
        }
        private void buttonAddAnimation_Click(object sender, EventArgs e)
        {
            // take name from text box and add frames in FramesList to animation list's frames
            // clear frameslist, and set it so when selecting animation in animlist it sets
            // the frames list to that anim's frames list
            if (textBoxAnimationName.Text != string.Empty && framesList.Count != 0)
            {
                Animation anim = new Animation();
                anim.AnimName1 = textBoxAnimationName.Text;
                anim.SheetFilename = sheetFile;
                anim.AnimSpeed = numericUpDownAnimSpeed.Value;
                foreach (Frame f in framesList)
                {
                    anim.AddFrame(f);
                }
                animList.Add(anim);
                listBoxAnimations.Items.Add(anim);
                // cleanup
                framesList.Clear();
                // clear rects and points
                FrameRect = Rectangle.Empty;
                AttackRect = Rectangle.Empty;
                CollisionRect = Rectangle.Empty;
                AnchorPoint = Point.Empty;
                TriggerPoint = Point.Empty;
                counter = 0;

                listBoxFramesList.Items.Clear();
                textBoxAnimationName.Clear();
                textBoxTriggerName.Text = string.Empty;
            }
            else
            {
                if (textBoxAnimationName.Text == string.Empty)
                    MessageBox.Show("Animation must have a name","Error");
                else
                    MessageBox.Show("Animation must have frames in it", "Error");
            }
            modified = true;

        }
        private void buttonDeleteAnimation_Click(object sender, EventArgs e)
        {
            // same as frameList box delete basically
            if (listBoxAnimations.SelectedIndex > -1)
            {
                Animation anim = (Animation)listBoxAnimations.Items[listBoxAnimations.SelectedIndex];
                animList.RemoveAt(listBoxAnimations.SelectedIndex);
                listBoxAnimations.Items.RemoveAt(listBoxAnimations.SelectedIndex);
            }
            modified = true;
        }
        private void listBoxAnimations_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBoxAnimations.SelectedIndex > -1)
            {
                // cleanup first
                framesList.Clear();
                listBoxFramesList.Items.Clear();
                // set framesList to selected animation's frames list.
                Animation anim = (Animation)listBoxAnimations.Items[listBoxAnimations.SelectedIndex];
                textBoxAnimationName.Text = anim.AnimName1;
                sheetFile = anim.SheetFilename;
                numericUpDownAnimSpeed.Value = anim.AnimSpeed;
                foreach (Frame f in anim.Frames)
                {
                    listBoxFramesList.Items.Add(f);
                    framesList.Add(f);
                }
                sheetID = tm.LoadTexture(anim.SheetFilename);
                // TODO: set up the scrollbars better
                if (tm.GetTextureWidth(sheetID) > panelSheet.Width ||
                    tm.GetTextureHeight(sheetID) > panelSheet.Height)
                {
                    hScrollBar1.Maximum = tm.GetTextureWidth(sheetID) - panelSheet.Width + 15;
                    vScrollBar1.Maximum = tm.GetTextureHeight(sheetID) - panelSheet.Height + 15;
                }
                else
                {
                    hScrollBar1.Maximum = 0;
                    vScrollBar1.Maximum = 0;
                }
                // maximums
                numericUpDownRectX.Maximum = tm.GetTextureWidth(sheetID) + 1000;
                numericUpDownRectY.Maximum = tm.GetTextureHeight(sheetID) + 1000;
                numericUpDownRectWidth.Maximum = tm.GetTextureWidth(sheetID) + 1000;
                numericUpDownRectHeight.Maximum = tm.GetTextureHeight(sheetID) + 1000;
                numericUpDownPointX.Maximum = tm.GetTextureWidth(sheetID) + 1000;
                numericUpDownPointY.Maximum = tm.GetTextureHeight(sheetID) + 1000;
                // minimums
                numericUpDownRectX.Minimum = -tm.GetTextureWidth(sheetID);
                numericUpDownRectY.Minimum = -tm.GetTextureHeight(sheetID);
                numericUpDownRectWidth.Minimum = -tm.GetTextureWidth(sheetID);
                numericUpDownRectHeight.Minimum = -tm.GetTextureHeight(sheetID);
                numericUpDownPointX.Minimum = -tm.GetTextureWidth(sheetID);
                numericUpDownPointY.Minimum = -tm.GetTextureHeight(sheetID);

                isPlaying = false;
            }
        }
        private void panelSheet_MouseClick(object sender, MouseEventArgs e)
        {
            if (drawtype == (int)drawType.ANCHOR)
            {
                // TODO: utilize the point in rect thing to see if they clicked
                // on the point already in there to move it??
                // base it off FrameRect
                Point offset = e.Location;
                offset.X += hScrollBar1.Value;
                offset.Y += vScrollBar1.Value;

                AnchorPoint = new Point(offset.X - FrameRect.X,offset.Y - FrameRect.Y);

                if (AnchorPoint.X > -1 && AnchorPoint.Y > -1)
                {
                    numericUpDownPointX.Value = AnchorPoint.X;
                    numericUpDownPointY.Value = AnchorPoint.Y;
                }
            }
            else if (drawtype == (int)drawType.TRIGGER)
            {
                // TODO: base it off Anchor Point
                // this is all messed up too
                Point offset = e.Location;
                offset.X += hScrollBar1.Value;
                offset.Y += vScrollBar1.Value;

                TriggerPoint = new Point(offset.X -(FrameRect.X + AnchorPoint.X),
                    offset.Y - (FrameRect.Y + AnchorPoint.Y));

                if (TriggerPoint.X > -1 && TriggerPoint.Y > -1)
                {
                    numericUpDownPointX.Value = TriggerPoint.X;
                    numericUpDownPointY.Value = TriggerPoint.Y;
                }
            }
        }
        private void buttonAnimPrevFrame_Click(object sender, EventArgs e)
        {
            if(listBoxFramesList.SelectedIndex > -1 && 
                listBoxFramesList.SelectedIndex > 0)
                listBoxFramesList.SelectedIndex--;
        }
        private void buttonAnimNextFrame_Click(object sender, EventArgs e)
        {
            if(listBoxFramesList.SelectedIndex > -1 && 
                listBoxFramesList.SelectedIndex < listBoxFramesList.Items.Count - 1)
                listBoxFramesList.SelectedIndex++;
        }
        private void buttonClear_Click(object sender, EventArgs e)
        {
            framesList.Clear();
            listBoxFramesList.Items.Clear();
            counter = 0;
        }
        private void buttonDeselect_Click(object sender, EventArgs e)
        {
            listBoxFramesList.ClearSelected();
        }
        private void buttonAnimClear_Click(object sender, EventArgs e)
        {
            animList.Clear();
            listBoxAnimations.Items.Clear();
            modified = true;
        }
        private void buttonAnimUpdate_Click(object sender, EventArgs e)
        {
            // update the animation list's animations to reflect any added
            // frames or changes to frames.
            if (listBoxAnimations.SelectedIndex > -1)
            {
                animList[listBoxAnimations.SelectedIndex].Frames.Clear();
                foreach (Frame f in framesList)
                {
                    animList[listBoxAnimations.SelectedIndex].Frames.Add(f);
                }
                animList[listBoxAnimations.SelectedIndex].SheetFilename = sheetFile;
                animList[listBoxAnimations.SelectedIndex].AnimSpeed = numericUpDownAnimSpeed.Value;
                animList[listBoxAnimations.SelectedIndex].AnimName1 = textBoxAnimationName.Text;
            }
            modified = true;
        }
        private void FormAnimationEditor_Shown(object sender, EventArgs e)
        {
            const string message = "Plese select a folder for your workspace.";
            const string caption = "Animation Editor - Workspace";
            var result = MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Information);

            // If the no button was pressed ...
            if (result == DialogResult.OK)
            {
                FolderBrowserDialog folder = new FolderBrowserDialog();
                if (folder.ShowDialog(this) == DialogResult.OK)
                {
                    System.IO.Directory.SetCurrentDirectory(folder.SelectedPath);
                }
            }

            modified = false;
        }
        private void changeWorkingDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog folder = new FolderBrowserDialog();
            if (folder.ShowDialog(this) == DialogResult.OK)
            {
                System.IO.Directory.SetCurrentDirectory(folder.SelectedPath);
            }
        }
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (modified)
            {
                DialogResult result = MessageBox.Show("Would you like to save?", "New",
                    MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    // save
                    saveToolStripMenuItem_Click(sender, e);

                    animList.Clear();
                    listBoxAnimations.Items.Clear();
                    framesList.Clear();
                    listBoxFramesList.Items.Clear();
                    textBoxAnimationName.Text = string.Empty;
                    textBoxTriggerName.Text = string.Empty;
                    FrameRect = Rectangle.Empty;
                    CollisionRect = Rectangle.Empty;
                    AttackRect = Rectangle.Empty;
                    AnchorPoint = Point.Empty;
                    TriggerPoint = Point.Empty;
                    numericUpDownPointX.Value = 0;
                    numericUpDownPointY.Value = 0;
                    numericUpDownRectX.Value = 0;
                    numericUpDownRectY.Value = 0;
                    numericUpDownRectWidth.Value = 0;
                    numericUpDownRectHeight.Value = 0;
                }
                else
                {
                    animList.Clear();
                    listBoxAnimations.Items.Clear();
                    framesList.Clear();
                    listBoxFramesList.Items.Clear();
                    textBoxAnimationName.Text = string.Empty;
                    textBoxTriggerName.Text = string.Empty;
                    FrameRect = Rectangle.Empty;
                    CollisionRect = Rectangle.Empty;
                    AttackRect = Rectangle.Empty;
                    AnchorPoint = Point.Empty;
                    TriggerPoint = Point.Empty;
                    numericUpDownPointX.Value = 0;
                    numericUpDownPointY.Value = 0;
                    numericUpDownRectX.Value = 0;
                    numericUpDownRectY.Value = 0;
                    numericUpDownRectWidth.Value = 0;
                    numericUpDownRectHeight.Value = 0;
                }
            }
            else
            {
                animList.Clear();
                listBoxAnimations.Items.Clear();
                framesList.Clear();
                listBoxFramesList.Items.Clear();
                textBoxAnimationName.Text = string.Empty;
                textBoxTriggerName.Text = string.Empty;
                FrameRect = Rectangle.Empty;
                CollisionRect = Rectangle.Empty;
                AttackRect = Rectangle.Empty;
                AnchorPoint = Point.Empty;
                TriggerPoint = Point.Empty;
                numericUpDownPointX.Value = 0;
                numericUpDownPointY.Value = 0;
                numericUpDownRectX.Value = 0;
                numericUpDownRectY.Value = 0;
                numericUpDownRectWidth.Value = 0;
                numericUpDownRectHeight.Value = 0;
            }
        }
    }
}

Here is a screen shot of the Animation Editor.
Animation Editor