private void ChartAreaValuesView1_AddClicked(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(_expressionTextProvider.Text))
            {
                _errorHandler.DisplayError(Strings.Expression_should_not_be_empty_,
                                           Strings.Warning_);
                return;
            }

            if (!AreChartValuesValid)
            {
                _errorHandler.DisplayError(
                    $"{Strings.Min_value_needs_to_be_less_than_Max_value}{Environment.NewLine}{Strings.CheckChartAreaValues}: x0, xN, y0, yN.",
                    Strings.Warning_);
                return;
            }
            try
            {
                customFunctionsEditor.ClearHighlightedErrors();
                CurrentChart.AddFunction(_expressionsEvaluator.Evaluate(_expressionTextProvider.Text,
                                                                        customFunctionsEditor.Text,
                                                                        _calculationsMode));
            }
            catch (Exception ex)
            {
                _exceptionsHandler.HandleException(ex);
            }
        }
        private void _view_ProcessClicked(object sender, EventArgs e)
        {
            _view.ConsoleOutput = Strings.ConsoleOutput + Environment.NewLine;

            _view.CodeEditorView.ClearHighlightedErrors();
            _customFunctionsEditor.ClearHighlightedErrors();

            try
            {
                var function = _eval.Evaluate(_view.CodeEditorView.Text, _customFunctionsEditor.Text);
                function.Evaluate(output => _view.AppendToConsole(output));
            }
            catch (Exception ex)
            {
                var exception = ex as CompilationException;
                if (exception != null)
                {
                    _view.CodeEditorView.HighlightErrors(exception.Errors[CompilationErrorPlace.MainCode]);
                }
                _exceptionsHandler.HandleException(ex);
            }
        }
예제 #3
0
 private void ChartAreaValuesView1_AddClicked(object sender, EventArgs e)
 {
     if (_expressionTextProvider.Text != "")
     {
         try
         {
             customFunctionsEditor.ClearHighlightedErrors();
             CurrentChart.AddFunction(_expressionsEvaluator.Evaluate(_expressionTextProvider.Text,
                                                                     customFunctionsEditor.Text,
                                                                     _calculationsMode));
         }
         catch (Exception ex)
         {
             _exceptionsHandler.HandleException(ex);
         }
     }
     else
     {
         _errorHandler.DispalyError(Strings.GUI_addToChartButton_Click_Expression_should_not_be_empty_,
                                    Strings.GUI_numericalOperationButton_Click_Warning_);
     }
 }