Browse Source

Merge pull request #818 from Radon222/multiple-instance-option

Allow Multiple Instance Option and Dialog
pull/863/head
Siegfried Pammer 8 years ago committed by GitHub
parent
commit
cb930968d9
  1. 4
      ILSpy/App.xaml.cs
  2. 9
      ILSpy/ILSpy.csproj
  3. 44
      ILSpy/Options/MiscSettings.cs
  4. 47
      ILSpy/Options/MiscSettingsLoader.cs
  5. 11
      ILSpy/Options/MiscSettingsPanel.xaml
  6. 35
      ILSpy/Options/MiscSettingsPanel.xaml.cs

4
ILSpy/App.xaml.cs

@ -30,6 +30,7 @@ using System.Windows.Navigation; @@ -30,6 +30,7 @@ using System.Windows.Navigation;
using System.Windows.Threading;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.ILSpy.Options;
namespace ICSharpCode.ILSpy
{
@ -57,8 +58,9 @@ namespace ICSharpCode.ILSpy @@ -57,8 +58,9 @@ namespace ICSharpCode.ILSpy
public App()
{
var cmdArgs = Environment.GetCommandLineArgs().Skip(1);
var allowMultipleInstance = MiscSettingsInstance.Current.LoadMiscSettings().AllowMultipleInstances;
App.CommandLineArguments = new CommandLineArguments(cmdArgs);
if (App.CommandLineArguments.SingleInstance ?? true) {
if ((App.CommandLineArguments.SingleInstance ?? true) && (!allowMultipleInstance)) {
cmdArgs = cmdArgs.Select(FullyQualifyPath);
string message = string.Join(Environment.NewLine, cmdArgs);
if (SendToPreviousInstance("ILSpy:\r\n" + message, !App.CommandLineArguments.NoActivate)) {

9
ILSpy/ILSpy.csproj

@ -151,6 +151,11 @@ @@ -151,6 +151,11 @@
<DependentUpon>DisplaySettingsPanel.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Options\MiscSettings.cs" />
<Compile Include="Options\MiscSettingsLoader.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>
@ -288,6 +293,10 @@ @@ -288,6 +293,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" />
<Page Include="TextView\DecompilerTextView.xaml" />

44
ILSpy/Options/MiscSettings.cs

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

47
ILSpy/Options/MiscSettingsLoader.cs

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

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>

35
ILSpy/Options/MiscSettingsPanel.xaml.cs

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