예제 #1
0
 public override void Calculate(CalculationItemStack calculationStack, bool isToAdd = true)
 {
     foreach (CalculationItem item in Equations)
     {
         item.Calculate(calculationStack);
     }
 }
예제 #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);
            }
        }
예제 #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;
        }
예제 #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);
            }
        }
예제 #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);
                }
            }
        }
예제 #6
0
파일: For.cs 프로젝트: macieja79/formulas
 public override void Calculate(CalculationItemStack calculationStack, bool isToAdd = true)
 {
 }
예제 #7
0
 public abstract void Calculate(CalculationItemStack calculationStack, bool isToAdd = true);