Browse Source

Wait adorner over the decompiler view during decompile

Mirrors ILSpy/TextView/DecompilerTextView.xaml's wait-adorner shape: a
translucent overlay above the editor with a centred "Decompiling…"
title, an indeterminate ProgressBar, and a Cancel button. Visibility is
driven by a new IsDecompiling flag on DecompilerTabPageModel, set
around the Task.Run that runs the decompile. The Cancel button is
wired to a [RelayCommand] CancelDecompilation that triggers the
existing CancellationTokenSource.

Assisted-by: Claude:claude-opus-4-7:Claude Code
pull/3755/head
Siegfried Pammer 2 months ago
parent
commit
4e748aa78e
  1. 21
      ILSpy/TextView/DecompilerTabPageModel.cs
  2. 42
      ILSpy/TextView/DecompilerTextView.axaml

21
ILSpy/TextView/DecompilerTabPageModel.cs

@ -27,6 +27,7 @@ using AvaloniaEdit.Folding; @@ -27,6 +27,7 @@ using AvaloniaEdit.Folding;
using AvaloniaEdit.Highlighting;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using ICSharpCode.Decompiler;
@ -68,8 +69,21 @@ namespace ILSpy.TextView @@ -68,8 +69,21 @@ namespace ILSpy.TextView
[ObservableProperty]
private IReadOnlyList<NewFolding>? foldings;
/// <summary>
/// True while a decompilation is in flight. The view shows an indeterminate progress bar
/// in the header while this is set.
/// </summary>
[ObservableProperty]
private bool isDecompiling;
ILSpyTreeNode? currentNode;
[RelayCommand]
void CancelDecompilation()
{
activeCts?.Cancel();
}
public ILSpyTreeNode? CurrentNode {
get => currentNode;
set {
@ -96,12 +110,14 @@ namespace ILSpy.TextView @@ -96,12 +110,14 @@ namespace ILSpy.TextView
if (node == null || language == null)
{
Text = string.Empty;
IsDecompiling = false;
return;
}
Title = node.Text?.ToString() ?? "(unnamed)";
Text = "Decompiling…";
var nodeTitle = node.Text?.ToString() ?? "(unnamed)";
Title = nodeTitle;
SyntaxExtension = language.FileExtension;
IsDecompiling = true;
try
{
@ -136,6 +152,7 @@ namespace ILSpy.TextView @@ -136,6 +152,7 @@ namespace ILSpy.TextView
HighlightingModel = model;
Foldings = collectedFoldings;
Text = rendered;
IsDecompiling = false;
});
}
catch (OperationCanceledException)

42
ILSpy/TextView/DecompilerTextView.axaml

@ -5,13 +5,43 @@ @@ -5,13 +5,43 @@
xmlns:ae="using:AvaloniaEdit"
xmlns:textView="using:ILSpy.TextView"
mc:Ignorable="d" d:DesignWidth="600" d:DesignHeight="400"
Name="self"
x:Class="ILSpy.TextView.DecompilerTextView"
x:DataType="textView:DecompilerTabPageModel">
<ae:TextEditor Name="Editor"
IsReadOnly="True"
ShowLineNumbers="True"
Background="#FFFFE1"
FontFamily="Consolas, Menlo, Monospace"
FontSize="13" />
<!-- Wait-adorner pattern ported from ILSpy/TextView/DecompilerTextView.xaml: a translucent
overlay above the editor with a centred title + progress bar + cancel button while a
decompilation is in flight. -->
<Grid>
<ae:TextEditor Name="Editor"
IsReadOnly="True"
ShowLineNumbers="True"
Background="#FFFFE1"
FontFamily="Consolas, Menlo, Monospace"
FontSize="13" />
<Border Name="WaitAdorner"
Background="#80FFFFFF"
IsVisible="{Binding IsDecompiling}">
<Grid ColumnDefinitions="*,Auto,*">
<StackPanel Grid.Column="1"
VerticalAlignment="Center"
HorizontalAlignment="Center">
<TextBlock Name="ProgressTitle"
FontSize="18"
Margin="3"
TextWrapping="Wrap"
HorizontalAlignment="Center"
TextAlignment="Center"
Text="Decompiling…" />
<ProgressBar Name="ProgressBar"
IsIndeterminate="True"
Height="16" />
<Button HorizontalAlignment="Center"
Margin="3"
Content="Cancel"
Command="{Binding CancelDecompilationCommand}" />
</StackPanel>
</Grid>
</Border>
</Grid>
</UserControl>

Loading…
Cancel
Save