예제 #1
0
 public Sinusad(ref Sinusad E, ref Equation A)
 {
     InitializeComponent();
     E = this;
     EqationVariable = A;
 }
예제 #2
0
        public override bool TryCreate(List <string> lines, CalculationBuilder builder, out CalculationItem item)
        {
            string pattern = lines.First();

            bool isMatch = Regex.IsMatch(pattern, REGEX_PATTERN);

            if (!isMatch)
            {
                FormulaItem supposedFormula = _formulaBuilder.Create(pattern);
                if (supposedFormula is ValueItem)
                {
                    Equation iEquation = new Equation();
                    iEquation.Value = (ValueItem)supposedFormula;
                    item            = iEquation;
                    builder.RemoveLines(lines, 1);
                    return(true);
                }

                if (supposedFormula is SymbolItem)
                {
                    Equation iEquation = new Equation();
                    iEquation.Symbol = (SymbolItem)supposedFormula;
                    item             = iEquation;
                    builder.RemoveLines(lines, 1);
                    return(true);
                }

                item = null;
                return(false);
            }

            string left  = RegexTools.GetValue(pattern, REGEX_PATTERN, "left");
            string right = RegexTools.GetValue(pattern, REGEX_PATTERN, "right");

            FormulaItem symbol  = _formulaBuilder.Create(left);
            FormulaItem formula = _formulaBuilder.Create(right);

            Equation equation = new Equation();

            equation.Symbol = (SymbolItem)symbol;

            if (formula is ValueItem)
            {
                equation.Value = (ValueItem)formula;
            }
            else
            {
                if (formula.IsSymbol)
                {
                    equation.Symbolic = formula;
                }
                else
                {
                    equation.Numbers = formula;
                }
            }

            item = equation;

            builder.RemoveLines(lines, 1);

            return(true);
        }