예제 #1
0
 private void RemoveParents(int level)
 {
     while (ParentStack.Count > level)
     {
         ParentStack.Pop();
     }
 }
예제 #2
0
        private string GetParent()
        {
            string parent = string.Empty;

            foreach (var s in ParentStack.Reverse())
            {
                parent = parent + " " + s;
            }
            return(parent);
        }
예제 #3
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);
                        }
                    }
                }
            }
        }
예제 #4
0
 public void PushBufferUpTheStack()
 {
     ParentStack.Push(ValueInX);
     ClearBuffer();
 }
예제 #5
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);
 }
예제 #6
0
 private void SetSameLevel(string line)
 {
     ParentStack.Pop();
     WriteChild(line);
     ParentStack.Push(line);
 }