/// <summary> /// Creates a new document by filtering out the lines of the current document using the supplied filter function. /// </summary> /// <param name="Filter">The function that will filter the lines out of the current document.</param> /// <param name="Data">User supplied data that may control filtering.</param> /// <returns>A new document containing filtered lines from the current document.</returns> public OutputWindowDocument CreateFilteredDocument(OutputWindowDocumentFilterDelegate Filter, object Data) { if (Filter == null) { throw new ArgumentNullException("Filter"); } OutputWindowDocument NewDoc = new OutputWindowDocument(); NewDoc.mLines.Capacity = mLines.Capacity; DocumentLine LastLine = null; foreach (DocumentLine CurLine in mLines) { if (!Filter(new ReadOnlyDocumentLine(CurLine), Data)) { DocumentLine NewLine = (DocumentLine)CurLine.Clone(); NewDoc.mLines.Add(NewLine); int LineLength = GetLineLength(NewLine); if (LineLength > NewDoc.mLongestLineLength) { NewDoc.mLongestLineLength = LineLength; } LastLine = NewLine; } } // If the last line is a full line we need to append an empty line because the empty line has been filtered out if (LastLine != null && LastLine.ToString().EndsWith(Environment.NewLine)) { NewDoc.mLines.Add(new DocumentLine()); } return(NewDoc); }
/// <summary> /// Constructor. /// </summary> /// <param name="LineIndex">The index of the line within its document.</param> /// <param name="Txt">The line of text.</param> public OutputWindowDocumentLineAddedEventArgs(int LineIndex, OutputWindowDocument.ReadOnlyDocumentLine Txt) { mLine = Txt; mLineIndex = LineIndex; }
/// <summary> /// Creates a new document by filtering out the lines of the current document using the supplied filter function. /// </summary> /// <param name="Filter">The function that will filter the lines out of the current document.</param> /// <param name="Data">User supplied data that may control filtering.</param> /// <returns>A new document containing filtered lines from the current document.</returns> public OutputWindowDocument CreateFilteredDocument(OutputWindowDocumentFilterDelegate Filter, object Data) { if(Filter == null) { throw new ArgumentNullException("Filter"); } OutputWindowDocument NewDoc = new OutputWindowDocument(); NewDoc.mLines.Capacity = mLines.Capacity; DocumentLine LastLine = null; foreach(DocumentLine CurLine in mLines) { if(!Filter(new ReadOnlyDocumentLine(CurLine), Data)) { DocumentLine NewLine = (DocumentLine)CurLine.Clone(); NewDoc.mLines.Add(NewLine); int LineLength = GetLineLength(NewLine); if(LineLength > NewDoc.mLongestLineLength) { NewDoc.mLongestLineLength = LineLength; } LastLine = NewLine; } } // If the last line is a full line we need to append an empty line because the empty line has been filtered out if(LastLine != null && LastLine.ToString().EndsWith(Environment.NewLine)) { NewDoc.mLines.Add(new DocumentLine()); } return NewDoc; }