public void SetFrame(AnimationPatternFrame f, Image img) { PN_Preview.BackgroundImage = img; NUM_Index.Value = f.ImageIndex; NUM_Opacity.Value = Convert.ToDecimal(f.Opacity); NUM_PosX.Value = f.Position.X; NUM_PosY.Value = f.Position.Y; NUM_Ratio.Value = Convert.ToDecimal(f.Ratio); NUM_Rotation.Value = Convert.ToDecimal(f.Rotation); CB_Inverted.Checked = f.Fliped; DDL_Blending.SelectedIndex = f.Blending+1; }
private void BTN_Start_Click(object sender, EventArgs e) { if (NUM_StartIndex.Value > NUM_EndIndex.Value) { Decimal temp = NUM_StartIndex.Value; NUM_StartIndex.Value = NUM_EndIndex.Value; NUM_EndIndex.Value = temp; } Int32 FrameAt = Convert.ToInt32(NUM_FromFrame.Value); for (int i = Convert.ToInt32(NUM_StartIndex.Value); i < Convert.ToInt32(NUM_EndIndex.Value); i++) { if (FrameAt >= animation.GetFrameCount() && CB_AddNewFrames.Checked) animation.AddFrame(); else if (FrameAt >= animation.GetFrameCount()) break; AnimationFrame frame = animation.FrameAt(FrameAt); AnimationPatternFrame apf = new AnimationPatternFrame(); apf.Blending = DDL_Blending.SelectedIndex - 1; apf.Fliped = CB_Invert.Checked; apf.ImageIndex = i; apf.Position = Position; apf.Ratio = Convert.ToSingle(NUM_Ratio.Value); apf.Rotation = Convert.ToSingle(NUM_Rotation.Value); frame.Images.Add(apf); animation.AlterFrameAt(FrameAt, frame); FrameAt++; } Close(); }
private void PN_Canvas_MouseClick(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left && PatternFrameIndex != null) { AnimationFrame frame = CurrentAnimation.FrameAt(CurrentFrameIndex); AnimationPatternFrame apf = new AnimationPatternFrame(); apf.Position = ComputeClickPosition(e); apf.ImageIndex = PatternFrameIndex ?? -1; apf.Ratio = 1; apf.Rotation = 0; apf.Fliped = false; apf.Blending = 0; frame.Images.Add(apf); CurrentAnimation.AlterFrameAt(CurrentFrameIndex, frame); PN_Canvas.Refresh(); } else if (e.Button == System.Windows.Forms.MouseButtons.Right) { AnimationPatternFrame a = new AnimationPatternFrame() { Blending = -1000 }; AnimationFrame frame = CurrentAnimation.FrameAt(CurrentFrameIndex); Int32 index = 0; foreach (AnimationPatternFrame apf in frame.Images) { if (e.X > apf.Position.X + AbsoluteCenter.X && e.Y > apf.Position.Y + AbsoluteCenter.Y && e.X < apf.Position.X + AbsoluteCenter.X + 192 && e.Y < apf.Position.Y + AbsoluteCenter.Y + 192) { a = apf; break; } index++; } if (a.Blending != -1000) { Point location = MousePosition; AnimationFramePanelEditor dlg = new AnimationFramePanelEditor(); if (location.X + dlg.Width > Screen.PrimaryScreen.Bounds.Width) location.X = Screen.PrimaryScreen.Bounds.Width - dlg.Width; if (location.Y + dlg.Height > Screen.PrimaryScreen.Bounds.Height) location.Y = Screen.PrimaryScreen.Bounds.Height - dlg.Height; dlg.StartPosition = FormStartPosition.Manual; dlg.Location = location; dlg.SetFrame(a, PN_Pattern.Controls.Count <= a.ImageIndex ? new Bitmap(1, 1) : PN_Pattern.Controls[a.ImageIndex].BackgroundImage); switch(dlg.ShowDialog()) { case System.Windows.Forms.DialogResult.OK: { a = dlg.GetFrame(); frame.Images[index] = a; CurrentAnimation.AlterFrameAt(CurrentFrameIndex, frame); } break; case System.Windows.Forms.DialogResult.Abort: { frame.Images.RemoveAt(index); CurrentAnimation.AlterFrameAt(CurrentFrameIndex, frame); } break; case System.Windows.Forms.DialogResult.Cancel: break; default: break; } PN_Canvas.Refresh(); } } }
public object Clone() { AnimationPatternFrame apf = new AnimationPatternFrame(); apf.Blending = this.Blending; apf.Fliped = this.Fliped; apf.ImageIndex = this.ImageIndex; apf.Position = this.Position; apf.Ratio = this.Ratio; apf.Rotation = this.Rotation; apf.Opacity = this.Opacity; apf.RGBratio = new Single[] { this.RGBratio[0], this.RGBratio[1], this.RGBratio[2] }; apf.RGBadd = new Single[] { this.RGBadd[0], this.RGBadd[1], this.RGBadd[2] }; return apf; }