Example #1
0
        public void Functions()
        {
            var ctx = new MyFunctionContext();

            Assert.AreEqual(Parser.Parse("rectArea(10,20)").Eval(ctx), 200);
            Assert.AreEqual(Parser.Parse("rectPerimeter(10,20)").Eval(ctx), 60);
        }
Example #2
0
        private void textChangedEventHandler(object sender, TextChangedEventArgs args)
        {
            TextBox currentTextBox = sender as TextBox;

            Grid   targetGrid   = UIHelper.FindVisualParent <Grid>(currentTextBox);
            Button targetButton = UIHelper.FindChild <Button>(targetGrid, "OutputBox");

            targetButton.Content = currentTextBox.Text;



            string tex;
            var    ctx = new MyFunctionContext();

            //lib
            try
            {
                // need to set up library

                tex = Parser.Parse(currentTextBox.Text).Eval(ctx).ToString();
            }
            catch (Exception)
            {
                tex = "error";
            }

            targetButton.Content = tex;
        }