GUI: Show progress messages in busy indicator

This commit is contained in:
Katy Coe
2020-02-09 04:11:16 +01:00
parent 4129785e17
commit 755a8ec88c
5 changed files with 40 additions and 12 deletions

View File

@@ -21,6 +21,11 @@ namespace Il2CppInspectorGUI
public Exception LastException { get; private set; }
// Event to indicate current work status
public event EventHandler<string> OnStatusUpdate;
private void StatusUpdate(object sender, string status) => OnStatusUpdate?.Invoke(sender, status);
// Attempt to load an IL2CPP metadata file
public Task<bool> LoadMetadataAsync(string metadataFile) =>
Task.Run(() => {
@@ -38,7 +43,7 @@ namespace Il2CppInspectorGUI
Task.Run(() => {
try {
// This may throw other exceptions from the individual loaders as well
IFileFormatReader stream = FileFormatReader.Load(binaryFile);
IFileFormatReader stream = FileFormatReader.Load(binaryFile, StatusUpdate);
if (stream == null) {
throw new InvalidOperationException("Could not determine the binary file format");
}
@@ -49,6 +54,8 @@ namespace Il2CppInspectorGUI
// Multi-image binaries may contain more than one Il2Cpp image
Il2CppModels.Clear();
foreach (var image in stream.Images) {
OnStatusUpdate?.Invoke(this, "Analyzing IL2CPP data");
// Architecture-agnostic load attempt
try {
// If we can't load the IL2CPP data here, it's probably packed or obfuscated; ignore it
@@ -56,6 +63,7 @@ namespace Il2CppInspectorGUI
var inspector = new Inspector(binary, metadata);
// Build type model
OnStatusUpdate?.Invoke(this, "Building type model");
Il2CppModels.Add(new Il2CppModel(inspector));
}
}

View File

@@ -152,9 +152,9 @@
<Button Name="btnBack" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Bottom" Style="{StaticResource LightBoxButton}" FontSize="18" Width="120" Click="BtnBack_OnClick" Visibility="Hidden">&lt;&lt; Back</Button>
<!-- Busy indicator -->
<Border Name="areaBusyIndicator" BorderThickness="1" CornerRadius="2" BorderBrush="Gray" HorizontalAlignment="Center" VerticalAlignment="Center" Background="#F8F8F8" SnapsToDevicePixels="True" Visibility="Hidden">
<Border Name="areaBusyIndicator" Width="400" BorderThickness="1" CornerRadius="2" BorderBrush="Gray" HorizontalAlignment="Center" VerticalAlignment="Center" Background="White" SnapsToDevicePixels="True" Visibility="Hidden">
<StackPanel Margin="60,40,60,40">
<TextBlock Name="txtBusyStatus" Foreground="{StaticResource WindowsBlue}" FontSize="24">Getting things ready...</TextBlock>
<TextBlock Name="txtBusyStatus" Foreground="{StaticResource WindowsBlue}" FontSize="24" HorizontalAlignment="Center">Getting things ready...</TextBlock>
<Image gif:AnimationBehavior.SourceUri="Resources/pizza.gif" Width="100" Margin="0,20,0,0" RenderOptions.BitmapScalingMode="Fant" />
</StackPanel>
</Border>

View File

@@ -26,8 +26,13 @@ namespace Il2CppInspectorGUI
{
public MainWindow() {
InitializeComponent();
// Subscribe to status update events
((App) Application.Current).OnStatusUpdate += OnStatusUpdate;
}
private void OnStatusUpdate(object sender, string e) => txtBusyStatus.Dispatcher.Invoke(() => txtBusyStatus.Text = e + "...");
/// <summary>
/// Select global metadata file
/// </summary>