2019-12-08 22:30:49 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2020-01-11 06:43:40 +00:00
|
|
|
|
using System.Reactive.Disposables;
|
2019-12-08 22:30:49 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
2019-11-29 22:09:22 +00:00
|
|
|
|
using System.Windows.Controls;
|
2019-12-08 22:30:49 +00:00
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
using System.Windows.Navigation;
|
|
|
|
|
using System.Windows.Shapes;
|
2020-01-11 06:43:40 +00:00
|
|
|
|
using ReactiveUI;
|
|
|
|
|
using ReactiveUI.Fody.Helpers;
|
|
|
|
|
using Wabbajack.Lib;
|
|
|
|
|
using System.Windows.Controls.Primitives;
|
|
|
|
|
using System.Reactive.Linq;
|
2020-02-08 04:35:08 +00:00
|
|
|
|
using Wabbajack.Common;
|
2019-11-07 05:33:08 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2019-12-08 22:30:49 +00:00
|
|
|
|
/// Interaction logic for CpuView.xaml
|
2019-11-07 05:33:08 +00:00
|
|
|
|
/// </summary>
|
2020-01-11 06:43:40 +00:00
|
|
|
|
public partial class CpuView : UserControlRx<ICpuStatusVM>
|
2019-11-07 05:33:08 +00:00
|
|
|
|
{
|
2020-02-08 04:35:08 +00:00
|
|
|
|
public Percent ProgressPercent
|
2019-11-29 22:09:22 +00:00
|
|
|
|
{
|
2020-02-08 04:35:08 +00:00
|
|
|
|
get => (Percent)GetValue(ProgressPercentProperty);
|
2019-11-29 22:09:22 +00:00
|
|
|
|
set => SetValue(ProgressPercentProperty, value);
|
|
|
|
|
}
|
2020-02-08 04:35:08 +00:00
|
|
|
|
public static readonly DependencyProperty ProgressPercentProperty = DependencyProperty.Register(nameof(ProgressPercent), typeof(Percent), typeof(CpuView),
|
|
|
|
|
new FrameworkPropertyMetadata(default(Percent), WireNotifyPropertyChanged));
|
2019-11-29 22:09:22 +00:00
|
|
|
|
|
2020-01-11 06:43:40 +00:00
|
|
|
|
public MainSettings SettingsHook
|
|
|
|
|
{
|
|
|
|
|
get => (MainSettings)GetValue(SettingsHookProperty);
|
|
|
|
|
set => SetValue(SettingsHookProperty, value);
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty SettingsHookProperty = DependencyProperty.Register(nameof(SettingsHook), typeof(MainSettings), typeof(CpuView),
|
2020-01-20 21:59:26 +00:00
|
|
|
|
new FrameworkPropertyMetadata(default(SettingsVM), WireNotifyPropertyChanged));
|
2020-01-11 06:43:40 +00:00
|
|
|
|
|
|
|
|
|
private bool _ShowingSettings;
|
|
|
|
|
public bool ShowingSettings { get => _ShowingSettings; set => this.RaiseAndSetIfChanged(ref _ShowingSettings, value); }
|
|
|
|
|
|
2019-12-08 22:30:49 +00:00
|
|
|
|
public CpuView()
|
2019-11-07 05:33:08 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2020-01-11 06:43:40 +00:00
|
|
|
|
this.WhenActivated(disposable =>
|
|
|
|
|
{
|
|
|
|
|
Observable.CombineLatest(
|
|
|
|
|
this.WhenAny(x => x.ControlGrid.IsMouseOver),
|
|
|
|
|
this.WhenAny(x => x.SettingsHook.Performance.Manual)
|
|
|
|
|
.StartWith(true),
|
|
|
|
|
resultSelector: (over, manual) => over && !manual)
|
2020-02-08 04:35:08 +00:00
|
|
|
|
.Select(showing => showing ? Visibility.Visible : Visibility.Collapsed)
|
|
|
|
|
.BindToStrict(this, x => x.SettingsBar.Visibility)
|
2020-01-11 06:43:40 +00:00
|
|
|
|
.DisposeWith(disposable);
|
2020-02-08 04:35:08 +00:00
|
|
|
|
|
|
|
|
|
this.WhenAny(x => x.ViewModel.StatusList)
|
|
|
|
|
.BindToStrict(this, x => x.CpuListControl.ItemsSource)
|
2020-01-11 06:43:40 +00:00
|
|
|
|
.DisposeWith(disposable);
|
|
|
|
|
|
2020-02-08 04:35:08 +00:00
|
|
|
|
this.Bind(this.ViewModel, x => x.MWVM.Settings.Performance.TargetUsage, x => x.TargetPercentageSlider.Value)
|
2020-01-11 06:43:40 +00:00
|
|
|
|
.DisposeWith(disposable);
|
2020-01-11 20:20:14 +00:00
|
|
|
|
|
2020-02-08 04:35:08 +00:00
|
|
|
|
this.WhenAny(x => x.ViewModel.MWVM.Settings.Performance.TargetUsage)
|
|
|
|
|
.Select(p => p.ToString(0))
|
|
|
|
|
.BindToStrict(this, x => x.PercentageText.Text)
|
2020-01-11 20:20:14 +00:00
|
|
|
|
.DisposeWith(disposable);
|
|
|
|
|
|
|
|
|
|
this.WhenAny(x => x.ViewModel.CurrentCpuCount)
|
|
|
|
|
.DistinctUntilChanged()
|
2020-02-08 04:35:08 +00:00
|
|
|
|
.Select(x => $"{x.CurrentCPUs} / {x.DesiredCPUs}")
|
|
|
|
|
.BindToStrict(this, x => x.CpuCountText.Text)
|
|
|
|
|
.DisposeWith(disposable);
|
|
|
|
|
|
|
|
|
|
// Progress
|
|
|
|
|
this.WhenAny(x => x.ProgressPercent)
|
|
|
|
|
.Select(p => p.Value)
|
|
|
|
|
.BindToStrict(this, x => x.HeatedBorderRect.Opacity)
|
2020-01-11 20:20:14 +00:00
|
|
|
|
.DisposeWith(disposable);
|
2020-01-11 06:43:40 +00:00
|
|
|
|
});
|
2019-11-07 05:33:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|