internal EditableTextLine GetTextLineAtPos(int y) { if (lineCollection != null) { if (lineCollection is List <EditableTextLine> ) { List <EditableTextLine> lines = lineCollection as List <EditableTextLine>; if (lines != null) { int j = lines.Count; for (int i = 0; i < j; ++i) { EditableTextLine line = lines[i]; if (line.IntersectsWith(y)) { return(line); } } } } else { EditableTextLine line = (EditableTextLine)lineCollection; if (line.IntersectsWith(y)) { return(line); } } } return(null); }
internal EditableTextLine InsertNewLine(int insertAt) { EditableTextLine newLine = new EditableTextLine(this); this.InsertLine(insertAt, newLine); return(newLine); }
public void Accept() { EditableRun v = null; int sourceLineId = feeder.CurrentLineId; if (this.currentRelocatorLineId == sourceLineId) { } else if (sourceLineId > this.currentRelocatorLineId) { v = feeder.UnsafeRemoveCurrent(); currentLine.UnsafeAddLast(v); if (feeder.IsUnStableBlankLine) { feeder.RemoveCurrentBlankLine(); } } else { v = feeder.CurrentRun; EditableTextLine sourceLine = v.OwnerEditableLine; sourceLine.SplitToNewLine(v); feeder.Read(); currentRelocatorLineId = sourceLineId + 1; currentLine = sourceLines[currentRelocatorLineId]; } isFirstRunOfLine = false; }
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 void CloseCurrentLine(int lineWidth, int lineHeight) { currentLine.SetPostArrangeLineSize(lineWidth, lineHeight); if (isMultiLine) { if (currentRelocatorLineId < sourceLines.Count - 1) { ++currentRelocatorLineId; currentLine = sourceLines[currentRelocatorLineId]; } else { currentRelocatorLineId++; EditableTextLine newLine = new EditableTextLine(flowLayer); flowLayer.AppendLine(newLine); currentLine = newLine; } } else { currentRelocatorLineId++; EditableTextLine newLine = new EditableTextLine(flowLayer); flowLayer.AppendLine(newLine); sourceLines = (List <EditableTextLine>)flowLayer.lineCollection; currentLine = newLine; isMultiLine = true; } isFirstRunOfLine = true; }
public override bool HitTestCore(HitChain hitChain) { if ((layerFlags & IS_LAYER_HIDDEN) == 0) { if ((layerFlags & FLOWLAYER_HAS_MULTILINE) != 0) { List <EditableTextLine> lines = (List <EditableTextLine>)lineCollection; int j = lines.Count; int testYPos = hitChain.TestPoint.Y; for (int i = 0; i < j; ++i) { EditableTextLine line = lines[i]; if (line.LineBottom < testYPos) { continue; } else if (line.HitTestCore(hitChain)) { return(true); } else if (line.LineTop > testYPos) { return(false); } } } else { EditableTextLine onlyLine = (EditableTextLine)lineCollection; return(onlyLine.HitTestCore(hitChain)); } } return(false); }
public IEnumerable <EditableRun> dbugGetDrawingIter2() { 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].First; while (curNode != null) { yield return(curNode.Value); curNode = curNode.Next; } } } else { EditableTextLine onlyLine = (EditableTextLine)lineCollection; LinkedListNode <EditableRun> curNode = onlyLine.First; while (curNode != null) { yield return(curNode.Value); curNode = curNode.Next; } } }
public override IEnumerable <RenderElement> GetRenderElementIter() { if (lineCollection != null) { if ((layerFlags & FLOWLAYER_HAS_MULTILINE) != 0) { List <EditableTextLine> lines = (List <EditableTextLine>)lineCollection; int j = lines.Count; for (int i = 0; i < j; ++i) { EditableTextLine ln = lines[i]; LinkedListNode <EditableRun> veNode = ln.First; while (veNode != null) { yield return(veNode.Value); veNode = veNode.Next; } } } else { EditableTextLine ln = (EditableTextLine)lineCollection; LinkedListNode <EditableRun> veNode = ln.First; while (veNode != null) { yield return(veNode.Value); veNode = veNode.Next; } } } }
internal void Remove(int lineId) { #if DEBUG if (lineId < 0) { throw new NotSupportedException(); } #endif if ((layerFlags & FLOWLAYER_HAS_MULTILINE) == 0) { return; } List <EditableTextLine> lines = (List <EditableTextLine>)lineCollection; if (lines.Count < 2) { return; } EditableTextLine tobeRemovedLine = lines[lineId]; tobeRemovedLine.editableFlowLayer = null; int cy = tobeRemovedLine.Top; lines.RemoveAt(lineId); int j = lines.Count; for (int i = lineId; i < j; ++i) { EditableTextLine line = lines[i]; line.SetTop(cy); line.SetLineNumber(i); cy += line.ActualLineHeight; } if (lines.Count == 1) { lineCollection = lines[0]; FlowLayerHasMultiLines = false; } }
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 void JoinWithNextLine() { if (!IsLastLine) { EditableTextLine lowerLine = editableFlowLayer.GetTextLine(currentLineNumber + 1); this.LocalSuspendLineReArrange(); int cx = 0; EditableRun lastTextRun = (EditableRun)this.LastRun; if (lastTextRun != null) { cx = lastTextRun.Right; } foreach (EditableRun r in lowerLine) { this.AddLast(r); EditableRun.DirectSetLocation(r, cx, 0); cx += r.Width; } this.LocalResumeLineReArrange(); this.EndWithLineBreak = lowerLine.EndWithLineBreak; editableFlowLayer.Remove(lowerLine.currentLineNumber); } }
void debug_RecordLineInfo(RenderBoxBase owner, EditableTextLine line) { RootGraphic visualroot = this.dbugVRoot; if (visualroot.dbug_RecordDrawingChain) { } }
public EditableTextFlowLayer(TextEditRenderBox owner) : base(owner) { this.owner = owner; //start with single line per layer //and can change to multiline lineCollection = new EditableTextLine(this); }
public void SplitIntoNewLine() { EditableRun currentRun = feeder.CurrentRun; EditableTextLine line = currentRun.OwnerEditableLine; line.SplitToNewLine(currentRun); feeder.Read(); }
public void MoveToLine(int lineNumber) { currentLine = visualFlowLayer.GetTextLine(lineNumber); currentLineY = currentLine.Top; currentTextRun = (EditableRun)currentLine.FirstRun; rCharOffset = 0; rPixelOffset = 0; charIndex = -1; caretXPos = 0; }
void Load(List <EditableTextLine> sourceLines) { if (sourceLines.Count > 0) { this.currentLine = sourceLines[0]; } this.sourceLines = sourceLines; isMultiLine = true; isFirstRunOfLine = true; }
void Load(List<EditableTextLine> sourceLines) { if (sourceLines.Count > 0) { this.currentLine = sourceLines[0]; } this.sourceLines = sourceLines; isMultiLine = true; isFirstRunOfLine = true; }
void Load(List <EditableTextLine> sourceLines) { if (sourceLines.Count > 0) { this.currentLine = sourceLines[0]; } readState = 2; this.sourceLines = sourceLines; isMultiLine = true; }
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(); } }
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 void AddBefore(EditableRun beforeVisualElement, EditableRun visualElement) { EditableTextLine targetLine = beforeVisualElement.OwnerEditableLine; if (targetLine != null) { targetLine.AddBefore(beforeVisualElement, visualElement); } else { 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(); } }
public void Draw(DrawBoard destPage, Rectangle updateArea) { if (IsOnTheSameLine) { EditableTextLine line = _startLocation.line; if (line.OwnerFlowLayer == null) { //this marker should be remove or not return; } destPage.FillRectangle(BackgroundColor, _startLocation.x_offset, line.LineTop, _stopLocation.x_offset - _startLocation.x_offset, line.ActualLineHeight); } else { //multiple line EditableTextLine startLine = _startLocation.line; EditableTextLine endLine = _stopLocation.line; if (startLine.OwnerFlowLayer == null || endLine.OwnerFlowLayer == null) { //this marker should be remove or not return; } int lineYPos = startLine.LineTop; destPage.FillRectangle(BackgroundColor, _startLocation.x_offset, lineYPos, startLine.ActualLineWidth - _startLocation.x_offset, startLine.ActualLineHeight); int topLineId = startLine.LineNumber; int bottomLineId = endLine.LineNumber; if (bottomLineId - topLineId > 1) { EditableTextLine adjacentStartLine = startLine.Next; while (adjacentStartLine != endLine) { destPage.FillRectangle(BackgroundColor, 0, adjacentStartLine.LineTop, adjacentStartLine.LineWidth, adjacentStartLine.ActualLineHeight); adjacentStartLine = adjacentStartLine.Next; } } destPage.FillRectangle(BackgroundColor, 0, endLine.LineTop, _stopLocation.x_offset, endLine.ActualLineHeight); } }
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 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 SetCaretPos(int x, int y) { int j = textLineWriter.LineCount; if (j > 0) { EditableTextLine line = textLineWriter.GetTextLineAtPos(y); int calculatedLineId = 0; if (line != null) { calculatedLineId = line.LineNumber; } this.CurrentLineNumber = calculatedLineId; this.textLineWriter.CaretXPos = x; } }
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; } } } }
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); }
public void BindToTextLayer(EditableTextFlowLayer textLayer) { this.textLayer = textLayer; //check is on the sameline, //or multiple lines // if (IsOnTheSameLine) { EditableTextLine line = textLayer.GetTextLine(selectionRangeSnapshot.startLineNum); //at this line //find start and end point int startColNum = selectionRangeSnapshot.startColumnNum; int endColNum = selectionRangeSnapshot.endColumnNum; int lineHeight = line.ActualLineHeight; _startLocation = new MarkerLocation() { lineNum = line.LineNumber, x_offset = line.GetXOffsetAtCharIndex(startColNum), line = line }; _stopLocation = new MarkerLocation() { lineNum = line.LineNumber, x_offset = line.GetXOffsetAtCharIndex(endColNum), line = line }; } else { EditableTextLine startLine = textLayer.GetTextLine(selectionRangeSnapshot.startLineNum); _startLocation = new MarkerLocation() { lineNum = startLine.LineNumber, x_offset = startLine.GetXOffsetAtCharIndex(selectionRangeSnapshot.startColumnNum), line = startLine }; // EditableTextLine endLine = textLayer.GetTextLine(selectionRangeSnapshot.endLineNum); _stopLocation = new MarkerLocation() { lineNum = endLine.LineNumber, x_offset = endLine.GetXOffsetAtCharIndex(selectionRangeSnapshot.endColumnNum), line = endLine }; // } }
public override void Clear() { if ((layerFlags & FLOWLAYER_HAS_MULTILINE) != 0) { List <EditableTextLine> lines = (List <EditableTextLine>)lineCollection; for (int i = lines.Count - 1; i > -1; --i) { lines[i].editableFlowLayer = null; lines[i].Clear(); } lines.Clear(); lineCollection = new EditableTextLine(this); FlowLayerHasMultiLines = false; } else { ((EditableTextLine)lineCollection).Clear(); } }
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 override void TopDownReCalculateContentSize() { #if DEBUG vinv_dbug_EnterLayerReCalculateContent(this); #endif if (this.LineCount > 1) { List <EditableTextLine> lines = (List <EditableTextLine>) this.lineCollection; EditableTextLine lastline = lines[lines.Count - 1]; SetPostCalculateLayerContentSize(lastline.ActualLineWidth, lastline.ActualLineHeight + lastline.LineTop); } else { SetPostCalculateLayerContentSize(ReCalculateContentSizeHorizontalFlow(this)); } #if DEBUG vinv_dbug_ExitLayerReCalculateContent(); #endif }
public void Accept() { EditableRun v = null; int sourceLineId = feeder.CurrentLineId; if (this.currentRelocatorLineId == sourceLineId) { } else if (sourceLineId > this.currentRelocatorLineId) { v = feeder.UnsafeRemoveCurrent(); currentLine.UnsafeAddLast(v); if (feeder.IsUnStableBlankLine) { feeder.RemoveCurrentBlankLine(); } } else { v = feeder.CurrentRun; EditableTextLine sourceLine = v.OwnerEditableLine; sourceLine.SplitToNewLine(v); feeder.Read(); currentRelocatorLineId = sourceLineId + 1; currentLine = sourceLines[currentRelocatorLineId]; } isFirstRunOfLine = false; }
void AppendLine(EditableTextLine line) { if ((layerFlags & FLOWLAYER_HAS_MULTILINE) != 0) { List<EditableTextLine> lines = (List<EditableTextLine>)lineCollection; int lineCount = lines.Count; EditableTextLine lastLine = lines[lineCount - 1]; line.SetLineNumber(lineCount); line.SetTop(lastLine.Top + lastLine.ActualLineHeight); lines.Add(line); } else { EditableTextLine onlyLine = (EditableTextLine)lineCollection; List<EditableTextLine> newLineList = new List<EditableTextLine>(); newLineList.Add(onlyLine); line.SetTop(onlyLine.ActualLineHeight); line.SetLineNumber(1); newLineList.Add(line); lineCollection = newLineList; FlowLayerHasMultiLines = true; } }
public bool Read() { switch (readState) { case 2: if (this.currentLine != null) { curNode = currentLine.First; if (curNode != null) { readState = 0; return true; } else if (currentLine.EndWithLineBreak) { readState = 1; return true; } } readState = 3; return false; case 0: { curNode = curNode.Next; if (curNode != null) { return true; } else { if (currentLine.EndWithLineBreak) { readState = 1; return true; } else { if (!isMultiLine) { if (flowLayer.lineCollection is List<EditableTextLine>) { sourceLines = (List<EditableTextLine>)flowLayer.lineCollection; isMultiLine = true; } } if (isMultiLine) { readState = 3; while (currentFeederLineId < sourceLines.Count - 1) { ++currentFeederLineId; currentLine = sourceLines[currentFeederLineId]; curNode = currentLine.First; if (curNode != null) { readState = 0; return true; } else if (currentLine.EndWithLineBreak) { readState = 1; return true; } } return false; } } } } break; case 1: { if (isMultiLine) { readState = 3; while (currentFeederLineId < sourceLines.Count - 1) { ++currentFeederLineId; currentLine = sourceLines[currentFeederLineId]; curNode = currentLine.First; if (curNode != null) { readState = 0; return true; } else if (currentLine.EndWithLineBreak) { readState = 1; return true; } } return false; } } break; case 3: { return false; } } return false; }
void Load(EditableTextLine sourceLine) { this.currentLine = sourceLine; isFirstRunOfLine = true; }
public void RemoveCurrentBlankLine() { if (isMultiLine) { sourceLines.RemoveAt(currentFeederLineId); if (currentFeederLineId > 0) { currentFeederLineId--; currentLine = sourceLines[currentFeederLineId]; curNode = currentLine.Last; if (curNode == null) { if (currentLine.EndWithLineBreak) { readState = 1; } else { readState = 3; } } else { readState = 0; } } else if (currentFeederLineId == 0) { if (sourceLines.Count > 0) { currentLine = sourceLines[currentFeederLineId]; #if DEBUG string ss = currentLine.ToString(); #endif curNode = currentLine.First; ; readState = 2; } } } }
void Load(List<EditableTextLine> sourceLines) { if (sourceLines.Count > 0) { this.currentLine = sourceLines[0]; } readState = 2; this.sourceLines = sourceLines; isMultiLine = true; }
void debug_RecordLineInfo(RenderBoxBase owner, EditableTextLine line) { RootGraphic visualroot = this.dbugVRoot; if (visualroot.dbug_RecordDrawingChain) { } }
public void CloseCurrentLine(int lineWidth, int lineHeight) { currentLine.SetPostArrangeLineSize(lineWidth, lineHeight); if (isMultiLine) { if (currentRelocatorLineId < sourceLines.Count - 1) { ++currentRelocatorLineId; currentLine = sourceLines[currentRelocatorLineId]; } else { currentRelocatorLineId++; EditableTextLine newLine = new EditableTextLine(flowLayer); flowLayer.AppendLine(newLine); currentLine = newLine; } } else { currentRelocatorLineId++; EditableTextLine newLine = new EditableTextLine(flowLayer); flowLayer.AppendLine(newLine); sourceLines = (List<EditableTextLine>)flowLayer.lineCollection; currentLine = newLine; isMultiLine = true; } isFirstRunOfLine = true; }
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 MoveToLine(int lineNumber) { currentLine = visualFlowLayer.GetTextLine(lineNumber); currentLineY = currentLine.Top; currentTextRun = (EditableRun)currentLine.FirstRun; rCharOffset = 0; rPixelOffset = 0; charIndex = -1; caretXPos = 0; }
public static void InnerDoJoinWithNextLine(EditableTextLine line) { line.JoinWithNextLine(); }
void InsertLine(int insertAt, EditableTextLine textLine) { if (insertAt < 0) { throw new NotSupportedException(); } List<EditableTextLine> lines = lineCollection as List<EditableTextLine>; if (lines != null) { int j = lines.Count; if (insertAt > j - 1) { AppendLine(textLine); } else { EditableTextLine line = lines[insertAt]; int cy = line.Top; textLine.SetTop(cy); textLine.SetLineNumber(insertAt); cy += line.ActualLineHeight; for (int i = insertAt; i < j; i++) { line = lines[i]; line.SetTop(cy); line.SetLineNumber(i + 1); cy += line.ActualLineHeight; } textLine.editableFlowLayer = this; lines.Insert(insertAt, textLine); } } else { lines = new List<EditableTextLine>(); lines.Add((EditableTextLine)lineCollection); lineCollection = lines; FlowLayerHasMultiLines = true; int j = lines.Count; if (insertAt > j - 1) { AppendLine(textLine); } else { EditableTextLine line = lines[insertAt]; int cy = line.Top; textLine.SetTop(cy); textLine.SetLineNumber(insertAt); cy += line.ActualLineHeight; for (int i = insertAt; i < j; i++) { line = lines[i]; line.SetTop(cy); line.SetLineNumber(i + 1); cy += line.ActualLineHeight; } textLine.editableFlowLayer = this; lines.Insert(insertAt, textLine); } } }
void Load(EditableTextLine sourceLine) { this.currentLine = sourceLine; readState = 2; }
internal EditableTextLine InsertNewLine(int insertAt) { EditableTextLine newLine = new EditableTextLine(this); this.InsertLine(insertAt, newLine); return newLine; }
internal void SetInternalLinkedNode(LinkedListNode<EditableRun> linkedNode, EditableTextLine ownerTextLine) { this.ownerTextLine = ownerTextLine; this._editableRunInternalLinkedNode = linkedNode; EditableRun.SetParentLink(this, ownerTextLine); }
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(); }
public override void Clear() { if ((layerFlags & FLOWLAYER_HAS_MULTILINE) != 0) { List<EditableTextLine> lines = (List<EditableTextLine>)lineCollection; for (int i = lines.Count - 1; i > -1; --i) { lines[i].editableFlowLayer = null; lines[i].Clear(); } lines.Clear(); lineCollection = new EditableTextLine(this); FlowLayerHasMultiLines = false; } else { ((EditableTextLine)lineCollection).Clear(); } }