private void SearchAsYouType() { if (this.searchBox.Text == this.lastSearchTerm) { return; } if (string.IsNullOrWhiteSpace(this.searchBox.Text) || this.searchBox.SelectedText == this.searchBox.Text) { this.FilterTitlesAndUpdate(); return; } Func <string, string, bool> containsSubstring = (x, y) => x.Contains(y, StringComparison.OrdinalIgnoreCase); var foundTitles = TitleFilter.FilterTitles(this.allTitles, this.titleFilter) .Where( a => containsSubstring(a.Name.RemoveDiacritics(), this.searchBox.Text) || containsSubstring(a.TitleId, this.searchBox.Text) || containsSubstring(a.Serial, this.searchBox.Text)) .ToArray(); if (foundTitles.Any()) { this.titlesDataGrid.DataSource = new SortableBindingList <Nintendo3DSTitle>(foundTitles); this.SortDataGrid(); } else { this.UpdateAction("No titles found."); } this.lastSearchTerm = this.searchBox.Text; }
private async void MainForm_Shown(object sender, EventArgs e) { this.SetVersion(); this.currentTitleStatusLabel.Text = string.Empty; if (!File.Exists(Files.DbPath)) { var result = MessageBox.Show( Properties.Resources.Disclaimer, "boo", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (result == DialogResult.Cancel) { Environment.Exit(0); } this.statusProgressbar.Style = ProgressBarStyle.Marquee; this.UpdateAction("Downloading database..."); await Task.Run(() => DatabaseParser.DownloadDatabase(Files.DbPath)); this.UpdateAction($"Prettifying JSON in \"{Files.DbPath}\"..."); File.WriteAllText(Files.DbPath, JsonPrettifier.FormatJson(File.ReadAllText(Files.DbPath))); } if (!File.Exists(Files.SizesPath)) { this.UpdateAction("Downloading sizes data..."); await Task.Run(() => DatabaseParser.DownloadSizes(Files.SizesPath)); } this.UpdateAction($"Reading data from \"{Files.DbPath}\" and \"{Files.SizesPath}\"..."); this.allTitles = DatabaseParser.ParseFromDatabase(Files.DbPath, Files.SizesPath); if (File.Exists(Files.FilterPath)) { this.titleFilter = TitleFilterStorage.ParseFilterSettings(Files.FilterPath); } this.titles = new SortableBindingList <Nintendo3DSTitle>(TitleFilter.FilterTitles(this.allTitles, this.titleFilter)); this.titlesDataGrid.DoubleBuffered(true); this.titlesDataGrid.DataSource = this.titles; this.SortDataGrid(); this.UpdateAction(string.Empty); this.currentTitleStatusLabel.Text = string.Empty; this.titlesCountLabel.Text = this.titles.Count + " titles"; this.statusProgressbar.Style = ProgressBarStyle.Blocks; this.generateAllTicketsButton.Enabled = true; this.filterButton.Enabled = true; this.generateQrCodeButton.Enabled = true; }
private void FilterTitlesAndUpdate() { this.UpdateAction("Filtering..."); this.statusProgressbar.Style = ProgressBarStyle.Marquee; this.titlesDataGrid.DataSource = this.titles = new SortableBindingList <Nintendo3DSTitle>(TitleFilter.FilterTitles(this.allTitles, this.titleFilter)); this.SortDataGrid(); this.UpdateAction(string.Empty); this.statusProgressbar.Style = ProgressBarStyle.Blocks; this.titlesCountLabel.Text = $"{this.titles.Count} titles"; }