/// <summary> /// Generates some exmaple rich text to demonstrate all the colors /// </summary> /// <returns>String full of rich text</returns> private String generateExampleRtf() { SearchResultList list = new SearchResultList(@"D:\Projects\PND\unified-2011\submodules\technology\os\core\include\tsk\TSK_pub_lib.h"); SearchResult result = new SearchResult(); result.BeforeContext.Add(new LineText(1058, @" VARIABLES")); result.BeforeContext.Add(new LineText(1059, @"--------------------------------------------------------------------*/")); result.BeforeContext.Add(new LineText(1060, @"")); result.MatchLine.LineNumber = 1061; result.MatchLine.Text = @"extern TSK_id_t32 TSK_bkgd_id;"; result.AfterContext.Add(new LineText(1062, @"extern uint32 TSK_bkgd_stack[];")); result.AfterContext.Add(new LineText(1063, @"")); result.AfterContext.Add(new LineText(1064, @"extern TSK_id_t32 TSK_timr_id;")); list.Results.Add(result); result = new SearchResult(); result.BeforeContext.Add(new LineText(1338, @"*********************************************************************/")); result.BeforeContext.Add(new LineText(1339, @"")); result.BeforeContext.Add(new LineText(1340, @"#define TSK_multitasking() \")); result.MatchLine.LineNumber = 1341; result.MatchLine.Text = @"( ( ( *TSK_get_id_addr() == NULL) || ( TSK_get_id() == TSK_bkgd_id)) ? FALSE : TRUE)"; result.AfterContext.Add(new LineText(1342, @"")); result.AfterContext.Add(new LineText(1343, @"/*********************************************************************")); result.AfterContext.Add(new LineText(1344, @"*")); list.Results.Add(result); Regex regex = new Regex("TSK_bkgd_id"); return(RtfUtility.createRtf(list, false, regex)); }
/// <summary> /// Writes the example text to the rich text box. /// </summary> private void writeExampleText() { int oldContext = Settings.get().ContextLineCount; Settings.get().ContextLineCount = 3; using (MemoryStream stream = new MemoryStream()) { using (StreamWriter writer = new StreamWriter(stream)) { RtfUtility.WriteFileHeader(writer); writer.Write(generateExampleRtf()); writer.Flush(); stream.Position = 0; uRtfExample.LoadFile(stream, RichTextBoxStreamType.RichText); } } Settings.get().ContextLineCount = oldContext; }
/// <summary> /// Starts a search. Gets the search parameters and creates a new file searcher. Connects /// up with the results control. /// </summary> public void startSearch() { searchInit(); mUiUpdateThrottle.Enabled = true; RtfUtility.WriteFileHeader(mStreamWriter); mStreamWriter.Flush(); mInitialStreamLength = mMemoryStream.Position; if (Logger.get().LoggingEnabled) { Logger.get().AddData(new SearchParameters(Settings.get().SearchParams), "SearchParameters", "Search Parameters"); } Settings.get().SearchParams.SearchInProgress = true; mResults = TabManager.get().getControlForNewResults(); if (mFileSearcher != null) { mFileSearcher.HandleResults -= fileSearcher_HandleResults; mFileSearcher = null; } mFileSearcher = new Grep.FileSearcher(Settings.get().SearchParams); mFileSearcher.HandleResults += new Grep.FileSearcher.SearchResults(fileSearcher_HandleResults); mFileSearcher.search(); }