コード例 #1
0
        /// <summary>
        /// Done Button saves the calibration values,
        /// displays the linear equation and R2,
        /// message box is shown to either accept or not accept the calibration
        /// and shows Main Window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Done_B_Click(object sender, RoutedEventArgs e)
        {
            //Get A and B
            List <DTO_CalVal> linearRegression = cali.CalculateAAndB(dataReference, dataCalVal, 0, 0, 0, 0);

            //Get R2
            double _r2 = cali.CalculateR2Val(dataReference, dataCalVal, r2);

            //Save a and b
            foreach (var linear in linearRegression)
            {
                a = linear.A;
                b = linear.B;
            }

            //Display linear regression and R2
            AAndB_L.Content = "y=" + a + "x+" + b + " \n" + "R^2-værdi: " + _r2;

            //Show message box if R2<0.95
            if (_r2 < 0.95)
            {
                //Warning if calibration isn't approved
                MessageBox.Show("Kalibrering ikke godkendt! \n Foretag ny kalibrering.");

                //Close window
                this.Close();

                //Show main window
                mainWindow.Show();
            }
            else
            {
                //Calibration approved
                MessageBox.Show("Kalibrering godkendt.");

                //Close window
                this.Close();

                //Show main window
                mainWindow.Show();

                //Saving calibration
                cali.SaveCalval(new List <int>(2), new List <double>(2), 0, 0, 0, 0, DateTime.Now);
            }
        }