From b8762c80509edd5209f88b92603d3baa971aece0 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Tue, 10 Dec 2019 15:59:33 +0100 Subject: [PATCH] Fix #1653: Add "reset to defaults" in options dialog --- ILSpy/Options/DecompilerSettingsPanel.xaml.cs | 6 ++++++ ILSpy/Options/DisplaySettings.cs | 7 +++++++ ILSpy/Options/DisplaySettingsPanel.xaml.cs | 6 ++++++ ILSpy/Options/MiscSettings.cs | 5 +++++ ILSpy/Options/MiscSettingsPanel.xaml.cs | 6 ++++++ ILSpy/Options/OptionsDialog.xaml | 5 +++-- ILSpy/Options/OptionsDialog.xaml.cs | 12 +++++++++++- ILSpy/Properties/Resources.Designer.cs | 18 ++++++++++++++++++ ILSpy/Properties/Resources.resx | 6 ++++++ 9 files changed, 68 insertions(+), 3 deletions(-) diff --git a/ILSpy/Options/DecompilerSettingsPanel.xaml.cs b/ILSpy/Options/DecompilerSettingsPanel.xaml.cs index 134f9faf0..1b1daa917 100644 --- a/ILSpy/Options/DecompilerSettingsPanel.xaml.cs +++ b/ILSpy/Options/DecompilerSettingsPanel.xaml.cs @@ -128,6 +128,12 @@ namespace ICSharpCode.ILSpy.Options CheckBox checkBox = (CheckBox)sender; checkBox.IsChecked = IsGroupChecked((CollectionViewGroup)checkBox.DataContext); } + + public void LoadDefaults() + { + currentDecompilerSettings = new Decompiler.DecompilerSettings(); + this.DataContext = new DecompilerSettings(currentDecompilerSettings); + } } public class DecompilerSettings : INotifyPropertyChanged diff --git a/ILSpy/Options/DisplaySettings.cs b/ILSpy/Options/DisplaySettings.cs index a887e2913..950a9b6c4 100644 --- a/ILSpy/Options/DisplaySettings.cs +++ b/ILSpy/Options/DisplaySettings.cs @@ -29,6 +29,13 @@ namespace ICSharpCode.ILSpy.Options { public DisplaySettings() { + this.selectedFont = new FontFamily("Consolas"); + this.selectedFontSize = 10.0 * 4 / 3; + this.sortResults = true; + this.indentationUseTabs = true; + this.indentationSize = 4; + this.indentationTabSize = 4; + this.highlightMatchingBraces = true; } #region INotifyPropertyChanged implementation diff --git a/ILSpy/Options/DisplaySettingsPanel.xaml.cs b/ILSpy/Options/DisplaySettingsPanel.xaml.cs index ef13c55d9..a8196a560 100644 --- a/ILSpy/Options/DisplaySettingsPanel.xaml.cs +++ b/ILSpy/Options/DisplaySettingsPanel.xaml.cs @@ -164,6 +164,12 @@ namespace ICSharpCode.ILSpy.Options if (!text.All(char.IsDigit)) e.CancelCommand(); } + + public void LoadDefaults() + { + currentDisplaySettings = new DisplaySettings(); + this.DataContext = currentDisplaySettings; + } } public class FontSizeConverter : IValueConverter diff --git a/ILSpy/Options/MiscSettings.cs b/ILSpy/Options/MiscSettings.cs index a78cc8609..d5c7659a5 100644 --- a/ILSpy/Options/MiscSettings.cs +++ b/ILSpy/Options/MiscSettings.cs @@ -26,6 +26,11 @@ namespace ICSharpCode.ILSpy.Options bool allowMultipleInstances; bool loadPreviousAssemblies; + public MiscSettings() + { + this.loadPreviousAssemblies = true; + } + /// /// Allow multiple instances. /// diff --git a/ILSpy/Options/MiscSettingsPanel.xaml.cs b/ILSpy/Options/MiscSettingsPanel.xaml.cs index 75f0dd151..866efcf0a 100644 --- a/ILSpy/Options/MiscSettingsPanel.xaml.cs +++ b/ILSpy/Options/MiscSettingsPanel.xaml.cs @@ -71,5 +71,11 @@ namespace ICSharpCode.ILSpy.Options currentMiscSettings = null; // invalidate cached settings } + + public void LoadDefaults() + { + currentMiscSettings = new MiscSettings(); + this.DataContext = currentMiscSettings; + } } } diff --git a/ILSpy/Options/OptionsDialog.xaml b/ILSpy/Options/OptionsDialog.xaml index 5eb0389ee..f8b9232fb 100644 --- a/ILSpy/Options/OptionsDialog.xaml +++ b/ILSpy/Options/OptionsDialog.xaml @@ -15,8 +15,9 @@ - - +