Beispiel #1
0
 private void ReDraw(object sender, EventArgs e)
 {
     if (this.ViewStylemy == Form_offLine.ViewStyle.Spec)
     {
         Form_offLine.DrawDelegate drawDelegate = new Form_offLine.DrawDelegate(this.Draw);
         int index1 = this.comboBox1.SelectedIndex < 0 ? 0 : this.comboBox1.SelectedIndex;
         if (this.Data.Length > 0)
         {
             this.BeginInvoke((Delegate)drawDelegate, (object)"光谱图", (object)this.Data, (object)index1);
         }
         Spectrometer.Data[] dataArray = new Spectrometer.Data[1];
         dataArray[0].DataX = this.Data[index1].DataX;
         dataArray[0].DataY = new double[dataArray[0].DataX.Length];
         for (int index2 = 0; index2 < dataArray[0].DataX.Length; ++index2)
         {
             dataArray[0].DataY[index2] = this.StdErrY[index1, index2];
         }
         TextBox txtMeanErr = this.txtMeanErr;
         double  num        = this.DataHandlingmy.MeanValue(dataArray[0].DataY);
         string  str1       = num.ToString("0.000e0");
         txtMeanErr.Text = str1;
         TextBox txtMaxStdErr = this.txtMaxStdErr;
         num = this.DataHandlingmy.MaxValue(dataArray[0].DataY);
         string str2 = num.ToString("0.000e0");
         txtMaxStdErr.Text = str2;
     }
     else if (this.ViewStylemy == Form_offLine.ViewStyle.Energy)
     {
         Form_offLine.DrawDelegate drawDelegate = new Form_offLine.DrawDelegate(this.Draw);
         int num = this.comboBox1.SelectedIndex < 0 ? 0 : this.comboBox1.SelectedIndex;
         if (this.Data == null)
         {
             return;
         }
         this.BeginInvoke((Delegate)drawDelegate, (object)"能量图", (object)this.Data, (object)num);
     }
     else if (this.ViewStylemy == Form_offLine.ViewStyle.Mean)
     {
         this.btnMeanView_Click(sender, e);
     }
     else
     {
         if (this.ViewStylemy != Form_offLine.ViewStyle.StdErr)
         {
             return;
         }
         this.btnStdErrView_Click(sender, e);
     }
 }
Beispiel #2
0
        private void btnMeanView_Click(object sender, EventArgs e)
        {
            Form_offLine.DrawDelegate drawDelegate = new Form_offLine.DrawDelegate(this.Draw);
            int selectedIndex = this.comboBox1.SelectedIndex;

            Spectrometer.Data[] dataArray = new Spectrometer.Data[1];
            if (this.Data == null)
            {
                return;
            }
            dataArray[0].DataX = this.Data[selectedIndex].DataX;
            dataArray[0].DataY = new double[dataArray[0].DataX.Length];
            for (int index = 0; index < dataArray[0].DataX.Length; ++index)
            {
                dataArray[0].DataY[index] = this.MeanY[selectedIndex, index];
            }
            this.ViewStylemy = Form_offLine.ViewStyle.Mean;
            this.BeginInvoke((Delegate)drawDelegate, (object)"平均谱图", (object)dataArray, (object)0);
        }
Beispiel #3
0
        private void btnStdErrView_Click(object sender, EventArgs e)
        {
            Form_offLine.DrawDelegate drawDelegate = new Form_offLine.DrawDelegate(this.Draw);
            int selectedIndex = this.comboBox1.SelectedIndex;

            Spectrometer.Data[] dataArray = new Spectrometer.Data[1];
            if (this.Data == null)
            {
                return;
            }
            dataArray[0].DataX = this.Data[selectedIndex].DataX;
            dataArray[0].DataY = new double[dataArray[0].DataX.Length];
            for (int index = 0; index < dataArray[0].DataX.Length; ++index)
            {
                dataArray[0].DataY[index] = this.StdErrY[selectedIndex, index];
            }
            this.ViewStylemy = Form_offLine.ViewStyle.StdErr;
            this.BeginInvoke((Delegate)drawDelegate, (object)"标准差图", (object)dataArray, (object)0);
            this.txtMeanErr.Text   = this.DataHandlingmy.MeanValue(dataArray[0].DataY).ToString("0.000e0");
            this.txtMaxStdErr.Text = this.DataHandlingmy.MaxValue(dataArray[0].DataY).ToString("0.000e0");
        }
Beispiel #4
0
        private void btnOpemFile_Click(object sender, EventArgs e)
        {
            this.openFileDialog1.Title           = " 打开";
            this.openFileDialog1.Multiselect     = true;
            this.openFileDialog1.Filter          = " txt files(*.txt)|*.txt|All files(*.*)|*.*";
            this.openFileDialog1.CheckFileExists = true;
            if (this.openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            this.openFileDialog1.RestoreDirectory = true;
            this.SpectrumOpenPath = this.openFileDialog1.FileNames;
            this.comboBox1.Items.Clear();
            if (this.SpectrumOpenPath.Length <= 0 || this.SpectrumOpenPath.Length >= 21)
            {
                return;
            }
            this.Data         = new Spectrometer.Data[this.SpectrumOpenPath.Length];
            this.OpenFileName = new string[this.SpectrumOpenPath.Length];
            int length = this.DataIOmy.TXTReadData(this.SpectrumOpenPath[0], ref this.Data[0].DataX, ref this.Data[0].DataY, true);

            this.MeanY   = new double[this.SpectrumOpenPath.Length, length];
            this.StdErrY = new double[this.SpectrumOpenPath.Length, length];
            for (int index1 = 0; index1 < this.SpectrumOpenPath.Length; ++index1)
            {
                int num1 = this.SpectrumOpenPath[index1].LastIndexOf("\\");
                this.OpenFileName[index1] = this.SpectrumOpenPath[index1].Substring(num1 + 1, this.SpectrumOpenPath[index1].Length - num1 - 1);
                if (length == this.DataIOmy.TXTReadData(this.SpectrumOpenPath[index1], ref this.Data[index1].DataX, ref this.Data[index1].DataY, true))
                {
                    this.Data[index1].DataX = new double[length];
                    this.Data[index1].DataY = new double[length];
                    this.DataIOmy.TXTReadData(this.SpectrumOpenPath[index1], ref this.Data[index1].DataX, ref this.Data[index1].DataY, false);
                }
                double[,] X = new double[index1 + 1, length];
                for (int index2 = 0; index2 < index1 + 1; ++index2)
                {
                    for (int index3 = 0; index3 < length; ++index3)
                    {
                        X[index2, index3] = this.Data[index2].DataY[index3];
                    }
                }
                double[] numArray = this.DataHandlingmy.SpMean(X);
                double[] array    = this.DataHandlingmy.SpStdError(X);
                for (int index2 = 0; index2 < numArray.Length; ++index2)
                {
                    this.MeanY[index1, index2] = numArray[index2];
                }
                for (int index2 = 0; index2 < numArray.Length; ++index2)
                {
                    this.StdErrY[index1, index2] = array[index2];
                }
                TextBox txtMeanErr = this.txtMeanErr;
                double  num2       = this.DataHandlingmy.MeanValue(array);
                string  str1       = num2.ToString("0.000e0");
                txtMeanErr.Text = str1;
                TextBox txtMaxStdErr = this.txtMaxStdErr;
                num2 = this.DataHandlingmy.MaxValue(array);
                string str2 = num2.ToString("0.000e0");
                txtMaxStdErr.Text = str2;
                this.comboBox1.Items.Add((object)(index1 + 1).ToString());
                this.comboBox1.SelectedIndex = index1;
            }
            Form_offLine.DrawDelegate drawDelegate = new Form_offLine.DrawDelegate(this.Draw);
            this.ViewStylemy = Form_offLine.ViewStyle.Spec;
            this.BeginInvoke((Delegate)drawDelegate, (object)"光谱图", (object)this.Data, (object)this.comboBox1.SelectedIndex);
        }