From 89b7d2cfd36a2f28f1c60d47cda6d167d67637c7 Mon Sep 17 00:00:00 2001 From: morkt Date: Thu, 12 Jan 2017 11:14:05 +0400 Subject: [PATCH] (GUI): improved selection by mask performance on large directories. --- GUI/ListViewEx.cs | 5 +++++ GUI/MainWindow.xaml.cs | 14 +++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/GUI/ListViewEx.cs b/GUI/ListViewEx.cs index 5777ff7f..70da8756 100644 --- a/GUI/ListViewEx.cs +++ b/GUI/ListViewEx.cs @@ -44,6 +44,11 @@ namespace GARbro.GUI { } + new public bool SetSelectedItems (IEnumerable selected_items) + { + return base.SetSelectedItems (selected_items); + } + protected override DependencyObject GetContainerForItemOverride() { return new ListViewItemEx(); diff --git a/GUI/MainWindow.xaml.cs b/GUI/MainWindow.xaml.cs index 36d00471..6adab05c 100644 --- a/GUI/MainWindow.xaml.cs +++ b/GUI/MainWindow.xaml.cs @@ -1169,6 +1169,7 @@ namespace GARbro.GUI CurrentDirectory.SelectAll(); return; } + SetBusyState(); var glob = new FileNameGlob (selection.Mask.Text); var matching = ViewModel.Where (entry => glob.IsMatch (entry.Name)); if (!matching.Any()) @@ -1176,15 +1177,10 @@ namespace GARbro.GUI SetStatusText (string.Format (guiStrings.MsgNoMatching, selection.Mask.Text)); return; } - int count = 0; - foreach (var item in matching) - { - if (!CurrentDirectory.SelectedItems.Contains (item)) - { - CurrentDirectory.SelectedItems.Add (item); - ++count; - } - } + var selected = CurrentDirectory.SelectedItems.Cast(); + matching = matching.Except (selected).ToList(); + int count = matching.Count(); + CurrentDirectory.SetSelectedItems (selected.Concat (matching)); if (count != 0) SetStatusText (Localization.Format ("MsgSelectedFiles", count)); }