// 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); } } } } }
/// <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); }
public void PushBufferUpTheStack() { ParentStack.Push(ValueInX); ClearBuffer(); }
private void SetSameLevel(string line) { ParentStack.Pop(); WriteChild(line); ParentStack.Push(line); }