Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/wpf refactoring #3298

Merged
merged 2 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ILSpy/AssemblyTree/AssemblyTreeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,12 @@ private void LoadAssemblies(IEnumerable<string> fileNames, List<LoadedAssembly>?

private void TreeView_SelectionChanged()
{
if (SelectedItems.Length > 0)
if (SelectedItems.Length <= 0)
{
// To cancel any pending decompilation requests and show an empty tab
DecompileSelectedNodes();
}
else
{
var activeTabPage = DockWorkspace.Instance.ActiveTabPage;

Expand Down
34 changes: 19 additions & 15 deletions ILSpy/TextView/DecompilerTextView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace ICSharpCode.ILSpy.TextView
/// Manages the TextEditor showing the decompiled code.
/// Contains all the threading logic that makes the decompiler work in the background.
/// </summary>
public sealed partial class DecompilerTextView : UserControl, IDisposable, IHaveState, IProgress<DecompilationProgress>
public sealed partial class DecompilerTextView : UserControl, IHaveState, IProgress<DecompilationProgress>
{
readonly ReferenceElementGenerator referenceElementGenerator;
readonly UIElementGenerator uiElementGenerator;
Expand Down Expand Up @@ -125,7 +125,8 @@ public DecompilerTextView()
textEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService);
textEditor.TextArea.TextView.LineTransformers.Add(textMarkerService);
textEditor.ShowLineNumbers = true;
SettingsService.Instance.DisplaySettings.PropertyChanged += CurrentDisplaySettings_PropertyChanged;

MessageBus<SettingsChangedEventArgs>.Subscribers += Settings_Changed;

// SearchPanel
SearchPanel searchPanel = SearchPanel.Install(textEditor.TextArea);
Expand Down Expand Up @@ -179,15 +180,24 @@ void RemoveEditCommand(RoutedUICommand command)

#region Line margin

void CurrentDisplaySettings_PropertyChanged(object? sender, PropertyChangedEventArgs e)
private void Settings_Changed(object? sender, SettingsChangedEventArgs e)
{
if (e.PropertyName == nameof(DisplaySettings.ShowLineNumbers))
{
ShowLineMargin();
}
else if (e.PropertyName == nameof(DisplaySettings.HighlightCurrentLine))
Settings_PropertyChanged(sender, e);
}

private void Settings_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (sender is not DisplaySettings)
return;

switch (e.PropertyName)
{
SetHighlightCurrentLine();
case nameof(DisplaySettings.ShowLineNumbers):
ShowLineMargin();
break;
case nameof(DisplaySettings.HighlightCurrentLine):
SetHighlightCurrentLine();
break;
}
}

Expand Down Expand Up @@ -1286,12 +1296,6 @@ public static void RegisterHighlighting()
HighlightingManager.Instance.RegisterHighlighting("xml", new[] { ".xml", ".baml" }, "XML-Mode");
}


public void Dispose()
{
SettingsService.Instance.DisplaySettings.PropertyChanged -= CurrentDisplaySettings_PropertyChanged;
}

#region Unfold
public void UnfoldAndScroll(int lineNumber)
{
Expand Down
1 change: 0 additions & 1 deletion ILSpy/TextView/DecompilerTextView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
xmlns:editing="clr-namespace:ICSharpCode.AvalonEdit.Editing;assembly=ICSharpCode.AvalonEdit"
xmlns:folding="clr-namespace:ICSharpCode.AvalonEdit.Folding;assembly=ICSharpCode.AvalonEdit"
xmlns:styles="urn:TomsToolbox.Wpf.Styles"
xmlns:toms="urn:TomsToolbox"
xmlns:themes="clr-namespace:ICSharpCode.ILSpy.Themes">
<UserControl.Resources>
<SolidColorBrush x:Key="waitAdornerBackgoundBrush" Color="{DynamicResource {x:Static SystemColors.WindowColorKey}}" Opacity=".75" />
Expand Down
Loading