InstallationView Progress Bar tweaks

Now point to actual properties, but mostly disabled for now until progress reporting can be improved
This commit is contained in:
Justin Swanson 2019-10-31 19:21:24 -05:00
parent fbbb609fe9
commit b37d5312c4
2 changed files with 77 additions and 30 deletions

View File

@ -53,15 +53,27 @@ namespace Wabbajack
private readonly ObservableAsPropertyHelper<string> _HTMLReport;
public string HTMLReport => _HTMLReport.Value;
/// <summary>
/// Tracks whether an install is currently in progress
/// </summary>
private bool _Installing;
public bool Installing { get => _Installing; set => this.RaiseAndSetIfChanged(ref _Installing, value); }
/// <summary>
/// Tracks whether to show the installing pane
/// </summary>
private bool _InstallingMode;
public bool InstallingMode { get => _InstallingMode; set => this.RaiseAndSetIfChanged(ref _InstallingMode, value); }
private string _Location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
public string Location { get => _Location; set => this.RaiseAndSetIfChanged(ref _Location, value); }
private string _DownloadLocation;
public string DownloadLocation { get => _DownloadLocation; set => this.RaiseAndSetIfChanged(ref _DownloadLocation, value); }
private readonly ObservableAsPropertyHelper<float> _ProgressPercent;
public float ProgressPercent => _ProgressPercent.Value;
private readonly ObservableAsPropertyHelper<BitmapImage> _Image;
public BitmapImage Image => _Image.Value;
@ -118,6 +130,15 @@ namespace Wabbajack
this._ModListName = this.WhenAny(x => x.ModList)
.Select(modList => modList?.Name)
.ToProperty(this, nameof(this.ModListName));
this._ProgressPercent = Observable.CombineLatest(
this.WhenAny(x => x.Installing),
this.WhenAny(x => x.InstallingMode),
resultSelector: (installing, mode) => !installing && mode)
.Select(show => show ? 1f : 0f)
// Disable for now, until more reliable
//this.WhenAny(x => x.MWVM.QueueProgress)
// .Select(i => i / 100f)
.ToProperty(this, nameof(this.ProgressPercent));
this.Slideshow = new SlideShow(this);
@ -242,6 +263,7 @@ namespace Wabbajack
private void ExecuteBegin()
{
this.Installing = true;
this.InstallingMode = true;
var installer = new Installer(this.ModListPath, this.ModList, Location)
{
DownloadFolder = DownloadLocation
@ -259,6 +281,11 @@ namespace Wabbajack
Utils.Log(ex.ToString());
Utils.Log($"{ex.Message} - Can't continue");
}
finally
{
this.Installing = false;
}
})
{
Priority = ThreadPriority.BelowNormal

View File

@ -142,7 +142,7 @@
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsMouseOver, ElementName=Slideshow}" Value="True" />
<Condition Binding="{Binding Installing}" Value="True" />
<Condition Binding="{Binding InstallingMode}" Value="True" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard>
@ -257,12 +257,13 @@
Grid.Row="1"
Grid.RowSpan="2"
VerticalAlignment="Top"
Maximum="100"
Value="46"
Maximum="1"
Value="{Binding ProgressPercent, Mode=OneWay}"
Foreground="{StaticResource PrimaryVariantBrush}"
Background="Transparent"
BorderBrush="Transparent"
Height="16" Margin="-4" >
Height="16"
Margin="-4" >
<mahapps:MetroProgressBar.Effect>
<BlurEffect Radius="25" />
</mahapps:MetroProgressBar.Effect>
@ -271,12 +272,13 @@
Grid.Row="1"
Grid.RowSpan="2"
VerticalAlignment="Top"
Maximum="100"
Value="46"
Maximum="1"
Value="{Binding ProgressPercent, Mode=OneWay}"
Foreground="{StaticResource PrimaryBrush}"
Background="Transparent"
BorderBrush="Transparent"
Height="6" Margin="-4" >
Height="6"
Margin="-4" >
<mahapps:MetroProgressBar.Effect>
<BlurEffect Radius="20" />
</mahapps:MetroProgressBar.Effect>
@ -293,14 +295,15 @@
Background="{StaticResource WindowBackgroundBrush}"
BorderThickness="0"
Foreground="Transparent"
Maximum="100"
Value="46" />
Maximum="1"
Value="{Binding ProgressPercent, Mode=OneWay}" />
<mahapps:MetroProgressBar Grid.Column="0" Grid.ColumnSpan="4"
Background="Transparent"
BorderThickness="0"
Foreground="{StaticResource PrimaryVariantBrush}" Opacity="0.46"
Maximum="100"
Value="46" />
Foreground="{StaticResource PrimaryVariantBrush}"
Opacity="{Binding ProgressPercent, Mode=OneWay}"
Maximum="1"
Value="{Binding ProgressPercent, Mode=OneWay}" />
<TextBlock Grid.Column="0"
VerticalAlignment="Bottom"
Margin="10,0,0,8"
@ -313,10 +316,26 @@
<Setter Property="Text" Value="Configuring" />
<Setter Property="FontSize" Value="15" />
<Style.Triggers>
<DataTrigger Binding="{Binding Installing}" >
<Setter Property="Text" Value="Installing" />
<Setter Property="FontSize" Value="14" />
</DataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding InstallingMode}" Value="True" />
<Condition Binding="{Binding Installing}" Value="True" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter Property="Text" Value="Installing" />
<Setter Property="FontSize" Value="14" />
</MultiDataTrigger.Setters>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding InstallingMode}" Value="True" />
<Condition Binding="{Binding Installing}" Value="False" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter Property="Text" Value="Installed" />
<Setter Property="FontSize" Value="14" />
</MultiDataTrigger.Setters>
</MultiDataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
@ -327,11 +346,12 @@
FontSize="25"
FontWeight="Black"
FontFamily="Lucida Sans" />
<Button Grid.Column="2"
<!-- Readd when Pause/Stop implementations added -->
<!--<Button Grid.Column="2"
ToolTip="Pause Installation"
Margin="0,0,0,5"
Width="50"
Visibility="{Binding Installing, Converter={StaticResource bool2VisibilityConverter}}">
Visibility="{Binding InstallingMode, Converter={StaticResource bool2VisibilityConverter}}">
<icon:PackIconMaterial
Kind="Pause" />
</Button>
@ -339,19 +359,19 @@
ToolTip="Stop Installation"
Margin="0,0,0,5"
Width="50"
Visibility="{Binding Installing, Converter={StaticResource bool2VisibilityConverter}}" >
Visibility="{Binding InstallingMode, Converter={StaticResource bool2VisibilityConverter}}" >
<icon:PackIconFontAwesome
Width="25"
Height="25"
Kind="TimesCircleSolid" />
</Button>
</Button>-->
</Grid>
<mahapps:MetroProgressBar x:Name="BottomProgressBar"
Grid.Row="1"
Grid.RowSpan="2"
VerticalAlignment="Top"
Maximum="100"
Value="46"
Maximum="1"
Value="{Binding ProgressPercent, Mode=OneWay}"
Foreground="{StaticResource PrimaryBrush}"
Background="Transparent"
BorderBrush="Transparent"
@ -360,8 +380,8 @@
Grid.Row="1"
Grid.RowSpan="2"
VerticalAlignment="Top"
Maximum="100"
Value="46"
Maximum="1"
Value="{Binding ProgressPercent, Mode=OneWay}"
Background="Transparent"
BorderBrush="Transparent"
Height="5" >
@ -376,7 +396,7 @@
</mahapps:MetroProgressBar>
<!-- Bottom Area -->
<Grid Grid.Row="3"
Visibility="{Binding Installing, Converter={StaticResource bool2VisibilityConverter}, ConverterParameter=False}" >
Visibility="{Binding InstallingMode, Converter={StaticResource bool2VisibilityConverter}, ConverterParameter=False}" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="4" />
@ -406,7 +426,7 @@
Background="{StaticResource WindowBackgroundBrush}" >
<ScrollViewer VerticalScrollBarVisibility="Auto" Background="Transparent"
Margin="5"
Visibility="{Binding Installing, Converter={StaticResource bool2VisibilityConverter}, ConverterParameter=False}">
Visibility="{Binding InstallingMode, Converter={StaticResource bool2VisibilityConverter}, ConverterParameter=False}">
<Grid Margin="8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
@ -476,7 +496,7 @@
Fill="{StaticResource DarkBackgroundBrush}"/>
</Grid>
<Grid Grid.Row="3"
Visibility="{Binding Installing, Converter={StaticResource bool2VisibilityConverter}}" >
Visibility="{Binding InstallingMode, Converter={StaticResource bool2VisibilityConverter}}" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="4" />
@ -509,7 +529,7 @@
<Style TargetType="ProgressBar">
<Setter Property="Visibility" Value="Visible" />
<Style.Triggers>
<DataTrigger Binding="{Binding Progress}" Value="0">
<DataTrigger Binding="{Binding Progress, Mode=OneTime}" Value="0">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
@ -517,9 +537,9 @@
</ProgressBar.Style>
</ProgressBar>
<TextBlock Grid.Column="1" Text=" CPU " />
<TextBlock Grid.Column="2" Text="{Binding ID}" />
<TextBlock Grid.Column="2" Text="{Binding ID, Mode=OneTime}" />
<TextBlock Grid.Column="3" Text=" - " />
<TextBlock Grid.Column="4" Text="{Binding Msg}" />
<TextBlock Grid.Column="4" Text="{Binding Msg, Mode=OneTime}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>