Пример #1
0
        void LeftCopy(VisualPointInfo pointInfo, TextRangeCopy output)
        {
            if (pointInfo.LineId != _currentLineNumber)
            {
                throw new NotSupportedException();
            }
            Run tobeCutRun = pointInfo.Run;

            if (tobeCutRun == null)
            {
                return;
            }

            foreach (Run run in _runs)
            {
                if (run != tobeCutRun)
                {
                    output.AppendRun(run);
                }
                else
                {
                    break;
                }
            }
            CopyRun leftPart = tobeCutRun.LeftCopy(pointInfo.RunLocalSelectedIndex);

            if (leftPart != null)
            {
                output.AppendRun(leftPart);
            }
        }
Пример #2
0
        public void Copy(TextRangeCopy output)
        {
            LinkedListNode <Run> curNode = this.First;

            while (curNode != null)
            {
                output.AppendRun(curNode.Value);
                curNode = curNode.Next;
            }
        }
Пример #3
0
 public void CopySelectedTextToPlainText(StringBuilder stBuilder)
 {
     if (_selectionRange != null)
     {
         _selectionRange.SwapIfUnOrder();
         if (_selectionRange.IsOnTheSameLine)
         {
             var copyRuns = new TextRangeCopy();
             _lineEditor.CopySelectedTextRuns(_selectionRange, copyRuns);
             copyRuns.CopyContentToStringBuilder(stBuilder);
         }
         else
         {
             VisualPointInfo startPoint = _selectionRange.StartPoint;
             CurrentLineNumber = startPoint.LineId;
             _lineEditor.SetCurrentCharIndex(startPoint.LineCharIndex);
             var copyRuns = new TextRangeCopy();
             _lineEditor.CopySelectedTextRuns(_selectionRange, copyRuns);
             copyRuns.CopyContentToStringBuilder(stBuilder);
         }
     }
 }
Пример #4
0
        void RightCopy(VisualPointInfo pointInfo, TextRangeCopy output)
        {
            if (pointInfo.LineId != _currentLineNumber)
            {
                throw new NotSupportedException();
            }
            Run tobeCutRun = pointInfo.Run;

            if (tobeCutRun == null)
            {
                return;
            }
            CopyRun rightPart = tobeCutRun.Copy(pointInfo.RunLocalSelectedIndex);

            if (rightPart != null)
            {
                output.AppendRun(rightPart);
            }
            foreach (Run run in GetRunIterForward(tobeCutRun.NextRun, this.LastRun))
            {
                output.AppendRun(run);
            }
        }
Пример #5
0
        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);
                }
            }
        }
Пример #6
0
 //
 public void CopySelectedTextRuns(VisualSelectionRange selectionRange, TextRangeCopy output) => _currentLine.Copy(selectionRange, output);