using System;
using System.Windows.Forms;
using CRVM.Entity;
namespace CRVM
{
    public partial class SetDisplayForm : Form
    {
        public SetDisplayForm()
        {
            InitializeComponent();
        }

        private void displayingingSetting_Load(object sender, EventArgs e)
        {
            ColorPickerTime.BackColor = SysParam.Instance.colorTime;
            ColorPickerFre.BackColor = SysParam.Instance.colorFre;
            ColorPickerEnergy.BackColor = SysParam.Instance.colorEnergy;
            ColorPickerSpeed.BackColor = SysParam.Instance.colorSpeed;
            ColorPickerAlarm.BackColor = SysParam.Instance.colorAlarm;
            ColorPickerClose.BackColor = SysParam.Instance.colorDefect;
            ColorPickerCut.BackColor = SysParam.Instance.colorCut;
            ColorPickerWR.BackColor = SysParam.Instance.colorWorkRoll;
            ColorPickerMR.BackColor = SysParam.Instance.colorMidRoll;
            ColorPickerBR.BackColor = SysParam.Instance.colorBackupRoll;
            ColorPickerFont.BackColor = SysParam.Instance.colorFont;
            ColorPickerBack.BackColor = SysParam.Instance.colorBackgroud;
            ComboBoxFontSize.Text = SysParam.Instance.fontSize.ToString();
            ComboBoxGrid.SelectedIndex = SysParam.Instance.BackgroundGridOn ? 1 : 0;
            comboBoxRollLine.SelectedIndex = SysParam.Instance.rollLineVisible ? 1 : 0;
        }

        private void OkDrawing_Click(object sender, EventArgs e)
        {
            SysParam.Instance.colorTime = ColorPickerTime.BackColor;
            SysParam.Instance.colorFre = ColorPickerFre.BackColor;
            SysParam.Instance.colorEnergy = ColorPickerEnergy.BackColor;
            SysParam.Instance.colorSpeed = ColorPickerSpeed.BackColor;
            SysParam.Instance.colorAlarm = ColorPickerAlarm.BackColor;
            SysParam.Instance.colorDefect = ColorPickerClose.BackColor;
            SysParam.Instance.colorCut = ColorPickerCut.BackColor;
            SysParam.Instance.colorWorkRoll = ColorPickerWR.BackColor;
            SysParam.Instance.colorMidRoll = ColorPickerMR.BackColor;
            SysParam.Instance.colorBackupRoll = ColorPickerBR.BackColor;
            SysParam.Instance.colorFont = ColorPickerFont.BackColor;
            SysParam.Instance.colorBackgroud = ColorPickerBack.BackColor;
            SysParam.Instance.fontSize = Convert.ToInt32(ComboBoxFontSize.Text);
            SysParam.Instance.BackgroundGridOn = ComboBoxGrid.SelectedIndex == 1 ? true : false;
            SysParam.Instance.rollLineVisible = comboBoxRollLine.SelectedIndex == 1 ? true : false;
            this.Close();
        }

        private void CancelDrawing_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void ColorPickerButton1_Click(object sender, EventArgs e)
        {
            Button bt = (Button)sender;
            colorDialog1.ShowDialog();
            bt.BackColor = colorDialog1.Color;
        }
    }
}
