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. 10
      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
CheckBox checkBox = (CheckBox)sender; CheckBox checkBox = (CheckBox)sender;
checkBox.IsChecked = IsGroupChecked((CollectionViewGroup)checkBox.DataContext); checkBox.IsChecked = IsGroupChecked((CollectionViewGroup)checkBox.DataContext);
} }
public void LoadDefaults()
{
currentDecompilerSettings = new Decompiler.DecompilerSettings();
this.DataContext = new DecompilerSettings(currentDecompilerSettings);
}
} }
public class DecompilerSettings : INotifyPropertyChanged public class DecompilerSettings : INotifyPropertyChanged

7
ILSpy/Options/DisplaySettings.cs

@ -29,6 +29,13 @@ namespace ICSharpCode.ILSpy.Options
{ {
public DisplaySettings() 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 #region INotifyPropertyChanged implementation

6
ILSpy/Options/DisplaySettingsPanel.xaml.cs

@ -164,6 +164,12 @@ namespace ICSharpCode.ILSpy.Options
if (!text.All(char.IsDigit)) if (!text.All(char.IsDigit))
e.CancelCommand(); e.CancelCommand();
} }
public void LoadDefaults()
{
currentDisplaySettings = new DisplaySettings();
this.DataContext = currentDisplaySettings;
}
} }
public class FontSizeConverter : IValueConverter public class FontSizeConverter : IValueConverter

5
ILSpy/Options/MiscSettings.cs

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

6
ILSpy/Options/MiscSettingsPanel.xaml.cs

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

5
ILSpy/Options/OptionsDialog.xaml

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

10
ILSpy/Options/OptionsDialog.xaml.cs

@ -68,6 +68,15 @@ namespace ICSharpCode.ILSpy.Options
this.DialogResult = true; this.DialogResult = true;
Close(); 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 public interface IOptionsMetadata
@ -80,6 +89,7 @@ namespace ICSharpCode.ILSpy.Options
{ {
void Load(ILSpySettings settings); void Load(ILSpySettings settings);
void Save(XElement root); void Save(XElement root);
void LoadDefaults();
} }
[MetadataAttribute] [MetadataAttribute]

18
ILSpy/Properties/Resources.Designer.cs generated

@ -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> /// <summary>
/// Looks up a localized string similar to Resources file (*.resources)|*.resources|Resource XML file|*.resx. /// Looks up a localized string similar to Resources file (*.resources)|*.resources|Resource XML file|*.resx.
/// </summary> /// </summary>

6
ILSpy/Properties/Resources.resx

@ -802,4 +802,10 @@ Are you sure you want to continue?</value>
<data name="DecompilerSettings.SeparateLocalVariableDeclarations" xml:space="preserve"> <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> <value>Separate local variable declarations and initializers (int x = 5; -&gt; int x; x = 5;), if possible.</value>
</data> </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> </root>
Loading…
Cancel
Save