mirror of https://github.com/icsharpcode/ILSpy.git
5 changed files with 124 additions and 0 deletions
@ -0,0 +1,48 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Linq; |
||||||
|
using System.Text; |
||||||
|
|
||||||
|
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,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,56 @@ |
|||||||
|
using ICSharpCode.Decompiler; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Text; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Controls; |
||||||
|
using System.Windows.Data; |
||||||
|
using System.Windows.Documents; |
||||||
|
using System.Windows.Input; |
||||||
|
using System.Windows.Media; |
||||||
|
using System.Windows.Media.Imaging; |
||||||
|
using System.Windows.Navigation; |
||||||
|
using System.Windows.Shapes; |
||||||
|
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 = LoadDecompilerSettings(settings); |
||||||
|
} |
||||||
|
|
||||||
|
private MiscSettings LoadDecompilerSettings(ILSpySettings settings) |
||||||
|
{ |
||||||
|
XElement e = settings["MiscSettings"]; |
||||||
|
MiscSettings s = new MiscSettings(); |
||||||
|
s.AllowMultipleInstances = (bool?)e.Attribute("allowMultipleInstance") ?? s.AllowMultipleInstances; |
||||||
|
return s; |
||||||
|
} |
||||||
|
|
||||||
|
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