Пример #1
0
        // Methods/Functions
        public void AddDigit(string digit)
        {
            char chngSignChar = (char)0x00B1; //   the +/- symbol

            if (digit.Length != 1)
            {
                return;
            }
            if (char.IsDigit(digit, 0) || (digit == "." && !BufferHasDecimalPoint()))
            {
                if (BufferIsEmpty() && !XRegisterIsPlaceholder)
                {
                    ParentStack.Push(0);
                }
                XRegisterIsPlaceholder = false;
                if (BufferIsEmpty() && digit == ".")
                {
                    NewEntryBuffer = "0";
                }
                NewEntryBuffer += digit;
                ValueInX        = double.Parse(NewEntryBuffer);
            }
            else if (digit.CompareTo(chngSignChar.ToString()) == 0)
            {
                ValueInX *= -1;
                if (NewEntryBuffer.Length > 0)
                {
                    if (ValueInX < 0)
                    {
                        if (NewEntryBuffer.Substring(0, 1) != "-")
                        {
                            NewEntryBuffer = "-" + NewEntryBuffer;
                        }
                    }
                    else if (ValueInX > 0)
                    {
                        if (NewEntryBuffer.Substring(0, 1) == "-")
                        {
                            NewEntryBuffer = NewEntryBuffer.Substring(1);
                        }
                    }
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Controls the downgrade with multiple Pop() and insert a new parent to the tree.
 /// </summary>
 /// <param name="line"></param>
 private void SetDowngradeLevel(string line)
 {
     WriteChild(line);
     ParentStack.Push(line);
 }
Пример #3
0
 public void PushBufferUpTheStack()
 {
     ParentStack.Push(ValueInX);
     ClearBuffer();
 }
Пример #4
0
 private void SetSameLevel(string line)
 {
     ParentStack.Pop();
     WriteChild(line);
     ParentStack.Push(line);
 }