private void CheckRightOrWrong()
    {
        quantityErrors = new List <QuantityError>();
        //MeasureErrorFlag = false;
        foreach (var item in RecordManager.tempRecord.quantities)
        {
            if (item.processMethod == 1)
            {
                UserInputTable calc = new UserInputTable();
                calc.varname = item.Symbol;
                List <double> temp = new List <double>();
                for (int i = 0; i < item.MesuredData.data.Count; i++)
                {
                    temp.Add(double.Parse(item.MesuredData.data[i]));
                }
                calc.data         = new CalcVariable(double.Parse(StaticMethods.NumberFormat(GameManager.Instance.GetInstrument(item.InstrumentType).ErrorLimit / Math.Sqrt(3))), temp.Count, item.processMethod);
                calc.data.values  = temp;
                calc.data.userua  = double.Parse(StaticMethods.NumberFormat(item.UaExpression.GetExpressionExecuted()));
                calc.data.userub  = double.Parse(StaticMethods.NumberFormat(item.UbExpression.GetExpressionExecuted()));
                calc.data.userunc = double.Parse(StaticMethods.NumberFormat(item.ComplexExpression.GetExpressionExecuted()));
                CalcResult result = CalcResult.CheckTable(calc);
                if (!result.err.right)
                {
                    //MeasureErrorFlag = true;
                    if (!result.err.ua.right)
                    {
                        result.err.ua.userformula = item.UaExpression;
                    }
                    if (!result.err.ub.right)
                    {
                        result.err.ub.userformula = item.UbExpression;
                    }
                    if (!result.err.unc.right)
                    {
                        result.err.unc.userformula = item.ComplexExpression;
                    }
                    quantityErrors.Add(result.err);
                }
            }
            else if (item.processMethod == 2)//逐差法
            {
                UserInputSuccessiveDifference calc = new UserInputSuccessiveDifference();
                double[] temp = new double[item.DifferencedData.data.Count];
                for (int i = 0; i < item.DifferencedData.data.Count; i++)
                {
                    temp[i] = double.Parse(item.DifferencedData.data[i]);
                }
                calc.name = item.Symbol;
                calc.y_nplusi_minus_y_i = temp;
                calc.x_nplusi_minus_x_i = double.Parse(item.stepLength);
                calc.user_aver_b        = double.Parse(StaticMethods.NumberFormat(item.AverageExpression.GetExpressionExecuted()));
                calc.correct_b_uncb     = double.Parse(StaticMethods.NumberFormat(GameManager.Instance.GetInstrument(item.InstrumentType).ErrorLimit / Math.Sqrt(3))) / temp.Length;
                calc.user_b_unca        = double.Parse(StaticMethods.NumberFormat(item.UaExpression.GetExpressionExecuted()));
                calc.user_b_uncb        = double.Parse(StaticMethods.NumberFormat(item.UbExpression.GetExpressionExecuted()));
                calc.user_b_unc         = double.Parse(StaticMethods.NumberFormat(item.ComplexExpression.GetExpressionExecuted()));
                CalcResult result = CalcResult.CheckSuccessiveDifference(calc);
                if (!result.err.right)
                {
                    //MeasureErrorFlag = true;
                    if (!result.err.average.right)
                    {
                        result.err.average.userformula = item.AverageExpression;
                    }
                    if (!result.err.ua.right)
                    {
                        result.err.ua.userformula = item.UaExpression;
                    }
                    if (!result.err.ub.right)
                    {
                        result.err.ub.userformula = item.UbExpression;
                    }
                    if (!result.err.unc.right)
                    {
                        result.err.unc.userformula = item.ComplexExpression;
                    }
                    quantityErrors.Add(result.err);
                }
            }
            else if (item.processMethod == 3)//一元线性回归法
            {
                UserInputLinearRegression calc = new UserInputLinearRegression();
                calc.name = item.Symbol;
                double[] temp = new double[item.IndependentData.data.Count];
                for (int i = 0; i < item.IndependentData.data.Count; i++)
                {
                    temp[i] = double.Parse(item.IndependentData.data[i]);
                }
                calc.x = temp;
                double x_squre_mean, x_mean_square;
                //求方均根与均方根
                x_squre_mean  = StaticMethods.CenterMoment(temp, 2);
                x_mean_square = Math.Pow(StaticMethods.Average(temp), 2);
                //求方均根与均方根结束
                temp = new double[item.MesuredData.data.Count];
                for (int i = 0; i < item.MesuredData.data.Count; i++)
                {
                    temp[i] = double.Parse(item.MesuredData.data[i]);
                }
                calc.y            = temp;
                calc.a            = double.Parse(StaticMethods.NumberFormat(item.AExpression.GetExpressionExecuted()));
                calc.b            = double.Parse(StaticMethods.NumberFormat(item.BExpression.GetExpressionExecuted()));
                calc.r            = double.Parse(StaticMethods.NumberFormat(item.RelationExpression.GetExpressionExecuted()));
                calc.correct_uncb = double.Parse(StaticMethods.NumberFormat(GameManager.Instance.GetInstrument(item.InstrumentType).ErrorLimit / Math.Sqrt(3))) * Math.Sqrt(1 / (temp.Length * (x_squre_mean - x_mean_square)));
                calc.f_unca       = double.Parse(StaticMethods.NumberFormat(item.UaExpression.GetExpressionExecuted()));
                calc.f_uncb       = double.Parse(StaticMethods.NumberFormat(item.UbExpression.GetExpressionExecuted()));
                calc.f_unc        = double.Parse(StaticMethods.NumberFormat(item.ComplexExpression.GetExpressionExecuted()));
                calc.ifa          = (item.nextValue != 0);
                CalcResult result = CalcResult.CheckRegression(calc);
                if (!result.err.right)
                {
                    //MeasureErrorFlag = true;
                    if (!result.err.a.right)
                    {
                        result.err.a.userformula = item.AExpression;
                    }
                    if (!result.err.b.right)
                    {
                        result.err.b.userformula = item.BExpression;
                    }
                    if (!result.err.r.right)
                    {
                        result.err.r.userformula = item.RelationExpression;
                    }
                    if (!result.err.ua.right)
                    {
                        result.err.ua.userformula = item.UaExpression;
                    }
                    if (!result.err.ub.right)
                    {
                        result.err.ub.userformula = item.UbExpression;
                    }
                    if (!result.err.unc.right)
                    {
                        result.err.unc.userformula = item.ComplexExpression;
                    }
                    quantityErrors.Add(result.err);
                }
            }
            else if (item.processMethod == 4)
            {
                UserInputGraphic userInput = new UserInputGraphic()
                {
                    change_rate = double.Parse(item.change_rate),
                    point1_x    = double.Parse(item.point1_x),
                    point1_y    = double.Parse(item.point1_y),
                    point2_x    = double.Parse(item.point2_x),
                    point2_y    = double.Parse(item.point2_y),
                    varname     = item.Symbol
                };
                CalcResult result = CalcResult.CheckGraphic(userInput);
                if (!result.err.right)
                {
                    //MeasureErrorFlag = true;
                    if (!result.err.average.right)
                    {
                        result.err.average.userformula = item.AverageExpression;
                    }
                    quantityErrors.Add(result.err);
                }
            }
        }

        //直接测量量错误统计
        RecordManager.tempRecord.score.MeasureQuantityError += quantityErrors.Count;

        /*if (quantityErrors.Count > RecordManager.tempRecord.score.MeasureQuantityError)
         *  RecordManager.tempRecord.score.MeasureQuantityError = quantityErrors.Count;
         * else if (quantityErrors.Count < RecordManager.tempRecord.score.MeasureQuantityError)
         *  RecordManager.tempRecord.score.MeasureQuantityError += quantityErrors.Count;*/


        CheckComplex();
    }
    private void CheckComplex()
    {
        CalcArgs calc_complex = new CalcArgs();

        foreach (var item in RecordManager.tempRecord.quantities)
        {
            if (item.processMethod == 1)
            {
                calc_complex.AddVariable(item.Symbol, GameManager.Instance.GetInstrument(item.InstrumentType).ErrorLimit / Math.Sqrt(3), item.MesuredData.data.Count, item.processMethod);
                calc_complex.Measure(item.Symbol, item.MesuredData.data.ToDouble().ToArray());
            }
            else if (item.processMethod == 2)
            {
                double _ub = GameManager.Instance.GetInstrument(item.InstrumentType).ErrorLimit / Math.Sqrt(3) / item.DifferencedData.data.Count;
                calc_complex.AddVariable(item.Symbol, _ub, item.DifferencedData.data.Count, item.processMethod);
                calc_complex.Measure(item.Symbol, item.DifferencedData.data.ToDouble().ToArray());
            }
            else if (item.processMethod == 3)
            {
                double[] x = new double[item.MesuredData.data.Count];
                double[] y = new double[item.MesuredData.data.Count];
                for (int i = 0; i < item.MesuredData.data.Count; i++)
                {
                    y[i] = double.Parse(item.MesuredData.data[i]);
                    x[i] = double.Parse(item.IndependentData.data[i]);
                }

                //求n,方均根与均方根
                double[] temp = new double[item.IndependentData.data.Count];
                for (int i = 0; i < item.IndependentData.data.Count; i++)
                {
                    temp[i] = double.Parse(item.IndependentData.data[i]);
                }
                double k, x_squre_mean, x_mean_square;
                k             = temp.Length;
                x_squre_mean  = StaticMethods.CenterMoment(temp, 2);
                x_mean_square = Math.Pow(StaticMethods.Average(temp), 2);
                //求n,方均根与均方根结束
                double _ub = GameManager.Instance.GetInstrument(item.InstrumentType).ErrorLimit / Math.Sqrt(3) / Math.Sqrt(k * (x_squre_mean - x_mean_square));
                calc_complex.AddVariable(item.Symbol, _ub, x.Length, 3);
                calc_complex.Measure(item.Symbol, x);
                calc_complex.SelfValue(item.Symbol, y);
            }
            else
            {
                double[] x = new double[item.MesuredData.data.Count];
                double[] y = new double[item.MesuredData.data.Count];
                for (int i = 0; i < item.MesuredData.data.Count; i++)
                {
                    if (item.Yaxis == 0)
                    {
                        y[i] = double.Parse(item.MesuredData.data[i]);
                        x[i] = double.Parse(item.IndependentData.data[i]);
                    }
                    else
                    {
                        x[i] = double.Parse(item.MesuredData.data[i]);
                        y[i] = double.Parse(item.IndependentData.data[i]);
                    }
                }

                calc_complex.AddVariable(item.Symbol, 0, x.Length, 3);
                calc_complex.Measure(item.Symbol, x);
                calc_complex.SelfValue(item.Symbol, y);
            }

            if (item.processMethod == 4)
            {
                calc_complex.MeasureUserUnput(item.Symbol, 0, 0, 0);
            }
            else
            {
                calc_complex.MeasureUserUnput(item.Symbol, item.UaExpression.GetExpressionExecuted(), item.UbExpression.GetExpressionExecuted(), item.ComplexExpression.GetExpressionExecuted());
            }
        }
        CalcResult complexresult;

        if (RecordManager.tempRecord.quantities.Where(x => x.processMethod == 4).Any())
        {
            calc_complex.ComplexUserUnput(RecordManager.tempRecord.complexQuantityModel.AverageExpression.GetExpressionExecuted(), 0);
            complexresult = CalcArgs.CalculateComplexValueNoUncertain(RecordManager.tempRecord.stringExpression, calc_complex);
        }
        else
        {
            calc_complex.ComplexUserUnput(RecordManager.tempRecord.complexQuantityModel.AverageExpression.GetExpressionExecuted(), RecordManager.tempRecord.complexQuantityModel.UncertainExpression.GetExpressionExecuted());
            complexresult = CalcArgs.CalculateComplexValue(RecordManager.tempRecord.stringExpression, calc_complex);
        }

        if (complexresult.status != "计算无误")
        {
            if (!complexresult.err.answer.right)
            {
                RecordManager.tempRecord.score.ComplexQuantityError += 1;//合成测量量错误统计
                complexresult.err.answer.userformula = RecordManager.tempRecord.complexQuantityModel.AverageExpression;
            }
            if (!complexresult.err.answerunc.right)
            {
                RecordManager.tempRecord.score.ComplexQuantityError += 1;//合成测量量错误统计
                complexresult.err.answerunc.userformula              = RecordManager.tempRecord.complexQuantityModel.UncertainExpression;
            }
            quantityErrors.Add(complexresult.err);
        }
        //}
    }
    public string GetStatisticValue(MeasuredStatisticValue valueKind)
    {
        //根据记录的数据给公式编辑器传值
        string result = "error";

        if (valueKind == MeasuredStatisticValue.Symbol)
        {
            result = CurrentQuantity.Symbol;
        }
        else if (valueKind == MeasuredStatisticValue.Number)
        {
            result = CurrentQuantity.MesuredData.data.Count.ToString();
        }
        else if (valueKind == MeasuredStatisticValue.Average)
        {
            result = StaticMethods.Average(CurrentQuantity.MesuredData.data.ToDouble()).ToString();
        }
        else if (valueKind == MeasuredStatisticValue.SigmaX)
        {
            result = (StaticMethods.CenterMoment(CurrentQuantity.MesuredData.data.ToDouble(), 1)
                      * CurrentQuantity.MesuredData.data.Count).ToString();
        }
        else if (valueKind == MeasuredStatisticValue.SigmaXSquare)
        {
            result = (StaticMethods.CenterMoment(CurrentQuantity.MesuredData.data.ToDouble(), 2)
                      * CurrentQuantity.MesuredData.data.Count).ToString();
        }
        else if (valueKind == MeasuredStatisticValue.SigmaXCube)
        {
            result = (StaticMethods.CenterMoment(CurrentQuantity.MesuredData.data.ToDouble(), 3)
                      * CurrentQuantity.MesuredData.data.Count).ToString();
        }
        else if (valueKind == MeasuredStatisticValue.Variance)
        {
            result = StaticMethods.Variance(CurrentQuantity.MesuredData.data.ToDouble()).ToString();
        }
        else if (valueKind == MeasuredStatisticValue.StandardDeviation)
        {
            result = StaticMethods.StdDev(CurrentQuantity.MesuredData.data.ToDouble()).ToString();
        }
        else if (valueKind == MeasuredStatisticValue.InstrumentError)
        {
            result = GameManager.Instance.GetInstrument(CurrentQuantity.InstrumentType).ErrorLimit.ToString();
        }
        else if (valueKind == MeasuredStatisticValue.DeltaNumber)
        {
            result = CurrentQuantity.DifferencedData.data.Count.ToString();
        }
        else if (valueKind == MeasuredStatisticValue.DeltaXAverage)
        {
            result = StaticMethods.CenterMoment(CurrentQuantity.DifferencedData.data.ToDouble(), 1).ToString();
        }
        else if (valueKind == MeasuredStatisticValue.SigmaDeltaX)
        {
            result = (StaticMethods.CenterMoment(CurrentQuantity.DifferencedData.data.ToDouble(), 1)
                      * CurrentQuantity.DifferencedData.data.Count).ToString();
        }
        else if (valueKind == MeasuredStatisticValue.SigmaDeltaXSquare)
        {
            result = (StaticMethods.CenterMoment(CurrentQuantity.DifferencedData.data.ToDouble(), 2)
                      * CurrentQuantity.DifferencedData.data.Count).ToString();
        }
        else if (valueKind == MeasuredStatisticValue.SigmDeltaXCube)
        {
            result = (StaticMethods.CenterMoment(CurrentQuantity.DifferencedData.data.ToDouble(), 3)
                      * CurrentQuantity.DifferencedData.data.Count).ToString();
        }
        else if (valueKind == MeasuredStatisticValue.VarianceDelta)
        {
            result = StaticMethods.Variance(CurrentQuantity.DifferencedData.data.ToDouble()).ToString();
        }
        else if (valueKind == MeasuredStatisticValue.StandardDeviationDelta)
        {
            result = StaticMethods.StdDev(CurrentQuantity.DifferencedData.data.ToDouble()).ToString();
        }
        else if (valueKind == MeasuredStatisticValue.IndependentNumber)
        {
            result = CurrentQuantity.IndependentData.data.Count.ToString();
        }
        else if (valueKind == MeasuredStatisticValue.IndependentXAverage)
        {
            result = StaticMethods.Average(CurrentQuantity.IndependentData.data.ToDouble()).ToString();
        }
        else if (valueKind == MeasuredStatisticValue.SigmaIndependentX)
        {
            result = (StaticMethods.CenterMoment(CurrentQuantity.IndependentData.data.ToDouble(), 1)
                      * CurrentQuantity.IndependentData.data.Count).ToString();
        }
        else if (valueKind == MeasuredStatisticValue.SigmaIndependentXSquare)
        {
            result = (StaticMethods.CenterMoment(CurrentQuantity.IndependentData.data.ToDouble(), 2)
                      * CurrentQuantity.IndependentData.data.Count).ToString();
        }
        else if (valueKind == MeasuredStatisticValue.SigmIndependentXCube)
        {
            result = (StaticMethods.CenterMoment(CurrentQuantity.IndependentData.data.ToDouble(), 3)
                      * CurrentQuantity.IndependentData.data.Count).ToString();
        }
        else if (valueKind == MeasuredStatisticValue.SigmaXAndIndependentX)
        {
            List <double> list = new List <double>();
            for (int i = 0; i < CurrentQuantity.IndependentData.data.Count; i++)
            {
                list.Add(Convert.ToDouble(CurrentQuantity.IndependentData.data[i]) *
                         Convert.ToDouble(CurrentQuantity.MesuredData.data[i]));
            }
            result = (StaticMethods.CenterMoment(list, 1) * list.Count).ToString();
        }

        return(result);
    }