void AddInternal(Line line, Unit parentLeft, Unit topOfPage, Unit topOfParentLine) { var topOfLine = topOfParentLine + line.Top; foreach (var element in line.Elements) { var elementLeft = parentLeft + element.Left; Elements.Add(new FixedElement(element, elementLeft, topOfLine - topOfPage)); var elementTopBorder = element.Edge.Top; var elementLeftBorder = element.Edge.Left; foreach (var child in element.Children) { AddInternal(child, elementLeft + elementLeftBorder, topOfPage, topOfLine + elementTopBorder); } } }
public KeepTogetherBatch RetryByBacktracking(Line currentLine) { var lines = Results.Concat(currentLine).Concat(WorkingQueue).ToList(); var numberOfLinesToBacktrack = CurrentNumberOfLinesBeingBacktracked + 1; if (numberOfLinesToBacktrack < lines.Count) { var numberOfLinesInResultToLeaveAsIs = lines.Count - (numberOfLinesToBacktrack + 1); var keepAsResult = lines.Take(numberOfLinesInResultToLeaveAsIs).ToList(); var retry = lines.Skip(numberOfLinesInResultToLeaveAsIs).Select((x, i) => i == 0 ? x.DoNotStayPut() : x).ToList(); return new KeepTogetherBatch(this, retry, resetCanNotStayPut: false) { CurrentNumberOfLinesBeingBacktracked = numberOfLinesToBacktrack, Results = keepAsResult, }; } return new KeepTogetherBatch(this, lines, resetCanNotStayPut: true) { AllowKeepTogether = false }; }
public void Add(Line line, Unit topOfPage) { AddInternal(line, 0.cm(), topOfPage, 0.cm()); }