示例#1
0
        private void addClick(AnimationFrameEditor obj)
        {
            if (animation == null)
            {
                MessageBox.Show("You must create an animation first.", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            AddClick?.Invoke(this);

            if (Selection == null || Selection.Length <= 0)
            {
                return;
            }

            if (obj.FrameMask == null)
            {
                animation.Add(Selection, 0);
            }
            else
            {
                animation.Add(Selection, obj.FrameMask.Index);
            }
            buildTable();
            _Animation = animation;
        }
示例#2
0
 private void flipChanged(AnimationFrameEditor obj)
 {
     if (animation == null)
     {
         MessageBox.Show("You must create an animation first.", "Error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     _Animation = animation;
 }
示例#3
0
        private void exchangeClick(AnimationFrameEditor obj)
        {
            if (obj.FrameMask == null)
            {
                return;
            }

            animation.Exchange(obj.FrameMask.Index);

            obj.FrameMask = obj.FrameMask;
            int ind = obj.FrameMask.Index + 1;

            AnimationFrameEditor obj2 =
                (AnimationFrameEditor)tableLayoutPanel1.GetControlFromPosition(ind, 0);

            obj2.FrameMask = obj2.FrameMask;
            _Animation     = animation;
        }
示例#4
0
        private void removeClick(AnimationFrameEditor obj)
        {
            if (obj.FrameMask == null)
            {
                return;
            }
            Control c;
            AnimationFrameEditor afex;
            int fmInd = obj.FrameMask.Index;

            animation.Remove(fmInd);
            if (animation.Length <= 0)
            {
                buildTable();
                return;
            }

            tableLayoutPanel1.Controls.Remove(obj);
            for (int i = fmInd; i < tableLayoutPanel1.ColumnCount - 1; i++)
            {
                c              = tableLayoutPanel1.GetControlFromPosition(i + 1, 0);
                afex           = (AnimationFrameEditor)c;
                afex.FrameMask = afex.FrameMask;
                tableLayoutPanel1.Controls.Remove(c);
                tableLayoutPanel1.Controls.Add(c, i, 0);
            }
            if (fmInd >= animation.Length)
            {
                c = tableLayoutPanel1.
                    GetControlFromPosition(animation.Length - 1, 0);
                afex           = (AnimationFrameEditor)c;
                afex.FrameMask = afex.FrameMask;
            }
            tableLayoutPanel1.ColumnCount = animation.Length;
            tableLayoutPanel1.Width       = 208 * tableLayoutPanel1.ColumnCount;
            _Animation = animation;
        }
示例#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();
        }