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.GCBuffer;

namespace GcDevicePc.DeviceConfigUI
{
    public partial class Auxiliary : Form
    {
        #region 私有变量
        private HWConfig hWConfig;
        #endregion

        #region 构造函数
        public Auxiliary()
        {
            InitializeComponent();
        }

        public Auxiliary(ref HWConfig hwconfig)
        {
            InitializeComponent();
            this.hWConfig = hwconfig;
        }
        #endregion

        #region 窗口事件
        private void Auxiliary_Load(object sender, EventArgs e)
        {
            if (this.hWConfig != null)
            {
                //this.AuxHeaterNum.SelectedIndex = this.hWConfig.hwconfiginfo.u16AuxHeaterNum;
                this.AuxHeater1.Checked = this.hWConfig.hwconfiginfo.u16AuxHeater1 == 1 ? true : false;
                this.AuxHeaterName1.Text = this.hWConfig.hwconfiginfo.u16AuxHeaterName1;
                this.AuxHeaterPTemp1.Text = this.hWConfig.hwconfiginfo.u16AuxHeaterPTemp1.ToString();

                this.AuxHeater2.Checked = this.hWConfig.hwconfiginfo.u16AuxHeater2 == 1 ? true : false;
                this.AuxHeaterName2.Text = this.hWConfig.hwconfiginfo.u16AuxHeaterName2;
                this.AuxHeaterPTemp2.Text = this.hWConfig.hwconfiginfo.u16AuxHeaterPTemp2.ToString();

            }
            
        }
        #endregion

        #region 控件事件
        private void okbtn_Click(object sender, EventArgs e)
        {
            if (this.hWConfig != null)
            {
                //this.hWConfig.hwconfiginfo.u16AuxHeaterNum = this.AuxHeaterNum.SelectedIndex;.

                this.hWConfig.hwconfiginfo.u16AuxHeater = this.AuxHeater1.Checked || this.AuxHeater2.Checked ? 1 : 0;


                this.hWConfig.hwconfiginfo.u16AuxHeaterNum = (this.AuxHeater1.Checked ? 1 : 0) + (this.AuxHeater2.Checked ? 1 : 0);
                this.hWConfig.hwconfiginfo.u16AuxHeater1 = this.AuxHeater1.Checked ? 1 : 0;
                this.hWConfig.hwconfiginfo.u16AuxHeaterName1 = this.AuxHeaterName1.Text;
                this.hWConfig.hwconfiginfo.u16AuxHeaterPTemp1 = int.Parse(this.AuxHeaterPTemp1.Text);
                this.hWConfig.hwconfiginfo.u16AuxHeater2 = this.AuxHeater2.Checked ? 1 : 0;
                this.hWConfig.hwconfiginfo.u16AuxHeaterName2 = this.AuxHeaterName2.Text;
                this.hWConfig.hwconfiginfo.u16AuxHeaterPTemp2 = int.Parse(this.AuxHeaterPTemp2.Text);
            }

            this.Close();
        }

        private void cancelbtn_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        #endregion
    }
}
