public void Copy(VisualSelectionRange selectionRange, TextRangeCopy output) { EditableVisualPointInfo startPoint = selectionRange.StartPoint; EditableVisualPointInfo endPoint = selectionRange.EndPoint; if (startPoint.Run != null) { if (startPoint.Run == endPoint.Run) { CopyRun elem = startPoint.Run.Copy( startPoint.RunLocalSelectedIndex, endPoint.LineCharIndex - startPoint.LineCharIndex); if (elem != null) { output.AppendRun(elem); } } else { GetStartAndStopLine(startPoint, endPoint, out TextLineBox startLine, out TextLineBox stopLine); if (startLine == stopLine) { CopyRun rightPart = startPoint.Run.Copy(startPoint.RunLocalSelectedIndex); if (rightPart != null) { output.AppendRun(rightPart); } if (startPoint.Run.NextRun != endPoint.Run) { foreach (Run run in _textFlowLayer.TextRunForward( startPoint.Run.NextRun, endPoint.Run.PrevRun)) { output.AppendRun(run); } } CopyRun leftPart = endPoint.Run.LeftCopy(endPoint.RunLocalSelectedIndex); if (leftPart != null) { output.AppendRun(leftPart); } } else { int startLineId = startPoint.LineId; int stopLineId = endPoint.LineId; startLine.RightCopy(startPoint, output); for (int i = startLineId + 1; i < stopLineId; i++) { //begine new line output.AppendNewLine(); TextLineBox line = _textFlowLayer.GetTextLine(i); line.Copy(output); } if (endPoint.LineCharIndex > -1) { output.AppendNewLine(); stopLine.LeftCopy(endPoint, output); } } } } else { GetStartAndStopLine(startPoint, endPoint, out TextLineBox startLine, out TextLineBox stopLine); if (startLine == stopLine) { if (startPoint.LineCharIndex == -1) { foreach (Run t in _textFlowLayer.TextRunForward( startPoint.Run, endPoint.Run.PrevRun)) { output.AppendRun(t); } CopyRun postCutTextRun = endPoint.Run.Copy(endPoint.RunLocalSelectedIndex + 1); if (postCutTextRun != null) { output.AppendRun(postCutTextRun); } } else { CopyRun rightPart = startPoint.Run.Copy(startPoint.RunLocalSelectedIndex + 1); if (rightPart != null) { output.AppendRun(rightPart); } foreach (Run t in _textFlowLayer.TextRunForward( startPoint.Run.NextRun, endPoint.Run.PrevRun)) { output.AppendRun(t.CreateCopy()); } CopyRun leftPart = endPoint.Run.LeftCopy(startPoint.RunLocalSelectedIndex); if (leftPart != null) { output.AppendRun(leftPart); } } } else { int startLineId = startPoint.LineId; int stopLineId = endPoint.LineId; startLine.RightCopy(startPoint, output); for (int i = startLineId + 1; i < stopLineId; i++) { output.AppendNewLine(); TextLineBox line = _textFlowLayer.GetTextLine(i); line.Copy(output); } stopLine.LeftCopy(endPoint, output); } } }
// public void CopySelectedTextRuns(VisualSelectionRange selectionRange, TextRangeCopy output) => _currentLine.Copy(selectionRange, output);