Esempio n. 1
0
        private void Evaluate(Token e)
        {
            double? result = null;
            string info = string.Empty;
            try
            {
                result = evaluator.Evaluate(e);
                InputEntry.Text = result.ToString();
                InputEntry.SelectionStart = InputEntry.Text.Length;
                InputEntry.SelectionLength = 0;
            }
            catch (EvaluationException ex)
            {
                info = ex.Message;
            }
            catch (Exception)
            {
                info = "Could not evaluate the expression due to an unknown problem";
            }

            viewModel.History.Insert(0,
                new LogModel
                {
                    Expression = e,
                    RawExpression = e.ToString(),
                    Result = result,
                    Info = info,
                    InfoColor = new SolidColorBrush(Windows.UI.Colors.LightGray)
                });
            RefreshVariables();
        }