AddLast() 공개 메소드

public AddLast ( EditableRun v ) : void
v EditableRun
리턴 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);
        }
        void PerformHorizontalFlowArrangeForMultilineText(
            int ownerClientLeft, int ownerClientWidth,
            int ownerClientTop)
        {
#if DEBUG
            long startTick = DateTime.Now.Ticks;
#endif

            List <EditableTextLine> lines = (List <EditableTextLine>) this.lineCollection;
            int  ownerClientRight         = ownerClientLeft + ownerClientWidth;
            int  curX           = 0;
            int  curY           = 0;
            bool lastestIsBlock = false;
            int  maxWidth       = 0;
            int  curY_fromTop   = ownerClientTop;
            int  maxHeightInRow = EditableTextLine.DEFAULT_LINE_HEIGHT;
            int  lineCount      = lines.Count;
            for (int i = 0; i < lineCount; ++i)
            {
                EditableTextLine line = lines[i];
                curX           = ownerClientLeft;
                lastestIsBlock = false;
                line.SetTop(curY_fromTop);
                if (!line.NeedArrange)
                {
                    maxHeightInRow = line.ActualLineHeight;
                    if (line.ActualLineWidth > maxWidth)
                    {
                        maxWidth = line.ActualLineWidth;
                    }
                }
                else
                {
                    maxHeightInRow = EditableTextLine.DEFAULT_LINE_HEIGHT;
                    EditableTextLine newLine = null;
                    line.ValidateContentArrangement();
                    bool isFirstRunInThisLine = true;
                    foreach (EditableRun currentRun in line)
                    {
#if DEBUG
                        vinv_dbug_BeginSetElementBound(currentRun);
#endif
                        int v_desired_width  = currentRun.Width;
                        int v_desired_height = currentRun.Height;
                        if (isFirstRunInThisLine)
                        {
                            lastestIsBlock = currentRun.IsBlockElement;
                            if (v_desired_height > maxHeightInRow)
                            {
                                maxHeightInRow = v_desired_height;
                            }
                            EditableRun.DirectSetLocation(currentRun, curX, 0);
                            if (v_desired_height > maxHeightInRow)
                            {
                                maxHeightInRow = v_desired_height;
                            }
                            if (lastestIsBlock)
                            {
                                v_desired_width = ownerClientWidth;
                            }

                            EditableRun.DirectSetSize(currentRun,
                                                      v_desired_width, v_desired_height);
                            currentRun.MarkValidContentArrangement();
                            curX += v_desired_width;
                            isFirstRunInThisLine = false;
                        }
                        else
                        {
                            if (lastestIsBlock || currentRun.IsBlockElement ||
                                (curX + v_desired_width > ownerClientRight))
                            {
                                newLine = new EditableTextLine(this);
                                newLine.AddLast(currentRun);
                                curY           = curY_fromTop + maxHeightInRow;
                                curY_fromTop   = curY;
                                maxHeightInRow = EditableTextLine.DEFAULT_LINE_HEIGHT;
                                EditableRun nextR = currentRun.NextTextRun;
                                while (nextR != null)
                                {
                                    line.UnsafeRemoveVisualElement(nextR);
                                    newLine.AddLast(nextR);
                                    nextR = nextR.NextTextRun;
                                }
                                if (i + 1 == lineCount)
                                {
                                    lines.Add(newLine);
                                }
                                else
                                {
                                    lines.Insert(i + 1, newLine);
                                }
                                lineCount++;
                                break;
                            }
                            else
                            {
                                lastestIsBlock = currentRun.IsBlockElement;
                                if (v_desired_height > maxHeightInRow)
                                {
                                    maxHeightInRow = v_desired_height;
                                }
                                EditableRun.DirectSetLocation(currentRun, curX, 0);
                                EditableRun.DirectSetSize(currentRun,
                                                          v_desired_width, v_desired_height);
                                currentRun.MarkValidContentArrangement();
                                curX += v_desired_width;
                            }
                        }

#if DEBUG
                        vinv_dbug_EndSetElementBound(currentRun);
#endif
                    }
                    if (curX > maxWidth)
                    {
                        maxWidth = curX;
                    }
                }
                line.SetPostArrangeLineSize(maxWidth, maxHeightInRow);
                curY         = curY_fromTop + maxHeightInRow;
                curY_fromTop = curY;
            }

            ValidateArrangement();
        }
        void PerformHorizontalFlowArrangeForMultilineText(
            int ownerClientLeft, int ownerClientWidth,
            int ownerClientTop)
        {
#if DEBUG
            long startTick = DateTime.Now.Ticks;
#endif

            List<EditableTextLine> lines = (List<EditableTextLine>)this.lineCollection;
            int ownerClientRight = ownerClientLeft + ownerClientWidth;
            int curX = 0;
            int curY = 0;
            bool lastestIsBlock = false;
            int maxWidth = 0;
            int curY_fromTop = ownerClientTop;
            int maxHeightInRow = EditableTextLine.DEFAULT_LINE_HEIGHT;
            int lineCount = lines.Count;
            for (int i = 0; i < lineCount; ++i)
            {
                EditableTextLine line = lines[i];
                curX = ownerClientLeft;
                lastestIsBlock = false;
                line.SetTop(curY_fromTop);
                if (!line.NeedArrange)
                {
                    maxHeightInRow = line.ActualLineHeight;
                    if (line.ActualLineWidth > maxWidth)
                    {
                        maxWidth = line.ActualLineWidth;
                    }
                }
                else
                {
                    maxHeightInRow = EditableTextLine.DEFAULT_LINE_HEIGHT;
                    EditableTextLine newLine = null;
                    line.ValidateContentArrangement();
                    bool isFirstRunInThisLine = true;
                    foreach (EditableRun currentRun in line)
                    {
#if DEBUG
                        vinv_dbug_BeginSetElementBound(currentRun);
#endif
                        int v_desired_width = currentRun.Width;
                        int v_desired_height = currentRun.Height;
                        if (isFirstRunInThisLine)
                        {
                            lastestIsBlock = currentRun.IsBlockElement;
                            if (v_desired_height > maxHeightInRow)
                            {
                                maxHeightInRow = v_desired_height;
                            }
                            EditableRun.DirectSetLocation(currentRun, curX, 0);
                            if (v_desired_height > maxHeightInRow)
                            {
                                maxHeightInRow = v_desired_height;
                            }
                            if (lastestIsBlock)
                            {
                                v_desired_width = ownerClientWidth;
                            }

                            EditableRun.DirectSetSize(currentRun,
                                    v_desired_width, v_desired_height);
                            currentRun.MarkValidContentArrangement();
                            curX += v_desired_width;
                            isFirstRunInThisLine = false;
                        }
                        else
                        {
                            if (lastestIsBlock || currentRun.IsBlockElement ||
                            (curX + v_desired_width > ownerClientRight))
                            {
                                newLine = new EditableTextLine(this);
                                newLine.AddLast(currentRun);
                                curY = curY_fromTop + maxHeightInRow;
                                curY_fromTop = curY;
                                maxHeightInRow = EditableTextLine.DEFAULT_LINE_HEIGHT;
                                EditableRun nextR = currentRun.NextTextRun;
                                while (nextR != null)
                                {
                                    line.UnsafeRemoveVisualElement(nextR);
                                    newLine.AddLast(nextR);
                                    nextR = nextR.NextTextRun;
                                }
                                if (i + 1 == lineCount)
                                {
                                    lines.Add(newLine);
                                }
                                else
                                {
                                    lines.Insert(i + 1, newLine);
                                }
                                lineCount++;
                                break;
                            }
                            else
                            {
                                lastestIsBlock = currentRun.IsBlockElement;
                                if (v_desired_height > maxHeightInRow)
                                {
                                    maxHeightInRow = v_desired_height;
                                }
                                EditableRun.DirectSetLocation(currentRun, curX, 0);
                                EditableRun.DirectSetSize(currentRun,
                                       v_desired_width, v_desired_height);
                                currentRun.MarkValidContentArrangement();
                                curX += v_desired_width;
                            }
                        }

#if DEBUG
                        vinv_dbug_EndSetElementBound(currentRun);
#endif

                    }
                    if (curX > maxWidth)
                    {
                        maxWidth = curX;
                    }
                }
                line.SetPostArrangeLineSize(maxWidth, maxHeightInRow);
                curY = curY_fromTop + maxHeightInRow;
                curY_fromTop = curY;
            }

            ValidateArrangement();
        }