private void reDraw()
        {
            if (frameMask == null || frameMask.Next == null)
            {
                imageButton3.Enabled = false;
            }
            else
            {
                imageButton3.Enabled = true;
            }
            if (frameMask != null)
            {
                imageButton2.Enabled = true;
                label1.Text          = frameMask.Frame.Name;
            }
            else
            {
                imageButton2.Enabled = false;
                imageButton2.Refresh();
                label1.Text = "Frame0";
            }
            pictureBox1.Image = new Bitmap(pictureBox1.Width - 3,
                                           pictureBox1.Height - 3);
            Brush  b   = new SolidBrush(ColorPalette.GetGlobalColor(0));
            Bitmap bp  = null;
            float  per = 1;
            Font   f   = null;

            if (FrameMask != null)
            {
                bp = FrameMask.GetBitmap();
                if (bp != null)
                {
                    per = pictureBox1.Image.Width / (float)bp.Width;

                    if (bp.Width < bp.Height)
                    {
                        per = pictureBox1.Image.Height / (float)bp.Height;
                    }
                }

                f = new Font("Consolas", 11, FontStyle.Bold);
            }
            using (Graphics g = Graphics.FromImage(pictureBox1.Image))
            {
                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
                g.FillRectangle(b, 0, 0,
                                pictureBox1.Image.Width, pictureBox1.Image.Height);
                if (FrameMask != null)
                {
                    if (bp != null)
                    {
                        g.DrawImage(bp, 0, 0,
                                    bp.Width * per, bp.Height * per);
                    }
                    g.DrawString("" + frameMask.Index, f,
                                 Brushes.Black, 1, 1);
                }
            }
        }
Exemple #2
0
        public FrameMask ToFrameMask(Frame[] frames)
        {
            if (frames == null || frames.Length <= 0)
            {
                return(null);
            }
            Frame f = frames[0];

            for (int i = 0; i < frames.Length; i++)
            {
                if (frames[i].Name == FrameName)
                {
                    f = frames[i];
                    break;
                }
            }

            FrameMask fm = new FrameMask()
            {
                Frame = f,
                Time  = Time,
                FlipX = FlipX,
                FlipY = FlipY,
                Index = Index
            };

            return(fm);
        }
Exemple #3
0
 public void ToFrameMaskContainer(FrameMask fm)
 {
     FrameName = fm.Frame.Name;
     Time      = fm.Time;
     Index     = fm.Index;
     FlipX     = fm.FlipX;
     FlipY     = fm.FlipY;
 }
Exemple #4
0
        public Animation ToAnimation(Frame[] frames)
        {
            Animation an = new Animation()
            {
                PlayType = (PlayType)PlayType,
                Name     = Name
            };

            FrameMask[] fms = new FrameMask[FrameMasks.Length];

            for (int i = 0; i < FrameMasks.Length; i++)
            {
                fms[i] = FrameMasks[i].ToFrameMask(frames);
            }

            an.LoadFrameMasks(fms);

            return(an);
        }
Exemple #5
0
        private void buildTable()
        {
            if (animation == null || animation.Length == 0)
            {
                ClearLayoutTable();
                tableLayoutPanel1.ColumnCount = 1;
                tableLayoutPanel1.Width       = 208 * tableLayoutPanel1.ColumnCount;
                AnimationFrameEditor afex = new AnimationFrameEditor();
                afex.AddClick += addClick;
                afex.Name      = "NULL";

                tableLayoutPanel1.Controls.Add(afex, 0, 0);
                return;
            }
            int scroll = panel1.HorizontalScroll.Maximum;

            tableLayoutPanel1.SuspendLayout();
            ClearLayoutTable();

            tableLayoutPanel1.ColumnCount = animation.Length;
            tableLayoutPanel1.Width       = 208 * tableLayoutPanel1.ColumnCount;

            FrameMask            fm = animation[0];
            int                  i  = 0;
            AnimationFrameEditor afe;

            while (fm != null)
            {
                tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 208));

                afe = new AnimationFrameEditor
                {
                    FrameMask = fm
                };
                afe.AddClick      += addClick;
                afe.RemoveClick   += removeClick;
                afe.ExchangeClick += exchangeClick;
                afe.TimeChanged   += timeChanged;
                afe.FlipXChanged  += flipChanged;
                afe.FlipYChanged  += flipChanged;
                afe.FlipX          = fm.FlipX;
                afe.FlipY          = fm.FlipY;
                afe.Name           = $"FrameEditor{i}";

                if (tableLayoutPanel1.Controls.Contains(afe))
                {
                    tableLayoutPanel1.Controls.Remove(afe);
                }

                try
                {
                    tableLayoutPanel1.Controls.Add(afe, i, 0);
                }
                catch (Exception)
                {
                }
                fm = fm.Next;
                i++;
            }
            panel1.AutoScrollPosition = new Point(scroll, panel1.AutoScrollPosition.Y);
            tableLayoutPanel1.ResumeLayout();
        }