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

    public abstract class AdvancedSliderBase : LinearControlBase
    {
        private int barIndent = 10;
        private int barWidth = 10;
        private int indicatorWidth = 20;

        protected AdvancedSliderBase()
        {
        }

        [Category("Appearance"), Description("Left and right indents"), DefaultValue(10)]
        public int BarIndent
        {
            get
            {
                return this.barIndent;
            }
            set
            {
                if (this.barIndent != value)
                {
                    this.barIndent = value;
                    base.Invalidate();
                }
            }
        }

        protected Rectangle BarRectangle
        {
            get
            {
                Rectangle workRectangle = this.WorkRectangle;
                if (this.Orientation == InstrumentationControls.Orientation.Horizontal)
                {
                    return new Rectangle(workRectangle.X + this.BarIndent, this.CenterLine - (this.barWidth / 2), workRectangle.Width - (this.BarIndent * 2), this.barWidth);
                }
                return new Rectangle(this.CenterLine - (this.barWidth / 2), workRectangle.Y + this.BarIndent, this.barWidth, workRectangle.Height - (this.BarIndent * 2));
            }
        }

        [Description("Bar Width"), DefaultValue(10), Category("Appearance")]
        public int BarWidth
        {
            get
            {
                return this.barWidth;
            }
            set
            {
                if (this.barWidth != value)
                {
                    this.barWidth = value;
                    base.Invalidate();
                }
            }
        }

        protected override int CenterLine
        {
            get
            {
                int width;
                int x;
                Rectangle workRectangle = this.WorkRectangle;
                if (this.Orientation == InstrumentationControls.Orientation.Vertical)
                {
                    x = workRectangle.X;
                    width = workRectangle.Width;
                }
                else
                {
                    x = workRectangle.Y;
                    width = workRectangle.Height;
                }
                int num3 = x + (width / 2);
                switch (base.LabelsPosition)
                {
                    case SliderElementsPosition.TopLeft:
                        return (((x + width) - (this.indicatorWidth / 2)) - (((base.TicksPosition == SliderElementsPosition.BottomRight) || (base.TicksPosition == SliderElementsPosition.Both)) ? (base.TicksLenght + 2) : 0));

                    case SliderElementsPosition.BottomRight:
                        return ((x + (this.indicatorWidth / 2)) + (((base.TicksPosition == SliderElementsPosition.TopLeft) || (base.TicksPosition == SliderElementsPosition.Both)) ? (base.TicksLenght + 2) : 0));
                }
                return num3;
            }
        }

        protected override Rectangle IndicatorRectangle
        {
            get
            {
                Rectangle workRectangle = this.WorkRectangle;
                if (this.Orientation == InstrumentationControls.Orientation.Horizontal)
                {
                    return new Rectangle(workRectangle.X + this.BarIndent, this.CenterLine - (this.indicatorWidth / 2), workRectangle.Width - (this.BarIndent * 2), this.indicatorWidth);
                }
                return new Rectangle(this.CenterLine - (this.indicatorWidth / 2), workRectangle.Y + this.BarIndent, this.indicatorWidth, workRectangle.Height - (this.BarIndent * 2));
            }
        }

        [Category("Appearance"), DefaultValue(20), Description("Bar Width")]
        public int IndicatorWidth
        {
            get
            {
                return this.indicatorWidth;
            }
            set
            {
                if (this.indicatorWidth != value)
                {
                    this.indicatorWidth = value;
                    base.Invalidate();
                }
            }
        }
    }
}
