コード例 #1
0
        // -------------------------------------
        public void Recalculate()
        {
            try
            {
                if (EqPreviewVariables.Count > 0)
                {
                    if (_bCalculating) return;
                    _bCalculating = true;

                    UpdateCalcInputs();
                    ClearResults();

                    CalcStatus calcStatus = _currentEquationCalc.CalculateAll();

                    IList<FunCalcError> lowestErrors = new List<FunCalcError>();
                    IList<FunCalcError> allErrors = new List<FunCalcError>();
                    _currentEquationCalc.GetErrors(ref lowestErrors, ref allErrors, NumberFormat: NumberFormat);
                    if (lowestErrors?.Count > 0)
                    {
                        _errorMessage = lowestErrors[0].Message;
                    }
                    else
                    {
                        foreach (var item in EqPreviewVariables)
                        {
                            if (item.UnExpectedDimensions)
                            {
                                _errorMessage = "Unexpected Dimensions in variables or results";
                            }
                        }
                    }
                    OnMessagesChanged();

                    RefreshEqPreviewVariables();

                    SetMaxUOMLength();
                    CalculationFinished?.Invoke(this, null);
                }
            }
            catch (Exception ex)
            {
                Logging.LogException(ex);
                throw;
            }
            finally
            {
                _bCalculating = false;
            }
        }
コード例 #2
0
        // -------------------------------------
        public void Recalculate()
        {
            try
            {
                if (EqCalcVariables.Count > 0)
                {
                    if (_bCalculating)
                    {
                        return;
                    }
                    _bCalculating = true;

                    UpdateCalcInputs();
                    ClearResults();

                    CalcStatus calcStatus = CurrentEquationCalc.CalculateAll();

                    IList <FunCalcError> lowestErrors = new List <FunCalcError>();
                    IList <FunCalcError> allErrors    = new List <FunCalcError>();
                    CurrentEquationCalc.GetErrors(ref lowestErrors, ref allErrors, NumberFormat: NumberFormat);
                    if (lowestErrors?.Count > 0)
                    {
                        _errorMessage = lowestErrors[0].Message;
                    }
                    OnMessagesChanged();

                    RefreshEqCalcVariables();

                    SetMaxUOMLength();
                    CalculationFinished?.Invoke(this, null);
                }
            }
            catch (Exception ex)
            {
                Logging.LogException(ex);
                throw;
            }
            finally
            {
                _bCalculating = false;
            }
        }