using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace CMSControl
{
    public class Slot
    {
        public Boolean Enable { get; set; }
        public byte Index { get; set; }
        public string Name { get; set; }
        public string No { get; set; }
        public Boolean Opend { get; set; }
        public Color BackColor { get; set; }
        public Color ForeColor { get; set; }
        public Color BorderColor { get; set; }
        public float BorderSize { get; set; }

        public Rectangle Rect { get; set; }
        public Rectangle RectNo { get; set; }
        public Rectangle RectT { get; set; }        
        public Rectangle RectM { get; set; }
        public Rectangle RectB { get; set; }
        public Rectangle RectCnt { get; set; }
        public Boolean Selected { get; set; }

        public Boolean Expiration { get; set; }

        public System.Windows.Forms.Padding PaddingNo { get; set; }
        public System.Windows.Forms.Padding PaddingT { get; set; }
        public System.Windows.Forms.Padding PaddingM { get; set; }
        public System.Windows.Forms.Padding PaddingB { get; set; }
        public System.Windows.Forms.Padding PaddingCnt { get; set; }


        public Slot()
        {
            Index = 0;
            Name = "--";
            Name = string.Empty;
            Opend = false;
            BorderColor = Color.Black;
            BorderSize = 2f;
            Selected = false;
            Enable = true;
            BackColor = Color.White;
            Expiration = false;
        }

        
        void DrawString(Graphics g, Font f, string data, Rectangle rect, Color fcolor, int pos = 1)
        {
            var fsize = g.MeasureString(data, f);
            float cx, cy;
            cx = cy = 0;
            if (pos == 1)
            {
                cx = rect.Left + (rect.Width - fsize.Width) / 2;
                cy = rect.Top + (rect.Height - fsize.Height) / 2;
            }
            else if (pos == 0)
            {
                cx = rect.Left;
                cy = rect.Top + (rect.Height - fsize.Height) / 2;
            }
            else
            {
                cx = rect.Right - fsize.Width;
                cy = rect.Top + (rect.Height - fsize.Height) / 2;
            }

            g.DrawString(data, f, new SolidBrush(fcolor), new PointF(cx + 1, cy + 1));
        }
    }
}
