Update WPM.

This commit is contained in:
qianlifeng
2014-03-22 11:21:21 +08:00
parent 25cedff47a
commit d4446b2605

View File

@@ -18,16 +18,17 @@ namespace Wox.Plugin.PluginManagement
public class WoxPluginResult public class WoxPluginResult
{ {
public string downloadUrl; public string actionkeyword;
public string download;
public string author; public string author;
public string description; public string description;
public string id; public string id;
public string language; public int star;
public int like;
public string name; public string name;
public string version;
public string website;
} }
public class Main : IPlugin public class Main : IPlugin
{ {
private static string PluginPath = AppDomain.CurrentDomain.BaseDirectory + "Plugins"; private static string PluginPath = AppDomain.CurrentDomain.BaseDirectory + "Plugins";
@@ -170,31 +171,37 @@ namespace Wox.Plugin.PluginManagement
IcoPath = "Images\\plugin.png", IcoPath = "Images\\plugin.png",
Action = e => Action = e =>
{ {
string folder = Path.Combine(Path.GetTempPath(), "WoxPluginDownload"); DialogResult result = MessageBox.Show("Are your sure to install " + r.name + " plugin",
if (!Directory.Exists(folder)) Directory.CreateDirectory(folder); "Install plugin", MessageBoxButtons.YesNo);
string filePath = Path.Combine(folder, Guid.NewGuid().ToString() + ".wox");
context.StartLoadingBar(); if (result == DialogResult.Yes)
ThreadPool.QueueUserWorkItem(delegate
{ {
using (WebClient Client = new WebClient()) string folder = Path.Combine(Path.GetTempPath(), "WoxPluginDownload");
if (!Directory.Exists(folder)) Directory.CreateDirectory(folder);
string filePath = Path.Combine(folder, Guid.NewGuid().ToString() + ".wox");
context.StartLoadingBar();
ThreadPool.QueueUserWorkItem(delegate
{ {
try using (WebClient Client = new WebClient())
{ {
Client.DownloadFile(r1.downloadUrl, filePath); try
context.InstallPlugin(filePath); {
context.ReloadPlugins(); Client.DownloadFile(r1.download, filePath);
context.InstallPlugin(filePath);
context.ReloadPlugins();
}
catch (Exception exception)
{
MessageBox.Show("download plugin " + r.name + "failed. " + exception.Message);
}
finally
{
context.StopLoadingBar();
}
} }
catch (Exception exception) });
{ }
MessageBox.Show("download plugin " + r.name + "failed. " + exception.Message);
}
finally
{
context.StopLoadingBar();
}
}
});
return false; return false;
} }
}); });