mirror of
https://github.com/ZuneDev/ZuneModdingHelper.git
synced 2026-07-27 13:12:21 -07:00
Use Metro dialog for install progress
This commit is contained in:
@@ -37,7 +37,7 @@ namespace ZuneModCore.Mods
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make a backup of the file
|
// Make a backup of the file
|
||||||
File.Copy(zsDllInfo.FullName, Path.Combine(StorageDirectory, "ZuneService.original.dll"));
|
File.Copy(zsDllInfo.FullName, Path.Combine(StorageDirectory, "ZuneService.original.dll"), true);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,22 +55,5 @@
|
|||||||
<Button x:Name="InstallModsButton" Content="Install" ToolTip="Install selected mods" Click="InstallModsButton_Click"
|
<Button x:Name="InstallModsButton" Content="Install" ToolTip="Install selected mods" Click="InstallModsButton_Click"
|
||||||
Grid.RowSpan="2" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="4"/>
|
Grid.RowSpan="2" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="4"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Border x:Name="ProgressBorder" Padding="8" Margin="8" Visibility="Collapsed" Grid.RowSpan="2">
|
|
||||||
<Grid>
|
|
||||||
<StackPanel Margin="50,8,50,8" VerticalAlignment="Center" HorizontalAlignment="Stretch">
|
|
||||||
<TextBlock x:Name="ProgressDesc" Text="Preparing..." FontSize="14" FontWeight="SemiBold"
|
|
||||||
HorizontalAlignment="Stretch" TextAlignment="Center"/>
|
|
||||||
<mah:MetroProgressBar x:Name="Progress" Value="0" HorizontalAlignment="Stretch"/>
|
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
<Button x:Name="ProgressCloseButton" Content="Close" Visibility="Collapsed" Click="ProgressCloseButton_Click"
|
|
||||||
HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
|
|
||||||
</Grid>
|
|
||||||
|
|
||||||
<Border.Effect>
|
|
||||||
<DropShadowEffect BlurRadius="8" ShadowDepth="2" Direction="-90" Opacity="0.25"/>
|
|
||||||
</Border.Effect>
|
|
||||||
</Border>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</mah:MetroWindow>
|
</mah:MetroWindow>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using ControlzEx.Theming;
|
using ControlzEx.Theming;
|
||||||
using MahApps.Metro.Controls;
|
using MahApps.Metro.Controls;
|
||||||
|
using MahApps.Metro.Controls.Dialogs;
|
||||||
using OwlCore.AbstractUI.ViewModels;
|
using OwlCore.AbstractUI.ViewModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -40,21 +41,21 @@ namespace ZuneModdingHelper
|
|||||||
|
|
||||||
private async void InstallModsButton_Click(object sender, RoutedEventArgs e)
|
private async void InstallModsButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ProgressCloseButton.Visibility = Visibility.Collapsed;
|
var dialog = await this.ShowProgressAsync("Getting ready...", "Preparing to apply mods");
|
||||||
ProgressBorder.Visibility = Visibility.Visible;
|
|
||||||
ModList.IsEnabled = false;
|
ModList.IsEnabled = false;
|
||||||
InstallModsButton.IsEnabled = false;
|
InstallModsButton.IsEnabled = false;
|
||||||
Mod.ZuneInstallDir = ZuneInstallDirBox.Text;
|
Mod.ZuneInstallDir = ZuneInstallDirBox.Text;
|
||||||
var selectedMods = ModList.SelectedItems.Cast<Mod>();
|
var selectedMods = ModList.SelectedItems.Cast<Mod>();
|
||||||
|
|
||||||
double progTotal = selectedMods.Count() * 2;
|
dialog.Maximum = selectedMods.Count() * 2;
|
||||||
double progCompleted = 0;
|
int numCompleted = 0;
|
||||||
|
|
||||||
|
dialog.SetTitle("Installing mods...");
|
||||||
foreach (Mod mod in selectedMods)
|
foreach (Mod mod in selectedMods)
|
||||||
{
|
{
|
||||||
ProgressDesc.Text = $"Setting up '{mod.Title}'...";
|
dialog.SetMessage($"Setting up '{mod.Title}'");
|
||||||
await mod.Init();
|
await mod.Init();
|
||||||
Progress.Value = ++progCompleted / progTotal * 100;
|
dialog.SetProgress(++numCompleted);
|
||||||
|
|
||||||
// TODO: Implement AbstractUI display for options
|
// TODO: Implement AbstractUI display for options
|
||||||
//if (mod.OptionsUI != null)
|
//if (mod.OptionsUI != null)
|
||||||
@@ -64,29 +65,23 @@ namespace ZuneModdingHelper
|
|||||||
// optionsDialog.ShowDialog();
|
// optionsDialog.ShowDialog();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
ProgressDesc.Text = $"Applying '{mod.Title}'...";
|
dialog.SetMessage($"Applying '{mod.Title}'");
|
||||||
string applyResult = await mod.Apply();
|
string applyResult = await mod.Apply();
|
||||||
if (applyResult != null)
|
if (applyResult != null)
|
||||||
{
|
{
|
||||||
ProgressDesc.Text = $"Failed to apply '{mod.Title}':\r\n{applyResult}";
|
dialog.SetMessage($"Failed to apply '{mod.Title}':\r\n{applyResult}");
|
||||||
await Task.Delay(15000);
|
await Task.Delay(15000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Progress.Value = ++progCompleted / progTotal * 100;
|
dialog.SetProgress(++numCompleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgressDesc.Text = "Completed";
|
dialog.SetTitle("Completed");
|
||||||
ProgressCloseButton.Visibility = Visibility.Visible;
|
dialog.SetMessage("Finished installing selected mods");
|
||||||
|
await Task.Delay(5000);
|
||||||
|
dialog.CloseAsync();
|
||||||
ModList.IsEnabled = true;
|
ModList.IsEnabled = true;
|
||||||
InstallModsButton.IsEnabled = true;
|
InstallModsButton.IsEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProgressCloseButton_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
ProgressCloseButton.Visibility = Visibility.Collapsed;
|
|
||||||
ProgressBorder.Visibility = Visibility.Collapsed;
|
|
||||||
ProgressDesc.Text = "Preparing...";
|
|
||||||
Progress.Value = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user