diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
index 974eafa96..066188882 100644
--- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
+++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
@@ -190,5 +190,12 @@ namespace Flow.Launcher.Plugin
/// Type for Serialization
///
void SaveSettingJsonStorage() where T : new();
+
+ ///
+ /// Open Directory in explorer configured by user
+ ///
+ /// Directory Path to open
+ /// Extra FileName Info
+ public void OpenDirectory(string DirectoryPath, string FileName = null);
}
}
diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs
index 71f6f1be4..e90a53fc3 100644
--- a/Flow.Launcher/PublicAPIInstance.cs
+++ b/Flow.Launcher/PublicAPIInstance.cs
@@ -22,6 +22,8 @@ using System.Runtime.CompilerServices;
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Infrastructure.Storage;
using System.Collections.Concurrent;
+using Flow.Launcher.Plugin.SharedCommands;
+using System.Diagnostics;
namespace Flow.Launcher
{
@@ -158,7 +160,7 @@ namespace Flow.Launcher
if (!_pluginJsonStorages.ContainsKey(type))
_pluginJsonStorages[type] = new PluginJsonStorage();
- return ((PluginJsonStorage) _pluginJsonStorages[type]).Load();
+ return ((PluginJsonStorage)_pluginJsonStorages[type]).Load();
}
public void SaveSettingJsonStorage() where T : new()
@@ -167,7 +169,7 @@ namespace Flow.Launcher
if (!_pluginJsonStorages.ContainsKey(type))
_pluginJsonStorages[type] = new PluginJsonStorage();
- ((PluginJsonStorage) _pluginJsonStorages[type]).Save();
+ ((PluginJsonStorage)_pluginJsonStorages[type]).Save();
}
public void SaveJsonStorage(T settings) where T : new()
@@ -175,7 +177,22 @@ namespace Flow.Launcher
var type = typeof(T);
_pluginJsonStorages[type] = new PluginJsonStorage(settings);
- ((PluginJsonStorage) _pluginJsonStorages[type]).Save();
+ ((PluginJsonStorage)_pluginJsonStorages[type]).Save();
+ }
+
+ public void OpenDirectory(string DirectoryPath, string FileName = null)
+ {
+ using Process explorer = new Process();
+ var explorerInfo = _settingsVM.Settings.CustomExplorer;
+ explorer.StartInfo = new ProcessStartInfo
+ {
+ FileName = explorerInfo.Path,
+ Arguments = FileName is null ?
+ explorerInfo.DirectoryArgument.Replace("%d", DirectoryPath) :
+ explorerInfo.FileArgument.Replace("%d", DirectoryPath).Replace("%f",
+ Path.IsPathRooted(FileName) ? FileName : Path.Combine(DirectoryPath, FileName))
+ };
+ explorer.Start();
}
public event FlowLauncherGlobalKeyboardEventHandler GlobalKeyboardEvent;
@@ -188,7 +205,7 @@ namespace Flow.Launcher
{
if (GlobalKeyboardEvent != null)
{
- return GlobalKeyboardEvent((int) keyevent, vkcode, state);
+ return GlobalKeyboardEvent((int)keyevent, vkcode, state);
}
return true;
diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs
index 38ede8076..6d280ea3e 100644
--- a/Flow.Launcher/SettingWindow.xaml.cs
+++ b/Flow.Launcher/SettingWindow.xaml.cs
@@ -231,7 +231,7 @@ namespace Flow.Launcher
{
var directory = viewModel.SelectedPlugin.PluginPair.Metadata.PluginDirectory;
if (!string.IsNullOrEmpty(directory))
- FilesFolders.OpenPath(directory);
+ PluginManager.API.OpenDirectory(directory);
}
}
#endregion
@@ -269,7 +269,7 @@ namespace Flow.Launcher
private void OpenPluginFolder(object sender, RoutedEventArgs e)
{
- FilesFolders.OpenPath(Path.Combine(DataLocation.DataDirectory(), Constant.Themes));
+ PluginManager.API.OpenDirectory(Path.Combine(DataLocation.DataDirectory(), Constant.Themes));
}
private void OnPluginStoreRefreshClick(object sender, RoutedEventArgs e)
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs
index 7e12fea13..241e82efb 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs
@@ -34,7 +34,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
{
try
{
- FilesFolders.OpenPath(path);
+ Context.API.OpenDirectory(path);
return true;
}
catch (Exception ex)
@@ -101,7 +101,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
Score = 500,
Action = c =>
{
- FilesFolders.OpenPath(retrievedDirectoryPath);
+ Context.API.OpenDirectory(retrievedDirectoryPath);
return true;
},
TitleToolTip = retrievedDirectoryPath,
@@ -150,7 +150,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
}
else if (c.SpecialKeyState.CtrlPressed)
{
- FilesFolders.OpenContainingFolder(filePath);
+ Context.API.OpenDirectory(Path.GetDirectoryName(filePath), filePath);
}
else
{
diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs
index 282c8a25d..a3f271a6f 100644
--- a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs
+++ b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs
@@ -304,7 +304,7 @@ namespace Flow.Launcher.Plugin.Sys
Action = c =>
{
var logPath = Path.Combine(DataLocation.DataDirectory(), "Logs", Constant.Version);
- FilesFolders.OpenPath(logPath);
+ context.API.OpenDirectory(logPath);
return true;
}
},
@@ -326,7 +326,7 @@ namespace Flow.Launcher.Plugin.Sys
IcoPath = "Images\\app.png",
Action = c =>
{
- FilesFolders.OpenPath(DataLocation.DataDirectory());
+ context.API.OpenDirectory(DataLocation.DataDirectory());
return true;
}
}