using System;
using System.Windows.Forms;
using CRVM.Entity;

namespace CRVM
{
    public partial class SetSampleForm : Form
    {
        public SetSampleForm()
        {
            InitializeComponent();
        }

        private void Sampleparameter_Load(object sender, EventArgs e)
        {
            ComboBoxExpoint.Text = SysParam.Instance.samplePoint.ToString();
            ComboBoxExfre.Text = SysParam.Instance.sampleFre.ToString();
        }

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

        private void button1_Click(object sender, EventArgs e)
        {
            int samplePoint = 1024;
            int sampleFre = 3072;
            if (int.TryParse(ComboBoxExpoint.Text.Trim(), out samplePoint))
            {
                SysParam.Instance.samplePoint = samplePoint;
            }
            else
            {
                ComboBoxExpoint.Text = SysParam.Instance.samplePoint.ToString();
                MessageBox.Show("采集点数内容格式不正确，请重新输入！");
                return;
            }

            if (int.TryParse(ComboBoxExfre.Text.Trim(), out sampleFre))
            {
                SysParam.Instance.sampleFre = sampleFre;
            }
            else
            {
                ComboBoxExfre.Text = SysParam.Instance.sampleFre.ToString();
                MessageBox.Show("采集频率内容格式不正确，请重新输入！");
                return;
            }

            ConfigHelper.GetInstance("").SaveConfig(SysParam.Instance.appPath + "\\AppSetting.config");
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

    }
}
