public void UpdateSolutionData() { Schematix.ProjectExplorer.Project selProject = null; if ((core != null) && (core.Solution != null)) { selProject = core.Solution.CurrentSelectedProject; if (selProject == null) { if (core.Solution.ProjectList.Count >= 1) { selProject = core.Solution.ProjectList[0]; } } } ComboBoxTopProject.Items.Clear(); if ((core != null) && (core.Solution != null)) { foreach (Schematix.ProjectExplorer.Project proj in core.Solution.ProjectList) { ComboBoxTopProject.Items.Add(proj); } ComboBoxTopProject.SelectedItem = selProject; } if ((selProject != null) && (core != null) && (core.ProjectExplorerPanel != null) && (core.ProjectExplorerPanel.projectExplorerControl != null)) { ContextMenu cm = selProject.CreateElementContextMenu(core.ProjectExplorerPanel.projectExplorerControl); MenuItemProject.Items.Clear(); MenuItemProject.Visibility = System.Windows.Visibility.Visible; List <object> items = new List <object>(); foreach (object o in cm.Items) { items.Add(o); } cm.Items.Clear(); foreach (object o in items) { MenuItemProject.Items.Add(o); } } else { MenuItemProject.Visibility = System.Windows.Visibility.Collapsed; } textSearcher = new TextSearcher(); textSearcher.Searcher.StartOffset = 0; if (RadioButtonCurrentFileSearch.IsChecked == true) { textSearcher.Reset(SearchType.CurrentDocument); } if (RadioButtonCurrentProjectSearch.IsChecked == true) { textSearcher.Reset(SearchType.CurrentProject); } if (RadioButtonEntireSolutionSearchSearch.IsChecked == true) { textSearcher.Reset(SearchType.EntireSolution); } }
async void APIOnSearchResultHandler(TextSearcher sender, PageResults pageResults) { // Dispatch on the Controller thread, otherwise updating the `SearchResults` list will throw an exception. await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { foreach (var result in pageResults.Results) { SearchResults.Add(new SearchResultFormatter(result)); } }); }
/// <summary> /// Initializes the view model with the Pdf view. This is necessary as we have to trigger the search /// from the view. /// </summary> /// <param name="pdfView">The Pdf view of the page</param> public void Initialize(PdfView pdfView) { PdfView = pdfView; TextSearcher = new TextSearcher(); PdfView.InitializationCompletedHandler += delegate { // We register the search result handler as soon as the Pdf view is initialized. TextSearcher.SearchResultHandler += APIOnSearchResultHandler; }; }
public void ExecuteOther(CodeAnalyzerParameters parameters) { var textSearcher = new TextSearcher(parameters.GetExtractFunction()); textSearcher.ProcessFolder(parameters.Directory, parameters.SearchFilter); foreach (var report in parameters.Reports) { var result = textSearcher.GetFormattedReport(report); File.WriteAllLines(report.OutputFileName, result); } }
public void SendQuery(string query) { var n1GrammQuery = TextConvertor.TextToWordList(query); var texts = TextSearcher.Search(query); foreach (string text in texts) { var n1GrammText = TextConvertor.TextToWordList(text); var vectorizedText = _word2VecModelDB.CreateWordVectorList(n1GrammText); var vectorizedQuery = _word2VecModelDB.CreateWordVectorList(n1GrammQuery); var score = Cluster.GetAccordance(WordVector.GetVectors(vectorizedText), WordVector.GetVectors(vectorizedQuery)); _view.ShowTextWithScore(text, score); } }
private TextSearcher GetTestingObject() { var result = new TextSearcher(s => TextHelper.ExtractStringLiterals(s)); result.AddInfo("a", "1.txt", 5); result.AddInfo("bb", "1.txt", 10); result.AddInfo("a", "1.txt", 15); result.AddInfo("ccc", "2.txt", 8); result.AddInfo("dddd", "2.txt", 1); result.AddInfo("ccc", "2.txt", 5); result.AddInfo("ccc", "1.txt", 25); result.AddInfo("a", "3.txt", 7); result.AddInfo("ccc", "3.txt", 14); result.AddInfo("dddd", "1.txt", 21); return(result); }
static void Main(string[] args) { Console.Write("\n C# Client AutoTest for COM Project"); Console.Write("\n ===========================\n"); string reg = "(S)(.*)"; string regforname = "(T)(.*)"; string filepathDir = "../../../ATLProject2"; Console.WriteLine("Demostrating 1st COM, FileMng. This COM object should receive a string path and a regular expression, and return a string list of the matched filename/filepath."); Console.WriteLine("Finding regular expression '" + regforname + "' for filenames under " + filepathDir); FileMng fm = new FileMng(); object result = new object(); fm.GetFileList(filepathDir, regforname, ref result); Array ct = (Array)result; string[] content = new string[ct.Length]; ct.CopyTo(content, 0); Console.WriteLine(content.Length + " files are found:"); for (int i = 0; i < content.Length; i++) { Console.WriteLine("File " + i + ": " + content[i]); } Console.WriteLine("Press any key to see result of 2nd COM"); Console.ReadLine(); Console.WriteLine("Demostrating 2nd COM, TextSearch. This COM object should receive a string path and a regular expression, and return the line numbers that matches."); Console.WriteLine("Finding regular expression '" + reg + "' for lines under " + filepathDir); TextSearcher ts = new TextSearcher(); foreach (string i in content) { string reply = ""; ts.FindLines(i, reg, ref reply); if (reply != "") { Console.WriteLine(reply); } } Console.WriteLine("Press any key to exit"); Console.ReadLine(); }
public async Task OpenFile(string filePath) { IsEnabled = true; if (mFile != null) { mFile.Dispose();//TODO pensar em uma forma melhor de clean, talvez remover todo o User Control } this.filePath = filePath; fileSize = new FileInfo(filePath).Length; maximumStartOffset = GetMaximumStartOffset();//TODO precisa atualizar sempre que fizer resize mFile = MemoryMappedFile.CreateFromFile(filePath, FileMode.Open, null, 0, MemoryMappedFileAccess.Read); searcher = new TextSearcher(mFile, fileSize); LineIndexer = new LineIndexer(searcher); await GoToOffset(0, true); TxtContent.Focus(); }
public void Execute(string keyword, string targetText) { var keywordList = keyword.Split(new string[] { "..." }, StringSplitOptions.None); var textList = targetText.Split(new string[] { "\r\n" }, StringSplitOptions.None); StrExtractInfo info = new StrExtractInfo(keywordList[0], keywordList[1]); string extractTextData = ""; foreach (var textLine in textList) { var resText = TextSearcher.Extract(textLine, info); if (String.IsNullOrEmpty(resText)) { continue; } extractTextData += resText + Environment.NewLine; } if (string.IsNullOrEmpty(extractTextData)) { return; } File.AppendAllText(@"extract.txt", extractTextData); }
public bool FindTitle() { if (string.IsNullOrEmpty(_html)) { throw new Utils.ParserException("Код не был загружен. Сначала выполните Download Html"); } TextSearcher ts = new TextSearcher(_html); ts.Skip("avito.item.url = '/"); ts.Skip("<h1 itemprop=\"name\" class=\"h1\">"); string title = ts.ReadTo("</h1>"); try { _title = title; return(true); } catch { return(false); } }
public SearchReplaceUserControl(SchematixCore core, Schematix.Windows.Code.Code code) { this.core = core; textSearcher = new TextSearcher(); InitializeComponent(); }