/// <summary> /// Takes the existing numbering groups in this stack and increments the last one. /// Returns a full string of the last group along with any (contiguously) concatenated values from higher in the stack /// </summary> /// <returns></returns> public string Increment() { if (this.Count == 0) { return(string.Empty); } //Get the highest group that is concatenated int index = this.Count - 1; while (index >= 0) { if (_items[index].ConcatenateWithParent == false) { break; } else if (index == 0) { break; } else { index--; } } if (index < 0) { return(string.Empty); } //Concatenate all the values together StringBuilder sb = new StringBuilder(); for (int depth = index; depth < this.Count; depth++) { PDFListNumberingGroup curr = this._items[depth]; if (depth == this.Count - 1) { curr.Increment(); } string value = curr.ToString(depth); if (null != value) { sb.Append(value); } } return(sb.ToString()); }