Browse Source

- Remove static state from DisplaySettingsPanel

- Remove static state from DecompilerSettingsPanel
- Remove shortcut ctors from DecompilationOptions
pull/2785/head
Siegfried Pammer 3 years ago
parent
commit
92e9b28e4d
  1. 5
      ILSpy.ReadyToRun/ReadyToRunLanguage.cs
  2. 9
      ILSpy/Commands/DecompileAllCommand.cs
  3. 5
      ILSpy/Commands/DisassembleAllCommand.cs
  4. 2
      ILSpy/Commands/GeneratePdbContextMenuEntry.cs
  5. 4
      ILSpy/Commands/SaveCodeContextMenuEntry.cs
  6. 12
      ILSpy/DecompilationOptions.cs
  7. 3
      ILSpy/ExtensionMethods.cs
  8. 7
      ILSpy/Languages/CSharpILMixedLanguage.cs
  9. 6
      ILSpy/Languages/CSharpLanguage.cs
  10. 9
      ILSpy/Languages/ILLanguage.cs
  11. 16
      ILSpy/MainWindow.xaml.cs
  12. 2
      ILSpy/Metadata/DebugMetadataTablesTreeNode.cs
  13. 2
      ILSpy/Metadata/MetadataTablesTreeNode.cs
  14. 14
      ILSpy/Options/DecompilerSettingsPanel.xaml.cs
  15. 15
      ILSpy/Options/DisplaySettingsPanel.xaml.cs
  16. 6
      ILSpy/Search/SearchPane.cs
  17. 9
      ILSpy/SolutionWriter.cs
  18. 22
      ILSpy/TextView/DecompilerTextView.cs
  19. 4
      ILSpy/TextView/DocumentationUIBuilder.cs
  20. 8
      ILSpy/Themes/WindowStyleManagerBehavior.cs
  21. 4
      ILSpy/TreeNodes/AssemblyTreeNode.cs
  22. 4
      ILSpy/TreeNodes/ILSpyTreeNode.cs
  23. 2
      ILSpy/Views/DebugSteps.xaml.cs

5
ILSpy.ReadyToRun/ReadyToRunLanguage.cs

@ -157,8 +157,9 @@ namespace ICSharpCode.ILSpy.ReadyToRun @@ -157,8 +157,9 @@ namespace ICSharpCode.ILSpy.ReadyToRun
.GroupBy(m => m.MethodHandle)
.ToDictionary(g => g.Key, g => g.ToArray());
}
bool showMetadataTokens = ILSpy.Options.DisplaySettingsPanel.CurrentDisplaySettings.ShowMetadataTokens;
bool showMetadataTokensInBase10 = ILSpy.Options.DisplaySettingsPanel.CurrentDisplaySettings.ShowMetadataTokensInBase10;
var displaySettings = MainWindow.Instance.CurrentDisplaySettings;
bool showMetadataTokens = displaySettings.ShowMetadataTokens;
bool showMetadataTokensInBase10 = displaySettings.ShowMetadataTokensInBase10;
#if STRESS
ITextOutput originalOutput = output;
output = new DummyOutput();

9
ILSpy/Commands/DecompileAllCommand.cs

@ -29,6 +29,8 @@ using ICSharpCode.ILSpy.Properties; @@ -29,6 +29,8 @@ using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpyX;
using TomsToolbox.Essentials;
namespace ICSharpCode.ILSpy
{
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.DEBUGDecompile), MenuCategory = nameof(Resources.Open), MenuOrder = 2.5)]
@ -55,7 +57,10 @@ namespace ICSharpCode.ILSpy @@ -55,7 +57,10 @@ namespace ICSharpCode.ILSpy
{
try
{
new CSharpLanguage().DecompileAssembly(asm, new Decompiler.PlainTextOutput(writer), new DecompilationOptions() { FullDecompilation = true, CancellationToken = ct });
var options = MainWindow.Instance.CreateDecompilationOptions();
options.CancellationToken = ct;
options.FullDecompilation = true;
new CSharpLanguage().DecompileAssembly(asm, new PlainTextOutput(writer), options);
}
catch (Exception ex)
{
@ -88,7 +93,7 @@ namespace ICSharpCode.ILSpy @@ -88,7 +93,7 @@ namespace ICSharpCode.ILSpy
const int numRuns = 100;
var language = MainWindow.Instance.CurrentLanguage;
var nodes = MainWindow.Instance.SelectedNodes.ToArray();
var options = new DecompilationOptions();
var options = MainWindow.Instance.CreateDecompilationOptions();
Docking.DockWorkspace.Instance.RunWithCancellation(ct => Task<AvalonEditTextOutput>.Factory.StartNew(() => {
options.CancellationToken = ct;
Stopwatch w = Stopwatch.StartNew();

5
ILSpy/Commands/DisassembleAllCommand.cs

@ -53,7 +53,10 @@ namespace ICSharpCode.ILSpy @@ -53,7 +53,10 @@ namespace ICSharpCode.ILSpy
{
try
{
new ILLanguage().DecompileAssembly(asm, new Decompiler.PlainTextOutput(writer), new DecompilationOptions { FullDecompilation = true, CancellationToken = ct });
var options = MainWindow.Instance.CreateDecompilationOptions();
options.FullDecompilation = true;
options.CancellationToken = ct;
new ILLanguage().DecompileAssembly(asm, new Decompiler.PlainTextOutput(writer), options);
}
catch (Exception ex)
{

2
ILSpy/Commands/GeneratePdbContextMenuEntry.cs

@ -70,7 +70,7 @@ namespace ICSharpCode.ILSpy @@ -70,7 +70,7 @@ namespace ICSharpCode.ILSpy
dlg.InitialDirectory = Path.GetDirectoryName(assembly.FileName);
if (dlg.ShowDialog() != true)
return;
DecompilationOptions options = new DecompilationOptions();
DecompilationOptions options = MainWindow.Instance.CreateDecompilationOptions();
string fileName = dlg.FileName;
Docking.DockWorkspace.Instance.RunWithCancellation(ct => Task<AvalonEditTextOutput>.Factory.StartNew(() => {
AvalonEditTextOutput output = new AvalonEditTextOutput();

4
ILSpy/Commands/SaveCodeContextMenuEntry.cs

@ -22,6 +22,7 @@ using System.IO; @@ -22,6 +22,7 @@ using System.IO;
using System.Linq;
using System.Windows;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.ILSpy.Options;
using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpy.TreeNodes;
@ -83,7 +84,8 @@ namespace ICSharpCode.ILSpy.TextView @@ -83,7 +84,8 @@ namespace ICSharpCode.ILSpy.TextView
// Fallback: if nobody was able to handle the request, use default behavior.
// try to save all nodes to disk.
var options = new DecompilationOptions() { FullDecompilation = true };
var options = MainWindow.Instance.CreateDecompilationOptions();
options.FullDecompilation = true;
textView.SaveToDisk(currentLanguage, selectedNodes.OfType<ILSpyTreeNode>(), options);
});
}

12
ILSpy/DecompilationOptions.cs

@ -74,17 +74,7 @@ namespace ICSharpCode.ILSpy @@ -74,17 +74,7 @@ namespace ICSharpCode.ILSpy
internal int StepLimit = int.MaxValue;
internal bool IsDebug = false;
public DecompilationOptions()
: this(MainWindow.Instance.CurrentLanguageVersion, DecompilerSettingsPanel.CurrentDecompilerSettings, DisplaySettingsPanel.CurrentDisplaySettings)
{
}
public DecompilationOptions(LanguageVersion version)
: this(version, DecompilerSettingsPanel.CurrentDecompilerSettings, DisplaySettingsPanel.CurrentDisplaySettings)
{
}
public DecompilationOptions(LanguageVersion version, Decompiler.DecompilerSettings settings, Options.DisplaySettings displaySettings)
public DecompilationOptions(LanguageVersion version, Decompiler.DecompilerSettings settings, DisplaySettings displaySettings)
{
if (!Enum.TryParse(version?.Version, out Decompiler.CSharp.LanguageVersion languageVersion))
languageVersion = Decompiler.CSharp.LanguageVersion.Latest;

3
ILSpy/ExtensionMethods.cs

@ -78,7 +78,8 @@ namespace ICSharpCode.ILSpy @@ -78,7 +78,8 @@ namespace ICSharpCode.ILSpy
public static ICompilation? GetTypeSystemWithCurrentOptionsOrNull(this PEFile file)
{
return LoadedAssemblyExtensions.GetLoadedAssembly(file).GetTypeSystemOrNull(DecompilerTypeSystem.GetOptions(new DecompilationOptions().DecompilerSettings));
return LoadedAssemblyExtensions.GetLoadedAssembly(file)
.GetTypeSystemOrNull(DecompilerTypeSystem.GetOptions(MainWindow.Instance.CurrentDecompilerSettings));
}
#region DPI independence

7
ILSpy/Languages/CSharpILMixedLanguage.cs

@ -50,15 +50,16 @@ namespace ICSharpCode.ILSpy @@ -50,15 +50,16 @@ namespace ICSharpCode.ILSpy
protected override ReflectionDisassembler CreateDisassembler(ITextOutput output, DecompilationOptions options)
{
var displaySettings = MainWindow.Instance.CurrentDisplaySettings;
return new ReflectionDisassembler(output,
new MixedMethodBodyDisassembler(output, options) {
DetectControlStructure = detectControlStructure,
ShowSequencePoints = options.DecompilerSettings.ShowDebugInfo
},
options.CancellationToken) {
ShowMetadataTokens = Options.DisplaySettingsPanel.CurrentDisplaySettings.ShowMetadataTokens,
ShowMetadataTokensInBase10 = Options.DisplaySettingsPanel.CurrentDisplaySettings.ShowMetadataTokensInBase10,
ShowRawRVAOffsetAndBytes = Options.DisplaySettingsPanel.CurrentDisplaySettings.ShowRawOffsetsAndBytesBeforeInstruction,
ShowMetadataTokens = displaySettings.ShowMetadataTokens,
ShowMetadataTokensInBase10 = displaySettings.ShowMetadataTokensInBase10,
ShowRawRVAOffsetAndBytes = displaySettings.ShowRawOffsetsAndBytesBeforeInstruction,
ExpandMemberDefinitions = options.DecompilerSettings.ExpandMemberDefinitions
};
}

6
ILSpy/Languages/CSharpLanguage.cs

@ -533,7 +533,7 @@ namespace ICSharpCode.ILSpy @@ -533,7 +533,7 @@ namespace ICSharpCode.ILSpy
CSharpAmbience ambience = new CSharpAmbience();
// Do not forget to update CSharpAmbienceTests.ILSpyMainTreeViewTypeFlags, if this ever changes.
ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList | ConversionFlags.PlaceReturnTypeAfterParameterList;
if (new DecompilationOptions().DecompilerSettings.LiftNullables)
if (MainWindow.Instance.CurrentDecompilerSettings.LiftNullables)
{
ambience.ConversionFlags |= ConversionFlags.UseNullableSpecifierForValueTypes;
}
@ -721,7 +721,7 @@ namespace ICSharpCode.ILSpy @@ -721,7 +721,7 @@ namespace ICSharpCode.ILSpy
public override bool ShowMember(IEntity member)
{
PEFile assembly = member.ParentModule.PEFile;
return showAllMembers || !CSharpDecompiler.MemberIsHidden(assembly, member.MetadataToken, new DecompilationOptions().DecompilerSettings);
return showAllMembers || !CSharpDecompiler.MemberIsHidden(assembly, member.MetadataToken, MainWindow.Instance.CurrentDecompilerSettings);
}
public override RichText GetRichTextTooltip(IEntity entity)
@ -730,7 +730,7 @@ namespace ICSharpCode.ILSpy @@ -730,7 +730,7 @@ namespace ICSharpCode.ILSpy
var output = new StringWriter();
var decoratedWriter = new TextWriterTokenWriter(output);
var writer = new CSharpHighlightingTokenWriter(TokenWriter.InsertRequiredSpaces(decoratedWriter), locatable: decoratedWriter);
var settings = new DecompilationOptions().DecompilerSettings;
var settings = MainWindow.Instance.CurrentDecompilerSettings;
if (!settings.LiftNullables)
{
flags &= ~ConversionFlags.UseNullableSpecifierForValueTypes;

9
ILSpy/Languages/ILLanguage.cs

@ -56,13 +56,14 @@ namespace ICSharpCode.ILSpy @@ -56,13 +56,14 @@ namespace ICSharpCode.ILSpy
protected virtual ReflectionDisassembler CreateDisassembler(ITextOutput output, DecompilationOptions options)
{
var displaySettings = MainWindow.Instance.CurrentDisplaySettings;
output.IndentationString = options.DecompilerSettings.CSharpFormattingOptions.IndentationString;
return new ReflectionDisassembler(output, options.CancellationToken) {
DetectControlStructure = detectControlStructure,
ShowSequencePoints = options.DecompilerSettings.ShowDebugInfo,
ShowMetadataTokens = Options.DisplaySettingsPanel.CurrentDisplaySettings.ShowMetadataTokens,
ShowMetadataTokensInBase10 = Options.DisplaySettingsPanel.CurrentDisplaySettings.ShowMetadataTokensInBase10,
ShowRawRVAOffsetAndBytes = Options.DisplaySettingsPanel.CurrentDisplaySettings.ShowRawOffsetsAndBytesBeforeInstruction,
ShowMetadataTokens = displaySettings.ShowMetadataTokens,
ShowMetadataTokensInBase10 = displaySettings.ShowMetadataTokensInBase10,
ShowRawRVAOffsetAndBytes = displaySettings.ShowRawOffsetsAndBytesBeforeInstruction,
ExpandMemberDefinitions = options.DecompilerSettings.ExpandMemberDefinitions
};
}
@ -194,7 +195,7 @@ namespace ICSharpCode.ILSpy @@ -194,7 +195,7 @@ namespace ICSharpCode.ILSpy
public override RichText GetRichTextTooltip(IEntity entity)
{
var output = new AvalonEditTextOutput() { IgnoreNewLineAndIndent = true };
var disasm = CreateDisassembler(output, new DecompilationOptions());
var disasm = CreateDisassembler(output, MainWindow.Instance.CreateDecompilationOptions());
PEFile module = entity.ParentModule?.PEFile;
if (module == null)
{

16
ILSpy/MainWindow.xaml.cs

@ -45,6 +45,7 @@ using ICSharpCode.Decompiler.TypeSystem.Implementation; @@ -45,6 +45,7 @@ using ICSharpCode.Decompiler.TypeSystem.Implementation;
using ICSharpCode.ILSpy.Analyzers;
using ICSharpCode.ILSpy.Commands;
using ICSharpCode.ILSpy.Docking;
using ICSharpCode.ILSpy.Options;
using ICSharpCode.ILSpy.Search;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.Themes;
@ -100,15 +101,23 @@ namespace ICSharpCode.ILSpy @@ -100,15 +101,23 @@ namespace ICSharpCode.ILSpy
}
}
public DecompilerSettings CurrentDecompilerSettings { get; internal set; }
public DisplaySettings CurrentDisplaySettings { get; internal set; }
public DecompilationOptions CreateDecompilationOptions() => new DecompilationOptions(CurrentLanguageVersion, CurrentDecompilerSettings, CurrentDisplaySettings);
public MainWindow()
{
instance = this;
var spySettings = ILSpySettings.Load();
this.spySettingsForMainWindow_Loaded = spySettings;
this.sessionSettings = new SessionSettings(spySettings);
this.CurrentDecompilerSettings = DecompilerSettingsPanel.LoadDecompilerSettings(spySettings);
this.CurrentDisplaySettings = DisplaySettingsPanel.LoadDisplaySettings(spySettings);
this.AssemblyListManager = new AssemblyListManager(spySettings) {
ApplyWinRTProjections = Options.DecompilerSettingsPanel.CurrentDecompilerSettings.ApplyWindowsRuntimeProjections,
UseDebugSymbols = Options.DecompilerSettingsPanel.CurrentDecompilerSettings.UseDebugSymbols
ApplyWinRTProjections = CurrentDecompilerSettings.ApplyWindowsRuntimeProjections,
UseDebugSymbols = CurrentDecompilerSettings.UseDebugSymbols
};
// Make sure Images are initialized on the UI thread.
@ -1494,7 +1503,8 @@ namespace ICSharpCode.ILSpy @@ -1494,7 +1503,8 @@ namespace ICSharpCode.ILSpy
NavigateTo(new RequestNavigateEventArgs(newState.ViewedUri, null), recordHistory: false);
return;
}
var options = new DecompilationOptions() { TextViewState = newState };
var options = MainWindow.Instance.CreateDecompilationOptions();
options.TextViewState = newState;
decompilationTask = DockWorkspace.Instance.ActiveTabPage.ShowTextViewAsync(
textView => textView.DecompileAsync(this.CurrentLanguage, this.SelectedNodes, options)
);

2
ILSpy/Metadata/DebugMetadataTablesTreeNode.cs

@ -65,7 +65,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -65,7 +65,7 @@ namespace ICSharpCode.ILSpy.Metadata
if (ShowTable(TableIndex.CustomDebugInformation))
this.Children.Add(new CustomDebugInformationTableTreeNode(this.module, this.provider, isEmbedded));
bool ShowTable(TableIndex table) => !DisplaySettingsPanel.CurrentDisplaySettings.HideEmptyMetadataTables || this.provider.GetTableRowCount(table) > 0;
bool ShowTable(TableIndex table) => !MainWindow.Instance.CurrentDisplaySettings.HideEmptyMetadataTables || this.provider.GetTableRowCount(table) > 0;
}
public override bool View(TabPageModel tabPage)

2
ILSpy/Metadata/MetadataTablesTreeNode.cs

@ -112,7 +112,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -112,7 +112,7 @@ namespace ICSharpCode.ILSpy.Metadata
if (ShowTable(TableIndex.GenericParamConstraint))
this.Children.Add(new GenericParamConstraintTableTreeNode(module));
bool ShowTable(TableIndex table) => !DisplaySettingsPanel.CurrentDisplaySettings.HideEmptyMetadataTables || module.Metadata.GetTableRowCount(table) > 0;
bool ShowTable(TableIndex table) => !MainWindow.Instance.CurrentDisplaySettings.HideEmptyMetadataTables || module.Metadata.GetTableRowCount(table) > 0;
}

14
ILSpy/Options/DecompilerSettingsPanel.xaml.cs

@ -37,14 +37,6 @@ namespace ICSharpCode.ILSpy.Options @@ -37,14 +37,6 @@ namespace ICSharpCode.ILSpy.Options
InitializeComponent();
}
static Decompiler.DecompilerSettings currentDecompilerSettings;
public static Decompiler.DecompilerSettings CurrentDecompilerSettings {
get {
return currentDecompilerSettings ?? (currentDecompilerSettings = LoadDecompilerSettings(ILSpySettings.Load()));
}
}
public static Decompiler.DecompilerSettings LoadDecompilerSettings(ILSpySettings settings)
{
XElement e = settings["DecompilerSettings"];
@ -81,7 +73,7 @@ namespace ICSharpCode.ILSpy.Options @@ -81,7 +73,7 @@ namespace ICSharpCode.ILSpy.Options
else
root.Add(section);
currentDecompilerSettings = newSettings;
MainWindow.Instance.CurrentDecompilerSettings = newSettings;
MainWindow.Instance.AssemblyListManager.ApplyWinRTProjections = newSettings.ApplyWindowsRuntimeProjections;
MainWindow.Instance.AssemblyListManager.UseDebugSymbols = newSettings.UseDebugSymbols;
}
@ -137,8 +129,8 @@ namespace ICSharpCode.ILSpy.Options @@ -137,8 +129,8 @@ namespace ICSharpCode.ILSpy.Options
public void LoadDefaults()
{
currentDecompilerSettings = new Decompiler.DecompilerSettings();
this.DataContext = new DecompilerSettingsViewModel(currentDecompilerSettings);
MainWindow.Instance.CurrentDecompilerSettings = new Decompiler.DecompilerSettings();
this.DataContext = new DecompilerSettingsViewModel(MainWindow.Instance.CurrentDecompilerSettings);
}
}
}

15
ILSpy/Options/DisplaySettingsPanel.xaml.cs

@ -68,14 +68,6 @@ namespace ICSharpCode.ILSpy.Options @@ -68,14 +68,6 @@ namespace ICSharpCode.ILSpy.Options
this.DataContext = LoadDisplaySettings(settings);
}
static DisplaySettings currentDisplaySettings;
public static DisplaySettings CurrentDisplaySettings {
get {
return currentDisplaySettings ?? (currentDisplaySettings = LoadDisplaySettings(ILSpySettings.Load()));
}
}
static bool IsSymbolFont(FontFamily fontFamily)
{
foreach (var tf in fontFamily.GetTypefaces())
@ -162,8 +154,7 @@ namespace ICSharpCode.ILSpy.Options @@ -162,8 +154,7 @@ namespace ICSharpCode.ILSpy.Options
else
root.Add(section);
if (currentDisplaySettings != null)
currentDisplaySettings.CopyValues(s);
MainWindow.Instance.CurrentDisplaySettings.CopyValues(s);
}
private void TextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
@ -183,8 +174,8 @@ namespace ICSharpCode.ILSpy.Options @@ -183,8 +174,8 @@ namespace ICSharpCode.ILSpy.Options
public void LoadDefaults()
{
currentDisplaySettings = new DisplaySettings();
this.DataContext = currentDisplaySettings;
MainWindow.Instance.CurrentDisplaySettings.CopyValues(new DisplaySettings());
this.DataContext = MainWindow.Instance.CurrentDisplaySettings;
}
}

6
ILSpy/Search/SearchPane.cs

@ -248,7 +248,8 @@ namespace ICSharpCode.ILSpy.Search @@ -248,7 +248,8 @@ namespace ICSharpCode.ILSpy.Search
currentSearch = null;
}
resultsComparer = DisplaySettingsPanel.CurrentDisplaySettings.SortResults ?
MainWindow mainWindow = MainWindow.Instance;
resultsComparer = mainWindow.CurrentDisplaySettings.SortResults ?
SearchResult.ComparerByFitness :
SearchResult.ComparerByName;
Results.Clear();
@ -256,7 +257,6 @@ namespace ICSharpCode.ILSpy.Search @@ -256,7 +257,6 @@ namespace ICSharpCode.ILSpy.Search
RunningSearch startedSearch = null;
if (!string.IsNullOrEmpty(searchTerm))
{
MainWindow mainWindow = MainWindow.Instance;
searchProgressBar.IsIndeterminate = true;
startedSearch = new RunningSearch(await mainWindow.CurrentAssemblyList.GetAllAssemblies(), searchTerm,
@ -452,7 +452,7 @@ namespace ICSharpCode.ILSpy.Search @@ -452,7 +452,7 @@ namespace ICSharpCode.ILSpy.Search
request.RegEx = regex;
request.SearchResultFactory = new SearchResultFactory(language);
request.TreeNodeFactory = new TreeNodeFactory();
request.DecompilerSettings = new DecompilationOptions().DecompilerSettings;
request.DecompilerSettings = MainWindow.Instance.CurrentDecompilerSettings;
return request;
}

9
ILSpy/SolutionWriter.cs

@ -212,11 +212,10 @@ namespace ICSharpCode.ILSpy @@ -212,11 +212,10 @@ namespace ICSharpCode.ILSpy
using (var projectFileWriter = new StreamWriter(projectFileName))
{
var projectFileOutput = new PlainTextOutput(projectFileWriter);
var options = new DecompilationOptions() {
FullDecompilation = true,
CancellationToken = ct,
SaveAsProjectDirectory = targetDirectory
};
var options = MainWindow.Instance.CreateDecompilationOptions();
options.FullDecompilation = true;
options.CancellationToken = ct;
options.SaveAsProjectDirectory = targetDirectory;
var projectInfo = language.DecompileAssembly(loadedAssembly, projectFileOutput, options);
if (projectInfo != null)

22
ILSpy/TextView/DecompilerTextView.cs

@ -110,9 +110,9 @@ namespace ICSharpCode.ILSpy.TextView @@ -110,9 +110,9 @@ namespace ICSharpCode.ILSpy.TextView
textEditor.TextArea.Caret.PositionChanged += HighlightBrackets;
textEditor.MouseMove += TextEditorMouseMove;
textEditor.MouseLeave += TextEditorMouseLeave;
textEditor.SetBinding(Control.FontFamilyProperty, new Binding { Source = DisplaySettingsPanel.CurrentDisplaySettings, Path = new PropertyPath("SelectedFont") });
textEditor.SetBinding(Control.FontSizeProperty, new Binding { Source = DisplaySettingsPanel.CurrentDisplaySettings, Path = new PropertyPath("SelectedFontSize") });
textEditor.SetBinding(TextEditor.WordWrapProperty, new Binding { Source = DisplaySettingsPanel.CurrentDisplaySettings, Path = new PropertyPath("EnableWordWrap") });
textEditor.SetBinding(Control.FontFamilyProperty, new Binding { Source = MainWindow.Instance.CurrentDisplaySettings, Path = new PropertyPath("SelectedFont") });
textEditor.SetBinding(Control.FontSizeProperty, new Binding { Source = MainWindow.Instance.CurrentDisplaySettings, Path = new PropertyPath("SelectedFontSize") });
textEditor.SetBinding(TextEditor.WordWrapProperty, new Binding { Source = MainWindow.Instance.CurrentDisplaySettings, Path = new PropertyPath("EnableWordWrap") });
// disable Tab editing command (useless for read-only editor); allow using tab for focus navigation instead
RemoveEditCommand(EditingCommands.TabForward);
@ -122,7 +122,7 @@ namespace ICSharpCode.ILSpy.TextView @@ -122,7 +122,7 @@ namespace ICSharpCode.ILSpy.TextView
textEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService);
textEditor.TextArea.TextView.LineTransformers.Add(textMarkerService);
textEditor.ShowLineNumbers = true;
DisplaySettingsPanel.CurrentDisplaySettings.PropertyChanged += CurrentDisplaySettings_PropertyChanged;
MainWindow.Instance.CurrentDisplaySettings.PropertyChanged += CurrentDisplaySettings_PropertyChanged;
// SearchPanel
SearchPanel searchPanel = SearchPanel.Install(textEditor.TextArea);
@ -190,14 +190,14 @@ namespace ICSharpCode.ILSpy.TextView @@ -190,14 +190,14 @@ namespace ICSharpCode.ILSpy.TextView
{
if (margin is LineNumberMargin || margin is System.Windows.Shapes.Line)
{
margin.Visibility = DisplaySettingsPanel.CurrentDisplaySettings.ShowLineNumbers ? Visibility.Visible : Visibility.Collapsed;
margin.Visibility = MainWindow.Instance.CurrentDisplaySettings.ShowLineNumbers ? Visibility.Visible : Visibility.Collapsed;
}
}
}
void SetHighlightCurrentLine()
{
textEditor.Options.HighlightCurrentLine = DisplaySettingsPanel.CurrentDisplaySettings.HighlightCurrentLine;
textEditor.Options.HighlightCurrentLine = MainWindow.Instance.CurrentDisplaySettings.HighlightCurrentLine;
}
#endregion
@ -480,7 +480,7 @@ namespace ICSharpCode.ILSpy.TextView @@ -480,7 +480,7 @@ namespace ICSharpCode.ILSpy.TextView
public FlowDocumentTooltip(FlowDocument document)
{
TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);
double fontSize = DisplaySettingsPanel.CurrentDisplaySettings.SelectedFontSize;
double fontSize = MainWindow.Instance.CurrentDisplaySettings.SelectedFontSize;
viewer = new FlowDocumentScrollViewer() {
Width = document.MinPageWidth + fontSize * 5,
MaxWidth = MainWindow.Instance.ActualWidth
@ -527,7 +527,7 @@ namespace ICSharpCode.ILSpy.TextView @@ -527,7 +527,7 @@ namespace ICSharpCode.ILSpy.TextView
#region Highlight brackets
void HighlightBrackets(object? sender, EventArgs e)
{
if (DisplaySettingsPanel.CurrentDisplaySettings.HighlightMatchingBraces)
if (MainWindow.Instance.CurrentDisplaySettings.HighlightMatchingBraces)
{
var result = MainWindow.Instance.CurrentLanguage.BracketSearcher.SearchBracket(textEditor.Document, textEditor.CaretOffset);
bracketHighlightRenderer.SetHighlight(result);
@ -734,7 +734,7 @@ namespace ICSharpCode.ILSpy.TextView @@ -734,7 +734,7 @@ namespace ICSharpCode.ILSpy.TextView
{
if (state != null)
{
state.RestoreFoldings(textOutput.Foldings, DisplaySettingsPanel.CurrentDisplaySettings.ExpandMemberDefinitions);
state.RestoreFoldings(textOutput.Foldings, MainWindow.Instance.CurrentDisplaySettings.ExpandMemberDefinitions);
textEditor.ScrollToVerticalOffset(state.VerticalOffset);
textEditor.ScrollToHorizontalOffset(state.HorizontalOffset);
}
@ -758,7 +758,7 @@ namespace ICSharpCode.ILSpy.TextView @@ -758,7 +758,7 @@ namespace ICSharpCode.ILSpy.TextView
}
currentAddress = textOutput.Address;
currentTitle = textOutput.Title;
expandMemberDefinitions = DisplaySettingsPanel.CurrentDisplaySettings.ExpandMemberDefinitions;
expandMemberDefinitions = MainWindow.Instance.CurrentDisplaySettings.ExpandMemberDefinitions;
}
#endregion
@ -1215,7 +1215,7 @@ namespace ICSharpCode.ILSpy.TextView @@ -1215,7 +1215,7 @@ namespace ICSharpCode.ILSpy.TextView
public void Dispose()
{
DisplaySettingsPanel.CurrentDisplaySettings.PropertyChanged -= CurrentDisplaySettings_PropertyChanged;
MainWindow.Instance.CurrentDisplaySettings.PropertyChanged -= CurrentDisplaySettings_PropertyChanged;
}
#region Unfold

4
ILSpy/TextView/DocumentationUIBuilder.cs

@ -115,7 +115,7 @@ namespace ICSharpCode.ILSpy.TextView @@ -115,7 +115,7 @@ namespace ICSharpCode.ILSpy.TextView
// Paragraph sadly does not support TextWrapping.NoWrap
var text = new TextBlock {
FontFamily = GetCodeFont(),
FontSize = DisplaySettingsPanel.CurrentDisplaySettings.SelectedFontSize,
FontSize = MainWindow.Instance.CurrentDisplaySettings.SelectedFontSize,
TextAlignment = TextAlignment.Left
};
text.Inlines.AddRange(richText.CreateRuns(document));
@ -435,7 +435,7 @@ namespace ICSharpCode.ILSpy.TextView @@ -435,7 +435,7 @@ namespace ICSharpCode.ILSpy.TextView
FontFamily GetCodeFont()
{
return DisplaySettingsPanel.CurrentDisplaySettings.SelectedFont;
return MainWindow.Instance.CurrentDisplaySettings.SelectedFont;
}
public void AddInline(Inline inline)

8
ILSpy/Themes/WindowStyleManagerBehavior.cs

@ -16,7 +16,7 @@ namespace ICSharpCode.ILSpy.Themes @@ -16,7 +16,7 @@ namespace ICSharpCode.ILSpy.Themes
{
base.OnAttached();
DisplaySettingsPanel.CurrentDisplaySettings.PropertyChanged += DisplaySettings_PropertyChanged;
MainWindow.Instance.CurrentDisplaySettings.PropertyChanged += DisplaySettings_PropertyChanged;
UpdateWindowStyle();
@ -26,12 +26,12 @@ namespace ICSharpCode.ILSpy.Themes @@ -26,12 +26,12 @@ namespace ICSharpCode.ILSpy.Themes
{
base.OnDetaching();
DisplaySettingsPanel.CurrentDisplaySettings.PropertyChanged -= DisplaySettings_PropertyChanged;
MainWindow.Instance.CurrentDisplaySettings.PropertyChanged -= DisplaySettings_PropertyChanged;
}
private void UpdateWindowStyle()
{
if (!DisplaySettingsPanel.CurrentDisplaySettings.StyleWindowTitleBar)
if (!MainWindow.Instance.CurrentDisplaySettings.StyleWindowTitleBar)
{
return;
}
@ -49,7 +49,7 @@ namespace ICSharpCode.ILSpy.Themes @@ -49,7 +49,7 @@ namespace ICSharpCode.ILSpy.Themes
{
if (e.PropertyName == nameof(DisplaySettings.StyleWindowTitleBar))
{
if (!DisplaySettingsPanel.CurrentDisplaySettings.StyleWindowTitleBar)
if (!MainWindow.Instance.CurrentDisplaySettings.StyleWindowTitleBar)
{
restartNotificationThrottle.Tick();
return;

4
ILSpy/TreeNodes/AssemblyTreeNode.cs

@ -220,7 +220,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -220,7 +220,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
ns.Children.Clear();
}
namespaces.Clear();
bool useNestedStructure = DisplaySettingsPanel.CurrentDisplaySettings.UseNestedNamespaceNodes;
bool useNestedStructure = MainWindow.Instance.CurrentDisplaySettings.UseNestedNamespaceNodes;
foreach (var type in assembly.TopLevelTypeDefinitions.OrderBy(t => t.ReflectionName, NaturalStringComparer.Instance))
{
var ns = GetOrCreateNamespaceTreeNode(type.Namespace);
@ -429,7 +429,7 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -429,7 +429,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
dlg.Filter = language.Name + " project|*" + language.ProjectFileExtension + "|" + language.Name + " single file|*" + language.FileExtension + "|All files|*.*";
if (dlg.ShowDialog() == true)
{
DecompilationOptions options = new DecompilationOptions();
DecompilationOptions options = MainWindow.Instance.CreateDecompilationOptions();
options.FullDecompilation = true;
if (dlg.FilterIndex == 1)
{

4
ILSpy/TreeNodes/ILSpyTreeNode.cs

@ -188,11 +188,11 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -188,11 +188,11 @@ namespace ICSharpCode.ILSpy.TreeNodes
protected string GetSuffixString(EntityHandle handle)
{
if (!DisplaySettingsPanel.CurrentDisplaySettings.ShowMetadataTokens)
if (!MainWindow.Instance.CurrentDisplaySettings.ShowMetadataTokens)
return string.Empty;
int token = MetadataTokens.GetToken(handle);
if (DisplaySettingsPanel.CurrentDisplaySettings.ShowMetadataTokensInBase10)
if (MainWindow.Instance.CurrentDisplaySettings.ShowMetadataTokensInBase10)
return " @" + token;
return " @" + token.ToString("x8");
}

2
ILSpy/Views/DebugSteps.xaml.cs

@ -134,7 +134,7 @@ namespace ICSharpCode.ILSpy @@ -134,7 +134,7 @@ namespace ICSharpCode.ILSpy
var window = MainWindow.Instance;
var state = DockWorkspace.Instance.ActiveTabPage.GetState();
DockWorkspace.Instance.ActiveTabPage.ShowTextViewAsync(textView => textView.DecompileAsync(window.CurrentLanguage, window.SelectedNodes,
new DecompilationOptions(window.CurrentLanguageVersion) {
new DecompilationOptions(window.CurrentLanguageVersion, window.CurrentDecompilerSettings, window.CurrentDisplaySettings) {
StepLimit = step,
IsDebug = isDebug,
TextViewState = state as TextView.DecompilerTextViewState

Loading…
Cancel
Save