Ejemplo n.º 1
0
 public override void Calculate(CalculationItemStack calculationStack, bool isToAdd = true)
 {
     foreach (CalculationItem item in Equations)
     {
         item.Calculate(calculationStack);
     }
 }
Ejemplo n.º 2
0
        public override void Calculate(CalculationItemStack calculationStack, bool isToAdd = true)
        {
            if (null == Value)
            {
                if (null == Numbers)
                {
                    if (null != Symbolic)
                    {
                        List <SymbolValuePair> symbolValueList = calculationStack.GetAsSymbolValueList();
                        Numbers = Symbolic.Clone(symbolValueList);
                    }
                    else
                    {
                        if (null != Symbol)
                        {
                            List <SymbolValuePair> symbolValueList = calculationStack.GetAsSymbolValueList();
                            Value = (ValueItem)Symbol.Clone(symbolValueList);
                            return;
                        }
                    }
                }

                double value = Numbers.GetValue();
                Value       = new ValueItem();
                Value.Value = value;
            }

            if (isToAdd)
            {
                calculationStack.Items.Add(this);
            }
        }
Ejemplo n.º 3
0
        public override void Calculate(CalculationItemStack calculationStack, bool isToAdd = true)
        {
            Left.Calculate(calculationStack, false);
            Right.Calculate(calculationStack, false);

            bool isTrue = false;

            double leftValue  = Left.Value.GetValue();
            double rightValue = Right.Value.GetValue();

            if (TypeOfCondition == ConditionType.Equals)
            {
                isTrue = leftValue == rightValue;
            }
            else if (TypeOfCondition == ConditionType.Greater)
            {
                isTrue = leftValue > rightValue;
            }
            else if (TypeOfCondition == ConditionType.GreaterOrEqual)
            {
                isTrue = leftValue >= rightValue;
            }
            else if (TypeOfCondition == ConditionType.Less)
            {
                isTrue = leftValue < rightValue;
            }
            else if (TypeOfCondition == ConditionType.LessOrEqual)
            {
                isTrue = leftValue <= rightValue;
            }

            IsTrue = isTrue;
        }
Ejemplo n.º 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            try {
                List <string> lines   = textBox3.Lines.ToList();
                List <string> cleared = _calcBuilder.getCleaned(lines);

                cleared.Insert(0, "{");
                cleared.Add("}");

                CalculationItem      item  = _calcBuilder.Create(cleared);
                CalculationItemStack stack = new CalculationItemStack();
                item.Calculate(stack);

                EquationBlock block = new EquationBlock();
                foreach (CalculationItem stackItem in stack.Items)
                {
                    if (stackItem is Equation)
                    {
                        block.Equations.Add(stackItem);
                    }
                }

                _multiElement = _converter.Convert(block);
                panel2.Invalidate();
            } catch (Exception exc) {
                MessageBox.Show(exc.ToString(), "Bład", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 5
0
        public override void Calculate(CalculationItemStack calculationStack, bool isToAdd = true)
        {
            Condition.Calculate(calculationStack, false);

            if (Condition.IsTrue.Value)
            {
                TrueBlock.Calculate(calculationStack);
            }
            else
            {
                if (null != FalseBlock)
                {
                    FalseBlock.Calculate(calculationStack);
                }
            }
        }
Ejemplo n.º 6
0
 public override void Calculate(CalculationItemStack calculationStack, bool isToAdd = true)
 {
 }
Ejemplo n.º 7
0
 public abstract void Calculate(CalculationItemStack calculationStack, bool isToAdd = true);