Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            String deletedExpression = ExpressionList.GetItemText(ExpressionList.SelectedItem);

            ExpressionList.Items.Remove(deletedExpression);
            _cl.DeleteExpression(deletedExpression);
        }
Exemple #2
0
        private void ForceCalculateExpressionsButton_Click(object sender, EventArgs e)
        {
            try
            {
                Dictionary <String, Boolean> calculatedExpressions = _cl.ForceCalculateExpressions();

                String[] variables = _cl.GetVariables().Select(v => String.Format("{0} = {1}", v.Key, v.Value)).ToArray();

                String[] notCalculatedExpressions = ExpressionList.Items.OfType <String>()
                                                    .Where(ex => !calculatedExpressions.ContainsKey(ex)).ToArray();

                NotCalculatedExpressions.Items.Clear();
                NotCalculatedExpressions.Items.AddRange(notCalculatedExpressions);

                /*show variable list into form control*/
                VariableList.Items.Clear();
                VariableList.Items.AddRange(variables);

                Int32 selectedIndex = ExpressionList.SelectedIndex;

                if (selectedIndex >= 0)
                {
                    String markedExpression = ExpressionList.GetItemText(ExpressionList.Items[selectedIndex]);
                    ResultLabel.Text = (calculatedExpressions.ContainsKey(markedExpression))
                        ? String.Format("Result = {0}", calculatedExpressions[markedExpression])
                        : String.Format("Expression is not calculated");
                }
                else
                {
                    ResultLabel.Text = (calculatedExpressions.Count > 0)
                        ? String.Format("Result = {0}", calculatedExpressions.Last().Value)
                        : String.Format("Not exist calculated expressions");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }