public VisualPointInfo GetTextPointInfoFromCaretPoint(int caretX) { int accTextRunWidth = 0; int accTextRunCharCount = 0; EditableRun lastestTextRun = null; foreach (EditableRun t in this._runs) { lastestTextRun = t; int thisTextRunWidth = t.Width; if (accTextRunWidth + thisTextRunWidth > caretX) { EditableRunCharLocation localPointInfo = t.GetCharacterFromPixelOffset(caretX - thisTextRunWidth); EditableVisualPointInfo pointInfo = new EditableVisualPointInfo(this, accTextRunCharCount + localPointInfo.RunCharIndex); pointInfo.SetAdditionVisualInfo(t, accTextRunCharCount, caretX, accTextRunWidth); return(pointInfo); } else { accTextRunWidth += thisTextRunWidth; accTextRunCharCount += t.CharacterCount; } } if (lastestTextRun != null) { return(null); } else { EditableVisualPointInfo pInfo = new EditableVisualPointInfo(this, -1); pInfo.SetAdditionVisualInfo(null, accTextRunCharCount, caretX, accTextRunWidth); return(pInfo); } }
public VisualSelectionRange( EditableVisualPointInfo startPoint, EditableVisualPointInfo endPoint) { this.startPoint = startPoint; this.endPoint = endPoint; this.BackgroundColor = Color.LightGray; }
EditableVisualPointInfo CreateTextPointInfo(int lineId, int lineCharIndex, int caretPixelX, EditableRun onTextRun, int textRunCharOffset, int textRunPixelOffset) { EditableVisualPointInfo textPointInfo = new EditableVisualPointInfo(this, lineCharIndex); textPointInfo.SetAdditionVisualInfo(onTextRun, textRunCharOffset, caretPixelX, textRunPixelOffset); return(textPointInfo); }
public void UpdateSelectionRange() { if (startPoint.TextRun != null && !startPoint.TextRun.HasParent) { EditableTextLine startLine = startPoint.EditableLine; startPoint = startLine.GetTextPointInfoFromCharIndex(startPoint.LineCharIndex); } if (endPoint.TextRun != null && !endPoint.TextRun.HasParent) { EditableTextLine stopLine = endPoint.EditableLine; endPoint = stopLine.GetTextPointInfoFromCharIndex(endPoint.LineCharIndex); } }
public EditableVisualPointInfo GetCurrentPointInfo() { #if DEBUG if (currentTextRun != null && !currentTextRun.HasParent) { throw new NotSupportedException(); } if (currentTextRun == null) { } #endif EditableVisualPointInfo textPointInfo = new EditableVisualPointInfo(currentLine, caret_char_index); textPointInfo.SetAdditionVisualInfo(currentTextRun, rCharOffset, caretXPos, rPixelOffset); return(textPointInfo); }
public void Draw(Canvas destPage, Rectangle updateArea) { if (IsOnTheSameLine) { VisualPointInfo topEndPoint = TopEnd; VisualPointInfo bottomEndPoint = BottomEnd; int linetop = topEndPoint.LineTop; destPage.FillRectangle(Color.LightGray, topEndPoint.X, linetop, bottomEndPoint.X - topEndPoint.X, topEndPoint.ActualLineHeight); } else { EditableVisualPointInfo topEndPoint = TopEnd; int lineYPos = topEndPoint.LineTop; destPage.FillRectangle(Color.LightGray, topEndPoint.X, lineYPos, topEndPoint.CurrentWidth - topEndPoint.X, topEndPoint.ActualLineHeight); int topLineId = topEndPoint.LineId; int bottomLineId = BottomEnd.LineId; if (bottomLineId - topLineId > 1) { EditableTextLine adjacentStartLine = topEndPoint.EditableLine.Next; while (adjacentStartLine != BottomEnd.Line) { destPage.FillRectangle(Color.LightGray, 0, adjacentStartLine.LineTop, adjacentStartLine.CurrentWidth, adjacentStartLine.ActualLineHeight); adjacentStartLine = adjacentStartLine.Next; } EditableTextLine adjacentStopLine = BottomEnd.Line.Prev; } VisualPointInfo bottomEndPoint = BottomEnd; lineYPos = bottomEndPoint.LineTop; destPage.FillRectangle(Color.LightGray, 0, lineYPos, bottomEndPoint.X, bottomEndPoint.ActualLineHeight); } }
public void SwapIfUnOrder() { if (IsOnTheSameLine) { if (startPoint.LineCharIndex > endPoint.LineCharIndex) { EditableVisualPointInfo tmpPoint = startPoint; startPoint = endPoint; endPoint = tmpPoint; } } else { if (startPoint.LineId > endPoint.LineId) { EditableVisualPointInfo tmp = startPoint; startPoint = endPoint; endPoint = tmp; } } }
public EditableVisualPointInfo GetTextPointInfoFromCharIndex(int charIndex) { int limit = CharCount - 1; if (charIndex > limit) { charIndex = limit; } EditableVisualPointInfo textPointInfo = new EditableVisualPointInfo(this, charIndex); int rCharOffset = 0; int rPixelOffset = 0; EditableRun lastestRun = null; foreach (EditableRun r in this) { lastestRun = r; int thisCharCount = lastestRun.CharacterCount; if (thisCharCount + rCharOffset > charIndex) { int localCharOffset = charIndex - rCharOffset; int pixelOffset = lastestRun.GetRunWidth(localCharOffset); textPointInfo.SetAdditionVisualInfo(lastestRun, localCharOffset, rPixelOffset + pixelOffset , rPixelOffset); return(textPointInfo); } else { rCharOffset += thisCharCount; rPixelOffset += r.Width; } } textPointInfo.SetAdditionVisualInfo(lastestRun, rCharOffset - lastestRun.CharacterCount, rPixelOffset, rPixelOffset - lastestRun.Width); return(textPointInfo); }
public VisualSelectionRange(EditableVisualPointInfo startPoint, EditableVisualPointInfo endPoint) { this.startPoint = startPoint; this.endPoint = endPoint; }
public EditableVisualPointInfo GetTextPointInfoFromCharIndex(int charIndex) { int limit = CharCount - 1; if (charIndex > limit) { charIndex = limit; } EditableVisualPointInfo textPointInfo = new EditableVisualPointInfo(this, charIndex); int rCharOffset = 0; int rPixelOffset = 0; EditableRun lastestRun = null; foreach (EditableRun r in this) { lastestRun = r; int thisCharCount = lastestRun.CharacterCount; if (thisCharCount + rCharOffset > charIndex) { int localCharOffset = charIndex - rCharOffset; int pixelOffset = lastestRun.GetRunWidth(localCharOffset); textPointInfo.SetAdditionVisualInfo(lastestRun, localCharOffset, rPixelOffset + pixelOffset , rPixelOffset); return textPointInfo; } else { rCharOffset += thisCharCount; rPixelOffset += r.Width; } } textPointInfo.SetAdditionVisualInfo(lastestRun, rCharOffset - lastestRun.CharacterCount, rPixelOffset, rPixelOffset - lastestRun.Width); return textPointInfo; }
public VisualPointInfo GetTextPointInfoFromCaretPoint(int caretX) { int accTextRunWidth = 0; int accTextRunCharCount = 0; EditableRun lastestTextRun = null; foreach (EditableRun t in this) { lastestTextRun = t; int thisTextRunWidth = t.Width; if (accTextRunWidth + thisTextRunWidth > caretX) { EditableRunCharLocation localPointInfo = t.GetCharacterFromPixelOffset(caretX - thisTextRunWidth); EditableVisualPointInfo pointInfo = new EditableVisualPointInfo(this, accTextRunCharCount + localPointInfo.charIndex); pointInfo.SetAdditionVisualInfo(t, accTextRunCharCount, caretX, accTextRunWidth); return pointInfo; } else { accTextRunWidth += thisTextRunWidth; accTextRunCharCount += t.CharacterCount; } } if (lastestTextRun != null) { return null; } else { EditableVisualPointInfo pInfo = new EditableVisualPointInfo(this, -1); pInfo.SetAdditionVisualInfo(null, accTextRunCharCount, caretX, accTextRunWidth); return pInfo; } }
internal EditableVisualPointInfo Split(EditableVisualPointInfo pointInfo) { if (pointInfo.LineId != currentLineNumber) { throw new NotSupportedException(); } EditableRun tobeCutRun = (EditableRun)pointInfo.TextRun; if (tobeCutRun == null) { return(CreateTextPointInfo( pointInfo.LineId, pointInfo.LineCharIndex, pointInfo.X, null, pointInfo.TextRunCharOffset, pointInfo.TextRunPixelOffset)); } this.LocalSuspendLineReArrange(); EditableVisualPointInfo result = null; EditableRun preCutTextRun = (EditableRun)tobeCutRun.LeftCopy(pointInfo.RunLocalSelectedIndex); EditableRun postCutTextRun = (EditableRun)tobeCutRun.Copy(pointInfo.RunLocalSelectedIndex); if (preCutTextRun != null) { this.AddBefore(tobeCutRun, preCutTextRun); if (postCutTextRun != null) { this.AddAfter(tobeCutRun, postCutTextRun); } result = CreateTextPointInfo( pointInfo.LineId, pointInfo.LineCharIndex, pointInfo.X, preCutTextRun, pointInfo.TextRunCharOffset, pointInfo.TextRunPixelOffset); } else { if (postCutTextRun != null) { this.AddAfter(tobeCutRun, postCutTextRun); } EditableRun infoTextRun = null; if (IsSingleLine) { if (tobeCutRun.PrevTextRun != null) { infoTextRun = tobeCutRun.PrevTextRun; } else { infoTextRun = tobeCutRun.NextTextRun; } } else { if (IsFirstLine) { if (tobeCutRun.PrevTextRun != null) { infoTextRun = tobeCutRun.PrevTextRun; } else { if (tobeCutRun.NextTextRun.IsLineBreak) { infoTextRun = null; } else { infoTextRun = tobeCutRun.NextTextRun; } } } else if (IsLastLine) { if (tobeCutRun.PrevTextRun != null) { if (tobeCutRun.PrevTextRun.IsLineBreak) { if (tobeCutRun.NextTextRun != null) { infoTextRun = tobeCutRun.NextTextRun; } else { infoTextRun = null; } } else { infoTextRun = tobeCutRun.PrevTextRun; } } else { } } else { if (!tobeCutRun.NextTextRun.IsLineBreak) { infoTextRun = tobeCutRun.NextTextRun; } else { infoTextRun = null; } } } result = CreateTextPointInfo( pointInfo.LineId, pointInfo.LineCharIndex, pointInfo.X, infoTextRun, pointInfo.TextRunCharOffset, pointInfo.TextRunPixelOffset); } this.Remove(tobeCutRun); this.LocalResumeLineReArrange(); return(result); }
public void Copy(VisualSelectionRange selectionRange, List <EditableRun> output) { EditableVisualPointInfo startPoint = selectionRange.StartPoint; EditableVisualPointInfo endPoint = selectionRange.EndPoint; if (startPoint.TextRun != null) { if (startPoint.TextRun == endPoint.TextRun) { EditableRun elem = startPoint.TextRun.Copy( startPoint.RunLocalSelectedIndex, endPoint.LineCharIndex - startPoint.LineCharIndex); if (elem != null) { output.Add(elem); } } else { EditableTextLine startLine = null; EditableTextLine stopLine = null; if (startPoint.LineId == currentLineNumber) { startLine = this; } else { startLine = editableFlowLayer.GetTextLine(startPoint.LineId); } if (endPoint.LineId == currentLineNumber) { stopLine = this; } else { stopLine = editableFlowLayer.GetTextLine(endPoint.LineId); } if (startLine == stopLine) { EditableRun postCutTextRun = startPoint.TextRun.Copy(startPoint.RunLocalSelectedIndex); if (postCutTextRun != null) { output.Add(postCutTextRun); } if (startPoint.TextRun.NextTextRun != endPoint.TextRun) { foreach (EditableRun t in editableFlowLayer.TextRunForward(startPoint.TextRun.NextTextRun, endPoint.TextRun.PrevTextRun)) { output.Add(t.Clone()); } } EditableRun preCutTextRun = endPoint.TextRun.LeftCopy(endPoint.RunLocalSelectedIndex); if (preCutTextRun != null) { output.Add(preCutTextRun); } } else { int startLineId = startPoint.LineId; int stopLineId = endPoint.LineId; startLine.RightCopy(startPoint, output); for (int i = startLineId + 1; i < stopLineId; i++) { output.Add(new EditableTextRun(this.Root, '\n', this.CurrentTextSpanStyle)); EditableTextLine line = editableFlowLayer.GetTextLine(i); line.Copy(output); } if (endPoint.LineCharIndex > -1) { output.Add(new EditableTextRun(this.Root, '\n', this.CurrentTextSpanStyle)); stopLine.LeftCopy(endPoint, output); } } } } else { EditableTextLine startLine = null; EditableTextLine stopLine = null; if (startPoint.LineId == currentLineNumber) { startLine = this; } else { startLine = editableFlowLayer.GetTextLine(startPoint.LineId); } if (endPoint.LineId == currentLineNumber) { stopLine = this; } else { stopLine = editableFlowLayer.GetTextLine(endPoint.LineId); } if (startLine == stopLine) { if (startPoint.LineCharIndex == -1) { foreach (EditableRun t in editableFlowLayer.TextRunForward(startPoint.TextRun, endPoint.TextRun.PrevTextRun)) { output.Add(t.Clone()); } EditableRun postCutTextRun = endPoint.TextRun.Copy(endPoint.RunLocalSelectedIndex + 1); if (postCutTextRun != null) { output.Add(postCutTextRun); } } else { EditableRun postCutTextRun = startPoint.TextRun.Copy(startPoint.RunLocalSelectedIndex + 1); if (postCutTextRun != null) { output.Add(postCutTextRun); } foreach (EditableRun t in editableFlowLayer.TextRunForward(startPoint.TextRun.NextTextRun, endPoint.TextRun.PrevTextRun)) { output.Add(t.Clone()); } EditableRun preCutTextRun = endPoint.TextRun.LeftCopy(startPoint.RunLocalSelectedIndex); if (preCutTextRun != null) { output.Add(preCutTextRun); } } } else { int startLineId = startPoint.LineId; int stopLineId = endPoint.LineId; startLine.RightCopy(startPoint, output); for (int i = startLineId + 1; i < stopLineId; i++) { output.Add(new EditableTextRun(this.Root, '\n', this.CurrentTextSpanStyle)); EditableTextLine line = editableFlowLayer.GetTextLine(i); line.Copy(output); } stopLine.LeftCopy(endPoint, output); } } }
internal EditableVisualPointInfo[] Split(VisualSelectionRange selectionRange) { selectionRange.SwapIfUnOrder(); EditableVisualPointInfo startPoint = selectionRange.StartPoint; EditableVisualPointInfo endPoint = selectionRange.EndPoint; if (startPoint.TextRun == endPoint.TextRun) { EditableRun toBeCutTextRun = startPoint.TextRun; EditableRun preCutTextRun = (EditableRun)toBeCutTextRun.LeftCopy(startPoint.RunLocalSelectedIndex); EditableRun middleCutTextRun = (EditableRun)toBeCutTextRun.Copy(startPoint.RunLocalSelectedIndex + 1, endPoint.LineCharIndex - startPoint.LineCharIndex); EditableRun postCutTextRun = (EditableRun)toBeCutTextRun.Copy(endPoint.RunLocalSelectedIndex + 1); EditableVisualPointInfo newStartRangePointInfo = null; EditableVisualPointInfo newEndRangePointInfo = null; EditableTextLine line = this; if (startPoint.LineId != currentLineNumber) { line = editableFlowLayer.GetTextLine(startPoint.LineId); } line.LocalSuspendLineReArrange(); if (preCutTextRun != null) { line.AddBefore(toBeCutTextRun, preCutTextRun); newStartRangePointInfo = CreateTextPointInfo( startPoint.LineId, startPoint.LineCharIndex, startPoint.X, preCutTextRun, startPoint.TextRunCharOffset, startPoint.TextRunPixelOffset); } else { EditableRun prevTxtRun = GetPrevTextRun((EditableRun)startPoint.TextRun); if (prevTxtRun != null) { newStartRangePointInfo = CreateTextPointInfo( startPoint.LineId, startPoint.LineCharIndex, startPoint.X, prevTxtRun, startPoint.TextRunCharOffset - preCutTextRun.CharacterCount, startPoint.TextRunPixelOffset - prevTxtRun.Width); } else { newStartRangePointInfo = CreateTextPointInfo( startPoint.LineId, startPoint.LineCharIndex, 0, null, 0, 0); } } if (postCutTextRun != null) { line.AddAfter(toBeCutTextRun, postCutTextRun); newEndRangePointInfo = CreateTextPointInfo( endPoint.LineId, endPoint.LineCharIndex, endPoint.X, middleCutTextRun, startPoint.TextRunCharOffset + middleCutTextRun.CharacterCount, startPoint.TextRunPixelOffset + middleCutTextRun.Width); } else { EditableRun nextTxtRun = GetNextTextRun((EditableRun)endPoint.TextRun); if (nextTxtRun != null) { newEndRangePointInfo = CreateTextPointInfo( endPoint.LineId, endPoint.LineCharIndex, endPoint.X, nextTxtRun, endPoint.TextRunPixelOffset + endPoint.TextRun.CharacterCount, endPoint.TextRunPixelOffset + endPoint.TextRun.Width); } else { newEndRangePointInfo = CreateTextPointInfo( endPoint.LineId, endPoint.LineCharIndex, endPoint.X, middleCutTextRun, endPoint.TextRunCharOffset, endPoint.TextRunPixelOffset); } } if (middleCutTextRun != null) { line.AddAfter(toBeCutTextRun, middleCutTextRun); } else { throw new NotSupportedException(); } line.Remove(toBeCutTextRun); line.LocalResumeLineReArrange(); return(new EditableVisualPointInfo[] { newStartRangePointInfo, newEndRangePointInfo }); } else { EditableTextLine workingLine = this; if (startPoint.LineId != currentLineNumber) { workingLine = editableFlowLayer.GetTextLine(startPoint.LineId); } EditableVisualPointInfo newStartPoint = workingLine.Split(startPoint); workingLine = this; if (endPoint.LineId != currentLineNumber) { workingLine = editableFlowLayer.GetTextLine(endPoint.LineId); } EditableVisualPointInfo newEndPoint = workingLine.Split(endPoint); return(new EditableVisualPointInfo[] { newStartPoint, newEndPoint }); } }
EditableVisualPointInfo CreateTextPointInfo(int lineId, int lineCharIndex, int caretPixelX, EditableRun onTextRun, int textRunCharOffset, int textRunPixelOffset) { EditableVisualPointInfo textPointInfo = new EditableVisualPointInfo(this, lineCharIndex); textPointInfo.SetAdditionVisualInfo(onTextRun, textRunCharOffset, caretPixelX, textRunPixelOffset); return textPointInfo; }
public EditableVisualPointInfo GetCurrentPointInfo() { #if DEBUG if (currentTextRun != null && !currentTextRun.HasParent) { throw new NotSupportedException(); } if (currentTextRun == null) { } #endif EditableVisualPointInfo textPointInfo = new EditableVisualPointInfo(currentLine, charIndex); textPointInfo.SetAdditionVisualInfo(currentTextRun, rCharOffset, caretXPos, rPixelOffset); return textPointInfo; }
internal void Remove(VisualSelectionRange selectionRange) { EditableVisualPointInfo startPoint = selectionRange.StartPoint; EditableVisualPointInfo endPoint = selectionRange.EndPoint; if (startPoint.TextRun != null) { if (startPoint.TextRun == endPoint.TextRun) { EditableRun removedRun = (EditableRun)startPoint.TextRun; EditableRun.InnerRemove(removedRun, startPoint.RunLocalSelectedIndex, endPoint.LineCharIndex - startPoint.LineCharIndex, false); if (removedRun.CharacterCount == 0) { if (startPoint.LineId == this.currentLineNumber) { this.Remove(removedRun); } else { EditableTextLine line = editableFlowLayer.GetTextLine(startPoint.LineId); line.Remove(removedRun); } } } else { EditableVisualPointInfo newStartPoint = null; EditableVisualPointInfo newStopPoint = null; EditableTextLine startLine = null; EditableTextLine stopLine = null; if (startPoint.LineId == currentLineNumber) { startLine = this; } else { startLine = editableFlowLayer.GetTextLine(startPoint.LineId); } newStartPoint = startLine.Split(startPoint); if (endPoint.LineId == currentLineNumber) { stopLine = this; } else { stopLine = editableFlowLayer.GetTextLine(endPoint.LineId); } newStopPoint = stopLine.Split(endPoint); if (startLine == stopLine) { if (newStartPoint.TextRun != null) { LinkedList <EditableRun> tobeRemoveRuns = new LinkedList <EditableRun>(); if (newStartPoint.LineCharIndex == 0) { foreach (EditableRun t in editableFlowLayer.TextRunForward( (EditableRun)newStartPoint.TextRun, (EditableRun)newStopPoint.TextRun)) { tobeRemoveRuns.AddLast(t); } } else { foreach (EditableRun t in editableFlowLayer.TextRunForward( newStartPoint.TextRun.NextTextRun, (EditableRun)newStopPoint.TextRun)) { tobeRemoveRuns.AddLast(t); } } startLine.LocalSuspendLineReArrange(); foreach (EditableRun t in tobeRemoveRuns) { startLine.Remove(t); } startLine.LocalResumeLineReArrange(); } else { throw new NotSupportedException(); } } else { int startLineId = newStartPoint.LineId; int stopLineId = newStopPoint.LineId; if (newStopPoint.LineCharIndex > 0) { stopLine.RemoveLeft((EditableRun)newStopPoint.TextRun); } for (int i = stopLineId - 1; i > startLineId; i--) { EditableTextLine line = editableFlowLayer.GetTextLine(i); line.Clear(); line.JoinWithNextLine(); } if (newStartPoint.LineCharIndex == 0) { startLine.RemoveRight((EditableRun)newStartPoint.TextRun); } else { EditableRun nextRun = ((EditableRun)newStartPoint.TextRun).NextTextRun; if (nextRun != null && !nextRun.IsLineBreak) { startLine.RemoveRight(nextRun); } } startLine.JoinWithNextLine(); } } } else { VisualPointInfo newStartPoint = null; VisualPointInfo newStopPoint = null; EditableTextLine startLine = null; EditableTextLine stopLine = null; if (startPoint.LineId == this.currentLineNumber) { startLine = this; } else { startLine = editableFlowLayer.GetTextLine(startPoint.LineId); } newStartPoint = startLine.Split(startPoint); if (endPoint.LineId == currentLineNumber) { stopLine = this; } else { stopLine = editableFlowLayer.GetTextLine(endPoint.LineId); } newStopPoint = stopLine.Split(endPoint); if (startLine == stopLine) { if (newStartPoint.TextRun != null) { LinkedList <EditableRun> tobeRemoveRuns = new LinkedList <EditableRun>(); if (newStartPoint.LineCharIndex == -1) { foreach (EditableRun t in editableFlowLayer.TextRunForward( (EditableRun)newStartPoint.TextRun, (EditableRun)newStopPoint.TextRun)) { tobeRemoveRuns.AddLast(t); } } else { foreach (EditableRun t in editableFlowLayer.TextRunForward( newStartPoint.TextRun.NextTextRun, (EditableRun)newStopPoint.TextRun)) { tobeRemoveRuns.AddLast(t); } } foreach (EditableRun t in tobeRemoveRuns) { startLine.Remove(t); } } else { throw new NotSupportedException(); } } else { int startLineId = newStartPoint.LineId; int stopLineId = newStopPoint.LineId; if (newStopPoint.LineCharIndex > -1) { stopLine.RemoveLeft((EditableRun)newStopPoint.TextRun); } for (int i = stopLineId - 1; i > startLineId; i--) { EditableTextLine line = editableFlowLayer.GetTextLine(i); line.Clear(); line.JoinWithNextLine(); } if (newStartPoint.LineCharIndex == -1) { if (newStartPoint.TextRun != null) { startLine.RemoveRight((EditableRun)newStartPoint.TextRun); } } else { EditableRun nextRun = newStartPoint.TextRun.NextTextRun; if (nextRun != null && !nextRun.IsLineBreak) { startLine.RemoveRight(nextRun); } } startLine.JoinWithNextLine(); } } }
internal EditableVisualPointInfo Split(EditableVisualPointInfo pointInfo) { if (pointInfo.LineId != currentLineNumber) { throw new NotSupportedException(); } EditableRun tobeCutRun = (EditableRun)pointInfo.TextRun; if (tobeCutRun == null) { return CreateTextPointInfo( pointInfo.LineId, pointInfo.LineCharIndex, pointInfo.X, null, pointInfo.TextRunCharOffset, pointInfo.TextRunPixelOffset); } this.LocalSuspendLineReArrange(); EditableVisualPointInfo result = null; EditableRun preCutTextRun = (EditableRun)tobeCutRun.LeftCopy(pointInfo.LocalSelectedIndex); EditableRun postCutTextRun = (EditableRun)tobeCutRun.Copy(pointInfo.LocalSelectedIndex + 1); if (preCutTextRun != null) { this.AddBefore(tobeCutRun, preCutTextRun); if (postCutTextRun != null) { this.AddAfter(tobeCutRun, postCutTextRun); } result = CreateTextPointInfo( pointInfo.LineId, pointInfo.LineCharIndex, pointInfo.X, preCutTextRun, pointInfo.TextRunCharOffset, pointInfo.TextRunPixelOffset); } else { if (postCutTextRun != null) { this.AddAfter(tobeCutRun, postCutTextRun); } EditableRun infoTextRun = null; if (IsSingleLine) { if (tobeCutRun.PrevTextRun != null) { infoTextRun = tobeCutRun.PrevTextRun; } else { infoTextRun = tobeCutRun.NextTextRun; } } else { if (IsFirstLine) { if (tobeCutRun.PrevTextRun != null) { infoTextRun = tobeCutRun.PrevTextRun; } else { if (tobeCutRun.NextTextRun.IsLineBreak) { infoTextRun = null; } else { infoTextRun = tobeCutRun.NextTextRun; } } } else if (IsLastLine) { if (tobeCutRun.PrevTextRun.IsLineBreak) { if (tobeCutRun.NextTextRun != null) { infoTextRun = tobeCutRun.NextTextRun; } else { infoTextRun = null; } } else { infoTextRun = tobeCutRun.PrevTextRun; } } else { if (!tobeCutRun.NextTextRun.IsLineBreak) { infoTextRun = tobeCutRun.NextTextRun; } else { infoTextRun = null; } } } result = CreateTextPointInfo( pointInfo.LineId, pointInfo.LineCharIndex, pointInfo.X, infoTextRun, pointInfo.TextRunCharOffset, pointInfo.TextRunPixelOffset); } this.Remove(tobeCutRun); this.LocalResumeLineReArrange(); return result; }