Throttle selections to improve Select All performance. (#104)

Throttle selections to improve Select All performance in ItemFilterScriptViewModel.
This commit is contained in:
Glen M 2018-12-02 11:30:50 -05:00 committed by Ben Wallis
parent ae98c2d5de
commit f840fb69ad
6 changed files with 231 additions and 206 deletions

View File

@ -76,6 +76,9 @@
<Reference Include="DeltaCompressionDotNet.PatchApi, Version=1.1.0.0, Culture=neutral, PublicKeyToken=3e8888ee913ed789, processorArchitecture=MSIL">
<HintPath>..\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.PatchApi.dll</HintPath>
</Reference>
<Reference Include="DynamicData, Version=6.7.0.2529, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DynamicData.6.7.0.2529\lib\net46\DynamicData.dll</HintPath>
</Reference>
<Reference Include="Fluent, Version=6.1.0.326, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Fluent.Ribbon.6.1.0.326\lib\net45\Fluent.dll</HintPath>
</Reference>
@ -130,6 +133,9 @@
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Reactive, Version=4.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reactive.4.0.0\lib\net46\System.Reactive.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Remoting" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
@ -138,6 +144,7 @@
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Windows" />
<Reference Include="System.Windows.Controls.Input.Toolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\WPFToolkit.3.5.50211.1\lib\System.Windows.Controls.Input.Toolkit.dll</HintPath>

View File

@ -6,11 +6,13 @@ using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reactive.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using System.Windows.Forms;
using System.Windows.Media.Imaging;
using DynamicData.Binding;
using Filtration.Common.Services;
using Filtration.Common.ViewModels;
using Filtration.Interface;
@ -111,6 +113,7 @@ namespace Filtration.ViewModels
private Predicate<IItemFilterBlockViewModel> _blockFilterPredicate;
private ICommandManager _scriptCommandManager;
private List<IDisposable> _subscriptions;
private ObservableCollection<string> _customSoundsAvailable;
private readonly List<IItemFilterBlockViewModelBase> _lastAddedBlocks;
@ -130,14 +133,20 @@ namespace Filtration.ViewModels
_persistenceService = persistenceService;
_messageBoxService = messageBoxService;
_clipboardService = clipboardService;
_subscriptions = new List<IDisposable>();
ItemFilterBlockViewModels = new ObservableCollection<IItemFilterBlockViewModelBase>();
SelectedBlockViewModels = new ObservableCollection<IItemFilterBlockViewModelBase>();
SelectedBlockViewModels.CollectionChanged += (s, e) =>
{
_subscriptions.Add(
SelectedBlockViewModels.ToObservableChangeSet()
.Throttle(TimeSpan.FromMilliseconds(30))
.Subscribe(x => {
RaisePropertyChanged(nameof(SelectedBlockViewModels));
RaisePropertyChanged(nameof(LastSelectedBlockViewModel));
Messenger.Default.Send(new NotificationMessage("LastSelectedBlockChanged"));
};
})
);
_lastAddedBlocks = new List<IItemFilterBlockViewModelBase>();
_showAdvanced = Settings.Default.ShowAdvanced;
@ -815,6 +824,13 @@ namespace Filtration.ViewModels
private void CloseScript()
{
foreach (var disposable in Enumerable.Reverse(_subscriptions))
{
disposable.Dispose();
}
_subscriptions.Clear();
var openMasterThemForScript =
_avalonDockWorkspaceViewModel.OpenMasterThemeForScript(this);
if (openMasterThemForScript != null)

View File

@ -6,6 +6,7 @@
<package id="CommonServiceLocator" version="2.0.4" targetFramework="net461" />
<package id="ControlzEx" version="3.0.2.4" targetFramework="net461" />
<package id="DeltaCompressionDotNet" version="1.1.0" targetFramework="net461" />
<package id="DynamicData" version="6.7.0.2529" targetFramework="net461" />
<package id="Extended.Wpf.Toolkit" version="3.4.0" targetFramework="net461" />
<package id="Fluent.Ribbon" version="6.1.0.326" targetFramework="net461" />
<package id="MahApps.Metro" version="1.2.4.0" targetFramework="net461" />
@ -17,6 +18,7 @@
<package id="SharpCompress" version="0.17.1" targetFramework="net461" />
<package id="Splat" version="1.6.2" targetFramework="net461" />
<package id="squirrel.windows" version="1.9.0" targetFramework="net461" />
<package id="System.Reactive" version="4.0.0" targetFramework="net461" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net461" />
<package id="WindowsAPICodePack-Core" version="1.1.2" targetFramework="net461" />
<package id="WindowsAPICodePack-Shell" version="1.1.1" targetFramework="net461" />