Browse Source

Create allow-multiple-instances option and its option page

pull/818/head
LL 8 years ago
parent
commit
1827dd02d5
  1. 1
      ILSpy/CommandLineArguments.cs
  2. 8
      ILSpy/ILSpy.csproj
  3. 48
      ILSpy/Options/MiscSettings.cs
  4. 11
      ILSpy/Options/MiscSettingsPanel.xaml
  5. 56
      ILSpy/Options/MiscSettingsPanel.xaml.cs

1
ILSpy/CommandLineArguments.cs

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
using System;
using System.Collections.Generic;
using System.Configuration;
namespace ICSharpCode.ILSpy
{

8
ILSpy/ILSpy.csproj

@ -169,6 +169,10 @@ @@ -169,6 +169,10 @@
<DependentUpon>DisplaySettingsPanel.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Options\MiscSettings.cs" />
<Compile Include="Options\MiscSettingsPanel.xaml.cs">
<DependentUpon>MiscSettingsPanel.xaml</DependentUpon>
</Compile>
<Compile Include="Options\OptionsDialog.xaml.cs">
<DependentUpon>OptionsDialog.xaml</DependentUpon>
<SubType>Code</SubType>
@ -315,6 +319,10 @@ @@ -315,6 +319,10 @@
<Page Include="OpenListDialog.xaml" />
<Page Include="Options\DecompilerSettingsPanel.xaml" />
<Page Include="Options\DisplaySettingsPanel.xaml" />
<Page Include="Options\MiscSettingsPanel.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Options\OptionsDialog.xaml" />
<Page Include="SearchPane.xaml">
<DependentUpon>SearchPane.cs</DependentUpon>

48
ILSpy/Options/MiscSettings.cs

@ -0,0 +1,48 @@ @@ -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
}
}

11
ILSpy/Options/MiscSettingsPanel.xaml

@ -0,0 +1,11 @@ @@ -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>

56
ILSpy/Options/MiscSettingsPanel.xaml.cs

@ -0,0 +1,56 @@ @@ -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…
Cancel
Save