From 8b97914438192516c49181672fa6b0aa5abe61d2 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Thu, 12 Nov 2015 19:53:43 +0000 Subject: [PATCH] Fix web search icon part of #384 bug introduced in 38cc115c1f9e1efbb2256f6e88168493797adb5c --- .../Images/{websearch => }/google.png | Bin .../Images/{websearch => }/pictures.png | Bin .../Images/{websearch => }/wiki.png | Bin .../WebSearchSetting.xaml.cs | 18 +++++++++++------- .../Wox.Plugin.WebSearch/WebSearchStorage.cs | 6 +++--- .../Wox.Plugin.WebSearch.csproj | 18 +++++++----------- 6 files changed, 21 insertions(+), 21 deletions(-) rename Plugins/Wox.Plugin.WebSearch/Images/{websearch => }/google.png (100%) rename Plugins/Wox.Plugin.WebSearch/Images/{websearch => }/pictures.png (100%) rename Plugins/Wox.Plugin.WebSearch/Images/{websearch => }/wiki.png (100%) diff --git a/Plugins/Wox.Plugin.WebSearch/Images/websearch/google.png b/Plugins/Wox.Plugin.WebSearch/Images/google.png similarity index 100% rename from Plugins/Wox.Plugin.WebSearch/Images/websearch/google.png rename to Plugins/Wox.Plugin.WebSearch/Images/google.png diff --git a/Plugins/Wox.Plugin.WebSearch/Images/websearch/pictures.png b/Plugins/Wox.Plugin.WebSearch/Images/pictures.png similarity index 100% rename from Plugins/Wox.Plugin.WebSearch/Images/websearch/pictures.png rename to Plugins/Wox.Plugin.WebSearch/Images/pictures.png diff --git a/Plugins/Wox.Plugin.WebSearch/Images/websearch/wiki.png b/Plugins/Wox.Plugin.WebSearch/Images/wiki.png similarity index 100% rename from Plugins/Wox.Plugin.WebSearch/Images/websearch/wiki.png rename to Plugins/Wox.Plugin.WebSearch/Images/wiki.png diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs index 1c85340f67..4d8ba23014 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs @@ -11,7 +11,8 @@ namespace Wox.Plugin.WebSearch { public partial class WebSearchSetting : Window { - private string _defaultWebSearchImageDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Images\\websearch"); + private const string _imageDirectoryName = "Images"; + private string _pluginDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); private readonly WebSearchesSetting _settingWindow; private bool _isUpdate; private WebSearch _updateWebSearch; @@ -50,7 +51,7 @@ namespace Wox.Plugin.WebSearch private void ShowIcon(string path) { - imgIcon.Source = new BitmapImage(new Uri($"{_defaultWebSearchImageDirectory}\\{path}", UriKind.Absolute)); + imgIcon.Source = new BitmapImage(new Uri(Path.Combine(_pluginDirectory, path), UriKind.Absolute)); } private void BtnCancel_OnClick(object sender, RoutedEventArgs e) @@ -126,15 +127,15 @@ namespace Wox.Plugin.WebSearch private void BtnSelectIcon_OnClick(object sender, RoutedEventArgs e) { - if (!Directory.Exists(_defaultWebSearchImageDirectory)) + if (!Directory.Exists(_pluginDirectory)) { - _defaultWebSearchImageDirectory = + _pluginDirectory = Path.GetDirectoryName(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); } var dlg = new OpenFileDialog { - InitialDirectory = _defaultWebSearchImageDirectory, + InitialDirectory = Path.Combine(_pluginDirectory, _imageDirectoryName), Filter = "Image files (*.jpg, *.jpeg, *.gif, *.png, *.bmp) |*.jpg; *.jpeg; *.gif; *.png; *.bmp" }; @@ -142,8 +143,11 @@ namespace Wox.Plugin.WebSearch if (result == true) { string filename = dlg.FileName; - tbIconPath.Text = Path.GetFileName(filename); - ShowIcon(tbIconPath.Text); + if (filename != null) + { + tbIconPath.Text = Path.Combine(_imageDirectoryName, Path.GetFileName(filename)); + ShowIcon(tbIconPath.Text); + } } } } diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs index 2f6d92435a..fec8f937a4 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs @@ -41,7 +41,7 @@ namespace Wox.Plugin.WebSearch { Title = "Google", ActionKeyword = "g", - IconPath = @"google.png", + IconPath = @"Images\google.png", Url = "https://www.google.com/search?q={q}", Enabled = true }; @@ -52,7 +52,7 @@ namespace Wox.Plugin.WebSearch { Title = "Wikipedia", ActionKeyword = "wiki", - IconPath = @"wiki.png", + IconPath = @"Images\wiki.png", Url = "http://en.wikipedia.org/wiki/{q}", Enabled = true }; @@ -62,7 +62,7 @@ namespace Wox.Plugin.WebSearch { Title = "FindIcon", ActionKeyword = "findicon", - IconPath = @"pictures.png", + IconPath = @"Images\pictures.png", Url = "http://findicons.com/search/{q}", Enabled = true }; diff --git a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj index 9a450b0107..f2a5dd05bf 100644 --- a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj +++ b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj @@ -66,7 +66,13 @@ - + + PreserveNewest + + + PreserveNewest + + PreserveNewest @@ -114,16 +120,6 @@ PreserveNewest - - - PreserveNewest - - - - - PreserveNewest - -