Ejemplo n.º 1
0
        public FrameUpdate Layer3_modify()
        {
            BinaryOperator binaryOperator = Setting.Operators.GetBinary(Content);

            if (NumberField != null)
            {
                throw new Exception("ModifyBinary時Number不能有值");
            }
            ExpressionTreeManager.Modify(binaryOperator);
            return(new FrameUpdate(CurrentAnswer.ToString(), new ExpUpdate(removeLength: 1, updateString: Content.ToString())));
        }
Ejemplo n.º 2
0
        public FrameUpdate Layer3_add()
        {
            BinaryOperator binaryOperator = Setting.Operators.GetBinary(Content);

            //若沒有輸入過值,則視為輸入了0
            ExpressionTreeManager.Add((NumberField == null) ? 0 : NumberField.Number.Value);

            //數字歸零
            NumberField = null;

            //算出一個暫時的結果並存下
            CurrentAnswer = ExpressionTreeManager.TryGetTmpResult();

            ExpressionTreeManager.Add(binaryOperator);

            return(new FrameUpdate(CurrentAnswer.ToString(), new ExpUpdate(removeLength: 0, updateString: Content.ToString())));
        }
Ejemplo n.º 3
0
        public FrameUpdate Layer3_equalCombo()
        {
            string updateString = CurrentAnswer.ToString();

            //更新計算答案
            CurrentAnswer = ExpressionTreeManager.GetLastTreeReplaceLeftResult(CurrentAnswer);
            var op = ExpressionTreeManager.GetLastTreeTopOperator();

            updateString += op;

            var rightNumber = ExpressionTreeManager.GetLastTreeRightResult();

            updateString += rightNumber.ToString();

            updateString += "=";

            return(new FrameUpdate(CurrentAnswer.ToString(), new ExpUpdate(removeLength: ExpUpdate.REMOVE_ALL, updateString: updateString)));
        }
Ejemplo n.º 4
0
        public FrameUpdate Layer3_binaryAndEqualCombo()
        {
            //CurrentAnswer已經被Binary算好了
            ExpressionTreeManager.Add(CurrentAnswer);

            //result處理
            var result = ExpressionTreeManager.TryGetResult();
            var ans    = result.Answer;

            //做更新字串
            var updateString = CurrentAnswer.ToString();

            for (int i = 0; i < result.ExtraRightBracketCount; i++)
            {
                updateString += ")";
            }

            //送出結果
            updateString += "=";

            return(new FrameUpdate(ans.ToString(), new ExpUpdate(removeLength: 0, updateString: updateString)));
        }