Inheritance: MonoBehaviour
Example #1
0
        /// <summary>
        /// Event Handler that initiate a new animation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnNewAnimation_Click(object sender, EventArgs e)
        {
            saveFile.AddExtension = true;
            saveFile.DefaultExt   = "png";
            saveFile.Filter       = "PNG Files | *.png";
            if (saveFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                currentPath = saveFile.FileName;

                //Traitement du nom du fichier
                string filename = Path.GetFileNameWithoutExtension(currentPath);
                string charName = filename;
                string animName = "standing";
                if (filename.Contains("_"))
                {
                    string[] name = filename.Split("_".ToCharArray());
                    if (name.Length >= 2)
                    {
                        charName = name[0];
                        animName = name[1];
                    }
                }

                animation = new Anim();
                animation.CharacterName    = charName;
                animation.AnimName         = animName;
                txtCharacterName.Text      = animation.CharacterName;
                txtAnimationName.Text      = animation.AnimName;
                listDown.Sprites           = animation.SpritesDown;
                listDownLeft.Sprites       = animation.SpritesDownLeft;
                listDownRight.Sprites      = animation.SpritesDownRight;
                listLeft.Sprites           = animation.SpritesLeft;
                listRight.Sprites          = animation.SpritesRight;
                listUp.Sprites             = animation.SpritesUp;
                listUpLeft.Sprites         = animation.SpritesUpLeft;
                listUpRight.Sprites        = animation.SpritesUpRight;
                listDown.SelectedAnim      = animation;
                listDownLeft.SelectedAnim  = animation;
                listDownRight.SelectedAnim = animation;
                listLeft.SelectedAnim      = animation;
                listRight.SelectedAnim     = animation;
                listUp.SelectedAnim        = animation;
                listUpLeft.SelectedAnim    = animation;
                listUpRight.SelectedAnim   = animation;
                SelectedSprite             = null;
                listDown.RefreshList();
                listDownLeft.RefreshList();
                listDownRight.RefreshList();
                listLeft.RefreshList();
                listRight.RefreshList();
                listUp.RefreshList();
                listUpLeft.RefreshList();
                listUpRight.RefreshList();
                ActivateEverything();
                AnimPreview.Refresh();
            }
        }
Example #2
0
        public void Execute(object sender, ResourceEventArgs es)
        {
            if (!ChangeEnabledStateEventHandler(sender, es))
            {
                return;
            }

            try
            {
                AnimPreview.Execute(es.Items[0].Resource);
            }
            catch (Exception ex)
            {
                Helper.ExceptionMessage(ex);
            }
        }
Example #3
0
        /// <summary>
        /// Event handler that load an animation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLoadAnimation_Click(object sender, EventArgs e)
        {
            openFile.AddExtension = true;
            openFile.DefaultExt   = "png";
            openFile.Filter       = "PNG Files | *.png";
            if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                currentPath = openFile.FileName;

                //Traitement du nom du fichier
                string filename = Path.GetFileNameWithoutExtension(currentPath);
                string charName = filename;
                string animName = "standing";
                int    ways     = 0;
                int    width    = 0;
                if (filename.Contains("_"))
                {
                    string[] name = filename.Split("_".ToCharArray());
                    if (name.Length >= 4)
                    {
                        charName = name[0];
                        animName = name[1];
                        ways     = Convert.ToInt32(name[2].Replace("ways", string.Empty));
                        width    = Convert.ToInt32(name[3].Replace("width", string.Empty));

                        #region Chargement anim
                        animation = new Anim();
                        animation.CharacterName = charName;
                        animation.AnimName      = animName;
                        txtCharacterName.Text   = animation.CharacterName;
                        txtAnimationName.Text   = animation.AnimName;

                        listDown.Sprites           = animation.SpritesDown;
                        listDownLeft.Sprites       = animation.SpritesDownLeft;
                        listDownRight.Sprites      = animation.SpritesDownRight;
                        listLeft.Sprites           = animation.SpritesLeft;
                        listRight.Sprites          = animation.SpritesRight;
                        listUp.Sprites             = animation.SpritesUp;
                        listUpLeft.Sprites         = animation.SpritesUpLeft;
                        listUpRight.Sprites        = animation.SpritesUpRight;
                        listDown.SelectedAnim      = animation;
                        listDownLeft.SelectedAnim  = animation;
                        listDownRight.SelectedAnim = animation;
                        listLeft.SelectedAnim      = animation;
                        listRight.SelectedAnim     = animation;
                        listUp.SelectedAnim        = animation;
                        listUpLeft.SelectedAnim    = animation;
                        listUpRight.SelectedAnim   = animation;
                        SelectedSprite             = null;
                        listDown.RefreshList();
                        listDownLeft.RefreshList();
                        listDownRight.RefreshList();
                        listLeft.RefreshList();
                        listRight.RefreshList();
                        listUp.RefreshList();
                        listUpLeft.RefreshList();
                        listUpRight.RefreshList();
                        ActivateEverything();
                        AnimPreview.Refresh();

                        #region Gestion des sprites existants
                        Bitmap image = Tools.FromFileThenClose(currentPath);
                        if (ways == 4)
                        {
                            listUp.LoadPicture(image, 0, ways, width);
                            listRight.LoadPicture(image, 1, ways, width);
                            listDown.LoadPicture(image, 2, ways, width);
                            listLeft.LoadPicture(image, 3, ways, width);
                        }
                        #endregion
                        #endregion

                        ddpWidth.Value  = animation.MaxSize.Width;
                        ddpHeight.Value = animation.MaxSize.Height;
                    }
                    else
                    {
                        MessageBox.Show("Le fichier est incompatible ou mal formé.");
                    }
                }
                else
                {
                    MessageBox.Show("Le fichier est incompatible ou mal formé.");
                }
            }
        }