mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
UserIntervention views made to RxUserControls
This commit is contained in:
parent
29295a774e
commit
0e935ec261
@ -19,5 +19,6 @@ namespace Wabbajack
|
||||
int ConfigVisualVerticalOffset { get; }
|
||||
IObservable<bool> CanInstall { get; }
|
||||
Task<bool> Install();
|
||||
IUserIntervention InterventionConverter(IUserIntervention intervention);
|
||||
}
|
||||
}
|
||||
|
@ -397,11 +397,19 @@ namespace Wabbajack
|
||||
|
||||
// Listen for user interventions, and compile a dynamic list of all unhandled ones
|
||||
var activeInterventions = this.WhenAny(x => x.Installer.ActiveInstallation)
|
||||
.SelectMany(c => c?.LogMessages ?? Observable.Empty<IStatusMessage>())
|
||||
.WhereCastable<IStatusMessage, IUserIntervention>()
|
||||
.ToObservableChangeSet()
|
||||
.AutoRefresh(i => i.Handled)
|
||||
.Filter(i => !i.Handled)
|
||||
.WithLatestFrom(
|
||||
this.WhenAny(x => x.Installer),
|
||||
(activeInstall, installer) =>
|
||||
{
|
||||
if (activeInstall == null) return Observable.Empty<IChangeSet<IUserIntervention>>();
|
||||
return activeInstall.LogMessages
|
||||
.WhereCastable<IStatusMessage, IUserIntervention>()
|
||||
.ToObservableChangeSet()
|
||||
.AutoRefresh(i => i.Handled)
|
||||
.Filter(i => !i.Handled)
|
||||
.Transform(x => installer.InterventionConverter(x));
|
||||
})
|
||||
.Switch()
|
||||
.AsObservableList();
|
||||
|
||||
// Find the top intervention /w no CPU ID to be marked as "global"
|
||||
|
@ -169,5 +169,16 @@ namespace Wabbajack
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public IUserIntervention InterventionConverter(IUserIntervention intervention)
|
||||
{
|
||||
switch (intervention)
|
||||
{
|
||||
case ConfirmUpdateOfExistingInstall confirm:
|
||||
return new ConfirmUpdateOfExistingInstallVM(this, confirm);
|
||||
default:
|
||||
return intervention;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,5 +87,7 @@ namespace Wabbajack
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public IUserIntervention InterventionConverter(IUserIntervention intervention) => intervention;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
public class ConfirmUpdateOfExistingInstallVM : ViewModel, IUserIntervention
|
||||
{
|
||||
public ConfirmUpdateOfExistingInstall Source { get; }
|
||||
|
||||
public MO2InstallerVM Installer { get; }
|
||||
|
||||
public bool Handled => ((IUserIntervention)Source).Handled;
|
||||
|
||||
public int CpuID => ((IUserIntervention)Source).CpuID;
|
||||
|
||||
public DateTime Timestamp => ((IUserIntervention)Source).Timestamp;
|
||||
|
||||
public string ShortDescription => ((IUserIntervention)Source).ShortDescription;
|
||||
|
||||
public string ExtendedDescription => ((IUserIntervention)Source).ExtendedDescription;
|
||||
|
||||
public ConfirmUpdateOfExistingInstallVM(MO2InstallerVM installer, ConfirmUpdateOfExistingInstall confirm)
|
||||
{
|
||||
Source = confirm;
|
||||
Installer = installer;
|
||||
}
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
((IUserIntervention)Source).Cancel();
|
||||
}
|
||||
}
|
||||
}
|
@ -401,11 +401,18 @@
|
||||
x:Name="CpuView"
|
||||
Grid.Column="2"
|
||||
ViewModel="{Binding}" />
|
||||
<local:AttentionBorder x:Name="UserInterventionsControl" Grid.Column="2">
|
||||
<Grid>
|
||||
<local:ConfirmationInterventionView DataContext="{Binding ActiveGlobalUserIntervention}" Visibility="{Binding ActiveGlobalUserIntervention, Converter={StaticResource IsTypeVisibilityConverter}, ConverterParameter={x:Type common:ConfirmationIntervention}}" />
|
||||
<local:ConfirmUpdateOfExistingInstallView Visibility="{Binding ActiveGlobalUserIntervention, Converter={StaticResource IsTypeVisibilityConverter}, ConverterParameter={x:Type lib:ConfirmUpdateOfExistingInstall}}" />
|
||||
</Grid>
|
||||
<local:AttentionBorder
|
||||
x:Name="UserInterventionsControl"
|
||||
Grid.Column="2"
|
||||
Content="{Binding ActiveGlobalUserIntervention}">
|
||||
<local:AttentionBorder.Resources>
|
||||
<DataTemplate DataType="{x:Type common:ConfirmationIntervention}">
|
||||
<local:ConfirmationInterventionView ViewModel="{Binding}" />
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type local:ConfirmUpdateOfExistingInstallVM}">
|
||||
<local:ConfirmUpdateOfExistingInstallView ViewModel="{Binding}" />
|
||||
</DataTemplate>
|
||||
</local:AttentionBorder.Resources>
|
||||
</local:AttentionBorder>
|
||||
<local:InstallationCompleteView
|
||||
x:Name="InstallComplete"
|
||||
|
@ -1,12 +1,15 @@
|
||||
<UserControl
|
||||
<rxui:ReactiveUserControl
|
||||
x:Class="Wabbajack.ConfirmUpdateOfExistingInstallView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:lib="clr-namespace:Wabbajack.Lib;assembly=Wabbajack.Lib"
|
||||
xmlns:local="clr-namespace:Wabbajack"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:rxui="http://reactiveui.net"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
x:TypeArguments="local:ConfirmUpdateOfExistingInstallVM"
|
||||
mc:Ignorable="d">
|
||||
<Grid Margin="10">
|
||||
<Grid.ColumnDefinitions>
|
||||
@ -21,6 +24,7 @@
|
||||
<RowDefinition Height="2*" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock
|
||||
x:Name="ShortDescription"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="3"
|
||||
@ -28,15 +32,15 @@
|
||||
FontFamily="Lucida Sans"
|
||||
FontSize="14"
|
||||
FontWeight="Bold"
|
||||
Text="{Binding ActiveGlobalUserIntervention.ShortDescription}"
|
||||
TextWrapping="WrapWithOverflow" />
|
||||
<TextBlock
|
||||
x:Name="ExtendedDescription"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="3"
|
||||
Text="{Binding ActiveGlobalUserIntervention.ExtendedDescription}"
|
||||
TextWrapping="WrapWithOverflow" />
|
||||
<CheckBox
|
||||
x:Name="AutoOverwriteCheckbox"
|
||||
Grid.Row="2"
|
||||
Grid.Column="2"
|
||||
Margin="4"
|
||||
@ -45,14 +49,14 @@
|
||||
IsChecked="{Binding Installer.AutomaticallyOverwrite}"
|
||||
ToolTip="If installing over an existing installation next time, automatically replace it without asking permission." />
|
||||
<Button
|
||||
x:Name="CancelButton"
|
||||
Grid.Row="3"
|
||||
Grid.Column="0"
|
||||
Command="{Binding ActiveGlobalUserIntervention.CancelCommand}"
|
||||
Content="Cancel" />
|
||||
<Button
|
||||
x:Name="ConfirmButton"
|
||||
Grid.Row="3"
|
||||
Grid.Column="2"
|
||||
Command="{Binding ActiveGlobalUserIntervention.ConfirmCommand}"
|
||||
Content="Confirm" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
</rxui:ReactiveUserControl>
|
||||
|
@ -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,17 +13,39 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using ReactiveUI;
|
||||
using Wabbajack.Lib;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ConfirmUpdateOfExistingInstallView.xaml
|
||||
/// </summary>
|
||||
public partial class ConfirmUpdateOfExistingInstallView : UserControl
|
||||
public partial class ConfirmUpdateOfExistingInstallView : ReactiveUserControl<ConfirmUpdateOfExistingInstallVM>
|
||||
{
|
||||
public ConfirmUpdateOfExistingInstallView()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.WhenActivated(dispose =>
|
||||
{
|
||||
this.WhenAny(x => x.ViewModel.ShortDescription)
|
||||
.BindToStrict(this, x => x.ShortDescription.Text)
|
||||
.DisposeWith(dispose);
|
||||
this.WhenAny(x => x.ViewModel.ExtendedDescription)
|
||||
.BindToStrict(this, x => x.ExtendedDescription.Text)
|
||||
.DisposeWith(dispose);
|
||||
this.WhenAny(x => x.ViewModel.Source.ConfirmCommand)
|
||||
.BindToStrict(this, x => x.ConfirmButton.Command)
|
||||
.DisposeWith(dispose);
|
||||
this.WhenAny(x => x.ViewModel.Source.CancelCommand)
|
||||
.BindToStrict(this, x => x.CancelButton.Command)
|
||||
.DisposeWith(dispose);
|
||||
|
||||
this.BindStrict(this.ViewModel, x => x.Installer.AutomaticallyOverwrite, x => x.AutoOverwriteCheckbox.IsChecked,
|
||||
vmToViewConverter: x => x,
|
||||
viewToVmConverter: x => x ?? false)
|
||||
.DisposeWith(dispose);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,15 @@
|
||||
<UserControl
|
||||
<rxui:ReactiveUserControl
|
||||
x:Class="Wabbajack.ConfirmationInterventionView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:common="clr-namespace:Wabbajack.Common;assembly=Wabbajack.Common"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Wabbajack"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:rxui="http://reactiveui.net"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
x:TypeArguments="common:ConfirmationIntervention"
|
||||
mc:Ignorable="d">
|
||||
<Grid Margin="10">
|
||||
<Grid.ColumnDefinitions>
|
||||
@ -20,6 +23,7 @@
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock
|
||||
x:Name="ShortDescription"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="3"
|
||||
@ -27,23 +31,22 @@
|
||||
FontFamily="Lucida Sans"
|
||||
FontSize="14"
|
||||
FontWeight="Bold"
|
||||
Text="{Binding ShortDescription}"
|
||||
TextWrapping="WrapWithOverflow" />
|
||||
<TextBlock
|
||||
x:Name="ExtendedDescription"
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="3"
|
||||
Text="{Binding ExtendedDescription}"
|
||||
TextWrapping="WrapWithOverflow" />
|
||||
<Button
|
||||
x:Name="CancelButton"
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Command="{Binding CancelCommand}"
|
||||
Content="Cancel" />
|
||||
<Button
|
||||
x:Name="ConfirmButton"
|
||||
Grid.Row="2"
|
||||
Grid.Column="2"
|
||||
Command="{Binding ConfirmCommand}"
|
||||
Content="Confirm" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
</rxui:ReactiveUserControl>
|
||||
|
@ -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,17 +13,34 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using ReactiveUI;
|
||||
using Wabbajack.Common;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ConfirmationInterventionView.xaml
|
||||
/// </summary>
|
||||
public partial class ConfirmationInterventionView : UserControl
|
||||
public partial class ConfirmationInterventionView : ReactiveUserControl<ConfirmationIntervention>
|
||||
{
|
||||
public ConfirmationInterventionView()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.WhenActivated(dispose =>
|
||||
{
|
||||
this.WhenAny(x => x.ViewModel.ShortDescription)
|
||||
.BindToStrict(this, x => x.ShortDescription.Text)
|
||||
.DisposeWith(dispose);
|
||||
this.WhenAny(x => x.ViewModel.ExtendedDescription)
|
||||
.BindToStrict(this, x => x.ExtendedDescription.Text)
|
||||
.DisposeWith(dispose);
|
||||
this.WhenAny(x => x.ViewModel.ConfirmCommand)
|
||||
.BindToStrict(this, x => x.ConfirmButton.Command)
|
||||
.DisposeWith(dispose);
|
||||
this.WhenAny(x => x.ViewModel.CancelCommand)
|
||||
.BindToStrict(this, x => x.CancelButton.Command)
|
||||
.DisposeWith(dispose);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -174,6 +174,7 @@
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Extensions\DynamicDataExt.cs" />
|
||||
<Compile Include="View Models\Settings\AuthorFilesVM.cs" />
|
||||
<Compile Include="View Models\UserIntervention\ConfirmUpdateOfExistingInstallVM.cs" />
|
||||
<Compile Include="Views\Common\AttentionBorder.cs" />
|
||||
<Compile Include="Views\ModListTileView.xaml.cs">
|
||||
<DependentUpon>ModListTileView.xaml</DependentUpon>
|
||||
|
Loading…
Reference in New Issue
Block a user