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

namespace TimeClock
{
    public partial class LunarDay : UserControl
    {
        public LunarDay()
        {
            InitializeComponent();
            LblDay.Left = border_width;
            LblDay.Width = Width - border_width - border_width;
            LblLunarDay.Left = border_width;
            LblLunarDay.Width = Width - border_width - border_width;
            LblDay.Click += LblDay_Click;
            LblLunarDay.Click += LblDay_Click;
            LblState.Location = new Point(border_width, border_width);
            LblState.Visible = false;
        }
        int border_width = 4;
        public DateTime Date { get; set; } = DateTime.Now;
        private void LblDay_Click(object sender, EventArgs e)
        {
            base.OnClick(e); ;
        }
        /// <summary>
        /// 设置休息状态,1为休息,-1为上班，其它为不显示
        /// </summary>
        /// <param name="i"></param>
        public void SetRestState(int i)
        {
            if (i == -1) { LblState.Text = "班"; LblState.BackColor = Color.FromArgb(234, 131, 117); LblState.Visible = true; }
            else if (i == 1) { LblState.Text = "休"; LblState.BackColor = Color.FromArgb(0, 192, 0); LblState.Visible = true; }
            else { LblState.Visible = false; }
        }
        private int _day = 1;
        /// <summary>
        /// 日期
        /// </summary>
        public int Day
        {
            get { return _day; }
            set { _day = value;LblDay.Text = _day.ToString(); }
        }
        /// <summary>
        /// 农历
        /// </summary>
        public string Lunar_Day
        {
            get { return LblLunarDay.Text; }
            set { LblLunarDay.Text = value; }
        }
        /// <summary>
        /// 阳历日期字体颜色
        /// </summary>
        public Color Day_ForeColor
        {
            get { return LblDay.ForeColor; }
            set { LblDay.ForeColor = value; }
        }
        /// <summary>
        /// 阳历日期字体
        /// </summary>
        public Font Day_Font
        {
            get { return LblDay.Font; }
            set { LblDay.Font = value; }
        }
        /// <summary>
        /// 农历日期字体
        /// </summary>
        public Font Lunar_Day_Font
        {
            get { return LblLunarDay.Font; }
            set { LblLunarDay.Font = value; }
        }
        /// <summary>
        /// 农历部分字体颜色
        /// </summary>
        public Color Lunar_Day_ForeColor
        {
            get { return LblLunarDay.ForeColor; }
            set { LblLunarDay.ForeColor = value; }
        }
        private bool _Selected = false;
        public bool Selected
        {
            get { return _Selected; }
            set { _Selected = value;Refresh(); }
        }
        private void LunarDay_Paint(object sender, PaintEventArgs e)
        {
            if(Selected)
            e.Graphics.DrawRectangle(new Pen(Color.DeepSkyBlue,border_width), new Rectangle(0, 0, this.Width, this.Height));
        }
        private void DrawBorder(Graphics g, Rectangle rect, RoundStyle roundStyle, int radius)
        {
            rect.Width -= 1;
            rect.Height -= 1;
            using (GraphicsPath path =ryControls.Drawing.CreatePath(rect, radius, roundStyle, false))
            {
                SolidBrush myBrush = new SolidBrush(Color.White);
                using (Pen pen = new Pen(Color.Black))
                {
                    
                    g.FillPath(myBrush, path);
                    g.DrawPath(pen, path);
                }
            }
        }
    }
}
