private void TextDocument_TextSegmentAdded(object sender, AlterTextSegmentArgs e) { var textLine = e.TextSegment; var hdc = this.GetHdc().DangerousGetHandle(); var newInformation = textLine.CalculateVisuals(this, hdc, this.GetTextRectangle(false, true).Width, this.LineHeight); this.ReleaseHdc(); // Insert an empty one here that is later overwritten in "UpdateVisualInformationLine". // This insertion is just a placeholder so that the code later knows that all values have changed from the default. this._textSegmentVisualInformations.Insert(e.LineIndex, new TextSegmentVisualInfos()); this.UpdateVisualInformationLine(e.LineIndex, e.TextSegment, e.CharacterCountDifference, newInformation); }
private void TextDocument_TextSegmentAlter(object sender, AlterTextSegmentArgs e) { var textLine = e.TextSegment; if (this._textSegmentVisualInformations.Count - 1 < e.LineIndex) { // Add an empty one so that the check below returns that the previous line count was 0. this._textSegmentVisualInformations.Add(new TextSegmentVisualInfos()); } var hdc = this.GetHdc().DangerousGetHandle(); var information = textLine.CalculateVisuals(this, hdc, this.GetTextRectangle(false, true).Width, this.LineHeight); this.ReleaseHdc(); this.UpdateVisualInformationLine(e.LineIndex, e.TextSegment, e.CharacterCountDifference, information); }
private void TextDocument_TextSegmentRemoved(object sender, AlterTextSegmentArgs e) { var textLine = e.TextSegment; // Remove the line count. this._visualLineCount -= this.GetVisualInformation(e.LineIndex).GetLineCountVisual(e.TextColumnIndex); this._layoutLinesOverflow.Remove(textLine); // Remove any potential width overflow the line had. this._textSegmentVisualInformations.RemoveAt(e.LineIndex); if (Focused == false) { // If it is not focused, it means that this is probably a virtual copy of the text control, // and we need to make it keep the same selection start so it does not jump around. if (e.TextSegment.Index <= this.SelectionStart) { this.SelectionStart += e.CharacterCountDifference; } } }