Browse Source

Fix #1653: Add "reset to defaults" in options dialog

pull/1866/head
Siegfried Pammer 6 years ago
parent
commit
b8762c8050
  1. 6
      ILSpy/Options/DecompilerSettingsPanel.xaml.cs
  2. 7
      ILSpy/Options/DisplaySettings.cs
  3. 6
      ILSpy/Options/DisplaySettingsPanel.xaml.cs
  4. 5
      ILSpy/Options/MiscSettings.cs
  5. 6
      ILSpy/Options/MiscSettingsPanel.xaml.cs
  6. 5
      ILSpy/Options/OptionsDialog.xaml
  7. 12
      ILSpy/Options/OptionsDialog.xaml.cs
  8. 18
      ILSpy/Properties/Resources.Designer.cs
  9. 6
      ILSpy/Properties/Resources.resx

6
ILSpy/Options/DecompilerSettingsPanel.xaml.cs

@ -128,6 +128,12 @@ namespace ICSharpCode.ILSpy.Options @@ -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

7
ILSpy/Options/DisplaySettings.cs

@ -29,6 +29,13 @@ namespace ICSharpCode.ILSpy.Options @@ -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

6
ILSpy/Options/DisplaySettingsPanel.xaml.cs

@ -164,6 +164,12 @@ namespace ICSharpCode.ILSpy.Options @@ -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

5
ILSpy/Options/MiscSettings.cs

@ -26,6 +26,11 @@ namespace ICSharpCode.ILSpy.Options @@ -26,6 +26,11 @@ namespace ICSharpCode.ILSpy.Options
bool allowMultipleInstances;
bool loadPreviousAssemblies;
public MiscSettings()
{
this.loadPreviousAssemblies = true;
}
/// <summary>
/// Allow multiple instances.
/// </summary>

6
ILSpy/Options/MiscSettingsPanel.xaml.cs

@ -71,5 +71,11 @@ namespace ICSharpCode.ILSpy.Options @@ -71,5 +71,11 @@ namespace ICSharpCode.ILSpy.Options
currentMiscSettings = null; // invalidate cached settings
}
public void LoadDefaults()
{
currentMiscSettings = new MiscSettings();
this.DataContext = currentMiscSettings;
}
}
}

5
ILSpy/Options/OptionsDialog.xaml

@ -15,8 +15,9 @@ @@ -15,8 +15,9 @@
</Grid.RowDefinitions>
<TabControl Name="tabControl" />
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="12,8">
<Button IsDefault="True" Margin="2,0" Name="okButton" Click="OKButton_Click" Content="{x:Static properties:Resources.OK}"></Button>
<Button IsCancel="True" Margin="2,0" Content="{x:Static properties:Resources.Cancel}"></Button>
<Button Margin="2,0" Name="defaultsButton" Click="DefaultsButton_Click" Content="{x:Static properties:Resources.ResetToDefaults}" />
<Button IsDefault="True" Margin="2,0" Name="okButton" Click="OKButton_Click" Content="{x:Static properties:Resources.OK}" />
<Button IsCancel="True" Margin="2,0" Content="{x:Static properties:Resources.Cancel}" />
</StackPanel>
</Grid>
</Window>

12
ILSpy/Options/OptionsDialog.xaml.cs

@ -68,8 +68,17 @@ namespace ICSharpCode.ILSpy.Options @@ -68,8 +68,17 @@ namespace ICSharpCode.ILSpy.Options
this.DialogResult = true;
Close();
}
private void DefaultsButton_Click(object sender, RoutedEventArgs e)
{
if (MessageBox.Show(Properties.Resources.ResetToDefaultsConfirmationMessage, "ILSpy", MessageBoxButton.YesNo) == MessageBoxResult.Yes) {
var page = ((TabItem)tabControl.SelectedItem).Content as IOptionPage;
if (page != null)
page.LoadDefaults();
}
}
}
public interface IOptionsMetadata
{
string Title { get; }
@ -80,6 +89,7 @@ namespace ICSharpCode.ILSpy.Options @@ -80,6 +89,7 @@ namespace ICSharpCode.ILSpy.Options
{
void Load(ILSpySettings settings);
void Save(XElement root);
void LoadDefaults();
}
[MetadataAttribute]

18
ILSpy/Properties/Resources.Designer.cs generated

@ -1593,6 +1593,24 @@ namespace ICSharpCode.ILSpy.Properties { @@ -1593,6 +1593,24 @@ namespace ICSharpCode.ILSpy.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Reset to defaults.
/// </summary>
public static string ResetToDefaults {
get {
return ResourceManager.GetString("ResetToDefaults", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Do you really want to load the default settings for the active page?.
/// </summary>
public static string ResetToDefaultsConfirmationMessage {
get {
return ResourceManager.GetString("ResetToDefaultsConfirmationMessage", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Resources file (*.resources)|*.resources|Resource XML file|*.resx.
/// </summary>

6
ILSpy/Properties/Resources.resx

@ -802,4 +802,10 @@ Are you sure you want to continue?</value> @@ -802,4 +802,10 @@ Are you sure you want to continue?</value>
<data name="DecompilerSettings.SeparateLocalVariableDeclarations" xml:space="preserve">
<value>Separate local variable declarations and initializers (int x = 5; -&gt; int x; x = 5;), if possible.</value>
</data>
<data name="ResetToDefaults" xml:space="preserve">
<value>Reset to defaults</value>
</data>
<data name="ResetToDefaultsConfirmationMessage" xml:space="preserve">
<value>Do you really want to load the default settings for the active page?</value>
</data>
</root>
Loading…
Cancel
Save