상속: RenderElement
 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();
     }
 }
 internal IEnumerable<EditableRun> GetDrawingIter(EditableRun start, EditableRun stop)
 {
     if ((layerFlags & FLOWLAYER_HAS_MULTILINE) != 0)
     {
         List<EditableTextLine> lines = (List<EditableTextLine>)lineCollection;
         int j = lines.Count;
         for (int i = 0; i < j; ++i)
         {
             LinkedListNode<EditableRun> curNode = lines[i].Last;
             while (curNode != null)
             {
                 yield return curNode.Value;
                 curNode = curNode.Previous;
             }
         }
     }
     else
     {
         EditableTextLine onlyLine = (EditableTextLine)lineCollection;
         LinkedListNode<EditableRun> curNode = onlyLine.Last;
         while (curNode != null)
         {
             yield return curNode.Value;
             curNode = curNode.Previous;
         }
     }
 }
 public new void AddFirst(EditableRun v)
 {
     if (!v.IsLineBreak)
     {
         AddNormalRunToFirst(v);
     }
     else
     {
         AddLineBreakBefore(this.FirstRun);
     }
 }
 public new void AddLast(EditableRun v)
 {
     if (!v.IsLineBreak)
     {
         AddNormalRunToLast(v);
     }
     else
     {
         AddLineBreakAfter(this.LastRun);
     }
 }
 public void AddAfter(EditableRun afterVisualElement, EditableRun v)
 {
     if (!v.IsLineBreak)
     {
         AddNormalRunAfter(afterVisualElement, v);
     }
     else
     {
         AddLineBreakAfter(afterVisualElement);
     }
 }
 public void AddBefore(EditableRun beforeVisualElement, EditableRun v)
 {
     if (!v.IsLineBreak)
     {
         AddNormalRunBefore(beforeVisualElement, v);
     }
     else
     {
         AddLineBreakBefore(beforeVisualElement);
     }
 }
 public void AddBefore(EditableRun beforeVisualElement, EditableRun visualElement)
 {
     EditableTextLine targetLine = beforeVisualElement.OwnerEditableLine;
     if (targetLine != null)
     {
         targetLine.AddBefore(beforeVisualElement, visualElement);
     }
     else
     {
         throw new NotSupportedException();
     }
 }
 public void AddTop(EditableRun visualElement)
 {
     if ((layerFlags & FLOWLAYER_HAS_MULTILINE) != 0)
     {
         List<EditableTextLine> lines = (List<EditableTextLine>)lineCollection;
         lines[lines.Count - 1].AddLast(visualElement);
     }
     else
     {
         ((EditableTextLine)lineCollection).AddLast(visualElement);
     }
 }
예제 #9
0
        ////----------------------------------------------------------------------
        //public override void TopDownReCalculateContentSize()
        //{
        //    InnerTextRunTopDownReCalculateContentSize(this);
        //}

        public static void InnerTextRunTopDownReCalculateContentSize(EditableRun ve)
        {
            //#if DEBUG
            //            dbug_EnterTopDownReCalculateContent(ve);
            //#endif

            //
            ve.UpdateRunWidth();
            //
            //#if DEBUG
            //            dbug_ExitTopDownReCalculateContent(ve);
            //#endif
        }
        public void AddAfter(EditableRun afterVisualElement, EditableRun visualElement)
        {
            EditableTextLine targetLine = afterVisualElement.OwnerEditableLine;

            if (targetLine != null)
            {
                targetLine.AddAfter(afterVisualElement, visualElement);
            }
            else
            {
                throw new NotSupportedException();
            }
        }
        public void AddBefore(EditableRun beforeVisualElement, EditableRun visualElement)
        {
            EditableTextLine targetLine = beforeVisualElement.OwnerEditableLine;

            if (targetLine != null)
            {
                targetLine.AddBefore(beforeVisualElement, visualElement);
            }
            else
            {
                throw new NotSupportedException();
            }
        }
예제 #12
0
        LinkedList <EditableRun> CollectRightRuns(EditableRun t)
        {
            if (t.IsLineBreak)
            {
                throw new NotSupportedException();
            }
            LinkedList <EditableRun> colllectRun = new LinkedList <EditableRun>();

            foreach (EditableRun r in editableFlowLayer.TextRunForward(t, this.LastRun))
            {
                colllectRun.AddLast(r);
            }
            return(colllectRun);
        }
        public void RefreshInlineArrange()
        {
            EditableRun r        = this.FirstRun;
            int         lastestX = 0;

            while (r != null)
            {
                r.SetLocation(
                    lastestX,
                    r.Y);
                lastestX += r.Width;
                r         = r.NextTextRun;
            }
        }
        public void LocalResumeLineReArrange()
        {
            lineFlags &= ~LOCAL_SUSPEND_LINE_REARRANGE;
            LinkedListNode <EditableRun> curNode = this.First;
            int cx = 0;

            while (curNode != null)
            {
                EditableRun ve = curNode.Value;
                ve.SetLocation(cx, 0);
                cx     += ve.Width;
                curNode = curNode.Next;
            }
        }
예제 #15
0
        internal IEnumerable <EditableRun> GetVisualElementForward(EditableRun startVisualElement)
        {
            if (startVisualElement != null)
            {
                yield return(startVisualElement);

                var curRun = startVisualElement.NextTextRun;
                while (curRun != null)
                {
                    yield return(curRun);

                    curRun = curRun.NextTextRun;
                }
            }
        }
예제 #16
0
        LinkedList <EditableRun> CollectLeftRuns(EditableRun t)
        {
            if (t.IsLineBreak)
            {
                throw new NotSupportedException();
            }

            LinkedList <EditableRun> colllectRun = new LinkedList <EditableRun>();

            foreach (EditableRun r in GetVisualElementForward(this.FirstRun, t))
            {
                colllectRun.AddLast(r);
            }
            return(colllectRun);
        }
예제 #17
0
        public void MoveToLine(int lineNumber)
        {
            currentLine  = visualFlowLayer.GetTextLine(lineNumber);
            currentLineY = currentLine.Top;

            //if current line is a blank line
            //not first run => currentTextRun= null
            currentTextRun = (EditableRun)currentLine.FirstRun;

            rCharOffset  = 0;
            rPixelOffset = 0;

            caret_char_index = 0;
            caretXPos        = 0;
        }
        public void RefreshInlineArrange()
        {
            EditableRun r        = this.FirstRun;
            int         lastestX = 0;

            while (r != null)
            {
                RenderElement.DirectSetLocation(
                    r,
                    lastestX,
                    r.Y);
                lastestX += r.Width;
                r         = r.NextTextRun;
            }
        }
예제 #19
0
        public TextLineReader(EditableTextFlowLayer flowlayer)
        {
#if DEBUG
            this.dbug_MyId = dbugTotalId;
            dbugTotalId++;
#endif

            this.visualFlowLayer = flowlayer;
            flowlayer.Reflow    += new EventHandler(flowlayer_Reflow);
            currentLine          = flowlayer.GetTextLine(0);
            if (currentLine.FirstRun != null)
            {
                currentTextRun = currentLine.FirstRun;
            }
        }
        public void OnDoubleClick(UIMouseEventArgs e)
        {
            internalTextLayerController.CancelSelect();
            EditableRun textRun = this.CurrentTextRun;

            if (textRun != null)
            {
                VisualPointInfo pointInfo          = internalTextLayerController.GetCurrentPointInfo();
                int             lineCharacterIndex = pointInfo.LineCharIndex;
                int             localselIndex      = pointInfo.LocalSelectedIndex;
                internalTextLayerController.CharIndex = lineCharacterIndex - localselIndex - 1;
                internalTextLayerController.StartSelect();
                internalTextLayerController.CharIndex += textRun.CharacterCount;
                internalTextLayerController.EndSelect();
            }
        }
        internal IEnumerable <EditableRun> TextRunForward(EditableRun startRun, EditableRun stopRun)
        {
            EditableTextLine currentLine = startRun.OwnerEditableLine;
            EditableTextLine stopLine    = stopRun.OwnerEditableLine;

            if (currentLine == stopLine)
            {
                foreach (EditableRun r in currentLine.GetVisualElementForward(startRun, stopRun))
                {
                    yield return(r);
                }
            }
            else
            {
                foreach (EditableRun r in currentLine.GetVisualElementForward(startRun))
                {
                    yield return(r);
                }
                currentLine = currentLine.Next;
                while (currentLine != null)
                {
                    if (currentLine == stopLine)
                    {
                        foreach (EditableRun r in currentLine)
                        {
                            if (r == stopRun)
                            {
                                break;
                            }
                            else
                            {
                                yield return(r);
                            }
                        }
                        break;
                    }
                    else
                    {
                        foreach (EditableRun r in currentLine)
                        {
                            yield return(r);
                        }
                        currentLine = currentLine.Next;
                    }
                }
            }
        }
예제 #22
0
        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); RenderElement.DirectSetLocation(t, cx, 0);
                    cx += t.Width;
                }

                newTextline.LocalResumeLineReArrange(); this.LocalResumeLineReArrange();
            }
        }
예제 #23
0
        internal IEnumerable <EditableRun> GetVisualElementForward(EditableRun startVisualElement, EditableRun stopVisualElement)
        {
            if (startVisualElement != null)
            {
                LinkedListNode <EditableRun> lexnode = GetLineLinkedNode(startVisualElement);
                while (lexnode != null)
                {
                    yield return(lexnode.Value);

                    if (lexnode.Value == stopVisualElement)
                    {
                        break;
                    }
                    lexnode = lexnode.Next;
                }
            }
        }
예제 #24
0
 EditableRun MakeTextRun(int sourceIndex, int length)
 {
     if (length > 0)
     {
         EditableRun newTextRun = null;
         char[]      newContent = new char[length];
         Array.Copy(this.mybuffer, sourceIndex, newContent, 0, length);
         newTextRun             = new EditableTextRun(this.Root, newContent, this.SpanStyle);
         newTextRun.IsLineBreak = this.IsLineBreak;
         newTextRun.UpdateRunWidth();
         return(newTextRun);
     }
     else
     {
         throw new Exception("string must be null or zero length");
     }
 }
        void RemoveRight(EditableRun t)
        {
            if (t.IsLineBreak)
            {
                throw new NotSupportedException();
            }

            LinkedList <EditableRun>     tobeRemoveTextRuns = CollectRightRuns(t);
            LinkedListNode <EditableRun> curNode            = tobeRemoveTextRuns.First;

            LocalSuspendLineReArrange();
            while (curNode != null)
            {
                Remove(curNode.Value);
                curNode = curNode.Next;
            }
            LocalResumeLineReArrange();
        }
            public EditableRun UnsafeRemoveCurrent()
            {
                LinkedListNode <EditableRun> tobeRemoveNode = curNode;
                EditableRun      v    = tobeRemoveNode.Value;
                EditableTextLine line = v.OwnerEditableLine;

                if (tobeRemoveNode == line.First)
                {
                    curNode   = null;
                    readState = 2;
                }
                else
                {
                    curNode = tobeRemoveNode.Previous;
                }
                line.UnsafeRemoveVisualElement(v);
                return(v);
            }
예제 #27
0
        bool MoveToPreviousTextRun()
        {
#if DEBUG
            if (currentTextRun.IsLineBreak)
            {
                throw new NotSupportedException();
            }
#endif
            if (currentTextRun.PrevTextRun != null)
            {
                currentTextRun = currentTextRun.PrevTextRun; rCharOffset -= currentTextRun.CharacterCount;
                rPixelOffset  -= currentTextRun.Width;
                charIndex      = rCharOffset + currentTextRun.CharacterCount - 1;
                caretXPos      = rPixelOffset + currentTextRun.Width;
                return(true);
            }
            return(false);
        }
예제 #28
0
        public void FindCurrentUnderlyingWord(out int startAt, out int len)
        {
            EditableRun textRun = this.CurrentTextRun;

            if (textRun != null)
            {
                VisualPointInfo pointInfo          = internalTextLayerController.GetCurrentPointInfo();
                int             lineCharacterIndex = pointInfo.LineCharIndex;
                int             local_sel_Index    = pointInfo.RunLocalSelectedIndex;
                //default behaviour is select only a hit word under the caret
                //so ask the text layer to find a hit word
                internalTextLayerController.FindUnderlyingWord(out startAt, out len);
            }
            else
            {
                startAt = len = 0;
            }
        }
 public void ReplaceCurrentTextRunContent(int nBackSpace, EditableRun newTextRun)
 {
     if (newTextRun != null)
     {
         EnableUndoHistoryRecording = false; for (int i = 0; i < nBackSpace; i++)
         {
             DoBackspace();
         }
         EnableUndoHistoryRecording = true;
         int startLineNum = textLineWriter.LineNumber;
         int startCharIndex = textLineWriter.CharIndex;
         textLineWriter.AddTextSpan(newTextRun);
         textLineWriter.EnsureCurrentTextRun();
         commandHistory.AddDocAction(
             new DocActionInsertRuns(
                 new EditableRun[] { newTextRun }, startLineNum, startCharIndex,
                 textLineWriter.LineNumber, textLineWriter.CharIndex));
     }
 }
 public void ReplaceCurrentTextRunContent(int nBackSpace, EditableRun newTextRun)
 {
     if (newTextRun != null)
     {
         EnableUndoHistoryRecording = false; for (int i = 0; i < nBackSpace; i++)
         {
             DoBackspace();
         }
         EnableUndoHistoryRecording = true;
         int startLineNum   = textLineWriter.LineNumber;
         int startCharIndex = textLineWriter.CharIndex;
         textLineWriter.AddTextSpan(newTextRun);
         textLineWriter.EnsureCurrentTextRun();
         commandHistory.AddDocAction(
             new DocActionInsertRuns(
                 new EditableRun[] { newTextRun }, startLineNum, startCharIndex,
                 textLineWriter.LineNumber, textLineWriter.CharIndex));
     }
 }
        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); RenderElement.DirectSetLocation(t, cx, 0);
                    cx += t.Width;
                }

                newTextline.LocalResumeLineReArrange(); this.LocalResumeLineReArrange();
            }
        }
        void RemoveLeft(EditableRun t)
        {
            if (t != null)
            {
                if (t.IsLineBreak)
                {
                    throw new NotSupportedException();
                }

                LinkedList<EditableRun> tobeRemoveTextRuns = CollectLeftRuns(t);
                LinkedListNode<EditableRun> curNode = tobeRemoveTextRuns.First;
                LocalSuspendLineReArrange();
                while (curNode != null)
                {
                    Remove(curNode.Value);
                    curNode = curNode.Next;
                }
                LocalResumeLineReArrange();
            }
        }
예제 #33
0
        public void AddCharacter(char c)
        {
            if (CurrentLine.IsBlankLine)
            {
                //1. new
                EditableRun t = new EditableTextRun(this.Root,
                                                    c,
                                                    this.CurrentSpanStyle);

                var owner = this.FlowLayer.OwnerRenderElement;

                CurrentLine.AddLast(t);

                SetCurrentTextRun(t);
            }
            else
            {
                EditableRun cRun = CurrentTextRun;
                if (cRun != null)
                {
                    if (cRun.IsInsertable)
                    {
                        cRun.InsertAfter(CurrentTextRunCharIndex, c);
                    }
                    else
                    {
                        AddTextSpan(new EditableTextRun(this.Root, c, this.CurrentSpanStyle));
                        return;
                    }
                }
                else
                {
                    throw new NotSupportedException();
                }
            }

            CurrentLine.TextLineReCalculateActualLineSize();
            CurrentLine.RefreshInlineArrange();

            CharIndex++;
        }
        public new void Remove(EditableRun v)
        {
#if DEBUG
            if (v.IsLineBreak)
            {
                throw new NotSupportedException("not support line break");
            }
#endif


            base.Remove(GetLineLinkedNode(v));

            EditableRun.RemoveParentLink(v);


            if ((this.lineFlags & LOCAL_SUSPEND_LINE_REARRANGE) != 0)
            {
                return;
            }

            if (!this.EndWithLineBreak && this.Count == 0 && this.currentLineNumber > 0)
            {
                if (!editableFlowLayer.GetTextLine(currentLineNumber - 1).EndWithLineBreak)
                {
                    editableFlowLayer.Remove(currentLineNumber);
                }
            }
            else
            {
                //var ownerVe = editableFlowLayer.OwnerRenderElement;
                //if (ownerVe != null)
                //{
                //    RenderElement.InnerInvalidateLayoutAndStartBubbleUp(ownerVe);
                //}
                //else
                //{
                //    throw new NotSupportedException();
                //}
            }
        }
예제 #35
0
        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);
        }
예제 #36
0
        bool MoveToNextTextRun()
        {
#if DEBUG
            if (currentTextRun.IsLineBreak)
            {
                throw new NotSupportedException();
            }
#endif


            EditableRun nextTextRun = currentTextRun.NextTextRun;
            if (nextTextRun != null && !nextTextRun.IsLineBreak)
            {
                rCharOffset     += currentTextRun.CharacterCount;
                rPixelOffset    += currentTextRun.Width;
                currentTextRun   = nextTextRun;
                caret_char_index = rCharOffset;
                caretXPos        = rPixelOffset + currentTextRun.GetRunWidth(0);
                return(true);
            }
            return(false);
        }
예제 #37
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);
        }
예제 #38
0
        void RightCopy(VisualPointInfo pointInfo, List <EditableRun> output)
        {
            if (pointInfo.LineId != currentLineNumber)
            {
                throw new NotSupportedException();
            }
            EditableRun tobeCutRun = pointInfo.TextRun;

            if (tobeCutRun == null)
            {
                return;
            }
            EditableRun postCutTextRun = (EditableRun)tobeCutRun.Copy(pointInfo.RunLocalSelectedIndex + 1);

            if (postCutTextRun != null)
            {
                output.Add(postCutTextRun);
            }
            foreach (EditableRun t in GetVisualElementForward(tobeCutRun.NextTextRun, this.LastRun))
            {
                output.Add(t.Clone());
            }
        }
        public new void Remove(EditableRun v)
        {
#if DEBUG
            if (v.IsLineBreak)
            {
                throw new NotSupportedException("not support line break");
            }
#endif


            base.Remove(GetLineLinkedNode(v));
            EditableRun.RemoveParentLink(v);
            if ((this.lineFlags & LOCAL_SUSPEND_LINE_REARRANGE) != 0)
            {
                return;
            }

            if (!this.EndWithLineBreak && this.Count == 0 && this.currentLineNumber > 0)
            {
                if (!editableFlowLayer.GetTextLine(currentLineNumber - 1).EndWithLineBreak)
                {
                    editableFlowLayer.Remove(currentLineNumber);
                }
            }
            else
            {
                //var ownerVe = editableFlowLayer.OwnerRenderElement;
                //if (ownerVe != null)
                //{
                //    RenderElement.InnerInvalidateLayoutAndStartBubbleUp(ownerVe);
                //}
                //else
                //{
                //    throw new NotSupportedException();
                //}
            }
        }
예제 #40
0
        public void SplitToNewLine()
        {
            EditableRun lineBreakRun = new EditableTextRun(this.Root, '\n', this.CurrentSpanStyle);
            EditableRun currentRun   = CurrentTextRun;

            if (CurrentLine.IsBlankLine)
            {
                CurrentLine.AddLast(lineBreakRun);
            }
            else
            {
                if (CharIndex == -1)
                {
                    CurrentLine.AddFirst(lineBreakRun);
                    SetCurrentTextRun(null);
                }
                else
                {
                    EditableRun rightSplitedPart = EditableRun.InnerRemove(currentRun,
                                                                           CurrentTextRunCharIndex + 1, true);
                    if (rightSplitedPart != null)
                    {
                        CurrentLine.AddAfter(currentRun, rightSplitedPart);
                    }
                    CurrentLine.AddAfter(currentRun, lineBreakRun);

                    if (currentRun.CharacterCount == 0)
                    {
                        CurrentLine.Remove(currentRun);
                    }
                }
            }


            this.TextLayer.TopDownReCalculateContentSize();
            EnsureCurrentTextRun();
        }
예제 #41
0
        static Size ReCalculateContentSizeHorizontalFlow(EditableTextFlowLayer layer)
        {
            if (layer.lineCollection == null)
            {
                return(Size.Empty);
            }

            //only one line
            EditableTextLine             line   = (EditableTextLine)layer.lineCollection;
            LinkedListNode <EditableRun> c_node = line.First;
            //--------
            int curX = 0;

            int maxHeightInRow = 0;
            int maxWidth       = 0;

            while (c_node != null)
            {
                EditableRun run       = c_node.Value;
                int         runHeight = run.Height;
                if (runHeight > maxHeightInRow)
                {
                    maxHeightInRow = runHeight;
                }
                curX += run.Width;
                if (curX > maxWidth)
                {
                    maxWidth = curX;
                }


                //next
                c_node = c_node.Next;
            }

            return(new Size(maxWidth, maxHeightInRow));
        }
예제 #42
0
        public void TextLineReCalculateActualLineSize()
        {
            EditableRun r          = this.FirstRun;
            int         maxHeight  = 2;
            int         accumWidth = 0;

            while (r != null)
            {
                if (r.Height > maxHeight)
                {
                    maxHeight = r.Height;
                }
                accumWidth += r.Width;
                r           = r.NextTextRun;
            }
            this.actualLineWidth  = accumWidth;
            this.actualLineHeight = maxHeight;

            if (this.RunCount == 0)
            {
                //no span
                this.actualLineHeight = EditableTextLine.DEFAULT_LINE_HEIGHT;
            }
        }
예제 #43
0
 internal static EditableRun InnerRemove(EditableRun tt, int startIndex, bool withFreeRun)
 {
     return tt.Remove(startIndex, tt.CharacterCount - (startIndex), withFreeRun);
 }
 public new void AddBefore(LinkedListNode<EditableRun> beforequest, EditableRun visualNode)
 {
     throw new NotSupportedException();
 }
예제 #45
0
 internal static EditableRunCharLocation InnerGetCharacterFromPixelOffset(EditableRun tt, int pixelOffset)
 {
     return tt.GetCharacterFromPixelOffset(pixelOffset);
 }
 void AddNormalRunToFirst(EditableRun v)
 {
     v.SetInternalLinkedNode(base.AddFirst(v), this);
 }
 public new void AddAfter(LinkedListNode<EditableRun> afternode, EditableRun visualNode)
 {
     throw new NotSupportedException();
 }
 public void AddAfter(EditableRun afterVisualElement, EditableRun visualElement)
 {
     EditableTextLine targetLine = afterVisualElement.OwnerEditableLine;
     if (targetLine != null)
     {
         targetLine.AddAfter(afterVisualElement, visualElement);
     }
     else
     {
         throw new NotSupportedException();
     }
 }
 static LinkedListNode<EditableRun> GetLineLinkedNode(EditableRun ve)
 {
     return ve.LinkedNodeForEditableRun;
 }
예제 #50
0
 public void AddTextSpan(EditableRun textRun)
 {
     if (CurrentLine.IsBlankLine)
     {
         CurrentLine.AddLast(textRun);
         SetCurrentTextRun(textRun);
         CurrentLine.TextLineReCalculateActualLineSize();
         CurrentLine.RefreshInlineArrange();
         CharIndex += textRun.CharacterCount;
     }
     else
     {
         if (CurrentTextRun != null)
         {
             VisualPointInfo newPointInfo = CurrentLine.Split(GetCurrentPointInfo());
             if (newPointInfo.IsOnTheBeginOfLine)
             {
                 CurrentLine.AddBefore((EditableRun)newPointInfo.TextRun, textRun);
             }
             else
             {
                 CurrentLine.AddAfter((EditableRun)newPointInfo.TextRun, textRun);
             }
             CurrentLine.TextLineReCalculateActualLineSize();
             CurrentLine.RefreshInlineArrange();
             EnsureCurrentTextRun(CharIndex + textRun.CharacterCount);
         }
         else
         {
             throw new NotSupportedException();
         }
     }
 }
 void AddNormalRunAfter(EditableRun afterVisualElement, EditableRun v)
 {
     v.SetInternalLinkedNode(base.AddAfter(GetLineLinkedNode(afterVisualElement), v), this);
 }
예제 #52
0
        public TextLineReader(EditableTextFlowLayer flowlayer)
        {
#if DEBUG
            this.dbug_MyId = dbugTotalId;
            dbugTotalId++;
#endif

            this.visualFlowLayer = flowlayer;
            flowlayer.Reflow += new EventHandler(flowlayer_Reflow);
            currentLine = flowlayer.GetTextLine(0);
            if (currentLine.FirstRun != null)
            {
                currentTextRun = currentLine.FirstRun;
            }
        }
예제 #53
0
        public void ReplaceAllLineContent(EditableRun[] runs)
        {
            int charIndex = CharIndex;
            CurrentLine.Clear();
            int j = runs.Length;
            for (int i = 0; i < j; ++i)
            {
                CurrentLine.AddLast(runs[i]);
            }

            EnsureCurrentTextRun(charIndex);
        }
예제 #54
0
 protected void SetCurrentTextRun(EditableRun r)
 {
     currentTextRun = r;
 }
예제 #55
0
        bool MoveToPreviousTextRun()
        {
#if DEBUG
            if (currentTextRun.IsLineBreak)
            {
                throw new NotSupportedException();
            }
#endif
            if (currentTextRun.PrevTextRun != null)
            {
                currentTextRun = currentTextRun.PrevTextRun;
                rCharOffset -= currentTextRun.CharacterCount;
                rPixelOffset -= currentTextRun.Width;
                charIndex = rCharOffset + currentTextRun.CharacterCount - 1;
                caretXPos = rPixelOffset + currentTextRun.Width;
                return true;
            }
            return false;
        }
예제 #56
0
 public void MoveToLine(int lineNumber)
 {
     currentLine = visualFlowLayer.GetTextLine(lineNumber);
     currentLineY = currentLine.Top;
     currentTextRun = (EditableRun)currentLine.FirstRun;
     rCharOffset = 0;
     rPixelOffset = 0;
     charIndex = -1;
     caretXPos = 0;
 }
예제 #57
0
 internal static EditableRun InnerRemove(EditableRun tt, int startIndex, int length, bool withFreeRun)
 {
     return tt.Remove(startIndex, length, withFreeRun);
 }
 void AddNormalRunBefore(EditableRun beforeVisualElement, EditableRun v)
 {
     v.SetInternalLinkedNode(base.AddBefore(GetLineLinkedNode(beforeVisualElement), v), this);
 }
예제 #59
0
        bool MoveToNextTextRun()
        {
#if DEBUG
            if (currentTextRun.IsLineBreak)
            {
                throw new NotSupportedException();
            }
#endif


            EditableRun nextTextRun = currentTextRun.NextTextRun;
            if (nextTextRun != null && !nextTextRun.IsLineBreak)
            {
                rCharOffset += currentTextRun.CharacterCount;
                rPixelOffset += currentTextRun.Width;
                currentTextRun = nextTextRun;
                charIndex = rCharOffset;
                caretXPos = rPixelOffset + currentTextRun.GetRunWidth(0);
                return true;
            }
            return false;
        }
 public void AddTextRun(EditableRun textspan)
 {
     internalTextLayerController.AddTextRunToCurrentLine(textspan);
 }