Fix applicationDirectory issues and add plugin debuggerMode

This commit is contained in:
Yeechan Lu 2014-03-22 16:50:47 +08:00
parent 9d404b6679
commit 31bbf3cfd5
12 changed files with 37 additions and 13 deletions

View file

@ -11,7 +11,7 @@ namespace Wox.Infrastructure
[Serializable] [Serializable]
public class CommonStorage public class CommonStorage
{ {
private static string configPath = Directory.GetCurrentDirectory() + "\\config.json"; private static string configPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\config.json";
private static object locker = new object(); private static object locker = new object();
private static CommonStorage storage; private static CommonStorage storage;

View file

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Windows.Forms;
namespace Wox.Infrastructure.UserSettings namespace Wox.Infrastructure.UserSettings
{ {
@ -29,7 +30,7 @@ namespace Wox.Infrastructure.UserSettings
{ {
Title = "Google", Title = "Google",
ActionWord = "g", ActionWord = "g",
IconPath = Directory.GetCurrentDirectory() + @"\Images\websearch\google.png", IconPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\websearch\google.png",
Url = "https://www.google.com/search?q={q}", Url = "https://www.google.com/search?q={q}",
Enabled = true Enabled = true
}; };
@ -40,7 +41,7 @@ namespace Wox.Infrastructure.UserSettings
{ {
Title = "Wikipedia", Title = "Wikipedia",
ActionWord = "wiki", ActionWord = "wiki",
IconPath = Directory.GetCurrentDirectory() + @"\Images\websearch\wiki.png", IconPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\websearch\wiki.png",
Url = "http://en.wikipedia.org/wiki/{q}", Url = "http://en.wikipedia.org/wiki/{q}",
Enabled = true Enabled = true
}; };

View file

@ -27,7 +27,7 @@ namespace Wox.Plugin.System
{ {
Title = c.Name, Title = c.Name,
SubTitle = "Bookmark: " + c.Url, SubTitle = "Bookmark: " + c.Url,
IcoPath = Directory.GetCurrentDirectory() + @"\Images\bookmark.png", IcoPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\bookmark.png",
Score = 5, Score = 5,
Action = (e) => Action = (e) =>
{ {

View file

@ -12,7 +12,7 @@ namespace Wox.Plugin.System
public class CMD : BaseSystemPlugin public class CMD : BaseSystemPlugin
{ {
private Dictionary<string, int> cmdHistory = new Dictionary<string, int>(); private Dictionary<string, int> cmdHistory = new Dictionary<string, int>();
private string filePath = Directory.GetCurrentDirectory() + "\\CMDHistory.dat"; private string filePath = Path.GetDirectoryName(Application.ExecutablePath) + "\\CMDHistory.dat";
private PluginInitContext context; private PluginInitContext context;
protected override List<Result> QueryInternal(Query query) protected override List<Result> QueryInternal(Query query)

View file

@ -60,8 +60,8 @@ namespace Wox.UAC
public void RegisterInstaller() public void RegisterInstaller()
{ {
string filePath = Directory.GetCurrentDirectory() + "\\Wox.exe"; string filePath = Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Wox.exe");
string iconPath = Directory.GetCurrentDirectory() + "\\app.ico"; string iconPath = Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "app.ico");
SaveReg(filePath, ".wox", iconPath, true); SaveReg(filePath, ".wox", iconPath, true);
} }

View file

@ -54,6 +54,7 @@
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />

View file

@ -83,6 +83,11 @@ namespace Wox
return; return;
} }
if (e.Args.Length > 0 && e.Args[0].ToLower() == "plugindebugger")
{
var path = e.Args[1];
PluginLoader.Plugins.ActivatePluginDebugger(path);
}
window = new MainWindow(); window = new MainWindow();
if (e.Args.Length == 0 || e.Args[0].ToLower() != "hidestart") if (e.Args.Length == 0 || e.Args[0].ToLower() != "hidestart")

View file

@ -424,7 +424,7 @@ namespace Wox
{ {
var dict = new ResourceDictionary var dict = new ResourceDictionary
{ {
Source = new Uri(Path.Combine(Directory.GetCurrentDirectory(), "Themes\\" + themeName + ".xaml"), UriKind.Absolute) Source = new Uri(Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Themes\\" + themeName + ".xaml"), UriKind.Absolute)
}; };

View file

@ -13,7 +13,7 @@ namespace Wox.PluginLoader
{ {
public abstract class BasePluginLoader public abstract class BasePluginLoader
{ {
private static string PluginPath = AppDomain.CurrentDomain.BaseDirectory + "Plugins"; private static string PluginPath = Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Plugins");
private static string PluginConfigName = "plugin.json"; private static string PluginConfigName = "plugin.json";
protected static List<PluginMetadata> pluginMetadatas = new List<PluginMetadata>(); protected static List<PluginMetadata> pluginMetadatas = new List<PluginMetadata>();
public abstract List<PluginPair> LoadPlugin(); public abstract List<PluginPair> LoadPlugin();
@ -23,6 +23,12 @@ namespace Wox.PluginLoader
pluginMetadatas.Clear(); pluginMetadatas.Clear();
ParseSystemPlugins(); ParseSystemPlugins();
ParseThirdPartyPlugins(); ParseThirdPartyPlugins();
if (Plugins.DebuggerMode != null)
{
PluginMetadata metadata = GetMetadataFromJson(Plugins.DebuggerMode);
if (metadata != null) pluginMetadatas.Add(metadata);
}
} }
private static void ParseSystemPlugins() private static void ParseSystemPlugins()

View file

@ -12,6 +12,7 @@ namespace Wox.PluginLoader
{ {
public static class Plugins public static class Plugins
{ {
private static string debuggerMode = null;
private static List<PluginPair> plugins = new List<PluginPair>(); private static List<PluginPair> plugins = new List<PluginPair>();
public static void Init() public static void Init()
@ -68,5 +69,15 @@ namespace Wox.PluginLoader
return plugins.Any(o => o.Metadata.PluginType == PluginType.ThirdParty && o.Metadata.ActionKeyword == query.ActionName); return plugins.Any(o => o.Metadata.PluginType == PluginType.ThirdParty && o.Metadata.ActionKeyword == query.ActionName);
} }
public static void ActivatePluginDebugger(string path)
{
debuggerMode = path;
}
public static String DebuggerMode
{
get { return debuggerMode; }
}
} }
} }

View file

@ -47,7 +47,7 @@ namespace Wox.PluginLoader
private void SetPythonHome() private void SetPythonHome()
{ {
//Environment.SetEnvironmentVariable("PYTHONHOME",Path.Combine(Directory.GetCurrentDirectory(),"PythonHome")); //Environment.SetEnvironmentVariable("PYTHONHOME",Path.Combine(Path.GetDirectoryName(Application.ExecutablePath),"PythonHome"));
//PythonEngine.PythonHome = //PythonEngine.PythonHome =
//PythonEngine.ProgramName //PythonEngine.ProgramName
} }

View file

@ -139,7 +139,7 @@ namespace Wox
private List<string> LoadAvailableThemes() private List<string> LoadAvailableThemes()
{ {
string themePath = Directory.GetCurrentDirectory() + "\\Themes\\"; string themePath = Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Themes");
return Directory.GetFiles(themePath).Where(filePath => filePath.EndsWith(".xaml") && !filePath.EndsWith("Default.xaml")).ToList(); return Directory.GetFiles(themePath).Where(filePath => filePath.EndsWith(".xaml") && !filePath.EndsWith("Default.xaml")).ToList();
} }
@ -244,9 +244,9 @@ namespace Wox
IWshShortcut shortcut = (IWshShortcut)wshShell.CreateShortcut(woxLinkPath); IWshShortcut shortcut = (IWshShortcut)wshShell.CreateShortcut(woxLinkPath);
shortcut.TargetPath = Application.ExecutablePath; shortcut.TargetPath = Application.ExecutablePath;
shortcut.Arguments = "hideStart"; shortcut.Arguments = "hideStart";
shortcut.WorkingDirectory = Application.StartupPath; shortcut.WorkingDirectory = Path.GetDirectoryName(Application.ExecutablePath);
shortcut.Description = "Launch Wox"; shortcut.Description = "Launch Wox";
shortcut.IconLocation = Application.StartupPath + @"\App.ico"; shortcut.IconLocation = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "App.ico");
shortcut.Save(); shortcut.Save();
} }