mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-12 02:09:24 +08:00
Merge branch 'master' of https://github.com/qianlifeng/Wox.git
This commit is contained in:
commit
9177f4b47d
@ -30,17 +30,7 @@ namespace Wox.Plugin.Everything
|
||||
r.Action = (c) =>
|
||||
{
|
||||
context.HideApp();
|
||||
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
|
||||
info.UseShellExecute = true;
|
||||
info.FileName = path;
|
||||
try
|
||||
{
|
||||
System.Diagnostics.Process.Start(info);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
context.ShowMsg("Could not start " + r.Title, ex.Message, null);
|
||||
}
|
||||
context.ShellRun(path);
|
||||
return true;
|
||||
};
|
||||
results.Add(r);
|
||||
|
@ -5,7 +5,7 @@ using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.IO;
|
||||
|
||||
namespace Wox.Plugin.System
|
||||
namespace Wox.Infrastructure
|
||||
{
|
||||
/*
|
||||
* http://undoc.airesoft.co.uk/shell32.dll/ShellExecCmdLine.php
|
||||
@ -205,7 +205,7 @@ namespace Wox.Plugin.System
|
||||
// there might be args in that command
|
||||
args = PathGetArgs(cmd);
|
||||
if (args != null)
|
||||
cmd = cmd.Substring(0, cmd.Length - args.Length);
|
||||
cmd = cmd.Substring(0, cmd.Length - args.Length).Trim();
|
||||
}
|
||||
else
|
||||
args = null;
|
@ -60,6 +60,7 @@
|
||||
<Compile Include="UserSettings\UserSelectedRecords.cs" />
|
||||
<Compile Include="UserSettings\UserSetting.cs" />
|
||||
<Compile Include="UserSettings\WebSearch.cs" />
|
||||
<Compile Include="WindowsShellRun.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
@ -14,7 +14,7 @@ namespace Wox.Plugin.System
|
||||
{
|
||||
public class BrowserBookmarks : BaseSystemPlugin
|
||||
{
|
||||
|
||||
private PluginInitContext context;
|
||||
private List<Bookmark> bookmarks = new List<Bookmark>();
|
||||
|
||||
protected override List<Result> QueryInternal(Query query)
|
||||
@ -29,16 +29,10 @@ namespace Wox.Plugin.System
|
||||
SubTitle = "Bookmark: " + c.Url,
|
||||
IcoPath = Directory.GetCurrentDirectory() + @"\Images\bookmark.png",
|
||||
Score = 5,
|
||||
Action = (context) =>
|
||||
Action = (e) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(c.Url);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("open url failed:" + c.Url);
|
||||
}
|
||||
context.HideApp();
|
||||
context.ShellRun(c.Url);
|
||||
return true;
|
||||
}
|
||||
}).ToList();
|
||||
@ -57,6 +51,7 @@ namespace Wox.Plugin.System
|
||||
LoadChromeBookmarks();
|
||||
|
||||
bookmarks = bookmarks.Distinct().ToList();
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
private void ParseChromeBookmarks(String path, string source)
|
||||
|
@ -137,15 +137,8 @@ namespace Wox.Plugin.System
|
||||
|
||||
private void ExecuteCmd(string cmd)
|
||||
{
|
||||
try
|
||||
{
|
||||
WindowsShellRun.Start(cmd);
|
||||
if (context.ShellRun(cmd))
|
||||
AddCmdHistory(cmd);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("Wox cound't execute this command. \n\n" + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void InitInternal(PluginInitContext context)
|
||||
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Wox.Plugin.System
|
||||
namespace Wox.Plugin.System.ProgramSources
|
||||
{
|
||||
[global::System.ComponentModel.Browsable(false)]
|
||||
public class AppPathsProgramSource: AbstractProgramSource
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Wox.Plugin.System
|
||||
namespace Wox.Plugin.System.ProgramSources
|
||||
{
|
||||
[global::System.ComponentModel.Browsable(false)]
|
||||
public class CommonStartMenuProgramSource : FileSystemProgramSource
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace Wox.Plugin.System
|
||||
namespace Wox.Plugin.System.ProgramSources
|
||||
{
|
||||
public class FileSystemProgramSource : AbstractProgramSource
|
||||
{
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using IniParser;
|
||||
namespace Wox.Plugin.System
|
||||
namespace Wox.Plugin.System.ProgramSources
|
||||
{
|
||||
public class PortableAppsProgramSource : AbstractProgramSource
|
||||
{
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Wox.Plugin.System
|
||||
namespace Wox.Plugin.System.ProgramSources
|
||||
{
|
||||
[global::System.ComponentModel.Browsable(false)]
|
||||
public class UserStartMenuProgramSource : FileSystemProgramSource
|
@ -9,6 +9,7 @@ using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.Win32;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Plugin.System.ProgramSources;
|
||||
|
||||
namespace Wox.Plugin.System
|
||||
{
|
||||
@ -45,12 +46,13 @@ namespace Wox.Plugin.System
|
||||
List<Program> installedList = new List<Program>();
|
||||
List<IProgramSource> sources = new List<IProgramSource>();
|
||||
public static Dictionary<string, Type> SourceTypes = new Dictionary<string, Type>() {
|
||||
{"FileSystemProgramSource", typeof(FileSystemProgramSource)},
|
||||
{"PortableAppsProgramSource", typeof(PortableAppsProgramSource)},
|
||||
{"CommonStartMenuProgramSource", typeof(CommonStartMenuProgramSource)},
|
||||
{"UserStartMenuProgramSource", typeof(UserStartMenuProgramSource)},
|
||||
{"AppPathsProgramSource", typeof(AppPathsProgramSource)},
|
||||
{"PortableAppsProgramSource", typeof(PortableAppsProgramSource)},
|
||||
{"FileSystemProgramSource", typeof(FileSystemProgramSource)},
|
||||
};
|
||||
private PluginInitContext context;
|
||||
|
||||
protected override List<Result> QueryInternal(Query query)
|
||||
{
|
||||
@ -69,28 +71,10 @@ namespace Wox.Plugin.System
|
||||
SubTitle = c.ExecutePath,
|
||||
IcoPath = c.IcoPath,
|
||||
Score = 0,
|
||||
Action = (context) =>
|
||||
Action = (e) =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(c.ExecutePath))
|
||||
{
|
||||
MessageBox.Show("couldn't start" + c.Title);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(c.ExecutePath);
|
||||
}
|
||||
catch (Win32Exception)
|
||||
{
|
||||
//Do nothing.
|
||||
//It may be caused if UAC blocks the program.
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
context.HideApp();
|
||||
context.ShellRun(c.ExecutePath);
|
||||
return true;
|
||||
}
|
||||
}).ToList();
|
||||
@ -108,6 +92,8 @@ namespace Wox.Plugin.System
|
||||
|
||||
protected override void InitInternal(PluginInitContext context)
|
||||
{
|
||||
this.context = context;
|
||||
|
||||
if (CommonStorage.Instance.UserSetting.ProgramSources == null)
|
||||
CommonStorage.Instance.UserSetting.ProgramSources = CommonStorage.Instance.UserSetting.LoadDefaultProgramSources();
|
||||
|
||||
|
@ -51,17 +51,16 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AppPathsProgramSource.cs" />
|
||||
<Compile Include="CommonStartMenuProgramSource.cs" />
|
||||
<Compile Include="PortableAppsProgramSource.cs" />
|
||||
<Compile Include="ProgramSources\AppPathsProgramSource.cs" />
|
||||
<Compile Include="ProgramSources\CommonStartMenuProgramSource.cs" />
|
||||
<Compile Include="ProgramSources\PortableAppsProgramSource.cs" />
|
||||
<Compile Include="IProgramSource.cs" />
|
||||
<Compile Include="BaseSystemPlugin.cs" />
|
||||
<Compile Include="BrowserBookmarks.cs" />
|
||||
<Compile Include="Calculator.cs" />
|
||||
<Compile Include="FileSystemProgramSource.cs" />
|
||||
<Compile Include="UserStartMenuProgramSource.cs" />
|
||||
<Compile Include="ProgramSources\FileSystemProgramSource.cs" />
|
||||
<Compile Include="ProgramSources\UserStartMenuProgramSource.cs" />
|
||||
<Compile Include="WebSearchPlugin.cs" />
|
||||
<Compile Include="WindowsShellRun.cs" />
|
||||
<Compile Include="CMD.cs" />
|
||||
<Compile Include="DirectoryIndicator.cs" />
|
||||
<Compile Include="ISystemPlugin.cs" />
|
||||
|
@ -29,5 +29,7 @@ namespace Wox.Plugin
|
||||
|
||||
public Action StartLoadingBar { get; set; }
|
||||
public Action StopLoadingBar { get; set; }
|
||||
|
||||
public Func<string, bool> ShellRun { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -305,12 +305,14 @@ namespace Wox
|
||||
private void OnWinRPressed()
|
||||
{
|
||||
ShowWox(false);
|
||||
if (tbQuery.Text != ">")
|
||||
if (!tbQuery.Text.StartsWith(">"))
|
||||
{
|
||||
resultCtrl.Clear();
|
||||
ChangeQuery(">");
|
||||
}
|
||||
tbQuery.CaretIndex = tbQuery.Text.Length;
|
||||
tbQuery.SelectionStart = 1;
|
||||
tbQuery.SelectionLength = tbQuery.Text.Length - 1;
|
||||
}
|
||||
|
||||
private void updateCmdMode()
|
||||
@ -506,6 +508,21 @@ namespace Wox
|
||||
|
||||
#endregion
|
||||
|
||||
public bool ShellRun(string cmd)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(cmd))
|
||||
throw new ArgumentNullException();
|
||||
|
||||
Wox.Infrastructure.WindowsShellRun.Start(cmd);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ShowMsg("Could not start " + cmd, ex.Message, null);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -51,6 +51,7 @@ namespace Wox.PluginLoader
|
||||
})),
|
||||
StartLoadingBar = () => App.Window.Dispatcher.Invoke(new Action(() => App.Window.StartLoadingBar())),
|
||||
StopLoadingBar = () => App.Window.Dispatcher.Invoke(new Action(() => App.Window.StopLoadingBar())),
|
||||
ShellRun = (cmd) => (bool) App.Window.Dispatcher.Invoke(new Func<bool>(() => App.Window.ShellRun(cmd))),
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user