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 Detection : Form
    {

        #region 私有变量
        private HWConfig hWConfig;
        #endregion

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

        public Detection(ref HWConfig hwconfig)
        {
            InitializeComponent();
            this.hWConfig = hwconfig;
        }

        #endregion

        #region 窗口事件
        private void Detection_Load(object sender, EventArgs e)
        {
            if (this.hWConfig != null)
            {
                this.DetNum.SelectedIndex = this.hWConfig.hwconfiginfo.u16DetNum;
                this.DetFront.Checked = this.hWConfig.hwconfiginfo.u16DetFront == 1 ? true : false;
                this.DetFrontType.SelectedIndex = this.hWConfig.hwconfiginfo.u16DetFrontType;
                this.DetFrontPTemp.Text = this.hWConfig.hwconfiginfo.u16DetFrontPTemp.ToString();
                this.DetFrontAisle.SelectedIndex = this.hWConfig.hwconfiginfo.u16DetFrontAisle;

                this.DetInter.Checked = this.hWConfig.hwconfiginfo.u16DetInter == 1 ? true : false;
                this.DetInterType.SelectedIndex = this.hWConfig.hwconfiginfo.u16DetInterType;
                this.DetInterPTemp.Text = this.hWConfig.hwconfiginfo.u16DetInterPTemp.ToString();
                this.DetInterAisle.SelectedIndex = this.hWConfig.hwconfiginfo.u16DetInterAisle;

                this.DetBehind.Checked = this.hWConfig.hwconfiginfo.u16DetBehind == 1 ? true : false;
                this.DetBehindType.SelectedIndex = this.hWConfig.hwconfiginfo.u16DetBehindType;
                this.DetBehindPTemp.Text = this.hWConfig.hwconfiginfo.u16DetBehindPTemp.ToString();
                this.DetBehindAisle.SelectedIndex = this.hWConfig.hwconfiginfo.u16DetBehindAisle;
            }

        }
        #endregion

        #region 控件事件
        private void okbtn_Click(object sender, EventArgs e)
        {
            if (this.hWConfig != null)
            {
                this.hWConfig.hwconfiginfo.u16DetNum = (this.DetFront.Checked ? 1 : 0) + (this.DetInter.Checked ? 1 : 0) + (this.DetBehind.Checked ? 1 : 0);

                this.hWConfig.hwconfiginfo.u16DetFront = this.DetFront.Checked ? 1 : 0;
                this.hWConfig.hwconfiginfo.u16DetFrontType = this.DetFrontType.SelectedIndex;
                this.hWConfig.hwconfiginfo.u16DetFrontPTemp = int.Parse(this.DetFrontPTemp.Text);
                this.hWConfig.hwconfiginfo.u16DetFrontAisle = this.DetFrontAisle.SelectedIndex;

                this.hWConfig.hwconfiginfo.u16DetInter = this.DetInter.Checked ? 1 : 0;
                this.hWConfig.hwconfiginfo.u16DetInterType = this.DetInterType.SelectedIndex;
                this.hWConfig.hwconfiginfo.u16DetInterPTemp = int.Parse(this.DetInterPTemp.Text);
                this.hWConfig.hwconfiginfo.u16DetInterAisle = this.DetInterAisle.SelectedIndex;

                this.hWConfig.hwconfiginfo.u16DetBehind = this.DetBehind.Checked ? 1 : 0;
                this.hWConfig.hwconfiginfo.u16DetBehindType = this.DetBehindType.SelectedIndex;
                this.hWConfig.hwconfiginfo.u16DetBehindPTemp = int.Parse(this.DetBehindPTemp.Text);
                this.hWConfig.hwconfiginfo.u16DetBehindAisle = this.DetBehindAisle.SelectedIndex;
            }

            this.Close();
        }

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