-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor AnalyzerTreeView into View/ViewModel
- Loading branch information
tom-englert
committed
Aug 19, 2024
1 parent
9fb3400
commit d4df855
Showing
11 changed files
with
250 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System.Collections.Generic; | ||
using System.Collections.Specialized; | ||
using System.Linq; | ||
|
||
using ICSharpCode.ILSpy.Util; | ||
using ICSharpCode.ILSpyX; | ||
using ICSharpCode.ILSpyX.TreeView; | ||
|
||
namespace ICSharpCode.ILSpy.Analyzers; | ||
|
||
public sealed class AnalyzerRootNode : AnalyzerTreeNode | ||
{ | ||
public AnalyzerRootNode() | ||
{ | ||
MessageBus<CurrentAssemblyListChangedEventArgs>.Subscribers += (sender, e) => CurrentAssemblyList_Changed(sender, e); | ||
} | ||
|
||
void CurrentAssemblyList_Changed(object sender, NotifyCollectionChangedEventArgs e) | ||
{ | ||
if (e.Action == NotifyCollectionChangedAction.Reset) | ||
{ | ||
this.Children.Clear(); | ||
} | ||
else | ||
{ | ||
var removedAssemblies = e.OldItems?.Cast<LoadedAssembly>().ToArray() ?? []; | ||
var addedAssemblies = e.NewItems?.Cast<LoadedAssembly>().ToArray() ?? []; | ||
|
||
HandleAssemblyListChanged(removedAssemblies, addedAssemblies); | ||
} | ||
} | ||
|
||
public override bool HandleAssemblyListChanged(ICollection<LoadedAssembly> removedAssemblies, ICollection<LoadedAssembly> addedAssemblies) | ||
{ | ||
this.Children.RemoveAll( | ||
delegate (SharpTreeNode n) { | ||
AnalyzerTreeNode an = n as AnalyzerTreeNode; | ||
return an == null || !an.HandleAssemblyListChanged(removedAssemblies, addedAssemblies); | ||
}); | ||
return true; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<treeView:SharpTreeView | ||
x:Class="ICSharpCode.ILSpy.Analyzers.AnalyzerTreeView" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:toms="urn:TomsToolbox" | ||
xmlns:treeView="clr-namespace:ICSharpCode.ILSpy.Controls.TreeView" | ||
xmlns:analyzers="clr-namespace:ICSharpCode.ILSpy.Analyzers" | ||
mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" | ||
d:DataContext="{d:DesignInstance analyzers:AnalyzerTreeViewModel}" | ||
ShowRoot="False" | ||
BorderThickness="0" | ||
Root="{Binding Root}" | ||
toms:MultiSelectorExtensions.SelectionBinding="{Binding SelectedItems}" | ||
SelectedItem="{Binding SelectedItem, Mode=TwoWay}" | ||
SelectionChanged="AnalyzerTreeView_OnSelectionChanged"> | ||
|
||
<UIElement.InputBindings> | ||
<KeyBinding Key="R" Modifiers="Control" Command="{Binding AnalyzeCommand}" /> | ||
</UIElement.InputBindings> | ||
|
||
</treeView:SharpTreeView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.