namespace PerpetuumSoft.Widgets
{
    using PerpetuumSoft.Widgets.Licensing;
    using System;
    using System.ComponentModel;
    using System.Drawing;

    [LicenseProvider(typeof(WidgetsLicenseProvider)), ToolboxBitmap(typeof(DigitalClock))]
    public class DigitalClock : Clock
    {
        private DigitsDisplay digits = new DigitsDisplay();

        public DigitalClock()
        {
            this.BackColor = Color.Black;
        }

        protected override void Draw(Graphics g, Rectangle r)
        {
            Rectangle workRectangle = this.WorkRectangle;
            base.Draw(g, r);
            Point point = new Point(workRectangle.Left + 5, (workRectangle.Top + (workRectangle.Height / 2)) - (this.digits.DigitHeight / 2));
            this.digits.PaintString(g, (PointF) point, base.ClockText);
        }

        protected override void UpdateTime(DateTime oldTime, DateTime newTime)
        {
            base.Invalidate();
        }

        [DefaultValue(typeof(Color), "Black")]
        public override Color BackColor
        {
            get
            {
                return base.BackColor;
            }
            set
            {
                base.BackColor = value;
            }
        }

        protected override Size DefaultSize
        {
            get
            {
                return new Size(0x70, 0x30);
            }
        }

        [DesignerSerializationVisibility(2), Category("Appearance"), Description("Segment digits")]
        public DigitsDisplay Digits
        {
            get
            {
                return this.digits;
            }
            set
            {
                if (this.digits != value)
                {
                    this.digits = value;
                    base.Invalidate();
                }
            }
        }

        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public override System.Drawing.Font Font
        {
            get
            {
                return base.Font;
            }
            set
            {
                base.Font = value;
            }
        }

        [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
        public override Color ForeColor
        {
            get
            {
                return base.ForeColor;
            }
            set
            {
                base.ForeColor = value;
            }
        }

        [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
        public override string Text
        {
            get
            {
                return base.Text;
            }
            set
            {
                base.Text = value;
            }
        }
    }
}
