Modified CPU display to show oldest first. Hid unassigned CPU items

Kept it more visually stable
This commit is contained in:
Justin Swanson 2019-12-15 13:20:27 -06:00
parent 5db61d17ce
commit 5da5f246ed
5 changed files with 60 additions and 12 deletions

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Wabbajack.Common;
namespace Wabbajack
{
public class CPUDisplayVM
{
public CPUStatus Status { get; set; }
public DateTime StartTime { get; set; }
public void AbsorbStatus(CPUStatus cpu)
{
bool starting = cpu.IsWorking && ((!Status?.IsWorking) ?? true);
Status = cpu;
if (starting)
{
StartTime = DateTime.Now;
}
}
}
}

View File

@ -3,6 +3,7 @@ using DynamicData.Binding;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
@ -38,7 +39,7 @@ namespace Wabbajack
private readonly ObservableAsPropertyHelper<float> _percentCompleted;
public float PercentCompleted => _percentCompleted.Value;
public ObservableCollectionExtended<CPUStatus> StatusList { get; } = new ObservableCollectionExtended<CPUStatus>();
public ObservableCollectionExtended<CPUDisplayVM> StatusList { get; } = new ObservableCollectionExtended<CPUDisplayVM>();
public ObservableCollectionExtended<IStatusMessage> Log => MWVM.Log;
@ -142,15 +143,25 @@ namespace Wabbajack
.Select(x => !x));
// Compile progress updates and populate ObservableCollection
Dictionary<int, CPUDisplayVM> cpuDisplays = new Dictionary<int, CPUDisplayVM>();
this.WhenAny(x => x.Compiler.ActiveCompilation)
.SelectMany(c => c?.QueueStatus ?? Observable.Empty<CPUStatus>())
.ObserveOn(RxApp.TaskpoolScheduler)
.ToObservableChangeSet(x => x.ID)
// Attach start times to incoming CPU items
.Scan(
new CPUDisplayVM(),
(_, cpu) =>
{
var ret = cpuDisplays.TryCreate(cpu.ID);
ret.AbsorbStatus(cpu);
return ret;
})
.ToObservableChangeSet(x => x.Status.ID)
.Batch(TimeSpan.FromMilliseconds(250), RxApp.TaskpoolScheduler)
.EnsureUniqueChanges()
.Filter(i => i.IsWorking)
.Filter(i => i.Status.IsWorking && i.Status.ID != WorkQueue.UnassignedCpuId)
.ObserveOn(RxApp.MainThreadScheduler)
.Sort(SortExpressionComparer<CPUStatus>.Ascending(s => s.ID), SortOptimisations.ComparesImmutableValuesOnly)
.Sort(SortExpressionComparer<CPUDisplayVM>.Ascending(s => s.StartTime))
.Bind(StatusList)
.Subscribe()
.DisposeWith(CompositeDisposable);

View File

@ -19,6 +19,7 @@ using DynamicData;
using DynamicData.Binding;
using Wabbajack.Common.StatusFeed;
using System.Reactive;
using System.Collections.Generic;
namespace Wabbajack
{
@ -72,7 +73,7 @@ namespace Wabbajack
private readonly ObservableAsPropertyHelper<float> _percentCompleted;
public float PercentCompleted => _percentCompleted.Value;
public ObservableCollectionExtended<CPUStatus> StatusList { get; } = new ObservableCollectionExtended<CPUStatus>();
public ObservableCollectionExtended<CPUDisplayVM> StatusList { get; } = new ObservableCollectionExtended<CPUDisplayVM>();
public ObservableCollectionExtended<IStatusMessage> Log => MWVM.Log;
private readonly ObservableAsPropertyHelper<ModManager?> _TargetManager;
@ -292,16 +293,26 @@ namespace Wabbajack
})
.ToProperty(this, nameof(ProgressTitle));
Dictionary<int, CPUDisplayVM> cpuDisplays = new Dictionary<int, CPUDisplayVM>();
// Compile progress updates and populate ObservableCollection
this.WhenAny(x => x.Installer.ActiveInstallation)
.SelectMany(c => c?.QueueStatus ?? Observable.Empty<CPUStatus>())
.ObserveOn(RxApp.TaskpoolScheduler)
.ToObservableChangeSet(x => x.ID)
// Attach start times to incoming CPU items
.Scan(
new CPUDisplayVM(),
(_, cpu) =>
{
var ret = cpuDisplays.TryCreate(cpu.ID);
ret.AbsorbStatus(cpu);
return ret;
})
.ToObservableChangeSet(x => x.Status.ID)
.Batch(TimeSpan.FromMilliseconds(250), RxApp.TaskpoolScheduler)
.EnsureUniqueChanges()
.Filter(i => i.IsWorking)
.Filter(i => i.Status.IsWorking && i.Status.ID != WorkQueue.UnassignedCpuId)
.ObserveOn(RxApp.MainThreadScheduler)
.Sort(SortExpressionComparer<CPUStatus>.Ascending(s => s.ID), SortOptimisations.ComparesImmutableValuesOnly)
.Sort(SortExpressionComparer<CPUDisplayVM>.Ascending(s => s.StartTime))
.Bind(StatusList)
.Subscribe()
.DisposeWith(CompositeDisposable);

View File

@ -28,16 +28,16 @@
BorderThickness="0"
Foreground="Transparent"
Maximum="1"
Value="{Binding ProgressPercent, Mode=OneWay}" />
Value="{Binding Status.ProgressPercent, Mode=OneWay}" />
<mahapps:MetroProgressBar
Grid.Column="0"
Background="Transparent"
BorderThickness="0"
Foreground="{StaticResource PrimaryVariantBrush}"
Maximum="1"
Opacity="{Binding ProgressPercent, Mode=OneWay}"
Value="{Binding ProgressPercent, Mode=OneWay}" />
<TextBlock Grid.Column="0" Text="{Binding Msg}" />
Opacity="{Binding Status.ProgressPercent, Mode=OneWay}"
Value="{Binding Status.ProgressPercent, Mode=OneWay}" />
<TextBlock Grid.Column="0" Text="{Binding Status.Msg}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>

View File

@ -173,6 +173,7 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Converters\IsTypeVisibilityConverter.cs" />
<Compile Include="View Models\CPUDisplayVM.cs" />
<Compile Include="Views\Compilers\CompilationCompleteView.xaml.cs">
<DependentUpon>CompilationCompleteView.xaml</DependentUpon>
</Compile>