using System; using System.Collections.Generic; using System.Collections; using System.Linq; using System.Text; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Threading; namespace testAurigmaOne { public class AnimationObject : Aurigma.GraphicsMill.WinControls.VObject { protected Image _img = null; protected string imageFileName = ""; protected float _x; protected float _y; protected int _value = 0; protected new ImageSetInfo m_InRangeImage; // serializable attribute protected new ImageSetInfo m_OutOfRangeImage; protected System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer(); protected int _frame = 0; protected bool _playAnimation = false; public AnimationObject() { _matrix = new System.Drawing.Drawing2D.Matrix(); base.JointControlPointsProvider.RemoveProvider(base.GenericControlPointsProvider); base.Name = "animation"; initValue(); } public AnimationObject(string filePath) { _matrix = new System.Drawing.Drawing2D.Matrix(); base.JointControlPointsProvider.RemoveProvider(base.GenericControlPointsProvider); base.Name = "animation"; imageFileName = filePath; _img = Image.FromFile(filePath); initValue(); } public AnimationObject(string filePath, float x, float y) { _matrix = new System.Drawing.Drawing2D.Matrix(); base.JointControlPointsProvider.RemoveProvider(base.GenericControlPointsProvider); base.Name = "animation"; imageFileName = filePath; if (File.Exists(filePath)) _img = Image.FromFile(filePath); _x = x; _y = y; initValue(); myTimer.Tick += new EventHandler(CheckStatus); myTimer.Interval = 100; // myTimer.Start(); } protected void initValue() { m_InRangeImage = new ImageSetInfo(); m_OutOfRangeImage = new ImageSetInfo(); } public int Value { get { return _value; } set { _value = value; _frame = _value; Update(); } } public bool PlayAnimation { get { return _playAnimation; } set { _playAnimation = value; if (_playAnimation) { myTimer.Start(); } else { myTimer.Stop(); } } } public ArrayList InRangeFilenames { get { return m_InRangeImage.Filenames; } set { m_InRangeImage.Filenames = value; ImageUtil.LoadImageSet(ref m_InRangeImage); _img = m_InRangeImage.Images[_frame]; } } public AnimationObject(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) { _matrix = new System.Drawing.Drawing2D.Matrix(); base.JointControlPointsProvider.RemoveProvider(base.GenericControlPointsProvider); } public override void Draw(System.Drawing.Rectangle renderingRect, System.Drawing.Graphics g, Aurigma.GraphicsMill.WinControls.ICoordinateMapper coordinateMapper) { if (g == null) { throw (new System.ArgumentNullException("g")); } // g.DrawImage(_img, GetVObjectBounds()); if (_frame >= m_InRangeImage.Images.Count) _frame = 0; g.DrawImage(m_InRangeImage.Images[_frame], GetVObjectBounds()); } public void CheckStatus(Object myObject, EventArgs myEventArgs) { Update(); _frame++; } public override Aurigma.GraphicsMill.WinControls.IDesigner Designer { get { if (_editDesigner == null) { _editDesigner = new Aurigma.GraphicsMill.WinControls.GenericVObjectEditDesigner(this); } return _editDesigner; } } public override System.Drawing.RectangleF GetTransformedVObjectBounds() { return new RectangleF(_x, _y, _img.Width, _img.Height); } public override System.Drawing.RectangleF GetVObjectBounds() { return new System.Drawing.RectangleF(_x, _y, _img.Width, _img.Height); } public override bool HitTest(System.Drawing.PointF point, float precisionDelta) { return true; } public override System.Drawing.Drawing2D.Matrix Transform { get { return _matrix; } set { } } private Aurigma.GraphicsMill.WinControls.IDesigner _editDesigner; private System.Drawing.Drawing2D.Matrix _matrix; } }