using System;
using System.Windows.Forms;
using CRVM.Entity;
namespace CRVM
{
    public partial class GraCheckedEnergy : UserControl////20151102  jxp
    {

        //public delegate void ContentHandler(object sender, EventArgs e);

        public GraCheckedEnergy()
        {
            InitializeComponent();
        }

        private void EnergyGraphSelect_Load(object sender, EventArgs e)
        {
            checkBox2.Checked = SysParam.Instance.checkBoxEnergy;
            CheckBox_energy_all.Checked = SysParam.Instance.checkBoxEnergyAll;
            CheckBox_energy_l.Checked = SysParam.Instance.checkBoxEnergyL;
            CheckBox_energy_m.Checked = SysParam.Instance.checkBoxEnergyM;
            CheckBox_energy_h.Checked = SysParam.Instance.checkBoxEnergyH;
            CheckBox_energy_speed.Checked = SysParam.Instance.checkBoxEnergySpeed;

            CheckBox_energy_all.Enabled = SysParam.Instance.checkBoxEnergy;
            CheckBox_energy_l.Enabled = SysParam.Instance.checkBoxEnergy;
            CheckBox_energy_m.Enabled = SysParam.Instance.checkBoxEnergy;
            CheckBox_energy_h.Enabled = SysParam.Instance.checkBoxEnergy;
            CheckBox_energy_speed.Enabled = SysParam.Instance.checkBoxEnergy;

            ComboBoxE_energy_all.Text = SysParam.Instance.comboBoxEnergyAll;
            ComboBoxE_energy_l.Text = SysParam.Instance.comboBoxEnergyL;
            ComboBoxE_energy_m.Text = SysParam.Instance.comboBoxEnergyM;
            ComboBoxE_energy_h.Text = SysParam.Instance.comboBoxEnergyH;
            ComboBoxE_energy_speed.Text = SysParam.Instance.comboBoxEnergySpeed;

            ComboBoxE_energy_all.Enabled = SysParam.Instance.checkBoxEnergyAll;
            ComboBoxE_energy_l.Enabled = SysParam.Instance.checkBoxEnergyL;
            ComboBoxE_energy_m.Enabled = SysParam.Instance.checkBoxEnergyM;
            ComboBoxE_energy_h.Enabled = SysParam.Instance.checkBoxEnergyH;
            ComboBoxE_energy_speed.Enabled = SysParam.Instance.checkBoxEnergySpeed;

        }


        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            SysParam.Instance.checkBoxEnergy = checkBox2.Checked;
            if (SysParam.Instance.checkBoxEnergy)
            {
                CheckBox_energy_all.Enabled = true;
                CheckBox_energy_l.Enabled = true;
                CheckBox_energy_m.Enabled = true;
                CheckBox_energy_h.Enabled = true;
                CheckBox_energy_speed.Enabled = true;
            }
            else
            {
                CheckBox_energy_all.Checked = false;
                CheckBox_energy_l.Checked = false;
                CheckBox_energy_m.Checked = false;
                CheckBox_energy_h.Checked = false;
                CheckBox_energy_speed.Checked = false;
                CheckBox_energy_all.Enabled = false;
                CheckBox_energy_l.Enabled = false;
                CheckBox_energy_m.Enabled = false;
                CheckBox_energy_h.Enabled = false;
                CheckBox_energy_speed.Enabled = false;
            }           
        }

 //start  20151029  jxp
        private void ComboBoxE_energy_all_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                double txtValue = 0d;
                if (double.TryParse(ComboBoxE_energy_all.Text, out txtValue))
                {
                    if (txtValue>0)
                    {
                        SysParam.Instance.comboBoxEnergyAll = ComboBoxE_energy_all.Text;
                    }
                    else
                    {
                        ComboBoxE_energy_all.Text = SysParam.Instance.comboBoxEnergyAll;
                        MessageBox.Show("趋势图的Y轴幅值需大于0");
                    }
                    
                }
                else
                {
                    ComboBoxE_energy_all.Text = SysParam.Instance.comboBoxEnergyAll;
                }
            }
        }

        private void ComboBoxE_energy_l_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                double txtValue = 0d;
                if (double.TryParse(ComboBoxE_energy_l.Text, out txtValue))
                {
                    if (txtValue>0)
                    {
                        SysParam.Instance.comboBoxEnergyL = ComboBoxE_energy_l.Text;
                    }
                    else
                    {
                        ComboBoxE_energy_l.Text = SysParam.Instance.comboBoxEnergyL;
                        MessageBox.Show("趋势图的Y轴幅值需大于0");
                    }
                    
                }
                else
                {
                    ComboBoxE_energy_l.Text = SysParam.Instance.comboBoxEnergyL;
                }
            }
        }

        private void ComboBoxE_energy_m_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                double txtValue = 0d;
                if (double.TryParse(ComboBoxE_energy_m.Text, out txtValue))
                {
                    if (txtValue>0)
                    {
                        SysParam.Instance.comboBoxEnergyM = ComboBoxE_energy_m.Text;
                    }
                    else
                    {
                        ComboBoxE_energy_m.Text = SysParam.Instance.comboBoxEnergyM;
                        MessageBox.Show("趋势图的Y轴幅值需大于0");
                    }
                }
                else
                {
                    ComboBoxE_energy_m.Text = SysParam.Instance.comboBoxEnergyM;
                }
            }
        }

        private void ComboBoxE_energy_h_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                 double txtValue = 0d;
                 if (double.TryParse(ComboBoxE_energy_h.Text, out txtValue))
                 {
                     if (txtValue>0)
                     {
                         SysParam.Instance.comboBoxEnergyH = ComboBoxE_energy_h.Text;
                     }
                     else
                     {
                         ComboBoxE_energy_h.Text = SysParam.Instance.comboBoxEnergyH;
                         MessageBox.Show("趋势图的Y轴幅值需大于0");
                     }
                 }
                 else
                 {
                     ComboBoxE_energy_h.Text = SysParam.Instance.comboBoxEnergyH;
                 }
            }
        }

        private void ComboBoxE_energy_speed_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                double txtValue = 0d;
                if (double.TryParse(ComboBoxE_energy_speed.Text, out txtValue))
                {
                    if (txtValue>0)
                    {
                        SysParam.Instance.comboBoxEnergySpeed = ComboBoxE_energy_speed.Text;
                    }
                    else
                    {
                        ComboBoxE_energy_speed.Text = SysParam.Instance.comboBoxEnergySpeed;
                        MessageBox.Show("趋势图的Y轴幅值需大于0");
                    }
                    
                }
                else
                {
                    ComboBoxE_energy_speed.Text = SysParam.Instance.comboBoxEnergySpeed;
                }
            }
        }

        private void CheckBox_energy_all_CheckedChanged(object sender, EventArgs e)
        {
            ComboBoxE_energy_all.Enabled = CheckBox_energy_all.Checked;
            SysParam.Instance.checkBoxEnergyAll = CheckBox_energy_all.Checked;
        }

        private void CheckBox_energy_l_CheckedChanged(object sender, EventArgs e)
        {
            ComboBoxE_energy_l.Enabled = CheckBox_energy_l.Checked;
            SysParam.Instance.checkBoxEnergyL = CheckBox_energy_l.Checked;
        }

        private void CheckBox_energy_m_CheckedChanged(object sender, EventArgs e)
        {
            ComboBoxE_energy_m.Enabled = CheckBox_energy_m.Checked;
            SysParam.Instance.checkBoxEnergyM = CheckBox_energy_m.Checked;
        }

        private void CheckBox_energy_h_CheckedChanged(object sender, EventArgs e)
        {
            ComboBoxE_energy_h.Enabled = CheckBox_energy_h.Checked;
            SysParam.Instance.checkBoxEnergyH = CheckBox_energy_h.Checked;
        }

        private void CheckBox_energy_speed_CheckedChanged(object sender, EventArgs e)
        {
            ComboBoxE_energy_speed.Enabled = CheckBox_energy_speed.Checked;
            SysParam.Instance.checkBoxEnergySpeed = CheckBox_energy_speed.Checked;
        }

        private void ComboBoxE_energy_all_SelectedIndexChanged(object sender, EventArgs e)
        {
            SysParam.Instance.comboBoxEnergyAll = ComboBoxE_energy_all.Text;
        }

        private void ComboBoxE_energy_l_SelectedIndexChanged(object sender, EventArgs e)
        {
            SysParam.Instance.comboBoxEnergyL = ComboBoxE_energy_l.Text;
        }

        private void ComboBoxE_energy_m_SelectedIndexChanged(object sender, EventArgs e)
        {
            SysParam.Instance.comboBoxEnergyM = ComboBoxE_energy_m.Text;
        }

        private void ComboBoxE_energy_h_SelectedIndexChanged(object sender, EventArgs e)
        {
            SysParam.Instance.comboBoxEnergyH = ComboBoxE_energy_h.Text;
        }

        private void ComboBoxE_energy_speed_SelectedIndexChanged(object sender, EventArgs e)
        {
            SysParam.Instance.comboBoxEnergySpeed = ComboBoxE_energy_speed.Text;
        }
        

    }
}
