namespace InstrumentationControls
{
	using System.ComponentModel;
    using System.Drawing;
    using System.Drawing.Imaging;

    [ToolboxBitmap(typeof(SkinIndicator))]
    public class SkinIndicator : ValuePresenter
    {
        private System.Drawing.Image image = null;
        private ImageMode imageMode = InstrumentationControls.ImageMode.Center;

        protected override void Draw(Graphics g, Rectangle r)
        {
            Rectangle rectangle = this.DisplayRectangle;
            if (this.image != null)
            {
                int frameCount = this.image.GetFrameCount(FrameDimension.Time);
                int num2 = (int) ((((float) base.Value) / 100f) * (frameCount - 1));
                this.image.SelectActiveFrame(FrameDimension.Time, num2);
                if (this.ImageMode == InstrumentationControls.ImageMode.Stretch)
                {
                    g.DrawImage(this.image, rectangle);
                }
                else
                {
                    int num3 = (base.Width / 2) - (this.image.Width / 2);
                    int num4 = (base.Height / 2) - (this.image.Height / 2);
                    g.DrawImageUnscaled(this.image, num3, num4);
                }
            }
        }

        [DefaultValue((string) null)]
        public System.Drawing.Image Image
        {
            get
            {
                return this.image;
            }
            set
            {
                if (this.image != value)
                {
                    this.image = value;
                    base.Invalidate();
                }
            }
        }

        [DefaultValue(1)]
        public ImageMode ImageMode
        {
            get
            {
                return this.imageMode;
            }
            set
            {
                this.imageMode = value;
                base.Invalidate();
            }
        }
    }
}
