diff --git a/Plugins/Wox.Plugin.FindFile/Images/edit.png b/Plugins/Wox.Plugin.FindFile/Images/edit.png
deleted file mode 100644
index f1710b7c89..0000000000
Binary files a/Plugins/Wox.Plugin.FindFile/Images/edit.png and /dev/null differ
diff --git a/Plugins/Wox.Plugin.FindFile/Images/open.png b/Plugins/Wox.Plugin.FindFile/Images/open.png
new file mode 100644
index 0000000000..6006d12104
Binary files /dev/null and b/Plugins/Wox.Plugin.FindFile/Images/open.png differ
diff --git a/Plugins/Wox.Plugin.FindFile/Main.cs b/Plugins/Wox.Plugin.FindFile/Main.cs
index f53522f852..6d35e1ac45 100644
--- a/Plugins/Wox.Plugin.FindFile/Main.cs
+++ b/Plugins/Wox.Plugin.FindFile/Main.cs
@@ -92,7 +92,7 @@ namespace Wox.Plugin.FindFile
}
return true;
},
- IcoPath = "Images/edit.png"
+ IcoPath = "Images/open.png"
});
if (!record.IsFolder)
diff --git a/Plugins/Wox.Plugin.FindFile/Wox.Plugin.FindFile.csproj b/Plugins/Wox.Plugin.FindFile/Wox.Plugin.FindFile.csproj
index 707e2744f4..4db15cf579 100644
--- a/Plugins/Wox.Plugin.FindFile/Wox.Plugin.FindFile.csproj
+++ b/Plugins/Wox.Plugin.FindFile/Wox.Plugin.FindFile.csproj
@@ -54,9 +54,6 @@
-
- Always
-
Always
@@ -66,6 +63,9 @@
Always
+
+ Always
+
Always
diff --git a/Wox.Infrastructure/WindowsShellRun.cs b/Wox.Infrastructure/WindowsShellRun.cs
index 054802cc52..f8ec456b4a 100644
--- a/Wox.Infrastructure/WindowsShellRun.cs
+++ b/Wox.Infrastructure/WindowsShellRun.cs
@@ -78,7 +78,7 @@ namespace Wox.Infrastructure
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode)]
static extern bool UrlIs(string pszUrl, int UrlIs);
- static void ShellExecCmdLine(IntPtr hInstance, IntPtr hwnd, string command, string startDir, global::System.Diagnostics.ProcessWindowStyle nShow, ShellExecCmdLineFlags dwSeclFlags)
+ static void ShellExecCmdLine(IntPtr hInstance, IntPtr hwnd, string command, string startDir, global::System.Diagnostics.ProcessWindowStyle nShow, ShellExecCmdLineFlags dwSeclFlags,bool runAsAdministrator = false)
{
string cmd = command;
string args = null;
@@ -143,6 +143,7 @@ namespace Wox.Infrastructure
startInfo.UseShellExecute = true;
startInfo.Arguments = args;
startInfo.FileName = cmd;
+ if (runAsAdministrator) startInfo.Verb = "runas";
startInfo.WindowStyle = global::System.Diagnostics.ProcessWindowStyle.Normal;
startInfo.ErrorDialog = (dwSeclFlags | ShellExecCmdLineFlags.SECL_NO_UI) == 0;
startInfo.ErrorDialogParentHandle = hwnd;
@@ -280,17 +281,12 @@ namespace Wox.Infrastructure
hresult);
}
- public static void Start(string cmd)
+ public static void Start(string cmd, bool runAsAdministrator = false)
{
- Start(cmd, false);
+ Start(cmd, false, IntPtr.Zero,runAsAdministrator);
}
- public static void Start(string cmd, bool showErrorDialog)
- {
- Start(cmd, false, IntPtr.Zero);
- }
-
- public static void Start(string cmd, bool showErrorDialog, IntPtr errorDialogHwnd)
+ public static void Start(string cmd, bool showErrorDialog, IntPtr errorDialogHwnd, bool runAsAdministrator = false)
{
cmd = cmd.Trim(); // PathRemoveBlanks
cmd = Environment.ExpandEnvironmentVariables(cmd); // SHExpandEnvironmentStrings
@@ -306,7 +302,8 @@ namespace Wox.Infrastructure
cmd,
null, // i have no ideas about this field
global::System.Diagnostics.ProcessWindowStyle.Normal,
- ShellExecCmdLineFlags.SECL__IGNORE_ERROR | ShellExecCmdLineFlags.SECL_USE_IDLIST | ShellExecCmdLineFlags.SECL_LOG_USAGE | (showErrorDialog ? 0 : ShellExecCmdLineFlags.SECL_NO_UI)
+ ShellExecCmdLineFlags.SECL__IGNORE_ERROR | ShellExecCmdLineFlags.SECL_USE_IDLIST | ShellExecCmdLineFlags.SECL_LOG_USAGE | (showErrorDialog ? 0 : ShellExecCmdLineFlags.SECL_NO_UI),
+ runAsAdministrator
);
if (!string.IsNullOrEmpty(home) && Directory.Exists(home)) Environment.CurrentDirectory = oldCwd;
}
diff --git a/Wox.Plugin.SystemPlugins/Program/Programs.cs b/Wox.Plugin.SystemPlugins/Program/Programs.cs
index ff87a84667..75432d8b5d 100644
--- a/Wox.Plugin.SystemPlugins/Program/Programs.cs
+++ b/Wox.Plugin.SystemPlugins/Program/Programs.cs
@@ -42,6 +42,31 @@ namespace Wox.Plugin.SystemPlugins.Program
context.API.HideApp();
context.API.ShellRun(c.ExecutePath);
return true;
+ },
+ ContextMenu = new List()
+ {
+ new Result()
+ {
+ Title = "Open",
+ Action = _ =>
+ {
+ context.API.HideApp();
+ context.API.ShellRun(c.ExecutePath);
+ return true;
+ },
+ IcoPath = "Images/open.png"
+ },
+ new Result()
+ {
+ Title = "Open With Administrator",
+ Action = _ =>
+ {
+ context.API.HideApp();
+ context.API.ShellRun(c.ExecutePath,true);
+ return true;
+ },
+ IcoPath = "Images/cmd.png"
+ }
}
}).ToList();
}
@@ -84,11 +109,11 @@ namespace Wox.Plugin.SystemPlugins.Program
Type sourceClass;
if (SourceTypes.TryGetValue(source.Type, out sourceClass))
{
- ConstructorInfo constructorInfo = sourceClass.GetConstructor(new[] {typeof (ProgramSource)});
+ ConstructorInfo constructorInfo = sourceClass.GetConstructor(new[] { typeof(ProgramSource) });
if (constructorInfo != null)
{
IProgramSource programSource =
- constructorInfo.Invoke(new object[] {source}) as IProgramSource;
+ constructorInfo.Invoke(new object[] { source }) as IProgramSource;
sources.Add(programSource);
}
}
@@ -106,7 +131,7 @@ namespace Wox.Plugin.SystemPlugins.Program
}
// filter duplicate program
- tempPrograms = tempPrograms.GroupBy(x => new {x.ExecutePath, x.ExecuteName})
+ tempPrograms = tempPrograms.GroupBy(x => new { x.ExecutePath, x.ExecuteName })
.Select(g => g.First()).ToList();
programs = tempPrograms;
diff --git a/Wox.Plugin/IPublicAPI.cs b/Wox.Plugin/IPublicAPI.cs
index 85e501b651..64ff13ab08 100644
--- a/Wox.Plugin/IPublicAPI.cs
+++ b/Wox.Plugin/IPublicAPI.cs
@@ -9,7 +9,7 @@ namespace Wox.Plugin
void PushResults(Query query,PluginMetadata plugin, List results);
- bool ShellRun(string cmd);
+ bool ShellRun(string cmd, bool runAsAdministrator = false);
void ChangeQuery(string query, bool requery = false);
diff --git a/Wox/Converters/StringNullOrEmptyToVisibilityConverter.cs b/Wox/Converters/StringNullOrEmptyToVisibilityConverter.cs
index d6d01f0714..f536e74735 100644
--- a/Wox/Converters/StringNullOrEmptyToVisibilityConverter.cs
+++ b/Wox/Converters/StringNullOrEmptyToVisibilityConverter.cs
@@ -1,6 +1,8 @@
using System;
+using System.Collections.Generic;
using System.Globalization;
using System.Windows;
+using Wox.Plugin;
namespace Wox.Converters
{
@@ -21,4 +23,23 @@ namespace Wox.Converters
return this;
}
}
+
+ public class ContextMenuEmptyToWidthConverter : ConvertorBase
+ {
+ public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ List results = value as List;
+ return results == null || results.Count == 0 ? 0 : 17;
+ }
+
+ public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return null;
+ }
+
+ public override object ProvideValue(IServiceProvider serviceProvider)
+ {
+ return this;
+ }
+ }
}
\ No newline at end of file
diff --git a/Wox/Images/menu.png b/Wox/Images/menu.png
new file mode 100644
index 0000000000..d7395f4d9f
Binary files /dev/null and b/Wox/Images/menu.png differ
diff --git a/Wox/Images/open.png b/Wox/Images/open.png
new file mode 100644
index 0000000000..6006d12104
Binary files /dev/null and b/Wox/Images/open.png differ
diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs
index bce6c69777..dc3e617dd2 100644
--- a/Wox/MainWindow.xaml.cs
+++ b/Wox/MainWindow.xaml.cs
@@ -720,14 +720,14 @@ namespace Wox
this.Opacity = this.AllowsTransparency ? UserSettingStorage.Instance.Opacity : 1;
}
- public bool ShellRun(string cmd)
+ public bool ShellRun(string cmd, bool runAsAdministrator = false)
{
try
{
if (string.IsNullOrEmpty(cmd))
throw new ArgumentNullException();
- Wox.Infrastructure.WindowsShellRun.Start(cmd);
+ WindowsShellRun.Start(cmd, runAsAdministrator);
return true;
}
catch (Exception ex)
diff --git a/Wox/ResultPanel.xaml b/Wox/ResultPanel.xaml
index d1a8e28afd..a156d6fc18 100644
--- a/Wox/ResultPanel.xaml
+++ b/Wox/ResultPanel.xaml
@@ -7,7 +7,7 @@
mc:Ignorable="d" d:DesignWidth="100" d:DesignHeight="100">
-
+
@@ -24,6 +24,7 @@
+
@@ -32,14 +33,16 @@
-
+
+
+
diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj
index 6dbd0ac08f..e969c37806 100644
--- a/Wox/Wox.csproj
+++ b/Wox/Wox.csproj
@@ -392,6 +392,14 @@
+
+
+ PreserveNewest
+
+
+
+
+