private void btnAddActor_Click(object sender, EventArgs e)
        {
            if (
                MessageBox.Show("Are you sure you want to add this to the scene?", "Add Actor Confirmation", MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            // Disable all thse
            tbName.Enabled      = false;
            cbRole.Enabled      = false;
            gbSequences.Enabled = false;
            gbPreview.Enabled   = false;
            btnSave.Enabled     = false;

            pgBar.Style = ProgressBarStyle.Continuous;

            // Create our actor
            Actor = new EditorActor(Globals.Game, string.Empty, string.Empty);

            if (tvSequences.Nodes.Count >= 0)
            {
                // Set our Actors Role
                switch (cbRole.Text)
                {
                case "Player":
                    Actor.Role = ActorRole.Player;
                    break;

                case "Enemy":
                    Actor.Role = ActorRole.Enemy;
                    break;

                case "NPC":
                    Actor.Role = ActorRole.NPC;
                    break;

                case "Prop":
                    Actor.Role = ActorRole.Prop;
                    break;
                }

                Actor.Name = tbName.Text;

                // Init our clip player
                Actor.ClipPlayer = new AnimationPlayer2D(Globals.Game);
                Actor.ClipPlayer.Initialize();

                // Loop thru the Tree view controls Nodes adding our Key Frames to our Clip Player
                foreach (TreeNode node in tvSequences.Nodes)
                {
                    // Reset our frame index
                    {
                        int endFrameIndex = (node.Nodes.Count - 1);

                        Sequence2D sequence = new Sequence2D(node.Name);
                        sequence.StartFrame = 0;
                        sequence.EndFrame   = endFrameIndex;

                        // Add our Frames
                        foreach (TreeNode child in tvSequences.Nodes[node.Name].Nodes)
                        {
                            KeyFrame2D frame = new KeyFrame2D();
                            frame.Duration      = 1f;
                            frame.AssetFilename = child.Tag.ToString();

                            sequence.Frames.Add(frame);
                        }

                        // Add our Sequence
                        Actor.ClipPlayer.Sequences.Add(sequence);
                    }
                }

                // Generate our Sprite Sheet for the Clip Player
                SpriteTools.GenerateSpriteSheet(Actor, Globals.AppSettings.ProjectPath, tbName.Text);

                Actor.ClipPlayer.Texture = Catalyst3D.XNA.Engine.UtilityClasses.Utilitys.TextureFromFile(
                    Globals.Game.GraphicsDevice, Globals.AppSettings.ProjectPath + @"\" + Actor.SpriteSheetFileName);
            }

            // Default to the idle sequence
            if (Actor.Sequences.Count > 0)
            {
                Actor.Play(Actor.ClipPlayer.Sequences[0].Name, true);
            }

            // Add it to our Scene
            Globals.ActorAdded.Invoke(Actor);

            tvSequences.Nodes.Clear();

            Close();
        }
        private void LoadProject(bool showresult)
        {
            // Create our Open File Dialog
            OpenFileDialog dia = new OpenFileDialog();

            dia.Filter           = "Catalyst3D Actor File|*.a2d";
            dia.InitialDirectory = Globals.AppSettings.ProjectPath;

            if (dia.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if (Globals.IsProjectLoaded)
                    {
                        // Flush the sequencer drop down for available sequences
                        tsSequence.Items.Clear();
                        conRenderer.Manager.CurrentScreen.VisualObjects.Clear();
                    }

                    // Store our current projects path and file name
                    Globals.AppSettings.ProjectPath     = Path.GetDirectoryName(dia.FileName);
                    Globals.AppSettings.ProjectFilename = Path.GetFileName(dia.FileName);

                    Actor original = Serializer.Deserialize <Actor>(dia.FileName);

                    EditorActor actor = new EditorActor(Globals.Game, string.Empty, original.AssetName)
                    {
                        AssetName           = original.AssetName,
                        SpriteSheetFileName = original.SpriteSheetFileName,
                        Direction           = original.Direction,
                        DrawOrder           = original.DrawOrder,
                        UpdateOrder         = original.UpdateOrder,
                        Name        = original.Name,
                        PlayerIndex = original.PlayerIndex,
                        Position    = Vector2.Zero,
                        Role        = original.Role,
                        Scale       = original.Scale,
                        Enabled     = original.Enabled,
                        Visible     = original.Visible,
                        GameScreen  = Globals.Renderer
                    };

                    actor.ClipPlayer = new AnimationPlayer2D(Globals.Game)
                    {
                        AssetName  = original.ClipPlayer.AssetName,
                        Sequences  = original.ClipPlayer.Sequences,
                        GameScreen = Globals.Renderer
                    };

                    actor.ClipPlayer.Initialize();

                    actor.ClipPlayer.Texture = Catalyst3D.XNA.Engine.UtilityClasses.Utilitys.TextureFromFile(Globals.Game.GraphicsDevice, Globals.AppSettings.ProjectPath + @"\" + original.SpriteSheetFileName);

                    // Play the first sequence by default after loading
                    if (actor.ClipPlayer.Sequences.Count > 0)
                    {
                        actor.Play(actor.ClipPlayer.Sequences[0].Name, true);
                    }

                    actor.Initialize();

                    conRenderer.Actor = actor;

                    pgGrid.SelectedObject = actor;

                    Globals.Renderer.AddVisualObject(actor);

                    Globals.RefreshSequenceDropDown.Invoke(false);

                    Globals.IsProjectLoaded = true;
                }
                catch
                {
                    MessageBox.Show("Error: Failed to load the sprite sheet for this actor project!");

                    Globals.IsProjectLoaded = false;

                    conRenderer.Actor = null;

                    if (conRenderer.Manager.CurrentScreen != null)
                    {
                        conRenderer.Manager.CurrentScreen.VisualObjects.Clear();
                    }
                }
            }
        }