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
{
    public partial class ShowConfig : Form
    {
        public INIOperation gcini;
        public InstrConfig fatherForm; 

        public ShowConfig()
        {
            InitializeComponent();
        }

        private void ShowConfig_Load(object sender, EventArgs e)
        {
            gcini = new INIOperation(globaldata.m_pcbuffer.gcpcinfo.pcfileinfo.cur_StatusName);
            InitChecked_ByConfig();

        }

        private void SetAll_Enable()
        {
            foreach (Control c in cfggroup.Controls)
            {
                c.Enabled = true;
            }
        }

        private void SetAll_Disable()
        {
            foreach(Control c in cfggroup.Controls)
            {
                c.Enabled = false;
            }
        }

        private void InitChecked_ByConfig()
        {
            bool rbet = false;
            rbet = globaldata.m_profileMethod.GetDevState();
            if (rbet)
            {
                set_all_checked();
                SetAll_Disable();
            }else
            {
                this.instrconfig.Text = "无";
                SetAll_Disable();
            }

        }

        public void set_all_checked()
        {
            int grade;
            ushort tmp;
            //string KingKey;

            //KingKey = "仪器档次";
            grade = CProfileDevice.m_DevParam.syspara.u16StartType;
            switch (grade)
            {
                case 1:
                    instrconfig.Text = "机械阀+压力流量";
                    break;
                case 2:
                    instrconfig.Text = "机械阀";
                    break;
                case 3:
                    instrconfig.Text = "EPC";
                    break;
                default:
                    instrconfig.Text = "无";
                    break;
            }

            //进样器
           // KingKey = "进样单元进样器";          
            this.Frontinjector.Checked = (CProfileDevice.m_DevParam.syspara.u16SampleFront == 1) ? true : false;
            if (this.Frontinjector.Checked)
            {
                this.FrontinjectorBox.SetItemChecked(0, this.Frontinjector.Checked);
                this.FrontinjectorBox.SetItemChecked(1, this.Frontinjector.Checked);
                this.FrontinjectorBox.SetItemChecked(2, this.Frontinjector.Checked);
            }

            this.Backinjector.Checked = (CProfileDevice.m_DevParam.syspara.u16SampleBehind == 1) ? true : false;
            if (this.Backinjector.Checked)
            {
                this.BackinjectorBox.SetItemChecked(0, this.Backinjector.Checked);
                this.BackinjectorBox.SetItemChecked(1, this.Backinjector.Checked);
                this.BackinjectorBox.SetItemChecked(2, this.Backinjector.Checked);
            }

            //前进样口
           // KingKey = "进样单元进样口";
            this.Frontinlet.Checked = (CProfileDevice.m_DevParam.syspara.u16InjPortFront == 1) ? true : false;
            if (this.Frontinlet.Checked)
            {
                this.FrontinletBox.SetItemChecked(0, this.Frontinlet.Checked);
                this.FrontinletBox.SetItemChecked(1, this.Frontinlet.Checked);
                this.FrontinletBox.SetItemChecked(2, this.Frontinlet.Checked);
                this.FrontinletBox.SetItemChecked(3, this.Frontinlet.Checked);
                this.FrontinletBox.SetItemChecked(4, this.Frontinlet.Checked);
            }

            //后进样口
            this.Backinlet.Checked = (CProfileDevice.m_DevParam.syspara.u16InjPortBehind == 1) ? true : false;
            if (this.Backinlet.Checked)
            {
                this.BackinletBox.SetItemChecked(0, this.Backinlet.Checked);
                this.BackinletBox.SetItemChecked(1, this.Backinlet.Checked);
                this.BackinletBox.SetItemChecked(2, this.Backinlet.Checked);
                this.BackinletBox.SetItemChecked(3, this.Backinlet.Checked);
                this.BackinletBox.SetItemChecked(4, this.Backinlet.Checked);
            }       

          //  KingKey = "进样单元切换阀";
            //阀箱
            this.ValveBox.Checked = (CProfileDevice.m_DevParam.syspara.u16ValveBox >= 1) ? true : false;
            if (this.ValveBox.Checked )
            {
                this.ValveListBox.SetItemChecked(0, (CProfileDevice.m_DevParam.syspara.u16ValveOne == 1) ? true : false);
                this.ValveListBox.SetItemChecked(1, (CProfileDevice.m_DevParam.syspara.u16ValveTwo == 1) ? true : false);
                this.ValveListBox.SetItemChecked(2, (CProfileDevice.m_DevParam.syspara.u16ValveThree == 1) ? true : false);
                this.ValveListBox.SetItemChecked(3, (CProfileDevice.m_DevParam.syspara.u16ValveFour == 1) ? true : false);
                this.ValveListBox.SetItemChecked(3, (CProfileDevice.m_DevParam.syspara.u16ValveFive == 1) ? true : false);
                this.ValveListBox.SetItemChecked(3, (CProfileDevice.m_DevParam.syspara.u16ValveSix == 1) ? true : false);
            }
           
            //KingKey = "柱箱单元柱箱";
            //柱箱
            this.Ovenbox.Checked = (CProfileDevice.m_DevParam.syspara.u16Col == 1) ? true : false;
            if (this.Ovenbox.Checked)
            {
                this.OvenListBox.SetItemChecked(0, this.Ovenbox.Checked);
            }

            //检测器
           // KingKey = "检测单元";       
            this.Frontdetector.Checked = (CProfileDevice.m_DevParam.syspara.u16DetFront == 1) ? true : false;
            if (this.Frontdetector.Checked)
            {
                this.FrontdetectorBox.SetItemChecked(0, this.Frontdetector.Checked);
                this.FrontdetectorBox.SetItemChecked(1, this.Frontdetector.Checked);
                this.FrontdetectorBox.SetItemChecked(2, this.Frontdetector.Checked);
                this.FrontdetectorBox.SetItemChecked(3, this.Frontdetector.Checked);
            }

            this.Interdetector.Checked = (CProfileDevice.m_DevParam.syspara.u16DetInter == 1) ? true : false;
            if (this.Interdetector.Checked)
            {
                this.InterdetectorBox.SetItemChecked(0, this.Interdetector.Checked);
                this.InterdetectorBox.SetItemChecked(1, this.Interdetector.Checked);

           //     tmp = CProfileDevice.m_DevParam.syspara.u16InjPortLoadGas_Front;

                this.InterdetectorBox.SetItemChecked(2, this.Interdetector.Checked);
                this.InterdetectorBox.SetItemChecked(3, this.Interdetector.Checked);
            }

            this.Reardetector.Checked = (CProfileDevice.m_DevParam.syspara.u16DetBehind == 1) ? true : false;
            if (this.Reardetector.Checked)
            {
                this.ReardetectorBox.SetItemChecked(0, this.Reardetector.Checked);
                this.ReardetectorBox.SetItemChecked(1, this.Reardetector.Checked);

            //    tmp = CProfileDevice.m_DevParam.syspara.u16InjPortLoadGas_Front;

                this.ReardetectorBox.SetItemChecked(2, this.Reardetector.Checked);
                this.ReardetectorBox.SetItemChecked(3, this.Reardetector.Checked);
            }

            //色谱柱
           // KingKey = "柱箱单元色谱柱";
            this.Column1.Checked = (CProfileDevice.m_DevParam.syspara.u16ChromFront == 1) ? true : false;
            if (this.Column1.Checked)
            {
                this.ColumnList1.SetItemChecked(0, this.Column1.Checked);
                this.ColumnList1.SetItemChecked(1, this.Column1.Checked);
                this.ColumnList1.SetItemChecked(2, this.Column1.Checked);
                this.ColumnList1.SetItemChecked(3, this.Column1.Checked);
            }

            this.Column2.Checked = (CProfileDevice.m_DevParam.syspara.u16ChromBehind == 1) ? true : false;
            if (this.Column2.Checked)
            {
                this.ColumnList2.SetItemChecked(0, this.Column2.Checked);
                this.ColumnList2.SetItemChecked(1, this.Column2.Checked);
                this.ColumnList2.SetItemChecked(2, this.Column2.Checked);
                this.ColumnList2.SetItemChecked(3, this.Column2.Checked);
            }

            //辅助加热器
           // KingKey = "辅助设置";
            this.Auxheater.Checked = (CProfileDevice.m_DevParam.syspara.u16AuxHeater == 1) ? true : false;
            tmp = CProfileDevice.m_DevParam.syspara.u16AuxHeaterNum;
            for (int i = 0; i < tmp; i++ )
                this.AuxheaterBox.SetItemChecked(i, true);
        }

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

        

    }
}
