diff --git a/ILSpy/TextView/DecompilerTabPageModel.cs b/ILSpy/TextView/DecompilerTabPageModel.cs index c992cdf72..f321ac469 100644 --- a/ILSpy/TextView/DecompilerTabPageModel.cs +++ b/ILSpy/TextView/DecompilerTabPageModel.cs @@ -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 [ObservableProperty] private IReadOnlyList? foldings; + /// + /// True while a decompilation is in flight. The view shows an indeterminate progress bar + /// in the header while this is set. + /// + [ObservableProperty] + private bool isDecompiling; + ILSpyTreeNode? currentNode; + [RelayCommand] + void CancelDecompilation() + { + activeCts?.Cancel(); + } + public ILSpyTreeNode? CurrentNode { get => currentNode; set { @@ -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 HighlightingModel = model; Foldings = collectedFoldings; Text = rendered; + IsDecompiling = false; }); } catch (OperationCanceledException) diff --git a/ILSpy/TextView/DecompilerTextView.axaml b/ILSpy/TextView/DecompilerTextView.axaml index 0628f4624..e58e40674 100644 --- a/ILSpy/TextView/DecompilerTextView.axaml +++ b/ILSpy/TextView/DecompilerTextView.axaml @@ -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"> - + + + + + + + + +