Profile editor - Performance improvements

This commit is contained in:
SpoinkyNL committed 2020-09-14 19:54:09 +02:00
1 parent 447112729d
commit 1d789bf23c
13 files changed
+58 -83

No files matched your search

@@ -11,7 +11,7 @@
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="0 12 0 0">
<DockPanel Margin="15" MaxWidth="1230" HorizontalAlignment="Center">
<TextBlock DockPanel.Dock="Top">Below you view and manage the devices that were detected by Artemis</TextBlock>
<ItemsControl ItemsSource="{Binding DeviceSettingsViewModels}">
<ItemsControl ItemsSource="{Binding Items}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
@@ -19,7 +19,7 @@
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<ContentControl s:View.Model="{Binding}" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top" />
<ContentControl s:View.Model="{Binding IsAsync=True}" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
@@ -6,7 +6,7 @@ using Stylet;
namespace Artemis.UI.Screens.Settings.Tabs.Devices
{
public class DeviceSettingsTabViewModel : Screen
public class DeviceSettingsTabViewModel : Conductor<DeviceSettingsViewModel>.Collection.AllActive
{
private readonly ISettingsVmFactory _settingsVmFactory;
private readonly ISurfaceService _surfaceService;
@@ -18,25 +18,17 @@ namespace Artemis.UI.Screens.Settings.Tabs.Devices
_surfaceService = surfaceService;
_settingsVmFactory = settingsVmFactory;
DeviceSettingsViewModels = new BindableCollection<DeviceSettingsViewModel>();
}
public BindableCollection<DeviceSettingsViewModel> DeviceSettingsViewModels
{
get => _deviceSettingsViewModels;
set => SetAndNotify(ref _deviceSettingsViewModels, value);
}
protected override void OnActivate()
{
// Take it off the UI thread to avoid freezing on tab change
Task.Run(() =>
{
DeviceSettingsViewModels.Clear();
Items.Clear();
var instances = _surfaceService.ActiveSurface.Devices.Select(d => _settingsVmFactory.CreateDeviceSettingsViewModel(d)).ToList();
foreach (var deviceSettingsViewModel in instances)
DeviceSettingsViewModels.Add(deviceSettingsViewModel);
Items.Add(deviceSettingsViewModel);
});
}
}