public PixelFamilyEdition(Animation animation)
        {
            InitializeComponent();

            Anim = animation;
            Init();
        }
        public AnimationPutEntirePattern(AnimationStudio parent, Animation animation, Int32 CurrentFrameIndex)
        {
            InitializeComponent();
            this.parent = parent;
            this.animation = animation;
            Buffer = new Bitmap(PN_Canvas.Size.Width, PN_Canvas.Size.Height);
            RulerWidth = parent.RulerWidth;
            AbsoluteCenter = new Point(PN_Canvas.Width / 2, PN_Canvas.Height / 2);

            FrameSize = animation.GetPattern().GetFrameSize();
            OriginalSize = animation.GetPattern().GetFrameSize();
            Position = new Point(-FrameSize.Width/2, -FrameSize.Height/2);

            NUM_StartIndex.Maximum = animation.GetPattern().GetFrameCount();
            NUM_StartIndex.Value = 0;

            NUM_EndIndex.Maximum = animation.GetPattern().GetFrameCount();
            NUM_EndIndex.Value = NUM_EndIndex.Maximum;

            NUM_FromFrame.Value = CurrentFrameIndex;
            DDL_Blending.SelectedIndex = 1;

            this.SetStyle(
                ControlStyles.UserPaint |
                ControlStyles.AllPaintingInWmPaint |
                ControlStyles.OptimizedDoubleBuffer, true);
        }
Пример #3
0
        public object Clone()
        {
            Animation anim = new Animation();
            anim.Name = this.Name;
            anim.Frames = this.Frames.Select(x => x.Clone() as AnimationFrame).ToList();
            if (this.Pattern != null) anim.Pattern = this.Pattern.Clone() as AnimationPattern;

            return anim;
        }
Пример #4
0
 public void LoadAnimation(Animation animation)
 {
     this.animation = animation;
     CurrentFrame = 0;
     DrawTimeLine();
     TriggerFrameChange();
 }
Пример #5
0
        private void SetPatternImage(Animation animation, Image image)
        {
            foreach (Control c in PN_Pattern.Controls)
                c.BackgroundImage.Dispose();

            PN_Pattern.Controls.Clear();

            animation.SetPattern(image);

            Int32 Count = 0;
            PatternFrameIndex = null;
            foreach (Image img in animation.CropPattern())
            {
                Panel pn = new Panel();

                // TODO : Change default values to current values
                pn.Size = new Size(192, 192);

                Int32 X = Count % (PN_Pattern.Size.Width / pn.Size.Width) * pn.Size.Width;
                Int32 Y = Count / (PN_Pattern.Size.Width / pn.Size.Height) * pn.Size.Height;

                pn.Location = new Point(X, Y);
                pn.BackgroundImageLayout = ImageLayout.None;
                pn.BackgroundImage = img.Clone() as Image;
                pn.BorderStyle = BorderStyle.FixedSingle;
                pn.Click += new EventHandler(PatternFrameSelected);
                pn.Name = Count.ToString();
                pn.BackColor = Color.White;

                PN_Pattern.Controls.Add(pn);

                img.Dispose();
                Count++;
            }
        }
Пример #6
0
        private void LIST_Animations_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Saving) return;

            if (LIST_Animations.SelectedItem != null)
            {
                String animationname = LIST_Animations.SelectedItem.ToString();

                DrawLoadingNotice("Initialisation de l'animation", animationname);
                Thread.Sleep(20);

                Animation animation = (LIST_Animations.SelectedItem as Animation).Clone() as Animation;

                if (animation.GetPattern() != null && animation.GetPattern().GetImage() != null)
                {
                    // Set pattern in pattern panel
                    DrawLoadingNotice("Chargement du motif", animationname);
                    SetPatternImage(animation, animation.GetPattern().GetImage());

                    // Dispose old textures
                    DrawLoadingNotice("Libération de la mémoire", animationname);
                    foreach (Texture2D texture in textures) texture.Dispose();

                    // Clear texture table
                    textures.Clear();

                    // Convert images into Texture2D for them to be used with XNA
                    DrawLoadingNotice("Adaptation du motif", animationname);

                    foreach (Control c in PN_Pattern.Controls)
                    using (XNAUtils utils = new XNAUtils())
                    {
                        textures.Add(utils.ConvertToTexture(c.BackgroundImage));
                    }
                }
                else
                {
                    // Dispose old textures
                    DrawLoadingNotice("Libération de la mémoire", animationname);
                    foreach (Texture2D texture in textures) texture.Dispose();

                    // Clear texture table
                    textures.Clear();

                    PN_Pattern.Controls.Clear();
                }

                // Set informations
                DrawLoadingNotice("Affichage des informations", animationname);
                LBL_AnimationName.Text = animation.ToString();

                // Update indexes
                DrawLoadingNotice("Mise à jour des index", animationname);
                CurrentAnimation = animation;
                CurrentIndex = LIST_Animations.SelectedIndex;

                // Update timeline
                DrawLoadingNotice("Chargement de la ligne de temps", animationname);
                animationTimeLine1.LoadAnimation(animation);
                DrawFrame(CurrentAnimation.FrameAt(0));

                GROUP_Animation.Visible = true;
            }
            else
            {
                CurrentAnimation = null;
                CurrentIndex = LIST_Animations.SelectedIndex;

                GROUP_Animation.Visible = false;
            }
        }
Пример #7
0
        private void BTN_PutEntirePattern_Click(object sender, EventArgs e)
        {
            if (CurrentAnimation.GetPattern() == null)
            {
                if (MessageBox.Show("Il n'y a aucun motif associé avec cette animation.\nVoulez-vous en charger un?", "Aucun motif", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    BTN_LoadPattern_Click(sender, e);

                    if (CurrentAnimation.GetPattern() == null) return;
                }
                else
                {
                    return;
                }
            }

            AnimationPutEntirePattern dlg = new AnimationPutEntirePattern(this, CurrentAnimation, CurrentFrameIndex);
            dlg.ShowDialog();

            CurrentAnimation = dlg.GetAnimation();

            animationTimeLine1.LoadAnimation(CurrentAnimation);
        }