diff --git a/Wabbajack/View Models/Compilers/CompilerVM.cs b/Wabbajack/View Models/Compilers/CompilerVM.cs index b5c2a069..944ad9c8 100644 --- a/Wabbajack/View Models/Compilers/CompilerVM.cs +++ b/Wabbajack/View Models/Compilers/CompilerVM.cs @@ -19,7 +19,7 @@ using Wabbajack.UI; namespace Wabbajack { - public class CompilerVM : ViewModel, IBackNavigatingVM + public class CompilerVM : ViewModel, IBackNavigatingVM, ICpuStatusVM { public MainWindowVM MWVM { get; } diff --git a/Wabbajack/View Models/Installers/InstallerVM.cs b/Wabbajack/View Models/Installers/InstallerVM.cs index df9a021b..ba6a4328 100644 --- a/Wabbajack/View Models/Installers/InstallerVM.cs +++ b/Wabbajack/View Models/Installers/InstallerVM.cs @@ -25,7 +25,7 @@ using Wabbajack.UI; namespace Wabbajack { - public class InstallerVM : ViewModel, IBackNavigatingVM + public class InstallerVM : ViewModel, IBackNavigatingVM, ICpuStatusVM { public SlideShow Slideshow { get; } diff --git a/Wabbajack/View Models/Interfaces/ICpuStatusVM.cs b/Wabbajack/View Models/Interfaces/ICpuStatusVM.cs new file mode 100644 index 00000000..c7c0eb22 --- /dev/null +++ b/Wabbajack/View Models/Interfaces/ICpuStatusVM.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DynamicData.Binding; +using ReactiveUI; + +namespace Wabbajack +{ + public interface ICpuStatusVM : IReactiveObject + { + ObservableCollectionExtended StatusList { get; } + MainWindowVM MWVM { get; } + } +} diff --git a/Wabbajack/Views/Common/CpuView.xaml b/Wabbajack/Views/Common/CpuView.xaml index c45e729f..436d152f 100644 --- a/Wabbajack/Views/Common/CpuView.xaml +++ b/Wabbajack/Views/Common/CpuView.xaml @@ -1,4 +1,4 @@ - - + - - - - - - + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + + - + diff --git a/Wabbajack/Views/Common/CpuView.xaml.cs b/Wabbajack/Views/Common/CpuView.xaml.cs index 987fa512..6e177dce 100644 --- a/Wabbajack/Views/Common/CpuView.xaml.cs +++ b/Wabbajack/Views/Common/CpuView.xaml.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reactive.Disposables; using System.Text; using System.Threading.Tasks; using System.Windows; @@ -12,13 +13,18 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using ReactiveUI; +using ReactiveUI.Fody.Helpers; +using Wabbajack.Lib; +using System.Windows.Controls.Primitives; +using System.Reactive.Linq; namespace Wabbajack { /// /// Interaction logic for CpuView.xaml /// - public partial class CpuView : UserControl + public partial class CpuView : UserControlRx { public double ProgressPercent { @@ -28,9 +34,39 @@ namespace Wabbajack public static readonly DependencyProperty ProgressPercentProperty = DependencyProperty.Register(nameof(ProgressPercent), typeof(double), typeof(CpuView), new FrameworkPropertyMetadata(default(double))); + public MainSettings SettingsHook + { + get => (MainSettings)GetValue(SettingsHookProperty); + set => SetValue(SettingsHookProperty, value); + } + public static readonly DependencyProperty SettingsHookProperty = DependencyProperty.Register(nameof(SettingsHook), typeof(MainSettings), typeof(CpuView), + new FrameworkPropertyMetadata(default(SettingsVM))); + + private bool _ShowingSettings; + public bool ShowingSettings { get => _ShowingSettings; set => this.RaiseAndSetIfChanged(ref _ShowingSettings, value); } + public CpuView() { InitializeComponent(); + 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) + .Subscribe(showing => + { + SettingsBar.Visibility = showing ? Visibility.Visible : Visibility.Collapsed; + }) + .DisposeWith(disposable); + + this.OneWayBindStrict(this.ViewModel, x => x.StatusList, x => x.CpuListControl.ItemsSource) + .DisposeWith(disposable); + + this.BindStrict(this.ViewModel, x => x.MWVM.Settings.Performance.TargetUsage, x => x.TargetPercentageSlider.Value) + .DisposeWith(disposable); + }); } } } diff --git a/Wabbajack/Views/Compilers/CompilerView.xaml b/Wabbajack/Views/Compilers/CompilerView.xaml index 7db0c6f2..99c843f2 100644 --- a/Wabbajack/Views/Compilers/CompilerView.xaml +++ b/Wabbajack/Views/Compilers/CompilerView.xaml @@ -307,6 +307,8 @@ diff --git a/Wabbajack/Views/Installers/InstallationView.xaml b/Wabbajack/Views/Installers/InstallationView.xaml index 62b0fb59..cd4b479e 100644 --- a/Wabbajack/Views/Installers/InstallationView.xaml +++ b/Wabbajack/Views/Installers/InstallationView.xaml @@ -422,6 +422,8 @@ diff --git a/Wabbajack/Views/UserControlRx.cs b/Wabbajack/Views/UserControlRx.cs index 17b310df..4debe0d0 100644 --- a/Wabbajack/Views/UserControlRx.cs +++ b/Wabbajack/Views/UserControlRx.cs @@ -40,4 +40,28 @@ namespace Wabbajack control.RaisePropertyChanged(e.Property.Name); } } + + public class UserControlRx : ReactiveUserControl, IReactiveObject + where TViewModel : class + { + public event PropertyChangedEventHandler PropertyChanged; + public event PropertyChangingEventHandler PropertyChanging; + + public void RaisePropertyChanging(PropertyChangingEventArgs args) + { + PropertyChanging?.Invoke(this, args); + } + + public void RaisePropertyChanged(PropertyChangedEventArgs args) + { + PropertyChanged?.Invoke(this, args); + } + + protected static void WireNotifyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (!(d is UserControlRx control)) return; + if (Equals(e.OldValue, e.NewValue)) return; + control.RaisePropertyChanged(e.Property.Name); + } + } } diff --git a/Wabbajack/Wabbajack.csproj b/Wabbajack/Wabbajack.csproj index 5feabcd8..71d3674b 100644 --- a/Wabbajack/Wabbajack.csproj +++ b/Wabbajack/Wabbajack.csproj @@ -180,6 +180,7 @@ + LoginItemView.xaml