mirror of https://github.com/icsharpcode/ILSpy.git
6 changed files with 149 additions and 1 deletions
@ -0,0 +1,44 @@ |
|||||||
|
using System.ComponentModel; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy.Options |
||||||
|
{ |
||||||
|
public class MiscSettings : INotifyPropertyChanged |
||||||
|
{ |
||||||
|
bool allowMultipleInstances = false; |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Decompile anonymous methods/lambdas.
|
||||||
|
/// </summary>
|
||||||
|
public bool AllowMultipleInstances |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return allowMultipleInstances; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
if (allowMultipleInstances != value) |
||||||
|
{ |
||||||
|
allowMultipleInstances = value; |
||||||
|
OnPropertyChanged("AllowMultipleInstance"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
#region INotifyPropertyChanged Implementation
|
||||||
|
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged; |
||||||
|
|
||||||
|
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e) |
||||||
|
{ |
||||||
|
PropertyChanged?.Invoke(this, e); |
||||||
|
} |
||||||
|
|
||||||
|
protected void OnPropertyChanged(string propertyName) |
||||||
|
{ |
||||||
|
OnPropertyChanged(new PropertyChangedEventArgs(propertyName)); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
using System.Xml.Linq; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy.Options |
||||||
|
{ |
||||||
|
public interface IMiscSettingsLoader |
||||||
|
{ |
||||||
|
MiscSettings LoadMiscSettings(); |
||||||
|
MiscSettings LoadMiscSettings(ILSpySettings settings); |
||||||
|
} |
||||||
|
|
||||||
|
public class MiscSettingsLoader : IMiscSettingsLoader |
||||||
|
{ |
||||||
|
private ILSpySettings settings; |
||||||
|
|
||||||
|
public MiscSettingsLoader() |
||||||
|
{ |
||||||
|
settings = ILSpySettings.Load(); |
||||||
|
} |
||||||
|
|
||||||
|
public MiscSettings LoadMiscSettings() |
||||||
|
{ |
||||||
|
return LoadMiscSettings(settings); |
||||||
|
} |
||||||
|
|
||||||
|
public MiscSettings LoadMiscSettings(ILSpySettings settings) |
||||||
|
{ |
||||||
|
XElement e = settings["MiscSettings"]; |
||||||
|
MiscSettings s = new MiscSettings(); |
||||||
|
s.AllowMultipleInstances = (bool?)e.Attribute("allowMultipleInstance") ?? s.AllowMultipleInstances; |
||||||
|
return s; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static class MiscSettingsInstance |
||||||
|
{ |
||||||
|
private static MiscSettingsLoader current; |
||||||
|
|
||||||
|
public static MiscSettingsLoader Current |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
current = current ?? new MiscSettingsLoader(); |
||||||
|
return current; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
<UserControl x:Class="ICSharpCode.ILSpy.Options.MiscSettingsPanel" |
||||||
|
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" |
||||||
|
mc:Ignorable="d" |
||||||
|
d:DesignHeight="300" d:DesignWidth="300"> |
||||||
|
<StackPanel Margin="10"> |
||||||
|
<CheckBox IsChecked="{Binding AllowMultipleInstances}">Allow multiple instances</CheckBox> |
||||||
|
</StackPanel> |
||||||
|
</UserControl> |
@ -0,0 +1,35 @@ |
|||||||
|
using System.Windows.Controls; |
||||||
|
using System.Xml.Linq; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy.Options |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for MiscSettingsPanel.xaml
|
||||||
|
/// </summary>
|
||||||
|
[ExportOptionPage(Title = "Misc", Order = 2)] |
||||||
|
public partial class MiscSettingsPanel : UserControl, IOptionPage |
||||||
|
{ |
||||||
|
public MiscSettingsPanel() |
||||||
|
{ |
||||||
|
InitializeComponent(); |
||||||
|
} |
||||||
|
|
||||||
|
public void Load(ILSpySettings settings) |
||||||
|
{ |
||||||
|
this.DataContext = MiscSettingsInstance.Current.LoadMiscSettings(settings); |
||||||
|
} |
||||||
|
|
||||||
|
public void Save(XElement root) |
||||||
|
{ |
||||||
|
MiscSettings s = (MiscSettings)this.DataContext; |
||||||
|
XElement section = new XElement("MiscSettings"); |
||||||
|
section.SetAttributeValue("allowMultipleInstance", s.AllowMultipleInstances); |
||||||
|
|
||||||
|
XElement existingElement = root.Element("MiscSettings"); |
||||||
|
if (existingElement != null) |
||||||
|
existingElement.ReplaceWith(section); |
||||||
|
else |
||||||
|
root.Add(section); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue