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.ConfigMethod
{
    public partial class ChromColumn : Form
    {
        HWConfig hwconfig;
        GCMethodConfig methodconfig;

        public ChromColumn(HWConfig hwconfig, ref GCMethodConfig methodconfig)
        {
            InitializeComponent();

            this.hwconfig = hwconfig;
            this.methodconfig = methodconfig;
        }

        public void reflashContent(int index)
        {
            this.methodconfig.GetChromAllPara();
            //int cFront = 0;
            //int cBehind = 1;


            //List<string> list = new List<string>();
            //2list.Add("111111");
            //list.Add("222222");
            //list.Add("333333");
            //list.Add("444444");
            //comboBox1.DataSource = list;
            //if (this.hwconfig.hwconfiginfo.u16ChromFront == 1)
            {
                txtCaliber.Text = this.methodconfig.chrom[index].fCalSet.ToString();

                txtChromColumnDescribe.Text = this.methodconfig.chrom[index].sDescribe.ToString();
                
                if (this.methodconfig.chrom[index].sChromSelect == 0)
                {
                    lblChromColumnLocation.Text = "前色谱柱";
                }
                else
                {
                    lblChromColumnLocation.Text = "后色谱柱";
                }

                //if (this.methodconfig.chrom[cFront].u16ChromType == 0)
                //{
                //    txtChromColumnType.Text = "毛细孔柱";
                //}
                //else
                //{
                //    txtChromColumnType.Text = "填充柱";
                //}


                ChromeType.SelectedIndex = this.methodconfig.chrom[index].u16ChromType;

                txtMaxProtectTemp.Text = this.methodconfig.chrom[index].fHigestTempSet.ToString();
                txtSize.Text = this.methodconfig.chrom[index].fLengthSet.ToString();
                txtThick.Text = this.methodconfig.chrom[index].fFilmThicknessSet.ToString();
            }
            
        }
        float string2float(string s)
        {
            float ret;

            if (string.IsNullOrEmpty(s))
            {
                ret = 0;
            }
            else
            {
                ret = float.Parse(s);
            }

            return ret;
        }
        public void recordCurData(int index)
        {
            //int cFront = 0;
            //int cBehind = 1;

            //if (this.hwconfig.hwconfiginfo.u16ChromFront == 1)
            {
                this.methodconfig.chrom[index].fCalSet = string2float(txtCaliber.Text);
                this.methodconfig.chrom[index].sDescribe = txtChromColumnDescribe.Text;
                this.methodconfig.chrom[index].fHigestTempSet = string2float(txtMaxProtectTemp.Text);
                this.methodconfig.chrom[index].fLengthSet = string2float(txtSize.Text);
                this.methodconfig.chrom[index].fFilmThicknessSet = string2float(txtThick.Text);
                
            }

            //if (this.hwconfig.hwconfiginfo.u16ChromBehind == 1)
            //{
            //    this.methodconfig.chrom[cBehind].fCalSet = string2float(txtCaliber.Text);
            //    this.methodconfig.chrom[cBehind].sDescribe = txtChromColumnDescribe.Text;
            //    this.methodconfig.chrom[cBehind].fHigestTempSet = string2float(txtMaxProtectTemp.Text);
            //    this.methodconfig.chrom[cBehind].fLengthSet = string2float(txtSize.Text);
            //    this.methodconfig.chrom[cBehind].fFilmThicknessSet = string2float(txtThick.Text);
            //}
        }
    }
}
