using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace DevComponents.DotNetBar.Controls
{
    [ToolboxBitmap(typeof(CircularProgress), "Controls.CircularProgress.ico"), ToolboxItem(true), DefaultEvent("ValueChanged")]
    public class CircularProgress : BaseItemControl
    {
        #region Constructor
        private CircularProgressItem _Item = null;
        /// 
        /// Initializes a new instance of the CircularProgress class.
        /// 
        public CircularProgress()
        {
            _Item = new CircularProgressItem();
            _Item.ValueChanged += new EventHandler(ItemValueChanged);
            _Item.TextVisible = false;
            this.HostItem = _Item;
        }
        #endregion
        #region Implementation
        protected override void Dispose(bool disposing)
        {
            _Item.Dispose();
            base.Dispose(disposing);
        }
        protected override void RecalcSize()
        {
            _Item.Diameter = Math.Min(this.Width, this.Height);
            base.RecalcSize();
        }
        private void ItemValueChanged(object sender, EventArgs e)
        {
            OnValueChanged(e);
        }
        /// 
        /// Occurs when Value property has changed.
        /// 
        public event EventHandler ValueChanged;
        /// 
        /// Raises ValueChanged event.
        /// 
        /// Provides event arguments.
        protected virtual void OnValueChanged(EventArgs e)
        {
            EventHandler handler = ValueChanged;
            if (handler != null)
                handler(this, e);
        }
        /// 
        /// Gets or sets the circular progress bar type.
        /// 
        [DefaultValue(eCircularProgressType.Line), Category("Appearance"), Description("Indicates circular progress bar type.")]
        public eCircularProgressType ProgressBarType
        {
            get { return _Item.ProgressBarType; }
            set
            {
                _Item.ProgressBarType = value;
            }
        }
        /// 
        /// Gets or sets the maximum value of the progress bar.
        /// 
        [Description("Indicates maximum value of the progress bar."), Category("Behavior"), DefaultValue(100)]
        public int Maximum
        {
            get { return _Item.Maximum; }
            set
            {
                _Item.Maximum = value;
            }
        }
        /// 
        /// Gets or sets the minimum value of the progress bar.
        /// 
        [Description("Indicates minimum value of the progress bar."), Category("Behavior"), DefaultValue(0)]
        public int Minimum
        {
            get { return _Item.Minimum; }
            set
            {
                _Item.Minimum = value;
            }
        }
        /// 
        /// Gets or sets the color of the progress percentage text.
        /// 
        [Category("Appearance"), Description("Indicates color of progress percentage text")]
        public Color ProgressTextColor
        {
            get { return _Item.ProgressTextColor; }
            set { _Item.ProgressTextColor = value; }
        }
        /// 
        /// Gets whether property should be serialized.
        /// 
        [EditorBrowsable(EditorBrowsableState.Never)]
        public bool ShouldSerializeProgressTextColor()
        {
            return _Item.ShouldSerializeProgressTextColor();
        }
        /// 
        /// Resets property to its default value.
        /// 
        [EditorBrowsable(EditorBrowsableState.Never)]
        public void ResetProgressTextColor()
        {
            _Item.ResetProgressTextColor();
        }
        /// 
        /// Gets or sets whether text that displays the progress bar completion percentage text is visible. Default value is false.
        /// 
        [DefaultValue(false), Category("Appearance"), Description("Indicates whether text that displays the progress bar completion percentage text is visible")]
        public bool ProgressTextVisible
        {
            get { return _Item.ProgressTextVisible; }
            set
            {
                _Item.ProgressTextVisible = value;
            }
        }
        /// 
        /// Gets or sets the text displayed on top of the circular progress bar.
        /// 
        [DefaultValue(""), Category("Appearance"), Description("Indicates text displayed on top of the circular progress bar.")]
        public string ProgressText
        {
            get { return _Item.ProgressText; }
            set
            {
                _Item.ProgressText = value;
            }
        }
        /// 
        /// Gets or sets the current value of the progress bar.
        /// 
        [Description("Indicates current value of the progress bar."), Category("Behavior"), DefaultValue(0)]
        public int Value
        {
            get { return _Item.Value; }
            set
            {
                _Item.Value = value;
            }
        }
        /// 
        /// Gets or sets whether endless type progress bar is running.
        /// 
        [Browsable(false), DefaultValue(false)]
        public bool IsRunning
        {
            get { return _Item.IsRunning; }
            set
            {
                _Item.IsRunning = value;
            }
        }
        /// 
        /// Gets or sets the color of the color of progress indicator.
        /// 
        [Category("Columns"), Description("Indicates color of progress indicator.")]
        public Color ProgressColor
        {
            get { return _Item.ProgressColor; }
            set { _Item.ProgressColor = value; }
        }
        /// 
        /// Gets whether property should be serialized.
        /// 
        [EditorBrowsable(EditorBrowsableState.Never)]
        public bool ShouldSerializeProgressColor()
        {
            return _Item.ShouldSerializeProgressColor();
        }
        /// 
        /// Resets property to its default value.
        /// 
        [EditorBrowsable(EditorBrowsableState.Never)]
        public void ResetProgressColor()
        {
            _Item.ResetProgressColor();
        }
        ///// 
        ///// Gets or sets circular progress indicator diameter in pixels.
        ///// 
        //[DefaultValue(24), Category("Appearance"), Description("Indicates circular progress indicator diameter in pixels.")]
        //public int Diameter
        //{
        //    get { return _Item.Diameter; }
        //    set
        //    {
        //        _Item.Diameter = value;
        //        this.RecalcLayout();
        //    }
        //}
        ///// 
        ///// Gets or sets the text position in relation to the circular progress indicator.
        ///// 
        //[DefaultValue(eTextPosition.Left), Category("Appearance"), Description("Indicatesd text position in relation to the circular progress indicator.")]
        //public eTextPosition TextPosition
        //{
        //    get { return _Item.TextPosition; }
        //    set
        //    {
        //        _Item.TextPosition = value;
        //    }
        //}
        ///// 
        ///// Gets or sets whether text/label displayed next to the item is visible. 
        ///// 
        //[DefaultValue(true), Category("Appearance"), Description("Indicates whether caption/label set using Text property is visible.")]
        //public bool TextVisible
        //{
        //    get { return _Item.TextVisible; }
        //    set
        //    {
        //        _Item.TextVisible = value;
        //    }
        //}
        ///// 
        ///// Gets or sets the suggested text-width. If you want to make sure that text you set wraps over multiple lines you can set suggested text-width so word break is performed.
        ///// 
        //[DefaultValue(0), Category("Appearance"), Description("Indicates suggested text-width. If you want to make sure that text you set wraps over multiple lines you can set suggested text-width so word break is performed.")]
        //public int TextWidth
        //{
        //    get { return _Item.TextWidth; }
        //    set
        //    {
        //        _Item.TextWidth = value;
        //    }
        //}
        ///// 
        ///// Gets or sets text padding.
        ///// 
        //[Browsable(true), Category("Appearance"), Description("Gets or sets text padding."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        //public Padding TextPadding
        //{
        //    get { return _Item.TextPadding; }
        //}
        //[EditorBrowsable(EditorBrowsableState.Never)]
        //public bool ShouldSerializeTextPadding()
        //{
        //    return _Item.ShouldSerializeTextPadding();
        //}
        //[EditorBrowsable(EditorBrowsableState.Never)]
        //public void ResetTextPadding()
        //{
        //    _Item.ResetTextPadding();
        //}
        //protected override void OnForeColorChanged(EventArgs e)
        //{
        //    _Item.TextColor = this.ForeColor;
        //    base.OnForeColorChanged(e);
        //}
        /// 
        /// Gets or sets the color of the pie progress bar dark border. 
        /// 
        [Category("Pie"), Description("Indicates color of pie progress bar dark border.")]
        public Color PieBorderDark
        {
            get { return _Item.PieBorderDark; }
            set { _Item.PieBorderDark = value; }
        }
        /// 
        /// Gets whether property should be serialized.
        /// 
        [EditorBrowsable(EditorBrowsableState.Never)]
        public bool ShouldSerializePieBorderDark()
        {
            return _Item.ShouldSerializePieBorderDark();
        }
        /// 
        /// Resets property to its default value.
        /// 
        [EditorBrowsable(EditorBrowsableState.Never)]
        public void ResetPieBorderDark()
        {
            _Item.ResetPieBorderDark();
        }
        /// 
        /// Gets or sets the color of the pie progress bar light border. 
        /// 
        [Category("Pie"), Description("Indicates color of pie progress bar light border. ")]
        public Color PieBorderLight
        {
            get { return _Item.PieBorderLight; }
            set { _Item.PieBorderLight = value; }
        }
        /// 
        /// Gets whether property should be serialized.
        /// 
        [EditorBrowsable(EditorBrowsableState.Never)]
        public bool ShouldSerializePieBorderLight()
        {
            return _Item.ShouldSerializePieBorderLight();
        }
        /// 
        /// Resets property to its default value.
        /// 
        [EditorBrowsable(EditorBrowsableState.Never)]
        public void ResetPieBorderLight()
        {
            _Item.ResetPieBorderLight();
        }
        /// 
        /// Gets or sets the color of the spoke progress bar dark border.
        /// 
        [Category("Spoke"), Description("Indicates color of spoke progress bar dark border.")]
        public Color SpokeBorderDark
        {
            get { return _Item.SpokeBorderDark; }
            set { _Item.SpokeBorderDark = value; }
        }
        /// 
        /// Gets whether property should be serialized.
        /// 
        [EditorBrowsable(EditorBrowsableState.Never)]
        public bool ShouldSerializeSpokeBorderDark()
        {
            return _Item.ShouldSerializeSpokeBorderDark();
        }
        /// 
        /// Resets property to its default value.
        /// 
        [EditorBrowsable(EditorBrowsableState.Never)]
        public void ResetSpokeBorderDark()
        {
            _Item.ResetSpokeBorderDark();
        }
        /// 
        /// Gets or sets the color of the spoke progress bar light border.
        /// 
        [Category("Spoke"), Description("Indicates color of spoke progress bar light border..")]
        public Color SpokeBorderLight
        {
            get { return _Item.SpokeBorderLight; }
            set { _Item.SpokeBorderLight = value; }
        }
        /// 
        /// Gets whether property should be serialized.
        /// 
        [EditorBrowsable(EditorBrowsableState.Never)]
        public bool ShouldSerializeSpokeBorderLight()
        {
            return _Item.ShouldSerializeSpokeBorderLight();
        }
        /// 
        /// Resets property to its default value.
        /// 
        [EditorBrowsable(EditorBrowsableState.Never)]
        public void ResetSpokeBorderLight()
        {
            _Item.ResetSpokeBorderLight();
        }
        /// 
        /// Gets or sets format string for progress value.
        /// 
        [DefaultValue("{0}%"), Category("Appearance"), Description("Indicates format string for progress value.")]
        public string ProgressTextFormat
        {
            get { return _Item.ProgressTextFormat; }
            set
            {
                _Item.ProgressTextFormat = value;
            }
        }
        /// 
        /// Gets or sets the animation speed for endless running progress. Lower number means faster running.
        /// 
        [DefaultValue(100), Description("Indicates the animation speed for endless running progress. Lower number means faster running."), Category("Behavior")]
        public int AnimationSpeed
        {
            get
            {
                return _Item.AnimationSpeed;
            }
            set
            {
            	_Item.AnimationSpeed = value;
            }
        }
        /// 
        /// Starts the progress bar loop for endless type progress bar. Progress bar will continue to run until Stop() method is called.
        /// 
        public void Start()
        {
            _Item.Start();
        }
        /// 
        /// Stops the progress bar loop for endless type progress bar.
        /// 
        public void Stop()
        {
            _Item.Stop(false);
        }
        #endregion
        #region Property-Hiding
        [Browsable(false)]
        public override eDotNetBarStyle Style
        {
            get { return base.Style; }
            set { base.Style = value;}
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public override Color ForeColor
        {
            get { return base.ForeColor; }
            set { base.ForeColor = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public override RightToLeft RightToLeft
        {
            get { return base.RightToLeft; }
            set { base.RightToLeft = value; }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public override string Text
        {
            get
            {
                return base.Text;
            }
            set
            {
                base.Text = value;
            }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public override Image BackgroundImage
        {
            get
            {
                return base.BackgroundImage;
            }
            set
            {
                base.BackgroundImage = value;
            }
        }
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public override ImageLayout BackgroundImageLayout
        {
            get
            {
                return base.BackgroundImageLayout;
            }
            set
            {
                base.BackgroundImageLayout = value;
            }
        }
        #endregion
    }
}