From d3f8b9dc552f720a5e2e3004a8da0931fbf50dcd Mon Sep 17 00:00:00 2001 From: "marco.silipo" Date: Sat, 14 Mar 2020 16:09:53 +0100 Subject: [PATCH] Added Open Folder --- Arma.Studio.Data/UI/Converters/IsNullConverter.cs | 10 ++++++++-- .../Properties/Language.Designer.cs | 9 +++++++++ .../Properties/Language.resx | 3 +++ .../SolutionExplorer.xaml | 8 ++++++++ .../SolutionExplorerDataContext.cs | 15 +++++++++++++++ Arma.Studio/App.xaml | 11 +++++++++++ 6 files changed, 54 insertions(+), 2 deletions(-) diff --git a/Arma.Studio.Data/UI/Converters/IsNullConverter.cs b/Arma.Studio.Data/UI/Converters/IsNullConverter.cs index bc49f61..0a677fa 100644 --- a/Arma.Studio.Data/UI/Converters/IsNullConverter.cs +++ b/Arma.Studio.Data/UI/Converters/IsNullConverter.cs @@ -18,13 +18,19 @@ public class IsNullConverter : IValueConverter /// A converted value. If the method returns null, the valid null value is used. public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { + bool success = true; + if (parameter is string para && (para.Equals("true", StringComparison.InvariantCultureIgnoreCase) || para.Equals("false", StringComparison.InvariantCultureIgnoreCase))) + { + success = System.Convert.ToBoolean(para); + } + if (value is string s) { - return String.IsNullOrWhiteSpace(s); + return String.IsNullOrWhiteSpace(s) ? success : !success; } else { - return value == null; + return value == null ? success : !success; } } diff --git a/Arma.Studio.SolutionExplorer/Properties/Language.Designer.cs b/Arma.Studio.SolutionExplorer/Properties/Language.Designer.cs index b03a6a0..2a44fce 100644 --- a/Arma.Studio.SolutionExplorer/Properties/Language.Designer.cs +++ b/Arma.Studio.SolutionExplorer/Properties/Language.Designer.cs @@ -186,6 +186,15 @@ public static string SolutionExplorer_ContextMenu_Add_PBO { } } + /// + /// Looks up a localized string similar to Open folder. + /// + public static string SolutionExplorer_ContextMenu_OpenFolder { + get { + return ResourceManager.GetString("SolutionExplorer_ContextMenu_OpenFolder", resourceCulture); + } + } + /// /// Looks up a localized string similar to Rescan. /// diff --git a/Arma.Studio.SolutionExplorer/Properties/Language.resx b/Arma.Studio.SolutionExplorer/Properties/Language.resx index c048eab..8eb6c9d 100644 --- a/Arma.Studio.SolutionExplorer/Properties/Language.resx +++ b/Arma.Studio.SolutionExplorer/Properties/Language.resx @@ -168,4 +168,7 @@ Add New Item + + Open folder + \ No newline at end of file diff --git a/Arma.Studio.SolutionExplorer/SolutionExplorer.xaml b/Arma.Studio.SolutionExplorer/SolutionExplorer.xaml index 7c59621..da5d9b5 100644 --- a/Arma.Studio.SolutionExplorer/SolutionExplorer.xaml +++ b/Arma.Studio.SolutionExplorer/SolutionExplorer.xaml @@ -47,6 +47,14 @@ IsEnabled="{Binding DataContext, Converter={StaticResource IsAssignableFromConverter}, ConverterParameter={x:Type data:PBO}}"> + + + + + diff --git a/Arma.Studio.SolutionExplorer/SolutionExplorerDataContext.cs b/Arma.Studio.SolutionExplorer/SolutionExplorerDataContext.cs index 2646851..322cae4 100644 --- a/Arma.Studio.SolutionExplorer/SolutionExplorerDataContext.cs +++ b/Arma.Studio.SolutionExplorer/SolutionExplorerDataContext.cs @@ -51,6 +51,21 @@ public object InRenameMode } } }); + public ICommand CmdOpenContainingFolder => new RelayCommand((ffb) => + { + switch (ffb) + { + case File file: + System.Diagnostics.Process.Start("explorer.exe", string.Format("/select,\"{0}\"", file.PhysicalPath.Replace('/', '\\'))); + break; + case PBO pbo: + System.Diagnostics.Process.Start("explorer.exe", pbo.FullPath.Replace('/', '\\')); + break; + case Folder folder: + System.Diagnostics.Process.Start("explorer.exe", folder.FullPath.Replace('/', '\\')); + break; + } + }); public ICommand CmdAddPbo => new RelayCommand(() => { diff --git a/Arma.Studio/App.xaml b/Arma.Studio/App.xaml index 7009651..287e270 100644 --- a/Arma.Studio/App.xaml +++ b/Arma.Studio/App.xaml @@ -28,6 +28,17 @@ + + + + + + + + + + +