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

using System.Windows.Forms;
using GcDevicePc.DevParam;
using GcDevicePc.IniParam;

namespace GcDevicePc.ConfigDlg
{
    public partial class AuxDlg : Form
    {
        public AuxDlg()
        {
            InitializeComponent();
        }

        public void reflashContent()
        {
           
            globaldata.m_profileMethod.GetDevState();
            globaldata.m_profileMethod.GetAuxiliaryAllPara();

            if(CProfileDevice.m_DevParam.syspara.u16AuxHeater1 == 1)
            {
                aidheatcheck1.Enabled = true;
                aidheatset1.Enabled = true;
                aidheatcheck1.Text = CProfileDevice.m_DevParam.syspara.u16AuxHeaterName1;
            }else
            {
                aidheatcheck1.Enabled = false;
                aidheatset1.Enabled = false;
                aidheatcheck1.Text = "未定义";
            }

            if (CProfileDevice.m_DevParam.syspara.u16AuxHeater2 == 1)
            {
                aidheatcheck2.Enabled = true;
                aidheatset2.Enabled = true;
                aidheatcheck2.Text = CProfileDevice.m_DevParam.syspara.u16AuxHeaterName2;
            }else
            {
                aidheatcheck2.Enabled = false;
                aidheatset2.Enabled = false;
                aidheatcheck2.Text = "未定义";
            }

            if (CProfileDevice.m_DevParam.syspara.u16AuxHeaterNum >= 1)
            {
                
                if (CProfileDevice.m_DevParam.aux.fTemp_Enable1)
                {
                    aidheatcheck1.CheckState = CheckState.Checked;
                }
                else
                {
                    aidheatcheck1.CheckState = CheckState.Unchecked;
                }

                if (CProfileDevice.m_DevParam.aux.fTemp_Enable2)
                {
                    aidheatcheck2.CheckState = CheckState.Checked;
                }
                else
                {
                    aidheatcheck2.CheckState = CheckState.Unchecked;
                }

                aidheatset1.Text = CProfileDevice.m_DevParam.aux.fSetTemp_HeatArea1.ToString();
                aidheatset2.Text = CProfileDevice.m_DevParam.aux.fSetTemp_HeatArea2.ToString();
                this.aidheatgroup.Enabled = true;
            }
            else
            {
                if (CProfileDevice.m_DevParam.aux.u16AuxHeatArea1 == 1)
                {
                    aidheatcheck1.CheckState = CheckState.Checked;
                }
                else
                {
                    aidheatcheck1.CheckState = CheckState.Unchecked;
                }
              
                if (CProfileDevice.m_DevParam.aux.u16AuxHeatArea2 == 1)
                {
                    aidheatcheck2.CheckState = CheckState.Checked;
                }
                else
                {
                    aidheatcheck2.CheckState = CheckState.Unchecked;
                }

                //aidheatset1.Text = CProfileDevice.m_DevParam.aux.fSetTemp_HeatArea1.ToString();
                //aidheatset2.Text = CProfileDevice.m_DevParam.aux.fSetTemp_HeatArea2.ToString();

                this.aidheatgroup.Enabled = false;
            }
          
            //实际温度设定
            this.aidheatvalue1.Text = "N/A";
            this.aidheatvalue2.Text = "N/A";

        }

        private void TextBoxDec_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 8 && !Char.IsDigit(e.KeyChar) && e.KeyChar != '.')
            {
                e.Handled = true;
            }
        }

        public void recordCurData()
        {
            if (aidheatset1.Text != "")
            {
            CProfileDevice.m_DevParam.aux.fSetTemp_HeatArea1 = float.Parse(aidheatset1.Text);
            }

            if (aidheatset2.Text != "")
            {
                CProfileDevice.m_DevParam.aux.fSetTemp_HeatArea2 = float.Parse(aidheatset2.Text);
            }
            
            CProfileDevice.m_DevParam.aux.fTemp_Enable1 = (aidheatcheck1.CheckState == CheckState.Checked) ? true : false;
            CProfileDevice.m_DevParam.aux.fTemp_Enable2 = (aidheatcheck2.CheckState == CheckState.Checked) ? true : false;         
        }
    }
}
