diff --git a/Plugins/Wox.Plugin.PluginManagement/Main.cs b/Plugins/Wox.Plugin.PluginManagement/Main.cs index c78f53bb72..697df3c739 100644 --- a/Plugins/Wox.Plugin.PluginManagement/Main.cs +++ b/Plugins/Wox.Plugin.PluginManagement/Main.cs @@ -182,7 +182,7 @@ namespace Wox.Plugin.PluginManagement { private void UnInstalledPlugins(PluginMetadata plugin) { string content = string.Format("Do you want to uninstall following plugin?\r\n\r\nName: {0}\r\nVersion: {1}\r\nAuthor: {2}", plugin.Name, plugin.Version, plugin.Author); if (MessageBox.Show(content, "Wox", MessageBoxButtons.YesNo) == DialogResult.Yes) { - File.Create(Path.Combine(plugin.PluginDirecotry, "NeedDelete.txt")).Close(); + File.Create(Path.Combine(plugin.PluginDirectory, "NeedDelete.txt")).Close(); MessageBox.Show("This plugin has been removed, restart Wox to take effect"); } } @@ -224,7 +224,7 @@ namespace Wox.Plugin.PluginManagement { try { metadata = JsonConvert.DeserializeObject(File.ReadAllText(configPath)); metadata.PluginType = PluginType.ThirdParty; - metadata.PluginDirecotry = pluginDirectory; + metadata.PluginDirectory = pluginDirectory; } catch (Exception) { string error = string.Format("Parse plugin config {0} failed: json format is not valid", configPath); diff --git a/Wox.Plugin.SystemPlugins/BaseSystemPlugin.cs b/Wox.Plugin.SystemPlugins/BaseSystemPlugin.cs index b9bc92c084..9e95d28c05 100644 --- a/Wox.Plugin.SystemPlugins/BaseSystemPlugin.cs +++ b/Wox.Plugin.SystemPlugins/BaseSystemPlugin.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.IO; using System.Linq; using Wox.Infrastructure.Storage.UserSettings; @@ -14,6 +15,19 @@ namespace Wox.Plugin.SystemPlugins public virtual string Description { get { return "System workflow"; } } public virtual string IcoPath { get { return null; } } + public string FullIcoPath + { + get + { + if (IcoPath.StartsWith("data:")) + { + return IcoPath; + } + + return Path.Combine(PluginDirectory, IcoPath); + } + } + protected abstract List QueryInternal(Query query); protected abstract void InitInternal(PluginInitContext context); diff --git a/Wox.Plugin.SystemPlugins/Sys.cs b/Wox.Plugin.SystemPlugins/Sys.cs index bf5720ee69..5d1360dc78 100644 --- a/Wox.Plugin.SystemPlugins/Sys.cs +++ b/Wox.Plugin.SystemPlugins/Sys.cs @@ -81,7 +81,7 @@ namespace Wox.Plugin.SystemPlugins IcoPath = "Images\\app.png", Action = (c) => { - context.CloseApp(); + context.API.CloseApp(); return true; } }); @@ -99,7 +99,7 @@ namespace Wox.Plugin.SystemPlugins Info.CreateNoWindow = true; Info.FileName = "cmd.exe"; Process.Start(Info); - context.CloseApp(); + context.API.CloseApp(); return true; } }); @@ -111,7 +111,7 @@ namespace Wox.Plugin.SystemPlugins IcoPath = "Images\\app.png", Action = (c) => { - context.OpenSettingDialog(); + context.API.OpenSettingDialog(); return true; } }); diff --git a/Wox.Plugin/PluginMetadata.cs b/Wox.Plugin/PluginMetadata.cs index 362659ff3a..9a566ecfbf 100644 --- a/Wox.Plugin/PluginMetadata.cs +++ b/Wox.Plugin/PluginMetadata.cs @@ -31,14 +31,27 @@ namespace Wox.Plugin public string ExecuteFilePath { - get { return Path.Combine(PluginDirecotry, ExecuteFileName); } + get { return Path.Combine(PluginDirectory, ExecuteFileName); } } public string ExecuteFileName { get; set; } - public string PluginDirecotry { get; set; } + public string PluginDirectory { get; set; } public string ActionKeyword { get; set; } public PluginType PluginType { get; set; } public string IcoPath { get; set; } + + public string FullIcoPath + { + get + { + if (IcoPath.StartsWith("data:")) + { + return IcoPath; + } + + return Path.Combine(PluginDirectory, IcoPath); + } + } } } diff --git a/Wox/Converters/ImagePathConverter.cs b/Wox/Converters/ImagePathConverter.cs index 8f97fe3eda..4468a3acd0 100644 --- a/Wox/Converters/ImagePathConverter.cs +++ b/Wox/Converters/ImagePathConverter.cs @@ -13,17 +13,12 @@ namespace Wox.Converters { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - if (value == null || value == DependencyProperty.UnsetValue) return null; - - string fullPath = value.ToString(); - - if (fullPath.StartsWith("data:", StringComparison.OrdinalIgnoreCase)) + if (value == null || value == DependencyProperty.UnsetValue) { - return new BitmapImage(new Uri(fullPath)); + return null; } - - return ImageLoader.Load(fullPath); + return ImageLoader.Load(value.ToString()); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) diff --git a/Wox/Helper/ImageLoader.cs b/Wox/Helper/ImageLoader.cs index a97d14ff26..bd01a230d6 100644 --- a/Wox/Helper/ImageLoader.cs +++ b/Wox/Helper/ImageLoader.cs @@ -55,28 +55,28 @@ namespace Wox.Helper public static ImageSource Load(string path) { - ImageSource img = null; - if (path == null) return null; + if (string.IsNullOrEmpty(path)) return null; if (imageCache.ContainsKey(path)) { return imageCache[path]; } + ImageSource img = null; string ext = Path.GetExtension(path).ToLower(); - string resolvedPath = string.Empty; - if (!string.IsNullOrEmpty(path) && path.Contains(":\\") && File.Exists(path)) + + if (path.StartsWith("data:", StringComparison.OrdinalIgnoreCase)) { - resolvedPath = path; + img = new BitmapImage(new Uri(path)); + } + else if (selfExts.Contains(ext)) + { + img = GetIcon(path); + } + else if (!string.IsNullOrEmpty(path) && imageExts.Contains(ext) && File.Exists(path)) + { + img = new BitmapImage(new Uri(path)); } - if (selfExts.Contains(ext)) - { - img = GetIcon(resolvedPath); - } - else if (!string.IsNullOrEmpty(resolvedPath) && imageExts.Contains(ext) && File.Exists(resolvedPath)) - { - img = new BitmapImage(new Uri(resolvedPath)); - } if (img != null) { diff --git a/Wox/Helper/PluginInstaller.cs b/Wox/Helper/PluginInstaller.cs index fee7004a4e..33e858b654 100644 --- a/Wox/Helper/PluginInstaller.cs +++ b/Wox/Helper/PluginInstaller.cs @@ -60,9 +60,9 @@ namespace Wox.Helper MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { - if (existingPlugin != null && Directory.Exists(existingPlugin.Metadata.PluginDirecotry)) + if (existingPlugin != null && Directory.Exists(existingPlugin.Metadata.PluginDirectory)) { - File.Create(Path.Combine(existingPlugin.Metadata.PluginDirecotry, "NeedDelete.txt")).Close(); + File.Create(Path.Combine(existingPlugin.Metadata.PluginDirectory, "NeedDelete.txt")).Close(); } UnZip(path, newPluginPath, true); @@ -106,7 +106,7 @@ namespace Wox.Helper { metadata = JsonConvert.DeserializeObject(File.ReadAllText(configPath)); metadata.PluginType = PluginType.ThirdParty; - metadata.PluginDirecotry = pluginDirectory; + metadata.PluginDirectory = pluginDirectory; } catch (Exception) { diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 1aa62b4505..d7838c267f 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -137,7 +137,7 @@ namespace Wox { results.ForEach(o => { - o.PluginDirectory = plugin.PluginDirecotry; + o.PluginDirectory = plugin.PluginDirectory; o.OriginQuery = query; }); OnUpdateResultView(results); diff --git a/Wox/PluginLoader/CSharpPluginLoader.cs b/Wox/PluginLoader/CSharpPluginLoader.cs index c23a4d1f16..2f53855174 100644 --- a/Wox/PluginLoader/CSharpPluginLoader.cs +++ b/Wox/PluginLoader/CSharpPluginLoader.cs @@ -32,7 +32,7 @@ namespace Wox.PluginLoader { var sys = pair.Plugin as BaseSystemPlugin; if (sys != null) { - sys.PluginDirectory = metadata.PluginDirecotry; + sys.PluginDirectory = metadata.PluginDirectory; } plugins.Add(pair); diff --git a/Wox/PluginLoader/PluginConfigLoader.cs b/Wox/PluginLoader/PluginConfigLoader.cs index 591af2143b..0f4ffcf217 100644 --- a/Wox/PluginLoader/PluginConfigLoader.cs +++ b/Wox/PluginLoader/PluginConfigLoader.cs @@ -40,7 +40,7 @@ namespace Wox.PluginLoader { PluginType = PluginType.System, ActionKeyword = "*", ExecuteFileName = "Wox.Plugin.SystemPlugins.dll", - PluginDirecotry = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) }); } @@ -71,7 +71,7 @@ namespace Wox.PluginLoader { try { metadata = JsonConvert.DeserializeObject(File.ReadAllText(configPath)); metadata.PluginType = PluginType.ThirdParty; - metadata.PluginDirecotry = pluginDirectory; + metadata.PluginDirectory = pluginDirectory; } catch (Exception) { string error = string.Format("Parse plugin config {0} failed: json format is not valid", configPath); diff --git a/Wox/SettingWindow.xaml b/Wox/SettingWindow.xaml index 9a29d3f411..1e3b66fb3c 100644 --- a/Wox/SettingWindow.xaml +++ b/Wox/SettingWindow.xaml @@ -12,12 +12,12 @@ WindowStartupLocation="CenterScreen" Height="600" Width="800"> - + @@ -38,62 +38,49 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - + + + + @@ -140,7 +127,10 @@ - + + + + diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs index 4044f5ae20..1579c0f2e6 100644 --- a/Wox/SettingWindow.xaml.cs +++ b/Wox/SettingWindow.xaml.cs @@ -22,6 +22,7 @@ using Application = System.Windows.Forms.Application; using File = System.IO.File; using MessageBox = System.Windows.MessageBox; using System.Windows.Data; +using Label = System.Windows.Forms.Label; namespace Wox { @@ -32,11 +33,6 @@ namespace Wox bool settingsLoaded = false; private Dictionary featureControls = new Dictionary(); - public SettingWindow() - { - InitializeComponent(); - } - public SettingWindow(MainWindow mainWindow) { this.MainWindow = mainWindow; @@ -419,14 +415,7 @@ namespace Wox pluginSubTitle.Text = pair.Metadata.Description; pluginId = pair.Metadata.ID; SyntaxSugars.CallOrRescueDefault( - () => - pluginIcon.Source = (ImageSource)new ImagePathConverter().Convert( - new object[] - { - pair.Metadata.IcoPath, - pair.Metadata.PluginDirecotry - }, null, null, - null)); + () => pluginIcon.Source = ImageLoader.Load(pair.Metadata.FullIcoPath)); } else { @@ -443,13 +432,7 @@ namespace Wox tbOpenPluginDirecoty.Visibility = Visibility.Collapsed; pluginActionKeywordTitle.Visibility = Visibility.Collapsed; pluginTitle.Cursor = Cursors.Arrow; - SyntaxSugars.CallOrRescueDefault( - () => - pluginIcon.Source = (ImageSource)new ImagePathConverter().Convert(new object[] - { - sys.IcoPath, - sys.PluginDirectory - }, null, null, null)); + SyntaxSugars.CallOrRescueDefault(() => pluginIcon.Source = ImageLoader.Load(sys.FullIcoPath)); } } @@ -565,7 +548,7 @@ namespace Wox { try { - Process.Start(pair.Metadata.PluginDirecotry); + Process.Start(pair.Metadata.PluginDirectory); } catch { } @@ -573,5 +556,15 @@ namespace Wox } } } + + private void tbMorePlugins_MouseUp(object sender, MouseButtonEventArgs e) + { + Process.Start("http://www.getwox.com/plugin"); + } + + private void tbMoreThemes_MouseUp(object sender, MouseButtonEventArgs e) + { + Process.Start("http://www.getwox.com/theme"); + } } }