Browse Source

Enable certain commands only on Windows (#3217)

pull/3219/head
Christoph Wille 12 months ago committed by GitHub
parent
commit
399ba1c010
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      ILSpy/AppEnv/AppEnvironment.cs
  2. 7
      ILSpy/Commands/OpenFromGacCommand.cs
  3. 2
      ILSpy/Options/MiscSettingsPanel.xaml
  4. 7
      ILSpy/Options/MiscSettingsViewModel.cs

9
ILSpy/AppEnv/AppEnvironment.cs

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
using System.Runtime.InteropServices;
namespace ICSharpCode.ILSpy.AppEnv
{
public static class AppEnvironment
{
public static bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
}
}

7
ILSpy/Commands/OpenFromGacCommand.cs

@ -16,12 +16,19 @@ @@ -16,12 +16,19 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using ICSharpCode.ILSpy.AppEnv;
using ICSharpCode.ILSpy.Properties;
namespace ICSharpCode.ILSpy
{
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.OpenFrom_GAC), MenuIcon = "Images/AssemblyListGAC", MenuCategory = nameof(Resources.Open), MenuOrder = 1)]
sealed class OpenFromGacCommand : SimpleCommand
{
public override bool CanExecute(object parameter)
{
return AppEnvironment.IsWindows;
}
public override void Execute(object parameter)
{
OpenFromGacDialog dlg = new OpenFromGacDialog();

2
ILSpy/Options/MiscSettingsPanel.xaml

@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
<StackPanel Margin="10">
<CheckBox IsChecked="{Binding AllowMultipleInstances}" Content="{x:Static properties:Resources.AllowMultipleInstances}" />
<CheckBox IsChecked="{Binding LoadPreviousAssemblies}" Content="{x:Static properties:Resources.LoadAssembliesThatWereLoadedInTheLastInstance}"/>
<Button Command="{Binding AddRemoveShellIntegrationCommand}" Content="{Binding AddRemoveShellIntegrationText}" Margin="3" />
<Button Command="{Binding AddRemoveShellIntegrationCommand}" IsEnabled="{Binding EnableShellIntegrationCommand}" Content="{Binding AddRemoveShellIntegrationText}" Margin="3" />
</StackPanel>
</GroupBox>
</StackPanel>

7
ILSpy/Options/MiscSettingsViewModel.cs

@ -16,7 +16,6 @@ @@ -16,7 +16,6 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.ComponentModel;
using System.IO;
using System.Reflection;
@ -42,7 +41,10 @@ namespace ICSharpCode.ILSpy.Options @@ -42,7 +41,10 @@ namespace ICSharpCode.ILSpy.Options
AllowMultipleInstances = s.AllowMultipleInstances;
LoadPreviousAssemblies = s.LoadPreviousAssemblies;
AddRemoveShellIntegrationCommand = new DelegateCommand<object>(AddRemoveShellIntegration);
if (EnableShellIntegrationCommand)
{
AddRemoveShellIntegrationCommand = new DelegateCommand<object>(AddRemoveShellIntegration);
}
}
/// <summary>
@ -74,6 +76,7 @@ namespace ICSharpCode.ILSpy.Options @@ -74,6 +76,7 @@ namespace ICSharpCode.ILSpy.Options
}
public ICommand AddRemoveShellIntegrationCommand { get; }
public bool EnableShellIntegrationCommand => AppEnvironment.IsWindows;
const string rootPath = @"Software\Classes\{0}\shell";
const string fullPath = @"Software\Classes\{0}\shell\Open with ILSpy\command";

Loading…
Cancel
Save