using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace Gsome
{
	public class ProgressBar : UserControl
	{
		public int Progress
		{
			get
			{
				return this._Progress;
			}
			set
			{
				this._Progress = value;
				base.Invalidate();
			}
		}

		public int Maximum
		{
			get
			{
				return this._Maximum;
			}
			set
			{
				this._Maximum = value;
			}
		}

		public ProgressBar()
		{
			this.SetNormalStyle();
			this.InitializeComponent();
			base.ResizeRedraw = true;
		}

		protected override void OnPaint(PaintEventArgs e)
		{
			Graphics graphics = e.Graphics;
			Rectangle rect = new Rectangle(0, 0, base.ClientRectangle.Width - 1, base.ClientRectangle.Height - 1);
			graphics.DrawRectangle(ProgressBar.penBorder, rect);
			if (this.Maximum != 0)
			{
				int num = (rect.Width - 3) * this.Progress / this.Maximum;
				if (num > 0)
				{
					rect = new Rectangle(2, 2, num, rect.Height - 3);
					using (LinearGradientBrush linearGradientBrush = new LinearGradientBrush(rect, this.clrFill1, this.clrFill2, LinearGradientMode.Vertical))
					{
						graphics.FillRectangle(linearGradientBrush, rect);
					}
				}
			}
			base.OnPaint(e);
		}

		public void SetNormalStyle()
		{
			this.clrFill1 = Color.Green;
			this.clrFill2 = Color.DarkGreen;
			base.Invalidate();
		}

		public void SetErrorStyle()
		{
			this.clrFill1 = Color.Red;
			this.clrFill2 = Color.DarkRed;
			base.Invalidate();
		}

		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}

		private void InitializeComponent()
		{
			base.SuspendLayout();
			base.AutoScaleDimensions = new SizeF(6f, 13f);
			base.AutoScaleMode = AutoScaleMode.Font;
			this.BackColor = Color.White;
			this.DoubleBuffered = true;
			base.Name = "ProgressBar";
			base.Size = new Size(229, 19);
			base.ResumeLayout(false);
		}

		private static Pen penBorder = new Pen(ProfessionalColors.ButtonSelectedHighlightBorder);

		private int _Progress;

		private int _Maximum = 100;

		private Color clrFill1;

		private Color clrFill2;

		private IContainer components;
	}
}
