From d4446b2605f04ba0fb004ecb97a4230b1058aa20 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Sat, 22 Mar 2014 11:21:21 +0800 Subject: [PATCH] Update WPM. --- Plugins/Wox.Plugin.PluginManagement/Main.cs | 55 ++++++++++++--------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/Plugins/Wox.Plugin.PluginManagement/Main.cs b/Plugins/Wox.Plugin.PluginManagement/Main.cs index 8294d07dad..6d62c78d8b 100644 --- a/Plugins/Wox.Plugin.PluginManagement/Main.cs +++ b/Plugins/Wox.Plugin.PluginManagement/Main.cs @@ -18,16 +18,17 @@ namespace Wox.Plugin.PluginManagement public class WoxPluginResult { - public string downloadUrl; + public string actionkeyword; + public string download; public string author; public string description; public string id; - public string language; - public int like; + public int star; public string name; + public string version; + public string website; } - public class Main : IPlugin { private static string PluginPath = AppDomain.CurrentDomain.BaseDirectory + "Plugins"; @@ -170,31 +171,37 @@ namespace Wox.Plugin.PluginManagement IcoPath = "Images\\plugin.png", Action = e => { - string folder = Path.Combine(Path.GetTempPath(), "WoxPluginDownload"); - if (!Directory.Exists(folder)) Directory.CreateDirectory(folder); - string filePath = Path.Combine(folder, Guid.NewGuid().ToString() + ".wox"); + DialogResult result = MessageBox.Show("Are your sure to install " + r.name + " plugin", + "Install plugin", MessageBoxButtons.YesNo); - context.StartLoadingBar(); - ThreadPool.QueueUserWorkItem(delegate + if (result == DialogResult.Yes) { - 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); - context.InstallPlugin(filePath); - context.ReloadPlugins(); + try + { + 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; } });