using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using GcDevicePc.IniParam;
using System.Windows.Forms;

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

        private void updatecombobox()
        {
            //cleanALLItem();
            //addALLItem("无");
            //if (CProfileDevice.m_DevParam.syspara.u16DetFront == 1)
            //{
            //    if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 0)  //TCD
            //    {
            //        addALLItem("TCD(前)");
            //    }
            //    else if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 1) //FID
            //    {
            //        addALLItem("FID(前)");
            //    }
            //}


            //if (CProfileDevice.m_DevParam.syspara.u16DetInter == 1)
            //{
            //    if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 0)  //TCD
            //    {
            //        addALLItem("TCD(中)");
            //    }
            //    else if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 1)  //FID
            //    {
            //        addALLItem("FID(中)");
            //    }
            //}


            //if (CProfileDevice.m_DevParam.syspara.u16DetBehind == 1)
            //{
            //    if (CProfileDevice.m_DevParam.syspara.u16DetBehindType == 0)  //TCD
            //    {
            //        addALLItem("TCD(后)");
            //    }
            //    else if (CProfileDevice.m_DevParam.syspara.u16DetBehindType == 1) // FID
            //    {
            //        addALLItem("FID(后)");
            //    }
            //}
        }

        public void reflashContent()
        {
            //const int MAX_NUM = 8;
            //int channel = 0;
            //ComboBox tmpcombox;
            //TextBox tmptextbox;
            //int i = 0;
            ////float time;

            //globaldata.m_profileMethod.GetDevState();
            //globaldata.m_profileMethod.GetDevSignalAllPara();
            //updatecombobox();

            //if (CProfileDevice.m_DevParam.signal.u16ChannelA == 1)
            //{
            //    signalA_sw.CheckState = CheckState.Checked;
            //}else
            //{
            //    signalA_sw.CheckState = CheckState.Unchecked;
            //}

            //if (CProfileDevice.m_DevParam.signal.u16ChannelB == 1)
            //{
            //    signalB_sw.CheckState = CheckState.Checked;
            //}
            //else
            //{
            //    signalB_sw.CheckState = CheckState.Unchecked;
            //}

            //for (i = 0; i < MAX_NUM; i++)
            //{
            //    channel = i + 1;
            //    tmpcombox = this.Controls.Find("signal_A_" + channel.ToString(), true)[0] as ComboBox;
            //    tmptextbox = (TextBox)(this.Controls.Find("signalAT" + channel.ToString(), true)[0]);

            //    tmpcombox.SelectedIndex = (int)CProfileDevice.m_DevParam.signal.uDetA[i];

            //    if (CProfileDevice.m_DevParam.signal.u16DetTimeLengthA[i] > 0)
            //    {
            //        tmptextbox.Text = ((float)CProfileDevice.m_DevParam.signal.u16DetTimeLengthA[i] / 60).ToString("#0.0");
            //    }
            //}

            //for (i = 0; i < MAX_NUM; i++)
            //{
            //    channel = i + 1;
            //    tmpcombox = (ComboBox)(this.Controls.Find("signal_B_" + channel.ToString(), true)[0]);
            //    tmptextbox = (TextBox)(this.Controls.Find("signalBT" + channel.ToString(), true)[0]);

            //    tmpcombox.SelectedIndex = (int)CProfileDevice.m_DevParam.signal.uDetB[i];

            //    if (CProfileDevice.m_DevParam.signal.u16DetTimeLengthB[i] > 0)
            //    {
            //        tmptextbox.Text = ((float)CProfileDevice.m_DevParam.signal.u16DetTimeLengthB[i] / 60).ToString("#0.0");
            //    }
            //}
        }

        private void cleanALLItem()
        {
            //const int MAX_NUM = 8;
            //int channel = 0;
            //ComboBox tmpcombox;
            //int i = 0;
            //for ( i = 0; i < MAX_NUM; i++)
            //{
            //    channel = i + 1;
            //    tmpcombox = (ComboBox)(this.Controls.Find("signal_A_" + channel.ToString(), true)[0]);
            //    tmpcombox.Items.Clear();
            //}

            //for ( i = 0; i < MAX_NUM; i++)
            //{
            //    channel = i + 1;
            //    tmpcombox = (ComboBox)(this.Controls.Find("signal_B_" + channel.ToString(), true)[0]);
            //    tmpcombox.Items.Clear();
            //}
        }

        private void addALLItem(string name)
        {
            //const int MAX_NUM = 8;
            //int channel = 0;
            //ComboBox tmpcombox;
            //int i = 0;
            //for (i = 0; i < MAX_NUM; i++)
            //{
            //    channel = i + 1;
            //    tmpcombox = (ComboBox)(this.Controls.Find("signal_A_" + channel.ToString(), true)[0]);
            //    tmpcombox.Items.Add(name);
            //}

            //for (i = 0; i < MAX_NUM; i++)
            //{
            //    channel = i + 1;
            //    tmpcombox = (ComboBox)(this.Controls.Find("signal_B_" + channel.ToString(), true)[0]);
            //    tmpcombox.Items.Add(name);
            //}
        }

        private void SignalDlg_Load(object sender, EventArgs e)
        {

            //cleanALLItem();
            //addALLItem("无");
            //if (CProfileDevice.m_DevParam.syspara.u16DetFront == 1)
            //{
            //    if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 0)  //TCD
            //    {
            //        addALLItem("TCD(前)");
            //    }
            //    else if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 1) //FID
            //    {
            //        addALLItem("FID(前)");
            //    }
            //}


            //if (CProfileDevice.m_DevParam.syspara.u16DetInter == 1)
            //{
            //    if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 0)  //TCD
            //    {
            //        addALLItem("TCD(中)");
            //    }
            //    else if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 1)  //FID
            //    {
            //        addALLItem("FID(中)");
            //    }
            //}


            //if (CProfileDevice.m_DevParam.syspara.u16DetBehind == 1)
            //{
            //    if (CProfileDevice.m_DevParam.syspara.u16DetBehindType == 0)  //TCD
            //    {
            //        addALLItem("TCD(后)");
            //    }
            //    else if (CProfileDevice.m_DevParam.syspara.u16DetBehindType == 1) // FID
            //    {
            //        addALLItem("FID(后)");
            //    }
            //}

        }

        private void TextBoxDec_KeyPress(object sender, KeyPressEventArgs e)
        {
            //if (!(((e.KeyChar >= '0') && (e.KeyChar <= '9')) || e.KeyChar <= 31))
            //{
            //    if (e.KeyChar == '.')
            //    {
            //        if (((TextBox)sender).Text.Trim().IndexOf('.') > -1)
            //            e.Handled = true;
            //    }
            //    else
            //        e.Handled = true;
            //}
            //else
            //{
            //    if (e.KeyChar <= 31)
            //    {
            //        e.Handled = false;
            //    }
            //    else if (((TextBox)sender).Text.Trim().IndexOf('.') > -1)
            //    {
            //        if (((TextBox)sender).Text.Trim().Substring(((TextBox)sender).Text.Trim().IndexOf('.') + 1).Length >= 4)
            //            e.Handled = true;
            //    }
            //}
          
        }


        public void recordCurData()
        {
            
            //const int MAX_NUM = 8;
            //int channel = 0;
            //ComboBox tmpcombox;
            //TextBox tmptextbox;
            //int i = 0;
            //float time;

            //ushort newtime;

            //CProfileDevice.m_DevParam.signal.u16ChannelA = (signalA_sw.CheckState == CheckState.Checked) ? (ushort)1 : (ushort)0;
            //CProfileDevice.m_DevParam.signal.u16ChannelB = (signalB_sw.CheckState == CheckState.Checked) ? (ushort)1 : (ushort)0;

            //for (i = 0; i < MAX_NUM; i++)
            //{
            //    channel = i + 1;
            //    tmpcombox = (ComboBox)(this.Controls.Find("signal_A_" + channel.ToString(), true)[0]);
            //    tmptextbox = (TextBox)(this.Controls.Find("signalAT" + channel.ToString(), true)[0]);

            //    if(tmpcombox.SelectedIndex < 0)
            //        CProfileDevice.m_DevParam.signal.uDetA[i] = 0;
            //    else
            //        CProfileDevice.m_DevParam.signal.uDetA[i] = (ushort)tmpcombox.SelectedIndex;

            //    if (string.IsNullOrEmpty(tmptextbox.Text))
            //    {
            //        CProfileDevice.m_DevParam.signal.u16DetTimeLengthA[i] = 0;
            //    }
            //    else
            //    {
            //        time = (float)Convert.ToDecimal(tmptextbox.Text);
            //        newtime = (ushort)Convert.ToDecimal((time * 60).ToString());
            //        CProfileDevice.m_DevParam.signal.u16DetTimeLengthA[i] = newtime;

            //    }
            //}

            //for (i = 0; i < MAX_NUM; i++)
            //{
            //    channel = i + 1;
            //    tmpcombox = (ComboBox)(this.Controls.Find("signal_B_" + channel.ToString(), true)[0]);
            //    tmptextbox = (TextBox)(this.Controls.Find("signalBT" + channel.ToString(), true)[0]);

            //    if (tmpcombox.SelectedIndex < 0)
            //        CProfileDevice.m_DevParam.signal.uDetB[i] = 0;
            //    else
            //        CProfileDevice.m_DevParam.signal.uDetB[i] = (ushort)tmpcombox.SelectedIndex;

            //    if (string.IsNullOrEmpty(tmptextbox.Text))
            //    {
            //        CProfileDevice.m_DevParam.signal.u16DetTimeLengthB[i] = 0;
            //    }else{
            //        time = (float)Convert.ToDecimal(tmptextbox.Text);
            //        newtime = (ushort)Convert.ToDecimal((time * 60).ToString());
            //        CProfileDevice.m_DevParam.signal.u16DetTimeLengthB[i] = newtime;
            //    }
            //}


        }


    }
}
