LocalSuspendLineReArrange() публичный Метод

public LocalSuspendLineReArrange ( ) : void
Результат void
Пример #1
0
        void AddLineBreakBefore(EditableRun beforeTextRun)
        {
            if (beforeTextRun == null)
            {
                this.EndWithLineBreak = true;
                editableFlowLayer.InsertNewLine(currentLineNumber + 1);
            }
            else
            {
                List <EditableRun> tempTextRuns = new List <EditableRun>();
                if (beforeTextRun != null)
                {
                    foreach (EditableRun t in GetVisualElementForward(beforeTextRun))
                    {
                        tempTextRuns.Add(t);
                    }
                }
                this.EndWithLineBreak = true;
                EditableTextLine newTextline = editableFlowLayer.InsertNewLine(currentLineNumber + 1);

                this.LocalSuspendLineReArrange();
                newTextline.LocalSuspendLineReArrange();
                int j = tempTextRuns.Count;
                for (int i = 0; i < j; ++i)
                {
                    EditableRun t = tempTextRuns[i];
                    this.Remove(t);
                    newTextline.AddLast(t);
                }
                this.LocalResumeLineReArrange();
                newTextline.LocalResumeLineReArrange();
            }
        }
        void AddLineBreakAfter(EditableRun afterTextRun)
        {
            if (afterTextRun == null)
            {
                this.EndWithLineBreak = true;
                EditableTextLine newline = editableFlowLayer.InsertNewLine(currentLineNumber + 1);
                //
                if (editableFlowLayer.LineCount - 1 != newline.LineNumber)
                {
                    newline.EndWithLineBreak = true;
                }
                return;
            }
            if (afterTextRun.NextTextRun == null)
            {
                this.EndWithLineBreak = true;
                EditableTextLine newline = editableFlowLayer.InsertNewLine(currentLineNumber + 1);
                //
                if (editableFlowLayer.LineCount - 1 != newline.LineNumber)
                {
                    newline.EndWithLineBreak = true;
                }
            }
            else
            {
                List <EditableRun> tempTextRuns = new List <EditableRun>(this.Count);
                if (afterTextRun != null)
                {
                    foreach (EditableRun t in GetVisualElementForward(afterTextRun.NextTextRun))
                    {
                        tempTextRuns.Add(t);
                    }
                }

                this.EndWithLineBreak = true;
                this.LocalSuspendLineReArrange();
                EditableTextLine newTextline = editableFlowLayer.InsertNewLine(currentLineNumber + 1);
                //
                int j = tempTextRuns.Count;
                newTextline.LocalSuspendLineReArrange(); int cx = 0;
                for (int i = 0; i < j; ++i)
                {
                    EditableRun t = tempTextRuns[i];
                    this.Remove(t);
                    newTextline.AddLast(t);
                    t.SetLocation(cx, 0);

                    cx += t.Width;
                }

                newTextline.LocalResumeLineReArrange(); this.LocalResumeLineReArrange();
            }
        }
Пример #3
0
        internal EditableTextLine SplitToNewLine(EditableRun startVisualElement)
        {
            LinkedListNode <EditableRun> curNode        = GetLineLinkedNode(startVisualElement);
            EditableTextLine             newSplitedLine = editableFlowLayer.InsertNewLine(this.currentLineNumber + 1);

            newSplitedLine.LocalSuspendLineReArrange();
            while (curNode != null)
            {
                LinkedListNode <EditableRun> tobeRemovedNode = curNode;
                curNode = curNode.Next;
                if (tobeRemovedNode.List != null)
                {
                    EditableRun tmpv = tobeRemovedNode.Value;
                    _runs.Remove(tobeRemovedNode);
                    newSplitedLine.AddLast(tmpv);
                }
                else
                {
                }
            }
            newSplitedLine.LocalResumeLineReArrange();
            return(newSplitedLine);
        }
Пример #4
0
        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 });
            }
        }
Пример #5
0
        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();
                }
            }
        }