using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Tashrifat
{
    public partial class SpecialLine : UserControl
    {
        public enum Styles
        {
            normal,fade
        }
        public enum Direction
        {
            vertical,horizontal
        }
        private Direction _direction = Direction.horizontal;

        public Direction direction
        {
            get { return _direction; }
            set
            {
                _direction = value;
                if (value == Direction.horizontal)
                {
                    this.Width = 200;
                    this.Height = 3;
                }
                else
                {
                    this.Height =200;
                    this.Width = 3;
                }
            }
        }
        private Color _color = Color.FromArgb(60, 150, 250);

        public Color color
        {
            get { return _color; }
            set { _color = value; }
        }
        private Styles _style = Styles.fade;

        public Styles Style
        {
            get { return _style; }
            set { _style = value; }
        }
        public SpecialLine()
        {
            InitializeComponent();
        }

        private void SpecialLine_Paint(object sender, PaintEventArgs e)
        {
            if (_direction == Direction.horizontal)
            {
                if (_style == Styles.normal)
                {
                    this.BackColor = Color.FromArgb(150, 150, 130);
                    e.Graphics.DrawLine(Pens.White, 0, 1, this.Width, 1);
                }
                else
                {
                    this.BackColor = Color.Transparent;
                    Pen p = new Pen(Color.FromArgb(0, _color));
                    int j = 0, k = this.Width;
                    for (int i = 0; i < 235; i += 20)
                    {
                        e.Graphics.DrawLine(p, j, 0, k, 0);
                        if (j + 10 < this.Width / 2)
                            j += 10;
                        if (k - 10 > this.Width / 2)
                            k -= 10;
                        p.Color = Color.FromArgb(i, _color);
                    }
                }
            }
            else
            {
                if (_style == Styles.normal)
                {
                    this.BackColor = Color.FromArgb(150, 150, 130);
                    Pen p = new Pen(ParentForm.BackColor);
                    e.Graphics.DrawLine(Pens.White, 1, 0, 1, this.Height);
                }
                else
                {
                    this.BackColor = Color.Transparent;
                    Pen p = new Pen(Color.FromArgb(0, _color));
                    int j = 0, k = this.Height;
                    for (int i = 0; i < 235; i += 20)
                    {
                        e.Graphics.DrawLine(p, 0, j, 0,k);
                        if (j + 10 < this.Height / 2)
                            j += 10;
                        if (k - 10 > this.Height/ 2)
                            k -= 10;
                        p.Color = Color.FromArgb(i, _color);
                    }
                }
            }
        }

        private void SpecialLine_Resize(object sender, EventArgs e)
        {
            if (this.Height > 2 && _direction==Direction.horizontal)
                this.Height = 2;
            else if(this.Width>2 && _direction==Direction.vertical)
                this.Width = 2;
        }

        private void SpecialLine_Load(object sender, EventArgs e)
        {
            this.TabStop = false;
        }
    }
}