From ae42c4df164da5b467a946e47287e932dc649092 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Wed, 6 Jan 2016 21:18:36 +0000 Subject: [PATCH 01/11] Fix accident bug --- Wox/MainWindow.xaml.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 466ef5d705..5ff2dd37a0 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -831,7 +831,6 @@ namespace Wox private void UpdateResultView(List list, PluginMetadata metadata, Query originQuery) { - Thread.Sleep(3000); _queryHasReturn = true; progressBar.Dispatcher.Invoke(new Action(StopProgress)); From 0daa3a8f57c11f0f66c31f10ea10609c028dd91d Mon Sep 17 00:00:00 2001 From: bao-qian Date: Wed, 6 Jan 2016 21:34:42 +0000 Subject: [PATCH 02/11] ReSharper: remove redundant code --- Plugins/Wox.Plugin.CMD/CMD.cs | 16 ++--- Plugins/Wox.Plugin.Caculator/Calculator.cs | 11 ++-- .../Wox.Plugin.ControlPanel/ControlPanel.cs | 2 +- .../ControlPanelList.cs | 16 ++--- .../Everything/EverythingAPI.cs | 2 +- Plugins/Wox.Plugin.Everything/Main.cs | 22 ++++--- Plugins/Wox.Plugin.Folder/FolderLink.cs | 2 +- Plugins/Wox.Plugin.Folder/FolderPlugin.cs | 2 +- .../FolderPluginSettings.xaml.cs | 26 ++++---- .../PluginIndicator.cs | 4 +- .../AddProgramSource.xaml.cs | 35 +++++------ .../Wox.Plugin.Program/FileChangeWatcher.cs | 2 +- Plugins/Wox.Plugin.Program/IProgramSource.cs | 2 +- Plugins/Wox.Plugin.Program/Program.cs | 6 +- .../Wox.Plugin.Program/ProgramSetting.xaml.cs | 14 ++--- Plugins/Wox.Plugin.Program/ProgramSource.cs | 2 +- .../ProgramSources/AppPathsProgramSource.cs | 9 ++- .../CommonStartMenuProgramSource.cs | 5 +- .../ProgramSources/FileSystemProgramSource.cs | 4 +- .../UserStartMenuProgramSource.cs | 5 +- Plugins/Wox.Plugin.Program/Programs.cs | 24 ++++---- .../StringEmptyConverter.cs | 5 +- Plugins/Wox.Plugin.Sys/Sys.cs | 20 +++--- Plugins/Wox.Plugin.Sys/SysSettings.xaml.cs | 2 +- .../WebSearchSetting.xaml.cs | 2 +- .../WebSearchesSetting.xaml.cs | 6 +- Wox.Core/Plugin/CSharpPluginLoader.cs | 4 +- Wox.Core/Plugin/JsonRPCPlugin.cs | 11 ++-- Wox.Core/Plugin/JsonRPCPluginLoader.cs | 2 +- Wox.Core/Plugin/PluginConfig.cs | 7 ++- Wox.Core/Plugin/PluginInstaller.cs | 8 +-- Wox.Core/Plugin/PythonPlugin.cs | 4 +- Wox.Core/Theme/Theme.cs | 8 +-- Wox.Core/Updater/SemanticVersion.cs | 2 +- Wox.Core/Updater/UpdaterManager.cs | 6 +- Wox.Core/Updater/WoxUpdateSource.cs | 18 +++--- Wox.Core/UserSettings/UserSettingStorage.cs | 2 +- Wox.Core/i18n/AvailableLanguages.cs | 2 +- Wox.Core/i18n/Internationalization.cs | 6 +- Wox.CrashReporter/ReportWindow.xaml.cs | 4 +- Wox.Infrastructure/FuzzyMatcher.cs | 12 ++-- Wox.Infrastructure/Hotkey/HotkeyModel.cs | 2 +- Wox.Infrastructure/Hotkey/KeyEvent.cs | 2 +- Wox.Infrastructure/Http/HttpRequest.cs | 5 +- Wox.Infrastructure/Logger/Log.cs | 1 - Wox.Infrastructure/Storage/BinaryStorage.cs | 2 +- Wox.Test/FuzzyMatcherTest.cs | 9 +-- Wox.UpdateFeedGenerator/ConfigStorage.cs | 2 +- Wox.UpdateFeedGenerator/FileInfoEx.cs | 3 +- .../FileSystemEnumerator.cs | 4 +- Wox/ActionKeywords.xaml.cs | 1 - .../StringNullOrEmptyToVisibilityConverter.cs | 2 - Wox/CustomQueryHotkeySetting.xaml.cs | 2 +- Wox/Helper/DWMDropShadow.cs | 4 +- Wox/Helper/ErrorReporting.cs | 4 +- Wox/Helper/SingleInstance.cs | 7 ++- Wox/Helper/WallpaperPathRetrieval.cs | 2 +- Wox/ImageLoader/ImageCacheStroage.cs | 2 +- Wox/ImageLoader/ImageLoader.cs | 5 +- Wox/MainWindow.xaml.cs | 61 +++++++++++-------- Wox/Msg.xaml.cs | 6 +- Wox/Properties/AssemblyInfo.cs | 3 +- Wox/SettingWindow.xaml.cs | 41 ++++++------- Wox/Storage/QueryHistoryStorage.cs | 4 +- Wox/Storage/TopMostRecordStorage.cs | 13 ++-- 65 files changed, 279 insertions(+), 250 deletions(-) diff --git a/Plugins/Wox.Plugin.CMD/CMD.cs b/Plugins/Wox.Plugin.CMD/CMD.cs index eef2564f6a..deeca82c5a 100644 --- a/Plugins/Wox.Plugin.CMD/CMD.cs +++ b/Plugins/Wox.Plugin.CMD/CMD.cs @@ -59,11 +59,11 @@ namespace Wox.Plugin.CMD !results.Any(p => o.Equals(p.Title, StringComparison.OrdinalIgnoreCase)) && !results.Any(p => o.Equals(p.Title, StringComparison.OrdinalIgnoreCase))).ToList(); autocomplete.Sort(); - results.AddRange(autocomplete.ConvertAll(m => new Result() + results.AddRange(autocomplete.ConvertAll(m => new Result { Title = m, IcoPath = "Images/cmd.png", - Action = (c) => + Action = c => { ExecuteCMD(m); return true; @@ -96,7 +96,7 @@ namespace Wox.Plugin.CMD Title = m.Key, SubTitle = string.Format(context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value), IcoPath = "Images/cmd.png", - Action = (c) => + Action = c => { ExecuteCMD(m.Key); return true; @@ -115,7 +115,7 @@ namespace Wox.Plugin.CMD Score = 5000, SubTitle = context.API.GetTranslation("wox_plugin_cmd_execute_through_shell"), IcoPath = "Images/cmd.png", - Action = (c) => + Action = c => { ExecuteCMD(cmd); return true; @@ -133,7 +133,7 @@ namespace Wox.Plugin.CMD Title = m.Key, SubTitle = string.Format(context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value), IcoPath = "Images/cmd.png", - Action = (c) => + Action = c => { ExecuteCMD(m.Key); return true; @@ -219,9 +219,9 @@ namespace Wox.Plugin.CMD public List LoadContextMenus(Result selectedResult) { - return new List() - { - new Result() + return new List + { + new Result { Title = context.API.GetTranslation("wox_plugin_cmd_run_as_administrator"), Action = c => diff --git a/Plugins/Wox.Plugin.Caculator/Calculator.cs b/Plugins/Wox.Plugin.Caculator/Calculator.cs index 0f6acdfcce..6dbfb79b53 100644 --- a/Plugins/Wox.Plugin.Caculator/Calculator.cs +++ b/Plugins/Wox.Plugin.Caculator/Calculator.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.IO; using System.Reflection; +using System.Runtime.InteropServices; using System.Text.RegularExpressions; using System.Windows; using YAMP; @@ -18,7 +19,7 @@ namespace Wox.Plugin.Caculator @"[ei]|[0-9]|[\+\-\*\/\^\., ""]|[\(\)\|\!\[\]]" + @")+$", RegexOptions.Compiled); private static Regex regBrackets = new Regex(@"[\(\)\[\]]", RegexOptions.Compiled); - private static ParseContext yampContext = null; + private static ParseContext yampContext; private PluginInitContext context { get; set; } static Calculator() @@ -39,19 +40,21 @@ namespace Wox.Plugin.Caculator var result = yampContext.Run(query.Search); if (result.Output != null && !string.IsNullOrEmpty(result.Result)) { - return new List() { new Result() { + return new List + { new Result + { Title = result.Result, IcoPath = "Images/calculator.png", Score = 300, SubTitle = "Copy this number to the clipboard", - Action = (c) => + Action = c => { try { Clipboard.SetText(result.Result); return true; } - catch (System.Runtime.InteropServices.ExternalException e) + catch (ExternalException e) { MessageBox.Show("Copy failed, please try later"); return false; diff --git a/Plugins/Wox.Plugin.ControlPanel/ControlPanel.cs b/Plugins/Wox.Plugin.ControlPanel/ControlPanel.cs index e8d64fd7c5..84e8d0b334 100644 --- a/Plugins/Wox.Plugin.ControlPanel/ControlPanel.cs +++ b/Plugins/Wox.Plugin.ControlPanel/ControlPanel.cs @@ -47,7 +47,7 @@ namespace Wox.Plugin.ControlPanel var fuzzyMather = FuzzyMatcher.Create(myQuery); if (MatchProgram(item, fuzzyMather)) { - results.Add(new Result() + results.Add(new Result { Title = item.LocalizedString, SubTitle = item.InfoTip, diff --git a/Plugins/Wox.Plugin.ControlPanel/ControlPanelList.cs b/Plugins/Wox.Plugin.ControlPanel/ControlPanelList.cs index 68f11a52c8..7b664f1fc7 100644 --- a/Plugins/Wox.Plugin.ControlPanel/ControlPanelList.cs +++ b/Plugins/Wox.Plugin.ControlPanel/ControlPanelList.cs @@ -123,7 +123,7 @@ namespace Wox.Plugin.ControlPanel if (currentKey.GetValue("LocalizedString") != null) { - localizedStringRaw = currentKey.GetValue("LocalizedString").ToString().Split(new string[] { ",-" }, StringSplitOptions.None); + localizedStringRaw = currentKey.GetValue("LocalizedString").ToString().Split(new[] { ",-" }, StringSplitOptions.None); if (localizedStringRaw.Length > 1) { @@ -184,7 +184,7 @@ namespace Wox.Plugin.ControlPanel if (currentKey.GetValue("InfoTip") != null) { - infoTipRaw = currentKey.GetValue("InfoTip").ToString().Split(new string[] { ",-" }, StringSplitOptions.None); + infoTipRaw = currentKey.GetValue("InfoTip").ToString().Split(new[] { ",-" }, StringSplitOptions.None); if (infoTipRaw.Length == 2) { @@ -229,7 +229,7 @@ namespace Wox.Plugin.ControlPanel { if (currentKey.OpenSubKey("DefaultIcon").GetValue(null) != null) { - iconString = new List(currentKey.OpenSubKey("DefaultIcon").GetValue(null).ToString().Split(new char[] { ',' }, 2)); + iconString = new List(currentKey.OpenSubKey("DefaultIcon").GetValue(null).ToString().Split(new[] { ',' }, 2)); if (iconString[0][0] == '@') { iconString[0] = iconString[0].Substring(1); @@ -247,7 +247,7 @@ namespace Wox.Plugin.ControlPanel if (iconPtr == IntPtr.Zero) { defaultIconPtr = IntPtr.Zero; - EnumResourceNamesWithID(dataFilePointer, GROUP_ICON, new EnumResNameDelegate(EnumRes), IntPtr.Zero); //Iterate through resources. + EnumResourceNamesWithID(dataFilePointer, GROUP_ICON, EnumRes, IntPtr.Zero); //Iterate through resources. iconPtr = LoadImage(dataFilePointer, defaultIconPtr, 1, iconSize, iconSize, 0); } @@ -312,16 +312,16 @@ namespace Wox.Plugin.ControlPanel private static uint GET_RESOURCE_ID(IntPtr value) { - if (IS_INTRESOURCE(value) == true) + if (IS_INTRESOURCE(value)) return (uint)value; - throw new System.NotSupportedException("value is not an ID!"); + throw new NotSupportedException("value is not an ID!"); } private static string GET_RESOURCE_NAME(IntPtr value) { - if (IS_INTRESOURCE(value) == true) + if (IS_INTRESOURCE(value)) return value.ToString(); - return Marshal.PtrToStringUni((IntPtr)value); + return Marshal.PtrToStringUni(value); } private static bool EnumRes(IntPtr hModule, IntPtr lpszType, IntPtr lpszName, IntPtr lParam) diff --git a/Plugins/Wox.Plugin.Everything/Everything/EverythingAPI.cs b/Plugins/Wox.Plugin.Everything/Everything/EverythingAPI.cs index 2d7a8e01b3..e6d688a012 100644 --- a/Plugins/Wox.Plugin.Everything/Everything/EverythingAPI.cs +++ b/Plugins/Wox.Plugin.Everything/Everything/EverythingAPI.cs @@ -233,7 +233,7 @@ namespace Wox.Plugin.Everything.Everything { Everything_GetResultFullPathName(idx, buffer, bufferSize); - var result = new SearchResult() { FullPath = buffer.ToString() }; + var result = new SearchResult { FullPath = buffer.ToString() }; if (Everything_IsFolderResult(idx)) result.Type = ResultType.Folder; else if (Everything_IsFileResult(idx)) diff --git a/Plugins/Wox.Plugin.Everything/Main.cs b/Plugins/Wox.Plugin.Everything/Main.cs index c65ccec8e4..dffa1ea87a 100644 --- a/Plugins/Wox.Plugin.Everything/Main.cs +++ b/Plugins/Wox.Plugin.Everything/Main.cs @@ -4,7 +4,9 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; +using System.Runtime.InteropServices; using System.ServiceProcess; +using System.Windows; using Wox.Plugin.Everything.Everything; namespace Wox.Plugin.Everything @@ -13,8 +15,8 @@ namespace Wox.Plugin.Everything { PluginInitContext context; EverythingAPI api = new EverythingAPI(); - private static List imageExts = new List() { ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".ico" }; - private static List executableExts = new List() { ".exe" }; + private static List imageExts = new List { ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".ico" }; + private static List executableExts = new List { ".exe" }; public List Query(Query query) { @@ -34,7 +36,7 @@ namespace Wox.Plugin.Everything r.Title = "Uninstall Everything"; r.SubTitle = "You need to uninstall everything service if you can not move/delete wox folder"; r.IcoPath = "Images\\find.png"; - r.Action = (c) => + r.Action = c => { UnInstallEverything(); return true; @@ -53,7 +55,7 @@ namespace Wox.Plugin.Everything r.Title = Path.GetFileName(path); r.SubTitle = path; r.IcoPath = GetIconPath(s); - r.Action = (c) => + r.Action = c => { context.API.HideApp(); Process.Start(new ProcessStartInfo @@ -70,7 +72,7 @@ namespace Wox.Plugin.Everything catch (IPCErrorException) { StartEverything(); - results.Add(new Result() + results.Add(new Result { Title = context.API.GetTranslation("wox_plugin_everything_is_not_running"), IcoPath = "Images\\warning.png" @@ -78,13 +80,13 @@ namespace Wox.Plugin.Everything } catch (Exception e) { - results.Add(new Result() + results.Add(new Result { Title = context.API.GetTranslation("wox_plugin_everything_query_error"), SubTitle = e.Message, Action = _ => { - System.Windows.Clipboard.SetText(e.Message + "\r\n" + e.StackTrace); + Clipboard.SetText(e.Message + "\r\n" + e.StackTrace); context.API.ShowMsg(context.API.GetTranslation("wox_plugin_everything_copied"), null, string.Empty); return false; }, @@ -120,13 +122,13 @@ namespace Wox.Plugin.Everything return "Images\\file.png"; } - [System.Runtime.InteropServices.DllImport("kernel32.dll")] + [DllImport("kernel32.dll")] private static extern int LoadLibrary(string name); private List GetDefaultContextMenu() { List defaultContextMenus = new List(); - ContextMenu openFolderContextMenu = new ContextMenu() + ContextMenu openFolderContextMenu = new ContextMenu { Name = context.API.GetTranslation("wox_plugin_everything_open_containing_folder"), Command = "explorer.exe", @@ -282,7 +284,7 @@ namespace Wox.Plugin.Everything foreach (ContextMenu contextMenu in availableContextMenus) { var menu = contextMenu; - contextMenus.Add(new Result() + contextMenus.Add(new Result { Title = contextMenu.Name, Action = _ => diff --git a/Plugins/Wox.Plugin.Folder/FolderLink.cs b/Plugins/Wox.Plugin.Folder/FolderLink.cs index 4f7fb440c4..2a09ec1fdc 100644 --- a/Plugins/Wox.Plugin.Folder/FolderLink.cs +++ b/Plugins/Wox.Plugin.Folder/FolderLink.cs @@ -12,7 +12,7 @@ namespace Wox.Plugin.Folder public string Nickname { - get { return Path.Split(new char[] { System.IO.Path.DirectorySeparatorChar }, StringSplitOptions.None).Last(); } + get { return Path.Split(new[] { System.IO.Path.DirectorySeparatorChar }, StringSplitOptions.None).Last(); } } } } diff --git a/Plugins/Wox.Plugin.Folder/FolderPlugin.cs b/Plugins/Wox.Plugin.Folder/FolderPlugin.cs index 638ac756f5..e31e701c38 100644 --- a/Plugins/Wox.Plugin.Folder/FolderPlugin.cs +++ b/Plugins/Wox.Plugin.Folder/FolderPlugin.cs @@ -51,7 +51,7 @@ namespace Wox.Plugin.Folder { List contextMenus = new List(); string folderPath = ((FolderLink) targetResult.ContextData).Path; - contextMenus.Add(new Result() + contextMenus.Add(new Result { Title = "Copy to this folder", IcoPath = "Images/copy.png", diff --git a/Plugins/Wox.Plugin.Folder/FolderPluginSettings.xaml.cs b/Plugins/Wox.Plugin.Folder/FolderPluginSettings.xaml.cs index 26b99f1676..9281c83715 100644 --- a/Plugins/Wox.Plugin.Folder/FolderPluginSettings.xaml.cs +++ b/Plugins/Wox.Plugin.Folder/FolderPluginSettings.xaml.cs @@ -1,7 +1,11 @@ using System.Collections.Generic; +using System.IO; using System.Linq; using System.Windows; using System.Windows.Forms; +using DataFormats = System.Windows.DataFormats; +using DragDropEffects = System.Windows.DragDropEffects; +using DragEventArgs = System.Windows.DragEventArgs; using MessageBox = System.Windows.MessageBox; using UserControl = System.Windows.Controls.UserControl; @@ -66,10 +70,10 @@ namespace Wox.Plugin.Folder private void btnAdd_Click(object sender, RoutedEventArgs e) { - var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog(); - if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) + var folderBrowserDialog = new FolderBrowserDialog(); + if (folderBrowserDialog.ShowDialog() == DialogResult.OK) { - var newFolder = new FolderLink() + var newFolder = new FolderLink { Path = folderBrowserDialog.SelectedPath }; @@ -86,9 +90,9 @@ namespace Wox.Plugin.Folder lbxFolders.Items.Refresh(); } - private void lbxFolders_Drop(object sender, System.Windows.DragEventArgs e) + private void lbxFolders_Drop(object sender, DragEventArgs e) { - string[] files = (string[])e.Data.GetData(System.Windows.DataFormats.FileDrop); + string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); if (files != null && files.Count() > 0) { @@ -99,9 +103,9 @@ namespace Wox.Plugin.Folder foreach (string s in files) { - if (System.IO.Directory.Exists(s) == true) + if (Directory.Exists(s)) { - var newFolder = new FolderLink() + var newFolder = new FolderLink { Path = s }; @@ -115,15 +119,15 @@ namespace Wox.Plugin.Folder } } - private void lbxFolders_DragEnter(object sender, System.Windows.DragEventArgs e) + private void lbxFolders_DragEnter(object sender, DragEventArgs e) { - if (e.Data.GetDataPresent(System.Windows.DataFormats.FileDrop)) + if (e.Data.GetDataPresent(DataFormats.FileDrop)) { - e.Effects = System.Windows.DragDropEffects.Link; + e.Effects = DragDropEffects.Link; } else { - e.Effects = System.Windows.DragDropEffects.None; + e.Effects = DragDropEffects.None; } } } diff --git a/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs b/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs index f7f518889c..151df63616 100644 --- a/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs +++ b/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs @@ -25,11 +25,11 @@ namespace Wox.Plugin.PluginIndicator SubTitle = $"Activate {metadata.Name} plugin", Score = 100, IcoPath = metadata.FullIcoPath, - Action = (c) => + Action = c => { context.API.ChangeQuery($"{keyword}{Plugin.Query.TermSeperater}"); return false; - }, + } }; return results.ToList(); } diff --git a/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs b/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs index 45fa4f44c4..c1dff38583 100644 --- a/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs +++ b/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs @@ -1,4 +1,5 @@ using System.Windows; +using System.Windows.Forms; namespace Wox.Plugin.Program { @@ -16,51 +17,51 @@ namespace Wox.Plugin.Program public AddProgramSource(ProgramSource edit) : this() { - this._editing = edit; - this.Directory.Text = this._editing.Location; - this.MaxDepth.Text = this._editing.MaxDepth.ToString(); - this.Suffixes.Text = this._editing.Suffixes; + _editing = edit; + Directory.Text = _editing.Location; + MaxDepth.Text = _editing.MaxDepth.ToString(); + Suffixes.Text = _editing.Suffixes; } private void BrowseButton_Click(object sender, RoutedEventArgs e) { - var dialog = new System.Windows.Forms.FolderBrowserDialog(); - System.Windows.Forms.DialogResult result = dialog.ShowDialog(); + var dialog = new FolderBrowserDialog(); + DialogResult result = dialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { - this.Directory.Text = dialog.SelectedPath; + Directory.Text = dialog.SelectedPath; } } private void ButtonAdd_OnClick(object sender, RoutedEventArgs e) { int max; - if(!int.TryParse(this.MaxDepth.Text, out max)) + if(!int.TryParse(MaxDepth.Text, out max)) { max = -1; } - if(this._editing == null) + if(_editing == null) { - ProgramStorage.Instance.ProgramSources.Add(new ProgramSource() + ProgramStorage.Instance.ProgramSources.Add(new ProgramSource { - Location = this.Directory.Text, + Location = Directory.Text, MaxDepth = max, - Suffixes = this.Suffixes.Text, + Suffixes = Suffixes.Text, Type = "FileSystemProgramSource", Enabled = true }); } else { - this._editing.Location = this.Directory.Text; - this._editing.MaxDepth = max; - this._editing.Suffixes = this.Suffixes.Text; + _editing.Location = Directory.Text; + _editing.MaxDepth = max; + _editing.Suffixes = Suffixes.Text; } ProgramStorage.Instance.Save(); - this.DialogResult = true; - this.Close(); + DialogResult = true; + Close(); } } } diff --git a/Plugins/Wox.Plugin.Program/FileChangeWatcher.cs b/Plugins/Wox.Plugin.Program/FileChangeWatcher.cs index 6119abdb15..255a61d9a2 100644 --- a/Plugins/Wox.Plugin.Program/FileChangeWatcher.cs +++ b/Plugins/Wox.Plugin.Program/FileChangeWatcher.cs @@ -7,7 +7,7 @@ namespace Wox.Plugin.Program { internal class FileChangeWatcher { - private static bool isIndexing = false; + private static bool isIndexing; private static List watchedPath = new List(); public static void AddWatch(string path, bool includingSubDirectory = true) diff --git a/Plugins/Wox.Plugin.Program/IProgramSource.cs b/Plugins/Wox.Plugin.Program/IProgramSource.cs index 7f4eea517f..2e8929a73d 100644 --- a/Plugins/Wox.Plugin.Program/IProgramSource.cs +++ b/Plugins/Wox.Plugin.Program/IProgramSource.cs @@ -23,7 +23,7 @@ namespace Wox.Plugin.Program protected Program CreateEntry(string file) { - var p = new Program() + var p = new Program { Title = Path.GetFileNameWithoutExtension(file), IcoPath = file, diff --git a/Plugins/Wox.Plugin.Program/Program.cs b/Plugins/Wox.Plugin.Program/Program.cs index 10257acdbe..608da9990a 100644 --- a/Plugins/Wox.Plugin.Program/Program.cs +++ b/Plugins/Wox.Plugin.Program/Program.cs @@ -1,4 +1,6 @@ using System; +using System.Text.RegularExpressions; +using System.Threading; using Wox.Infrastructure; namespace Wox.Plugin.Program @@ -6,7 +8,7 @@ namespace Wox.Plugin.Program [Serializable] public class Program { - private static readonly global::System.Text.RegularExpressions.Regex AbbrRegexp = new global::System.Text.RegularExpressions.Regex("[^A-Z0-9]", global::System.Text.RegularExpressions.RegexOptions.Compiled); + private static readonly Regex AbbrRegexp = new Regex("[^A-Z0-9]", RegexOptions.Compiled); private string m_Title; public string Title { @@ -19,7 +21,7 @@ namespace Wox.Plugin.Program m_Title = value; string pinyin = m_Title.Unidecode(); PinyinTitle = pinyin; - AbbrTitle = AbbrRegexp.Replace(global::System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(pinyin), ""); + AbbrTitle = AbbrRegexp.Replace(Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(pinyin), ""); if (AbbrTitle.Length < 2) AbbrTitle = null; } } diff --git a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs index 3d4b50a89b..35348d836a 100644 --- a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs +++ b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs @@ -1,4 +1,4 @@ -using System; +using System.IO; using System.Threading; using System.Windows; using System.Windows.Controls; @@ -31,9 +31,9 @@ namespace Wox.Plugin.Program programSourceView.Items.Refresh(); ThreadPool.QueueUserWorkItem(t => { - Dispatcher.Invoke(new Action(() => { indexingPanel.Visibility = Visibility.Visible; })); + Dispatcher.Invoke(() => { indexingPanel.Visibility = Visibility.Visible; }); Programs.IndexPrograms(); - Dispatcher.Invoke(new Action(() => { indexingPanel.Visibility = Visibility.Hidden; })); + Dispatcher.Invoke(() => { indexingPanel.Visibility = Visibility.Hidden; }); }); } @@ -42,7 +42,7 @@ namespace Wox.Plugin.Program var add = new AddProgramSource(); if(add.ShowDialog() ?? false) { - this.ReIndexing(); + ReIndexing(); } } @@ -75,7 +75,7 @@ namespace Wox.Plugin.Program var add = new AddProgramSource(selectedProgramSource); if (add.ShowDialog() ?? false) { - this.ReIndexing(); + ReIndexing(); } } else @@ -116,9 +116,9 @@ namespace Wox.Plugin.Program { foreach (string s in files) { - if (System.IO.Directory.Exists(s) == true) + if (Directory.Exists(s)) { - ProgramStorage.Instance.ProgramSources.Add(new ProgramSource() + ProgramStorage.Instance.ProgramSources.Add(new ProgramSource { Location = s, Type = "FileSystemProgramSource", diff --git a/Plugins/Wox.Plugin.Program/ProgramSource.cs b/Plugins/Wox.Plugin.Program/ProgramSource.cs index 97a779d969..bac55bf33a 100644 --- a/Plugins/Wox.Plugin.Program/ProgramSource.cs +++ b/Plugins/Wox.Plugin.Program/ProgramSource.cs @@ -16,7 +16,7 @@ namespace Wox.Plugin.Program public override string ToString() { - return (this.Type ?? "") + ":" + this.Location ?? ""; + return (Type ?? "") + ":" + Location ?? ""; } } } diff --git a/Plugins/Wox.Plugin.Program/ProgramSources/AppPathsProgramSource.cs b/Plugins/Wox.Plugin.Program/ProgramSources/AppPathsProgramSource.cs index 6cec459bfc..17cc37fd8f 100644 --- a/Plugins/Wox.Plugin.Program/ProgramSources/AppPathsProgramSource.cs +++ b/Plugins/Wox.Plugin.Program/ProgramSources/AppPathsProgramSource.cs @@ -1,11 +1,14 @@ using System; using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using Microsoft.Win32; using Wox.Infrastructure.Logger; namespace Wox.Plugin.Program.ProgramSources { [Serializable] - [System.ComponentModel.Browsable(false)] + [Browsable(false)] public class AppPathsProgramSource : AbstractProgramSource { public AppPathsProgramSource() @@ -28,7 +31,7 @@ namespace Wox.Plugin.Program.ProgramSources private void ReadAppPaths(string rootpath, List list) { - using (var root = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(rootpath)) + using (var root = Registry.LocalMachine.OpenSubKey(rootpath)) { if (root == null) return; foreach (var item in root.GetSubKeyNames()) @@ -49,7 +52,7 @@ namespace Wox.Plugin.Program.ProgramSources path = path.Substring(begin + 1, path.Length - 2); } - if (!System.IO.File.Exists(path)) continue; + if (!File.Exists(path)) continue; var entry = CreateEntry(path); entry.ExecuteName = item; list.Add(entry); diff --git a/Plugins/Wox.Plugin.Program/ProgramSources/CommonStartMenuProgramSource.cs b/Plugins/Wox.Plugin.Program/ProgramSources/CommonStartMenuProgramSource.cs index 4cd741ae40..df37a6dc51 100644 --- a/Plugins/Wox.Plugin.Program/ProgramSources/CommonStartMenuProgramSource.cs +++ b/Plugins/Wox.Plugin.Program/ProgramSources/CommonStartMenuProgramSource.cs @@ -1,11 +1,12 @@ using System; +using System.ComponentModel; using System.Runtime.InteropServices; using System.Text; namespace Wox.Plugin.Program.ProgramSources { [Serializable] - [global::System.ComponentModel.Browsable(false)] + [Browsable(false)] public class CommonStartMenuProgramSource : FileSystemProgramSource { [DllImport("shell32.dll")] @@ -28,7 +29,7 @@ namespace Wox.Plugin.Program.ProgramSources public CommonStartMenuProgramSource(ProgramSource source) : this() { - this.BonusPoints = source.BonusPoints; + BonusPoints = source.BonusPoints; } public override string ToString() diff --git a/Plugins/Wox.Plugin.Program/ProgramSources/FileSystemProgramSource.cs b/Plugins/Wox.Plugin.Program/ProgramSources/FileSystemProgramSource.cs index b266cc654f..653140158c 100644 --- a/Plugins/Wox.Plugin.Program/ProgramSources/FileSystemProgramSource.cs +++ b/Plugins/Wox.Plugin.Program/ProgramSources/FileSystemProgramSource.cs @@ -27,7 +27,7 @@ namespace Wox.Plugin.Program.ProgramSources public FileSystemProgramSource(ProgramSource source) : this(source.Location, source.MaxDepth, source.Suffixes) { - this.BonusPoints = source.BonusPoints; + BonusPoints = source.BonusPoints; } public override List LoadPrograms() @@ -78,7 +78,7 @@ namespace Wox.Plugin.Program.ProgramSources public override string ToString() { - return typeof(FileSystemProgramSource).Name + ":" + this.baseDirectory; + return typeof(FileSystemProgramSource).Name + ":" + baseDirectory; } } } diff --git a/Plugins/Wox.Plugin.Program/ProgramSources/UserStartMenuProgramSource.cs b/Plugins/Wox.Plugin.Program/ProgramSources/UserStartMenuProgramSource.cs index 6c248feac1..4b1ad87bf9 100644 --- a/Plugins/Wox.Plugin.Program/ProgramSources/UserStartMenuProgramSource.cs +++ b/Plugins/Wox.Plugin.Program/ProgramSources/UserStartMenuProgramSource.cs @@ -1,9 +1,10 @@ using System; +using System.ComponentModel; namespace Wox.Plugin.Program.ProgramSources { [Serializable] - [global::System.ComponentModel.Browsable(false)] + [Browsable(false)] public class UserStartMenuProgramSource : FileSystemProgramSource { public UserStartMenuProgramSource() @@ -14,7 +15,7 @@ namespace Wox.Plugin.Program.ProgramSources public UserStartMenuProgramSource(ProgramSource source) : this() { - this.BonusPoints = source.BonusPoints; + BonusPoints = source.BonusPoints; } public override string ToString() diff --git a/Plugins/Wox.Plugin.Program/Programs.cs b/Plugins/Wox.Plugin.Program/Programs.cs index 80323029db..73856909e7 100644 --- a/Plugins/Wox.Plugin.Program/Programs.cs +++ b/Plugins/Wox.Plugin.Program/Programs.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using System.Reflection; using System.Windows; +using System.Windows.Controls; using Wox.Infrastructure; using Wox.Infrastructure.Logger; using Wox.Plugin.Program.ProgramSources; @@ -17,11 +18,12 @@ namespace Wox.Plugin.Program private static object lockObject = new object(); private static List programs = new List(); private static List sources = new List(); - private static Dictionary SourceTypes = new Dictionary() { + private static Dictionary SourceTypes = new Dictionary + { {"FileSystemProgramSource", typeof(FileSystemProgramSource)}, {"CommonStartMenuProgramSource", typeof(CommonStartMenuProgramSource)}, {"UserStartMenuProgramSource", typeof(UserStartMenuProgramSource)}, - {"AppPathsProgramSource", typeof(AppPathsProgramSource)}, + {"AppPathsProgramSource", typeof(AppPathsProgramSource)} }; private PluginInitContext context; @@ -32,14 +34,14 @@ namespace Wox.Plugin.Program var results = programs.Where(p => MatchProgram(p, fuzzyMather)). Select(ScoreFilter). OrderByDescending(p => p.Score) - .Select(c => new Result() + .Select(c => new Result { Title = c.Title, SubTitle = c.ExecutePath, IcoPath = c.IcoPath, Score = c.Score, ContextData = c, - Action = (e) => + Action = e => { context.API.HideApp(); Process.Start(c.ExecutePath); @@ -128,19 +130,19 @@ namespace Wox.Plugin.Program private static List LoadDeaultProgramSources() { var list = new List(); - list.Add(new ProgramSource() + list.Add(new ProgramSource { BonusPoints = 0, Enabled = ProgramStorage.Instance.EnableStartMenuSource, Type = "CommonStartMenuProgramSource" }); - list.Add(new ProgramSource() + list.Add(new ProgramSource { BonusPoints = 0, Enabled = ProgramStorage.Instance.EnableStartMenuSource, Type = "UserStartMenuProgramSource" }); - list.Add(new ProgramSource() + list.Add(new ProgramSource { BonusPoints = -10, Enabled = ProgramStorage.Instance.EnableRegistrySource, @@ -166,7 +168,7 @@ namespace Wox.Plugin.Program #region ISettingProvider Members - public System.Windows.Controls.Control CreateSettingPanel() + public Control CreateSettingPanel() { return new ProgramSetting(context); } @@ -190,9 +192,9 @@ namespace Wox.Plugin.Program public List LoadContextMenus(Result selectedResult) { Program p = selectedResult.ContextData as Program; - List contextMenus = new List() + List contextMenus = new List { - new Result() + new Result { Title = context.API.GetTranslation("wox_plugin_program_run_as_administrator"), Action = _ => @@ -207,7 +209,7 @@ namespace Wox.Plugin.Program }, IcoPath = "Images/cmd.png" }, - new Result() + new Result { Title = context.API.GetTranslation("wox_plugin_program_open_containing_folder"), Action = _ => diff --git a/Plugins/Wox.Plugin.Program/StringEmptyConverter.cs b/Plugins/Wox.Plugin.Program/StringEmptyConverter.cs index eb2e4b9c18..d098063620 100644 --- a/Plugins/Wox.Plugin.Program/StringEmptyConverter.cs +++ b/Plugins/Wox.Plugin.Program/StringEmptyConverter.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using System.Windows.Data; using System.Windows.Markup; @@ -6,13 +7,13 @@ namespace Wox.Plugin.Program { public class StringEmptyConverter : MarkupExtension, IValueConverter { - public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return string.IsNullOrEmpty((string)value) ? parameter : value; } public object ConvertBack( - object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + object value, Type targetType, object parameter, CultureInfo culture) { throw new NotSupportedException(); } diff --git a/Plugins/Wox.Plugin.Sys/Sys.cs b/Plugins/Wox.Plugin.Sys/Sys.cs index 2f68e3c995..206072772a 100644 --- a/Plugins/Wox.Plugin.Sys/Sys.cs +++ b/Plugins/Wox.Plugin.Sys/Sys.cs @@ -76,14 +76,14 @@ namespace Wox.Plugin.Sys private void LoadCommands() { - availableResults.AddRange(new Result[] + availableResults.AddRange(new[] { new Result { Title = "Shutdown", SubTitle = context.API.GetTranslation("wox_plugin_sys_shutdown_computer"), IcoPath = "Images\\exit.png", - Action = (c) => + Action = c => { var reuslt = MessageBox.Show("Are you sure you want to shut the computer down?", "Shutdown Computer?", MessageBoxButton.YesNo, MessageBoxImage.Warning); @@ -99,7 +99,7 @@ namespace Wox.Plugin.Sys Title = "Restart", SubTitle = context.API.GetTranslation("wox_plugin_sys_restart_computer"), IcoPath = "Images\\restartcomp.png", - Action = (c) => + Action = c => { var result = MessageBox.Show("Are you sure you want to restart the computer?", "Restart Computer?", MessageBoxButton.YesNo, MessageBoxImage.Warning); @@ -115,14 +115,14 @@ namespace Wox.Plugin.Sys Title = "Log off", SubTitle = context.API.GetTranslation("wox_plugin_sys_log_off"), IcoPath = "Images\\logoff.png", - Action = (c) => ExitWindowsEx(EWX_LOGOFF, 0) + Action = c => ExitWindowsEx(EWX_LOGOFF, 0) }, new Result { Title = "Lock", SubTitle = context.API.GetTranslation("wox_plugin_sys_lock"), IcoPath = "Images\\lock.png", - Action = (c) => + Action = c => { LockWorkStation(); return true; @@ -133,14 +133,14 @@ namespace Wox.Plugin.Sys Title = "Sleep", SubTitle = context.API.GetTranslation("wox_plugin_sys_sleep"), IcoPath = "Images\\sleep.png", - Action = (c) => FormsApplication.SetSuspendState(PowerState.Suspend, false, false) + Action = c => FormsApplication.SetSuspendState(PowerState.Suspend, false, false) }, new Result { Title = "Empty Recycle Bin", SubTitle = context.API.GetTranslation("wox_plugin_sys_emptyrecyclebin"), IcoPath = "Images\\recyclebin.png", - Action = (c) => + Action = c => { // http://www.pinvoke.net/default.aspx/shell32/SHEmptyRecycleBin.html // 0 for nothing @@ -160,7 +160,7 @@ namespace Wox.Plugin.Sys Title = "Exit", SubTitle = context.API.GetTranslation("wox_plugin_sys_exit"), IcoPath = "Images\\app.png", - Action = (c) => + Action = c => { context.API.CloseApp(); return true; @@ -171,7 +171,7 @@ namespace Wox.Plugin.Sys Title = "Restart Wox", SubTitle = context.API.GetTranslation("wox_plugin_sys_restart"), IcoPath = "Images\\restart.png", - Action = (c) => + Action = c => { context.API.RestarApp(); return false; @@ -182,7 +182,7 @@ namespace Wox.Plugin.Sys Title = "Settings", SubTitle = context.API.GetTranslation("wox_plugin_sys_setting"), IcoPath = "Images\\app.png", - Action = (c) => + Action = c => { context.API.OpenSettingDialog(); return true; diff --git a/Plugins/Wox.Plugin.Sys/SysSettings.xaml.cs b/Plugins/Wox.Plugin.Sys/SysSettings.xaml.cs index 8c0546be69..bb1abc8194 100644 --- a/Plugins/Wox.Plugin.Sys/SysSettings.xaml.cs +++ b/Plugins/Wox.Plugin.Sys/SysSettings.xaml.cs @@ -11,7 +11,7 @@ namespace Wox.Plugin.Sys foreach (var Result in Results) { - this.lbxCommands.Items.Add(Result); + lbxCommands.Items.Add(Result); } } } diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs index 4d8ba23014..7284ce59d8 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs @@ -110,7 +110,7 @@ namespace Wox.Plugin.WebSearch MessageBox.Show(exception.Message); return; } - WebSearchStorage.Instance.WebSearches.Add(new WebSearch() + WebSearchStorage.Instance.WebSearches.Add(new WebSearch { ActionKeyword = newActionKeyword, Enabled = cbEnable.IsChecked ?? false, diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchesSetting.xaml.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchesSetting.xaml.cs index f925f9d05a..b6e21209e0 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchesSetting.xaml.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchesSetting.xaml.cs @@ -29,10 +29,10 @@ namespace Wox.Plugin.WebSearch ? Visibility.Visible : Visibility.Collapsed; - List items = new List() + List items = new List { - new ComboBoxItem() {Content = "Google"}, - new ComboBoxItem() {Content = "Baidu"}, + new ComboBoxItem {Content = "Google"}, + new ComboBoxItem {Content = "Baidu"} }; ComboBoxItem selected = items.FirstOrDefault(o => o.Content.ToString() == WebSearchStorage.Instance.WebSearchSuggestionSource); if (selected == null) diff --git a/Wox.Core/Plugin/CSharpPluginLoader.cs b/Wox.Core/Plugin/CSharpPluginLoader.cs index 5eb4a830e0..7fb02fbd1d 100644 --- a/Wox.Core/Plugin/CSharpPluginLoader.cs +++ b/Wox.Core/Plugin/CSharpPluginLoader.cs @@ -29,7 +29,7 @@ namespace Wox.Core.Plugin foreach (Type type in types) { - PluginPair pair = new PluginPair() + PluginPair pair = new PluginPair { Plugin = Activator.CreateInstance(type) as IPlugin, Metadata = metadata @@ -38,7 +38,7 @@ namespace Wox.Core.Plugin plugins.Add(pair); } } - catch (System.Exception e) + catch (Exception e) { Log.Error(new WoxPluginException(metadata.Name, $"Couldn't load plugin", e)); } diff --git a/Wox.Core/Plugin/JsonRPCPlugin.cs b/Wox.Core/Plugin/JsonRPCPlugin.cs index 5c08f9a8a2..c0654336d7 100644 --- a/Wox.Core/Plugin/JsonRPCPlugin.cs +++ b/Wox.Core/Plugin/JsonRPCPlugin.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; @@ -41,7 +42,7 @@ namespace Wox.Core.Plugin foreach (JsonRPCResult result in queryResponseModel.Result) { JsonRPCResult result1 = result; - result.Action = (c) => + result.Action = c => { if (result1.JsonRPCAction == null) return false; @@ -72,7 +73,7 @@ namespace Wox.Core.Plugin } return results; } - catch (System.Exception e) + catch (Exception e) { Log.Error(e); } @@ -89,7 +90,7 @@ namespace Wox.Core.Plugin { methodInfo.Invoke(PluginManager.API, parameters); } - catch (System.Exception) + catch (Exception) { #if (DEBUG) { @@ -150,7 +151,7 @@ namespace Wox.Core.Plugin } } } - catch(System.Exception e) + catch(Exception e) { throw new WoxJsonRPCException(e.Message); } diff --git a/Wox.Core/Plugin/JsonRPCPluginLoader.cs b/Wox.Core/Plugin/JsonRPCPluginLoader.cs index d4b2a4f90a..eb88356719 100644 --- a/Wox.Core/Plugin/JsonRPCPluginLoader.cs +++ b/Wox.Core/Plugin/JsonRPCPluginLoader.cs @@ -11,7 +11,7 @@ namespace Wox.Core.Plugin T jsonRPCPlugin = new T(); List jsonRPCPluginMetadatas = pluginMetadatas.Where(o => o.Language.ToUpper() == jsonRPCPlugin.SupportedLanguage.ToUpper()).ToList(); - return jsonRPCPluginMetadatas.Select(metadata => new PluginPair() + return jsonRPCPluginMetadatas.Select(metadata => new PluginPair { Plugin = new T(), //every JsonRPC plugin should has its own plugin instance Metadata = metadata diff --git a/Wox.Core/Plugin/PluginConfig.cs b/Wox.Core/Plugin/PluginConfig.cs index 30bacef838..0a8d286c1d 100644 --- a/Wox.Core/Plugin/PluginConfig.cs +++ b/Wox.Core/Plugin/PluginConfig.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; using System.Linq; using Newtonsoft.Json; @@ -45,7 +46,7 @@ namespace Wox.Core.Plugin Directory.Delete(directory, true); continue; } - catch (System.Exception e) + catch (Exception e) { Log.Fatal(e); } @@ -77,7 +78,7 @@ namespace Wox.Core.Plugin // for plugin still use old ActionKeyword metadata.ActionKeyword = metadata.ActionKeywords?[0]; } - catch (System.Exception e) + catch (Exception e) { string msg = $"Parse plugin config {configPath} failed: json format is not valid"; Log.Error(new WoxException(msg)); diff --git a/Wox.Core/Plugin/PluginInstaller.cs b/Wox.Core/Plugin/PluginInstaller.cs index ec022a582a..4f7f221d75 100644 --- a/Wox.Core/Plugin/PluginInstaller.cs +++ b/Wox.Core/Plugin/PluginInstaller.cs @@ -107,12 +107,12 @@ namespace Wox.Core.Plugin metadata = JsonConvert.DeserializeObject(File.ReadAllText(configPath)); metadata.PluginDirectory = pluginDirectory; } - catch (System.Exception) + catch (Exception) { string error = $"Parse plugin config {configPath} failed: json format is not valid"; #if (DEBUG) { - throw new System.Exception(error); + throw new Exception(error); } #endif return null; @@ -124,7 +124,7 @@ namespace Wox.Core.Plugin string error = $"Parse plugin config {configPath} failed: invalid language {metadata.Language}"; #if (DEBUG) { - throw new System.Exception(error); + throw new Exception(error); } #endif return null; @@ -134,7 +134,7 @@ namespace Wox.Core.Plugin string error = $"Parse plugin config {configPath} failed: ExecuteFile {metadata.ExecuteFilePath} didn't exist"; #if (DEBUG) { - throw new System.Exception(error); + throw new Exception(error); } #endif return null; diff --git a/Wox.Core/Plugin/PythonPlugin.cs b/Wox.Core/Plugin/PythonPlugin.cs index bf1edb4c16..fac59fa298 100644 --- a/Wox.Core/Plugin/PythonPlugin.cs +++ b/Wox.Core/Plugin/PythonPlugin.cs @@ -41,8 +41,8 @@ namespace Wox.Core.Plugin protected override string ExecuteQuery(Query query) { - JsonRPCServerRequestModel request = new JsonRPCServerRequestModel() - { + JsonRPCServerRequestModel request = new JsonRPCServerRequestModel + { Method = "query", Parameters = new object[] { query.GetAllRemainingParameter() }, HttpProxy = HttpProxy.Instance diff --git a/Wox.Core/Theme/Theme.cs b/Wox.Core/Theme/Theme.cs index 1317b5f9cc..b54192bd11 100644 --- a/Wox.Core/Theme/Theme.cs +++ b/Wox.Core/Theme/Theme.cs @@ -35,7 +35,7 @@ namespace Wox.Core.Theme { Directory.CreateDirectory(pluginDirectory); } - catch (System.Exception e) + catch (Exception e) { Log.Error(e); } @@ -51,7 +51,7 @@ namespace Wox.Core.Theme themePath = GetThemePath("Dark"); if (string.IsNullOrEmpty(themePath)) { - throw new System.Exception("Change theme failed"); + throw new Exception("Change theme failed"); } } @@ -94,8 +94,8 @@ namespace Wox.Core.Theme Setter fontWeight = new Setter(TextBlock.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontWeight)); Setter fontStretch = new Setter(TextBlock.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontStretch)); - Setter[] setters = new Setter[] { fontFamily, fontStyle, fontWeight, fontStretch }; - Array.ForEach(new Style[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle }, o => Array.ForEach(setters, p => o.Setters.Add(p))); + Setter[] setters = { fontFamily, fontStyle, fontWeight, fontStretch }; + Array.ForEach(new[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle }, o => Array.ForEach(setters, p => o.Setters.Add(p))); } return dict; } diff --git a/Wox.Core/Updater/SemanticVersion.cs b/Wox.Core/Updater/SemanticVersion.cs index ed3ef7b317..01012183dd 100644 --- a/Wox.Core/Updater/SemanticVersion.cs +++ b/Wox.Core/Updater/SemanticVersion.cs @@ -9,7 +9,7 @@ namespace Wox.Core.Updater public int MINOR { get; set; } public int PATCH { get; set; } - public SemanticVersion(System.Version version) + public SemanticVersion(Version version) { MAJOR = version.Major; MINOR = version.Minor; diff --git a/Wox.Core/Updater/UpdaterManager.cs b/Wox.Core/Updater/UpdaterManager.cs index b9284a5caa..9b15e10082 100644 --- a/Wox.Core/Updater/UpdaterManager.cs +++ b/Wox.Core/Updater/UpdaterManager.cs @@ -92,7 +92,7 @@ namespace Wox.Core.Updater StartUpdate(); } } - catch (System.Exception e) + catch (Exception e) { Log.Error(e); } @@ -112,7 +112,7 @@ namespace Wox.Core.Updater { ((UpdateProcessAsyncResult)asyncResult).EndInvoke(); } - catch (System.Exception e) + catch (Exception e) { Log.Error(e); updManager.CleanUp(); @@ -148,7 +148,7 @@ namespace Wox.Core.Updater { UpdateManager.Instance.ApplyUpdates(true, UserSettingStorage.Instance.EnableUpdateLog, false); } - catch (System.Exception e) + catch (Exception e) { string updateError = InternationalizationManager.Instance.GetTranslation("update_wox_update_error"); Log.Error(e); diff --git a/Wox.Core/Updater/WoxUpdateSource.cs b/Wox.Core/Updater/WoxUpdateSource.cs index 192bf9d2bc..a9f86807d3 100644 --- a/Wox.Core/Updater/WoxUpdateSource.cs +++ b/Wox.Core/Updater/WoxUpdateSource.cs @@ -15,30 +15,30 @@ namespace Wox.Core.Updater public WoxUpdateSource(string feedUrl,IWebProxy proxy) { - this.FeedUrl = feedUrl; - this.Proxy = proxy; + FeedUrl = feedUrl; + Proxy = proxy; } private void TryResolvingHost() { - Uri uri = new Uri(this.FeedUrl); + Uri uri = new Uri(FeedUrl); try { Dns.GetHostEntry(uri.Host); } - catch (System.Exception ex) + catch (Exception ex) { - throw new WebException(string.Format("Failed to resolve {0}. Check your connectivity.", (object)uri.Host), WebExceptionStatus.ConnectFailure); + throw new WebException(string.Format("Failed to resolve {0}. Check your connectivity.", uri.Host), WebExceptionStatus.ConnectFailure); } } public string GetUpdatesFeed() { - this.TryResolvingHost(); + TryResolvingHost(); string str = string.Empty; - WebRequest webRequest = WebRequest.Create(this.FeedUrl); + WebRequest webRequest = WebRequest.Create(FeedUrl); webRequest.Method = "GET"; - webRequest.Proxy = this.Proxy; + webRequest.Proxy = Proxy; using (WebResponse response = webRequest.GetResponse()) { Stream responseStream = response.GetResponseStream(); @@ -56,7 +56,7 @@ namespace Wox.Core.Updater if (!string.IsNullOrEmpty(baseUrl) && !baseUrl.EndsWith("/")) baseUrl += "/"; FileDownloader fileDownloader = !Uri.IsWellFormedUriString(url, UriKind.Absolute) ? (!Uri.IsWellFormedUriString(baseUrl, UriKind.Absolute) ? (string.IsNullOrEmpty(baseUrl) ? new FileDownloader(url) : new FileDownloader(new Uri(new Uri(baseUrl), url))) : new FileDownloader(new Uri(new Uri(baseUrl, UriKind.Absolute), url))) : new FileDownloader(url); - fileDownloader.Proxy = this.Proxy; + fileDownloader.Proxy = Proxy; if (string.IsNullOrEmpty(tempLocation) || !Directory.Exists(Path.GetDirectoryName(tempLocation))) tempLocation = Path.GetTempFileName(); return fileDownloader.DownloadToFile(tempLocation, onProgress); diff --git a/Wox.Core/UserSettings/UserSettingStorage.cs b/Wox.Core/UserSettings/UserSettingStorage.cs index 13017c6ea1..a52a90ba99 100644 --- a/Wox.Core/UserSettings/UserSettingStorage.cs +++ b/Wox.Core/UserSettings/UserSettingStorage.cs @@ -172,7 +172,7 @@ namespace Wox.Core.UserSettings var customizedPluginConfig = CustomizedPluginConfigs.FirstOrDefault(o => o.ID == metadata.ID); if (customizedPluginConfig == null) { - CustomizedPluginConfigs.Add(new CustomizedPluginConfig() + CustomizedPluginConfigs.Add(new CustomizedPluginConfig { Disabled = false, ID = metadata.ID, diff --git a/Wox.Core/i18n/AvailableLanguages.cs b/Wox.Core/i18n/AvailableLanguages.cs index 30a0dc69d1..b0d41c414b 100644 --- a/Wox.Core/i18n/AvailableLanguages.cs +++ b/Wox.Core/i18n/AvailableLanguages.cs @@ -18,7 +18,7 @@ namespace Wox.Core.i18n Chinese, Chinese_TW, Russian, - French, + French }; return languages; } diff --git a/Wox.Core/i18n/Internationalization.cs b/Wox.Core/i18n/Internationalization.cs index f2ad412da2..a8018ad057 100644 --- a/Wox.Core/i18n/Internationalization.cs +++ b/Wox.Core/i18n/Internationalization.cs @@ -30,7 +30,7 @@ namespace Wox.Core.i18n { Directory.CreateDirectory(DefaultDirectory); } - catch (System.Exception e) + catch (Exception e) { Log.Error(e); } @@ -64,7 +64,7 @@ namespace Wox.Core.i18n path = GetLanguagePath(AvailableLanguages.English); if (string.IsNullOrEmpty(path)) { - throw new System.Exception("Change Language failed"); + throw new Exception("Change Language failed"); } } @@ -115,7 +115,7 @@ namespace Wox.Core.i18n pluginPair.Metadata.Name = pluginI18n.GetTranslatedPluginTitle(); pluginPair.Metadata.Description = pluginI18n.GetTranslatedPluginDescription(); } - catch (System.Exception e) + catch (Exception e) { var woxPluginException = new WoxPluginException(pluginPair.Metadata.Name, "Update Plugin metadata translation failed:", e); Log.Error(woxPluginException); diff --git a/Wox.CrashReporter/ReportWindow.xaml.cs b/Wox.CrashReporter/ReportWindow.xaml.cs index 15a76abe11..f31585e2fc 100644 --- a/Wox.CrashReporter/ReportWindow.xaml.cs +++ b/Wox.CrashReporter/ReportWindow.xaml.cs @@ -47,10 +47,10 @@ namespace Wox.CrashReporter .SetUserDescription(reproduceSteps) .Submit(); ExceptionlessClient.Current.ProcessQueue(); - Dispatcher.Invoke(new Action(() => + Dispatcher.Invoke(() => { Close(); - })); + }); }); } diff --git a/Wox.Infrastructure/FuzzyMatcher.cs b/Wox.Infrastructure/FuzzyMatcher.cs index 31280ad9de..c2d7e02e94 100644 --- a/Wox.Infrastructure/FuzzyMatcher.cs +++ b/Wox.Infrastructure/FuzzyMatcher.cs @@ -28,7 +28,7 @@ namespace Wox.Infrastructure public MatchResult Evaluate(string str) { - if (string.IsNullOrEmpty(str) || string.IsNullOrEmpty(query)) return new MatchResult() { Success = false }; + if (string.IsNullOrEmpty(str) || string.IsNullOrEmpty(query)) return new MatchResult { Success = false }; var len = str.Length; var compareString = opt.IgnoreCase ? str.ToLower() : str; @@ -67,7 +67,7 @@ namespace Wox.Infrastructure // return rendered string if we have a match for every char if (patternIdx == pattern.Length) { - return new MatchResult() + return new MatchResult { Success = true, Value = sb.ToString(), @@ -75,7 +75,7 @@ namespace Wox.Infrastructure }; } - return new MatchResult() { Success = false }; + return new MatchResult { Success = false }; } private int CalScore(string str, int firstIndex, int matchLen) @@ -107,9 +107,9 @@ namespace Wox.Infrastructure { public MatchOption() { - this.Prefix = ""; - this.Suffix = ""; - this.IgnoreCase = true; + Prefix = ""; + Suffix = ""; + IgnoreCase = true; } /// diff --git a/Wox.Infrastructure/Hotkey/HotkeyModel.cs b/Wox.Infrastructure/Hotkey/HotkeyModel.cs index ea8d61d3bb..624473c086 100644 --- a/Wox.Infrastructure/Hotkey/HotkeyModel.cs +++ b/Wox.Infrastructure/Hotkey/HotkeyModel.cs @@ -131,7 +131,7 @@ namespace Wox.Infrastructure.Hotkey if (CharKey != Key.None) { text += specialSymbolDictionary.ContainsKey(CharKey) - ? specialSymbolDictionary[CharKey].ToString() + ? specialSymbolDictionary[CharKey] : CharKey.ToString(); } else if (!string.IsNullOrEmpty(text)) diff --git a/Wox.Infrastructure/Hotkey/KeyEvent.cs b/Wox.Infrastructure/Hotkey/KeyEvent.cs index f1b6eefd0c..7c601660ec 100644 --- a/Wox.Infrastructure/Hotkey/KeyEvent.cs +++ b/Wox.Infrastructure/Hotkey/KeyEvent.cs @@ -1,6 +1,6 @@ namespace Wox.Infrastructure.Hotkey { - public enum KeyEvent:int + public enum KeyEvent { /// /// Key down diff --git a/Wox.Infrastructure/Http/HttpRequest.cs b/Wox.Infrastructure/Http/HttpRequest.cs index 628d747887..1142f217fb 100644 --- a/Wox.Infrastructure/Http/HttpRequest.cs +++ b/Wox.Infrastructure/Http/HttpRequest.cs @@ -1,6 +1,7 @@ using System.IO; using System.Net; using System.Text; +using Wox.Infrastructure.Logger; using Wox.Plugin; namespace Wox.Infrastructure.Http @@ -56,7 +57,7 @@ namespace Wox.Infrastructure.Http } catch (System.Exception e) { - Logger.Log.Error(e); + Log.Error(e); return string.Empty; } @@ -109,7 +110,7 @@ namespace Wox.Infrastructure.Http } catch (System.Exception e) { - Logger.Log.Error(e); + Log.Error(e); return string.Empty; } diff --git a/Wox.Infrastructure/Logger/Log.cs b/Wox.Infrastructure/Logger/Log.cs index 92f84cfaa2..77b99fa48b 100644 --- a/Wox.Infrastructure/Logger/Log.cs +++ b/Wox.Infrastructure/Logger/Log.cs @@ -1,5 +1,4 @@ using NLog; -using Wox.Infrastructure.Exception; namespace Wox.Infrastructure.Logger { diff --git a/Wox.Infrastructure/Storage/BinaryStorage.cs b/Wox.Infrastructure/Storage/BinaryStorage.cs index de1c732f6e..fc433b9848 100644 --- a/Wox.Infrastructure/Storage/BinaryStorage.cs +++ b/Wox.Infrastructure/Storage/BinaryStorage.cs @@ -69,7 +69,7 @@ namespace Wox.Infrastructure.Storage } } - private System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) + private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { Assembly ayResult = null; string sShortAssemblyName = args.Name.Split(',')[0]; diff --git a/Wox.Test/FuzzyMatcherTest.cs b/Wox.Test/FuzzyMatcherTest.cs index 8290b2e06e..2856a0fdeb 100644 --- a/Wox.Test/FuzzyMatcherTest.cs +++ b/Wox.Test/FuzzyMatcherTest.cs @@ -2,6 +2,7 @@ using System.Linq; using NUnit.Framework; using Wox.Infrastructure; +using Wox.Plugin; namespace Wox.Test { @@ -11,20 +12,20 @@ namespace Wox.Test [Test] public void MatchTest() { - var sources = new List() + var sources = new List { "file open in browser-test", "Install Package", "add new bsd", "Inste", - "aac", + "aac" }; - var results = new List(); + var results = new List(); foreach (var str in sources) { - results.Add(new Plugin.Result() + results.Add(new Result { Title = str, Score = FuzzyMatcher.Create("inst").Evaluate(str).Score diff --git a/Wox.UpdateFeedGenerator/ConfigStorage.cs b/Wox.UpdateFeedGenerator/ConfigStorage.cs index 28f0c6c0b1..84bd970144 100644 --- a/Wox.UpdateFeedGenerator/ConfigStorage.cs +++ b/Wox.UpdateFeedGenerator/ConfigStorage.cs @@ -36,7 +36,7 @@ namespace Wox.UpdateFeedGenerator if (string.IsNullOrEmpty(config.OutputDirectory)) { config.OutputDirectory = @"Update"; - ConfigStorage.Instance.Save(); + Instance.Save(); } } diff --git a/Wox.UpdateFeedGenerator/FileInfoEx.cs b/Wox.UpdateFeedGenerator/FileInfoEx.cs index ff707162eb..c02704157e 100644 --- a/Wox.UpdateFeedGenerator/FileInfoEx.cs +++ b/Wox.UpdateFeedGenerator/FileInfoEx.cs @@ -1,5 +1,6 @@ using System.Diagnostics; using System.IO; +using NAppUpdate.Framework.Utils; namespace Wox.UpdateFeedGenerator { @@ -31,7 +32,7 @@ namespace Wox.UpdateFeedGenerator myFileInfo = new FileInfo(fileName); myFileVersion = FileVersionInfo.GetVersionInfo(fileName).FileVersion; if (myFileVersion != null) myFileVersion = myFileVersion.Replace(", ", "."); - myHash = NAppUpdate.Framework.Utils.FileChecksum.GetSHA256Checksum(fileName); + myHash = FileChecksum.GetSHA256Checksum(fileName); RelativeName = fileName.Substring(rootDirectoryLength + 1); } } diff --git a/Wox.UpdateFeedGenerator/FileSystemEnumerator.cs b/Wox.UpdateFeedGenerator/FileSystemEnumerator.cs index e7ef75d5f2..b087f9d4d2 100644 --- a/Wox.UpdateFeedGenerator/FileSystemEnumerator.cs +++ b/Wox.UpdateFeedGenerator/FileSystemEnumerator.cs @@ -162,9 +162,9 @@ namespace Wox.UpdateFeedGenerator if (fileTypesToMatch.IndexOfAny(new[] { ':', '<', '>', '/', '\\' }) >= 0) throw new ArgumentException("invalid cahracters in wildcard pattern", "fileTypesToMatch"); m_includeSubDirs = includeSubDirs; - m_paths = pathsToSearch.Split(new[] { ';', ',' }); + m_paths = pathsToSearch.Split(';', ','); - string[] specs = fileTypesToMatch.Split(new[] { ';', ',' }); + string[] specs = fileTypesToMatch.Split(';', ','); m_fileSpecs = new List(specs.Length); foreach (string spec in specs) { // trim whitespace off file spec and convert Win32 wildcards to regular expressions diff --git a/Wox/ActionKeywords.xaml.cs b/Wox/ActionKeywords.xaml.cs index 3c2662e1fb..46868ebbcb 100644 --- a/Wox/ActionKeywords.xaml.cs +++ b/Wox/ActionKeywords.xaml.cs @@ -19,7 +19,6 @@ namespace Wox { MessageBox.Show(InternationalizationManager.Instance.GetTranslation("cannotFindSpecifiedPlugin")); Close(); - return; } } diff --git a/Wox/Converters/StringNullOrEmptyToVisibilityConverter.cs b/Wox/Converters/StringNullOrEmptyToVisibilityConverter.cs index 543fecd322..f536e74735 100644 --- a/Wox/Converters/StringNullOrEmptyToVisibilityConverter.cs +++ b/Wox/Converters/StringNullOrEmptyToVisibilityConverter.cs @@ -8,8 +8,6 @@ namespace Wox.Converters { public class StringNullOrEmptyToVisibilityConverter : ConvertorBase { - public StringNullOrEmptyToVisibilityConverter() { } - public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return string.IsNullOrEmpty(value as string) ? Visibility.Collapsed : Visibility.Visible; diff --git a/Wox/CustomQueryHotkeySetting.xaml.cs b/Wox/CustomQueryHotkeySetting.xaml.cs index 9d17619101..8cf21b62d0 100644 --- a/Wox/CustomQueryHotkeySetting.xaml.cs +++ b/Wox/CustomQueryHotkeySetting.xaml.cs @@ -38,7 +38,7 @@ namespace Wox UserSettingStorage.Instance.CustomPluginHotkeys = new List(); } - var pluginHotkey = new CustomPluginHotkey() + var pluginHotkey = new CustomPluginHotkey { Hotkey = ctlHotkey.CurrentHotkey.ToString(), ActionKeyword = tbAction.Text diff --git a/Wox/Helper/DWMDropShadow.cs b/Wox/Helper/DWMDropShadow.cs index d1fd92757e..a998f75a1d 100644 --- a/Wox/Helper/DWMDropShadow.cs +++ b/Wox/Helper/DWMDropShadow.cs @@ -25,7 +25,7 @@ namespace Wox.Helper { if (!DropShadow(window)) { - window.SourceInitialized += new EventHandler(window_SourceInitialized); + window.SourceInitialized += window_SourceInitialized; } } @@ -35,7 +35,7 @@ namespace Wox.Helper DropShadow(window); - window.SourceInitialized -= new EventHandler(window_SourceInitialized); + window.SourceInitialized -= window_SourceInitialized; } /// diff --git a/Wox/Helper/ErrorReporting.cs b/Wox/Helper/ErrorReporting.cs index b13ed405bc..560a35cf20 100644 --- a/Wox/Helper/ErrorReporting.cs +++ b/Wox/Helper/ErrorReporting.cs @@ -16,14 +16,14 @@ namespace Wox.Helper public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e) { //handle non-ui thread exceptions - App.Window.Dispatcher.Invoke(new Action(() => + App.Window.Dispatcher.Invoke(() => { Report((Exception)e.ExceptionObject); if (!(e.ExceptionObject is WoxException)) { Environment.Exit(0); } - })); + }); } public static void DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) diff --git a/Wox/Helper/SingleInstance.cs b/Wox/Helper/SingleInstance.cs index c62fefc0ad..58fe0adef4 100644 --- a/Wox/Helper/SingleInstance.cs +++ b/Wox/Helper/SingleInstance.cs @@ -9,6 +9,7 @@ using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Ipc; using System.Runtime.Serialization.Formatters; using System.Security; +using System.Text; using System.Threading; using System.Windows; using System.Windows.Threading; @@ -131,7 +132,7 @@ namespace Wox.Helper // This is the hard-coded message value used by WinForms for Shell_NotifyIcon. // It's relatively safe to reuse. TRAYMOUSEMESSAGE = 0x800, //WM_USER + 1024 - APP = 0x8000, + APP = 0x8000 } [SuppressUnmanagedCodeSecurity] @@ -342,7 +343,7 @@ namespace Wox.Helper { try { - using (TextReader reader = new StreamReader(cmdLinePath, System.Text.Encoding.Unicode)) + using (TextReader reader = new StreamReader(cmdLinePath, Encoding.Unicode)) { args = NativeMethods.CommandLineToArgvW(reader.ReadToEnd()); } @@ -465,7 +466,7 @@ namespace Wox.Helper { // Do an asynchronous call to ActivateFirstInstance function Application.Current.Dispatcher.BeginInvoke( - DispatcherPriority.Normal, new DispatcherOperationCallback(SingleInstance.ActivateFirstInstanceCallback), args); + DispatcherPriority.Normal, new DispatcherOperationCallback(ActivateFirstInstanceCallback), args); } } diff --git a/Wox/Helper/WallpaperPathRetrieval.cs b/Wox/Helper/WallpaperPathRetrieval.cs index 000146ebe1..95d7a212f0 100644 --- a/Wox/Helper/WallpaperPathRetrieval.cs +++ b/Wox/Helper/WallpaperPathRetrieval.cs @@ -35,7 +35,7 @@ namespace Wox.Helper { try { - var parts = result.ToString().Trim().Split(new char[] {' '}, 3).Select(byte.Parse).ToList(); + var parts = result.ToString().Trim().Split(new[] {' '}, 3).Select(byte.Parse).ToList(); return Color.FromRgb(parts[0], parts[1], parts[2]); } catch diff --git a/Wox/ImageLoader/ImageCacheStroage.cs b/Wox/ImageLoader/ImageCacheStroage.cs index 9c13aab06b..22240cc0b8 100644 --- a/Wox/ImageLoader/ImageCacheStroage.cs +++ b/Wox/ImageLoader/ImageCacheStroage.cs @@ -10,7 +10,7 @@ namespace Wox.ImageLoader [Serializable] public class ImageCacheStroage : BinaryStorage { - private int counter = 0; + private int counter; private const int maxCached = 200; public Dictionary TopUsedImages = new Dictionary(); diff --git a/Wox/ImageLoader/ImageLoader.cs b/Wox/ImageLoader/ImageLoader.cs index 9bf59006d5..6ab671d00e 100644 --- a/Wox/ImageLoader/ImageLoader.cs +++ b/Wox/ImageLoader/ImageLoader.cs @@ -4,6 +4,7 @@ using System.Drawing; using System.IO; using System.Runtime.InteropServices; using System.Windows; +using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Imaging; using Wox.Infrastructure; @@ -43,7 +44,7 @@ namespace Wox.ImageLoader Icon icon = GetFileIcon(fileName) ?? Icon.ExtractAssociatedIcon(fileName); if (icon != null) { - return System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(icon.Handle, + return Imaging.CreateBitmapSourceFromHIcon(icon.Handle, new Int32Rect(0, 0, icon.Width, icon.Height), BitmapSizeOptions.FromEmptyOptions()); } } @@ -206,7 +207,7 @@ namespace Wox.ImageLoader public string szDisplayName; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = NAMESIZE)] public string szTypeName; - }; + } private const uint SHGFI_ICON = 0x000000100; // get icon private const uint SHGFI_DISPLAYNAME = 0x000000200; // get display name diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 5ff2dd37a0..84e76e8860 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -10,6 +10,7 @@ using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; +using System.Windows.Forms; using System.Windows.Input; using System.Windows.Media.Animation; using NHotkey; @@ -24,11 +25,16 @@ using Wox.Infrastructure; using Wox.Infrastructure.Hotkey; using Wox.Plugin; using Wox.Storage; +using Application = System.Windows.Application; using ContextMenu = System.Windows.Forms.ContextMenu; -using NotifyIcon = System.Windows.Forms.NotifyIcon; -using Screen = System.Windows.Forms.Screen; +using DataFormats = System.Windows.DataFormats; +using DragEventArgs = System.Windows.DragEventArgs; +using IDataObject = System.Windows.IDataObject; +using KeyEventArgs = System.Windows.Input.KeyEventArgs; using MenuItem = System.Windows.Forms.MenuItem; +using MessageBox = System.Windows.MessageBox; using Stopwatch = Wox.Infrastructure.Stopwatch; +using ToolTip = System.Windows.Controls.ToolTip; namespace Wox { @@ -43,7 +49,7 @@ namespace Wox private Query _lastQuery = new Query(); private ToolTip toolTip = new ToolTip(); - private bool _ignoreTextChange = false; + private bool _ignoreTextChange; private List CurrentContextMenus = new List(); private string textBeforeEnterContextMenuMode; @@ -53,7 +59,7 @@ namespace Wox public void ChangeQuery(string query, bool requery = false) { - Dispatcher.Invoke(new Action(() => + Dispatcher.Invoke(() => { tbQuery.Text = query; tbQuery.CaretIndex = tbQuery.Text.Length; @@ -61,12 +67,12 @@ namespace Wox { TbQuery_OnTextChanged(null, null); } - })); + }); } public void ChangeQueryText(string query, bool selectAll = false) { - Dispatcher.Invoke(new Action(() => + Dispatcher.Invoke(() => { _ignoreTextChange = true; tbQuery.Text = query; @@ -75,7 +81,7 @@ namespace Wox { tbQuery.SelectAll(); } - })); + }); } public void CloseApp() @@ -96,50 +102,50 @@ namespace Wox public void HideApp() { - Dispatcher.Invoke(new Action(HideWox)); + Dispatcher.Invoke(HideWox); } public void ShowApp() { - Dispatcher.Invoke(new Action(() => ShowWox())); + Dispatcher.Invoke(() => ShowWox()); } public void ShowMsg(string title, string subTitle, string iconPath) { - Dispatcher.Invoke(new Action(() => + Dispatcher.Invoke(() => { var m = new Msg { Owner = GetWindow(this) }; m.Show(title, subTitle, iconPath); - })); + }); } public void OpenSettingDialog(string tabName = "general") { - Dispatcher.Invoke(new Action(() => + Dispatcher.Invoke(() => { SettingWindow sw = SingletonWindowOpener.Open(this); sw.SwitchTo(tabName); - })); + }); } public void StartLoadingBar() { - Dispatcher.Invoke(new Action(StartProgress)); + Dispatcher.Invoke(StartProgress); } public void StopLoadingBar() { - Dispatcher.Invoke(new Action(StopProgress)); + Dispatcher.Invoke(StopProgress); } public void InstallPlugin(string path) { - Dispatcher.Invoke(new Action(() => PluginManager.InstallPlugin(path))); + Dispatcher.Invoke(() => PluginManager.InstallPlugin(path)); } public void ReloadPlugins() { - Dispatcher.Invoke(new Action(() => PluginManager.Init(this))); + Dispatcher.Invoke(() => PluginManager.Init(this)); } public string GetTranslation(string key) @@ -241,7 +247,7 @@ namespace Wox UserSettingStorage.Instance.WindowLeft = Left; UserSettingStorage.Instance.WindowTop = Top; UserSettingStorage.Instance.Save(); - this.HideWox(); + HideWox(); e.Cancel = true; } @@ -293,10 +299,10 @@ namespace Wox private void OnPrepareUpdateReady(object sender, EventArgs e) { - Dispatcher.Invoke(new Action(() => + Dispatcher.Invoke(() => { new WoxUpdate().ShowDialog(); - })); + }); } public void SetHotkey(string hotkeyStr, EventHandler action) @@ -664,7 +670,7 @@ namespace Wox case Key.Back: if (BackKeyDownEvent != null) { - BackKeyDownEvent(new WoxKeyDownEventArgs() + BackKeyDownEvent(new WoxKeyDownEventArgs { Query = tbQuery.Text, keyEventArgs = e @@ -736,9 +742,10 @@ namespace Wox var executeQueryHistoryTitle = GetTranslation("executeQuery"); var lastExecuteTime = GetTranslation("lastExecuteTime"); pnlResult.RemoveResultsExcept(historyMetadata); - UpdateResultViewInternal(new List() + UpdateResultViewInternal(new List { - new Result(){ + new Result + { Title = string.Format(executeQueryHistoryTitle,history.Query), SubTitle = string.Format(lastExecuteTime,history.ExecutedDateTime), IcoPath = "Images\\history.png", @@ -815,7 +822,7 @@ namespace Wox { if (result.Action != null) { - bool hideWindow = result.Action(new ActionContext() + bool hideWindow = result.Action(new ActionContext { SpecialKeyState = GlobalHotkey.Instance.CheckModifiers() }); @@ -832,7 +839,7 @@ namespace Wox private void UpdateResultView(List list, PluginMetadata metadata, Query originQuery) { _queryHasReturn = true; - progressBar.Dispatcher.Invoke(new Action(StopProgress)); + progressBar.Dispatcher.Invoke(StopProgress); list.ForEach(o => { @@ -846,11 +853,11 @@ namespace Wox private void UpdateResultViewInternal(List list, PluginMetadata metadata) { - Dispatcher.Invoke(new Action(() => + Dispatcher.Invoke(() => { Stopwatch.Normal($"UI update cost for {metadata.Name}", () => { pnlResult.AddResults(list, metadata.ID); }); - })); + }); } private Result GetTopMostContextMenu(Result result) diff --git a/Wox/Msg.xaml.cs b/Wox/Msg.xaml.cs index 734d8c098d..ba46f6f9ae 100644 --- a/Wox/Msg.xaml.cs +++ b/Wox/Msg.xaml.cs @@ -12,7 +12,7 @@ namespace Wox public partial class Msg : Window { Storyboard fadeOutStoryboard = new Storyboard(); - private bool closing = false; + private bool closing; public Msg() { @@ -21,13 +21,13 @@ namespace Wox var dipWorkingArea = WindowIntelopHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, screen.WorkingArea.Height); - Left = dipWorkingArea.X - this.Width; + Left = dipWorkingArea.X - Width; Top = dipWorkingArea.Y; showAnimation.From = dipWorkingArea.Y; showAnimation.To = dipWorkingArea.Y - Height; // Create the fade out storyboard - fadeOutStoryboard.Completed += new EventHandler(fadeOutStoryboard_Completed); + fadeOutStoryboard.Completed += fadeOutStoryboard_Completed; DoubleAnimation fadeOutAnimation = new DoubleAnimation(dipWorkingArea.Y - Height, dipWorkingArea.Y, new Duration(TimeSpan.FromSeconds(0.3))) { AccelerationRatio = 0.2 diff --git a/Wox/Properties/AssemblyInfo.cs b/Wox/Properties/AssemblyInfo.cs index aebbd6d320..68eaa67960 100644 --- a/Wox/Properties/AssemblyInfo.cs +++ b/Wox/Properties/AssemblyInfo.cs @@ -1,9 +1,10 @@ using System.Reflection; using System.Windows; +using Exceptionless.Configuration; [assembly: AssemblyTitle("Wox")] [assembly: ThemeInfo( ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly )] -[assembly: Exceptionless.Configuration.Exceptionless("e0b256fbe9384498ba89aae2a6b7f8ab")] \ No newline at end of file +[assembly: Exceptionless("e0b256fbe9384498ba89aae2a6b7f8ab")] \ No newline at end of file diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs index f460fb5a73..28a481d6df 100644 --- a/Wox/SettingWindow.xaml.cs +++ b/Wox/SettingWindow.xaml.cs @@ -17,7 +17,6 @@ using Wox.Core.Theme; using Wox.Core.Updater; using Wox.Core.UserSettings; using Wox.Helper; -using Wox.Infrastructure.Exception; using Wox.Plugin; using Application = System.Windows.Forms.Application; using Stopwatch = Wox.Infrastructure.Stopwatch; @@ -27,13 +26,13 @@ namespace Wox public partial class SettingWindow : Window { public readonly MainWindow MainWindow; - bool settingsLoaded = false; + bool settingsLoaded; private Dictionary featureControls = new Dictionary(); - private bool themeTabLoaded = false; + private bool themeTabLoaded; public SettingWindow(MainWindow mainWindow) { - this.MainWindow = mainWindow; + MainWindow = mainWindow; InitializeComponent(); Loaded += Setting_Loaded; } @@ -248,7 +247,7 @@ namespace Wox #region Hotkey - void ctlHotkey_OnHotkeyChanged(object sender, System.EventArgs e) + void ctlHotkey_OnHotkeyChanged(object sender, EventArgs e) { if (ctlHotkey.CurrentHotkeyAvailable) { @@ -362,50 +361,50 @@ namespace Wox )); } - resultPanelPreview.AddResults(new List() + resultPanelPreview.AddResults(new List { - new Result() + new Result { Title = "Wox is an effective launcher for windows", SubTitle = "Wox provide bundles of features let you access infomations quickly.", IcoPath = "Images/app.png", - PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath) }, - new Result() + new Result { Title = "Search applications", SubTitle = "Search applications, files (via everything plugin) and browser bookmarks", IcoPath = "Images/app.png", - PluginDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath) }, - new Result() + new Result { Title = "Search web contents with shortcuts", SubTitle = "e.g. search google with g keyword or youtube keyword)", IcoPath = "Images/app.png", PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath) }, - new Result() + new Result { Title = "clipboard history ", IcoPath = "Images/app.png", PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath) }, - new Result() + new Result { Title = "Themes support", SubTitle = "get more themes from http://www.getwox.com/theme", IcoPath = "Images/app.png", PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath) }, - new Result() + new Result { Title = "Plugins support", SubTitle = "get more plugins from http://www.getwox.com/plugin", IcoPath = "Images/app.png", PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath) }, - new Result() + new Result { Title = "Wox is an open-source software", SubTitle = "Wox benefits from the open-source community a lot", @@ -416,7 +415,7 @@ namespace Wox foreach (string theme in ThemeManager.Theme.LoadAvailableThemes()) { - string themeName = System.IO.Path.GetFileNameWithoutExtension(theme); + string themeName = Path.GetFileNameWithoutExtension(theme); themeComboBox.Items.Add(themeName); } @@ -453,7 +452,7 @@ namespace Wox if (!settingsLoaded) return; string queryBoxFontName = cbQueryBoxFont.SelectedItem.ToString(); UserSettingStorage.Instance.QueryBoxFont = queryBoxFontName; - this.cbQueryBoxFontFaces.SelectedItem = ((FontFamily)cbQueryBoxFont.SelectedItem).ChooseRegularFamilyTypeface(); + cbQueryBoxFontFaces.SelectedItem = ((FontFamily)cbQueryBoxFont.SelectedItem).ChooseRegularFamilyTypeface(); UserSettingStorage.Instance.Save(); ThemeManager.Theme.ChangeTheme(UserSettingStorage.Instance.Theme); } @@ -466,8 +465,6 @@ namespace Wox { if (cbQueryBoxFontFaces.Items.Count > 0) cbQueryBoxFontFaces.SelectedIndex = 0; - - return; } else { @@ -484,7 +481,7 @@ namespace Wox if (!settingsLoaded) return; string resultItemFont = cbResultItemFont.SelectedItem.ToString(); UserSettingStorage.Instance.ResultItemFont = resultItemFont; - this.cbResultItemFontFaces.SelectedItem = ((FontFamily)cbResultItemFont.SelectedItem).ChooseRegularFamilyTypeface(); + cbResultItemFontFaces.SelectedItem = ((FontFamily)cbResultItemFont.SelectedItem).ChooseRegularFamilyTypeface(); UserSettingStorage.Instance.Save(); ThemeManager.Theme.ChangeTheme(UserSettingStorage.Instance.Theme); } @@ -596,7 +593,7 @@ namespace Wox if (customizedPluginConfig == null) { // todo when this part will be invoked - UserSettingStorage.Instance.CustomizedPluginConfigs.Add(new CustomizedPluginConfig() + UserSettingStorage.Instance.CustomizedPluginConfigs.Add(new CustomizedPluginConfig { Disabled = cbDisabled.IsChecked ?? true, ID = id, @@ -800,7 +797,7 @@ namespace Wox #endregion - private void Window_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) + private void Window_PreviewKeyDown(object sender, KeyEventArgs e) { // Hide window with ESC, but make sure it is not pressed as a hotkey if (e.Key == Key.Escape && !ctlHotkey.IsFocused) diff --git a/Wox/Storage/QueryHistoryStorage.cs b/Wox/Storage/QueryHistoryStorage.cs index 81ccc353ae..d6b65931fd 100644 --- a/Wox/Storage/QueryHistoryStorage.cs +++ b/Wox/Storage/QueryHistoryStorage.cs @@ -15,7 +15,7 @@ namespace Wox.Storage private List History = new List(); private int MaxHistory = 300; - private int cursor = 0; + private int cursor; public static PluginMetadata MetaData { get; } = new PluginMetadata { ID = "Query history", Name = "Query history" }; @@ -61,7 +61,7 @@ namespace Wox.Storage } else { - History.Add(new HistoryItem() + History.Add(new HistoryItem { Query = query, ExecutedDateTime = DateTime.Now diff --git a/Wox/Storage/TopMostRecordStorage.cs b/Wox/Storage/TopMostRecordStorage.cs index a1774a9fdd..c313d567ef 100644 --- a/Wox/Storage/TopMostRecordStorage.cs +++ b/Wox/Storage/TopMostRecordStorage.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Reflection; using Wox.Infrastructure.Storage; +using Wox.Plugin; namespace Wox.Storage { @@ -20,7 +21,7 @@ namespace Wox.Storage get { return "TopMostRecords"; } } - internal bool IsTopMost(Plugin.Result result) + internal bool IsTopMost(Result result) { return records.Any(o => o.Value.Title == result.Title && o.Value.SubTitle == result.SubTitle @@ -28,7 +29,7 @@ namespace Wox.Storage && o.Key == result.OriginQuery.RawQuery); } - internal void Remove(Plugin.Result result) + internal void Remove(Result result) { if (records.ContainsKey(result.OriginQuery.RawQuery)) { @@ -37,7 +38,7 @@ namespace Wox.Storage } } - internal void AddOrUpdate(Plugin.Result result) + internal void AddOrUpdate(Result result) { if (records.ContainsKey(result.OriginQuery.RawQuery)) { @@ -47,11 +48,11 @@ namespace Wox.Storage } else { - records.Add(result.OriginQuery.RawQuery, new TopMostRecord() - { + records.Add(result.OriginQuery.RawQuery, new TopMostRecord + { PluginID = result.PluginID, Title = result.Title, - SubTitle = result.SubTitle, + SubTitle = result.SubTitle }); } From b386af4121c94bdc85b218c68dd0eb1fc4fb63ce Mon Sep 17 00:00:00 2001 From: bao-qian Date: Wed, 6 Jan 2016 22:18:27 +0000 Subject: [PATCH 03/11] Add executable directory path --- Wox.Infrastructure/Properties/AssemblyInfo.cs | 6 +++++- Wox.Infrastructure/Wox.Infrastructure.csproj | 1 + Wox.Infrastructure/WoxDirectroy.cs | 13 +++++++++++++ Wox/App.xaml.cs | 5 +++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 Wox.Infrastructure/WoxDirectroy.cs diff --git a/Wox.Infrastructure/Properties/AssemblyInfo.cs b/Wox.Infrastructure/Properties/AssemblyInfo.cs index a75487010a..cd4944abf0 100644 --- a/Wox.Infrastructure/Properties/AssemblyInfo.cs +++ b/Wox.Infrastructure/Properties/AssemblyInfo.cs @@ -1,5 +1,9 @@ using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; [assembly: AssemblyTitle("Wox.Infrastructure")] -[assembly: Guid("aee57a31-29e5-4f03-a41f-7917910fe90f")] \ No newline at end of file +[assembly: Guid("aee57a31-29e5-4f03-a41f-7917910fe90f")] +[assembly: InternalsVisibleTo("Wox")] +[assembly: InternalsVisibleTo("Wox.Core")] +[assembly: InternalsVisibleTo("Wox.Test")] \ No newline at end of file diff --git a/Wox.Infrastructure/Wox.Infrastructure.csproj b/Wox.Infrastructure/Wox.Infrastructure.csproj index ff9276d5af..b62a1feb71 100644 --- a/Wox.Infrastructure/Wox.Infrastructure.csproj +++ b/Wox.Infrastructure/Wox.Infrastructure.csproj @@ -63,6 +63,7 @@ + diff --git a/Wox.Infrastructure/WoxDirectroy.cs b/Wox.Infrastructure/WoxDirectroy.cs new file mode 100644 index 0000000000..2cf383f28e --- /dev/null +++ b/Wox.Infrastructure/WoxDirectroy.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Wox.Infrastructure +{ + public static class WoxDirectroy + { + public static string Executable { get; internal set; } + } +} diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index 2d950b6892..19ff2c2f17 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -1,14 +1,18 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Linq; +using System.Reflection; using System.Threading; using System.Windows; using Wox.CommandArgs; using Wox.Core.Plugin; using Wox.Helper; +using Wox.Infrastructure; using Stopwatch = Wox.Infrastructure.Stopwatch; + namespace Wox { public partial class App : Application, ISingleInstanceApp @@ -33,6 +37,7 @@ namespace Wox Stopwatch.Debug("Startup Time", () => { base.OnStartup(e); + WoxDirectroy.Executable = Directory.GetParent(Assembly.GetExecutingAssembly().Location).ToString(); RegisterUnhandledException(); ThreadPool.QueueUserWorkItem(o => { ImageLoader.ImageLoader.PreloadImages(); }); Window = new MainWindow(); From b1ed51e72c313594fcfcb4a02cfe8d14d2f61ad0 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Thu, 7 Jan 2016 00:14:16 +0000 Subject: [PATCH 04/11] Fix missing using directive --- Wox.Infrastructure/Logger/Log.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Wox.Infrastructure/Logger/Log.cs b/Wox.Infrastructure/Logger/Log.cs index 77b99fa48b..92f84cfaa2 100644 --- a/Wox.Infrastructure/Logger/Log.cs +++ b/Wox.Infrastructure/Logger/Log.cs @@ -1,4 +1,5 @@ using NLog; +using Wox.Infrastructure.Exception; namespace Wox.Infrastructure.Logger { From c8a932b6b36de2d74b9b09c9e9e3902ea9533141 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Thu, 7 Jan 2016 02:31:17 +0000 Subject: [PATCH 05/11] Refactoring directory path for storage --- Plugins/Wox.Plugin.CMD/CMDStorage.cs | 10 +------- .../ContextMenuStorage.cs | 10 +------- Plugins/Wox.Plugin.Folder/FolderStorage.cs | 9 +------- .../Wox.Plugin.Program/ProgramCacheStorage.cs | 10 +------- Plugins/Wox.Plugin.Program/ProgramStorage.cs | 10 +------- .../Wox.Plugin.WebSearch/WebSearchStorage.cs | 10 +------- Wox.Core/UserSettings/UserSettingStorage.cs | 12 +--------- Wox.Infrastructure/Storage/BaseStorage.cs | 23 ++++++++----------- Wox.Infrastructure/Storage/BinaryStorage.cs | 4 ++-- Wox.Infrastructure/Storage/JsonStorage.cs | 4 ++-- Wox.UpdateFeedGenerator/ConfigStorage.cs | 10 +------- Wox/ImageLoader/ImageCacheStroage.cs | 10 +------- Wox/Storage/QueryHistoryStorage.cs | 10 +------- Wox/Storage/TopMostRecordStorage.cs | 18 ++++----------- Wox/Storage/UserSelectedRecordStorage.cs | 10 +------- 15 files changed, 29 insertions(+), 131 deletions(-) diff --git a/Plugins/Wox.Plugin.CMD/CMDStorage.cs b/Plugins/Wox.Plugin.CMD/CMDStorage.cs index ece62a06ad..c87bf37b48 100644 --- a/Plugins/Wox.Plugin.CMD/CMDStorage.cs +++ b/Plugins/Wox.Plugin.CMD/CMDStorage.cs @@ -17,15 +17,7 @@ namespace Wox.Plugin.CMD [JsonProperty] public Dictionary CMDHistory = new Dictionary(); - protected override string ConfigFolder - { - get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } - } - - protected override string ConfigName - { - get { return "CMDHistory"; } - } + protected override string FileName { get; } = "CMDHistory"; protected override CMDStorage LoadDefault() { diff --git a/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs b/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs index ac5c1bab1e..150f010145 100644 --- a/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs +++ b/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs @@ -15,15 +15,7 @@ namespace Wox.Plugin.Everything public IPublicAPI API { get; set; } - protected override string ConfigName - { - get { return "EverythingContextMenu"; } - } - - protected override string ConfigFolder - { - get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } - } + protected override string FileName { get; } = "EverythingContextMenu"; protected override void OnAfterLoad(ContextMenuStorage obj) { diff --git a/Plugins/Wox.Plugin.Folder/FolderStorage.cs b/Plugins/Wox.Plugin.Folder/FolderStorage.cs index 815643c9d8..f23273774d 100644 --- a/Plugins/Wox.Plugin.Folder/FolderStorage.cs +++ b/Plugins/Wox.Plugin.Folder/FolderStorage.cs @@ -10,14 +10,7 @@ namespace Wox.Plugin.Folder { [JsonProperty] public List FolderLinks { get; set; } - protected override string ConfigFolder - { - get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } - } - protected override string ConfigName - { - get { return "setting"; } - } + protected override string FileName { get; } = "settings_folder_plugin"; } } diff --git a/Plugins/Wox.Plugin.Program/ProgramCacheStorage.cs b/Plugins/Wox.Plugin.Program/ProgramCacheStorage.cs index f1b3a138cc..4f57910fb3 100644 --- a/Plugins/Wox.Plugin.Program/ProgramCacheStorage.cs +++ b/Plugins/Wox.Plugin.Program/ProgramCacheStorage.cs @@ -11,14 +11,6 @@ namespace Wox.Plugin.Program { public List Programs = new List(); - protected override string ConfigFolder - { - get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } - } - - protected override string ConfigName - { - get { return "ProgramIndexCache"; } - } + protected override string FileName { get; } = "ProgramIndexCache"; } } \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Program/ProgramStorage.cs b/Plugins/Wox.Plugin.Program/ProgramStorage.cs index d533443f01..a17171f7cd 100644 --- a/Plugins/Wox.Plugin.Program/ProgramStorage.cs +++ b/Plugins/Wox.Plugin.Program/ProgramStorage.cs @@ -23,11 +23,6 @@ namespace Wox.Plugin.Program [DefaultValue(true)] public bool EnableRegistrySource { get; set; } - protected override string ConfigFolder - { - get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } - } - protected override ProgramStorage LoadDefault() { ProgramSources = new List(); @@ -44,9 +39,6 @@ namespace Wox.Plugin.Program } } - protected override string ConfigName - { - get { return "setting"; } - } + protected override string FileName { get; } = "settings_plugin_program"; } } diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs index 5a059a2385..82e1d61356 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs @@ -17,14 +17,6 @@ namespace Wox.Plugin.WebSearch [JsonProperty] public string WebSearchSuggestionSource { get; set; } - protected override string ConfigFolder - { - get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } - } - - protected override string ConfigName - { - get { return "setting"; } - } + protected override string FileName { get; } = "settings_plugin_websearch"; } } diff --git a/Wox.Core/UserSettings/UserSettingStorage.cs b/Wox.Core/UserSettings/UserSettingStorage.cs index a52a90ba99..1cab071e82 100644 --- a/Wox.Core/UserSettings/UserSettingStorage.cs +++ b/Wox.Core/UserSettings/UserSettingStorage.cs @@ -107,17 +107,7 @@ namespace Wox.Core.UserSettings [JsonProperty] public int MaxResultsToShow { get; set; } - protected override string ConfigFolder - { - get { return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Config"); } - } - - protected override string ConfigName - { - get { return "config"; } - } - - + protected override string FileName { get; } = "Settings"; public void IncreaseActivateTimes() { diff --git a/Wox.Infrastructure/Storage/BaseStorage.cs b/Wox.Infrastructure/Storage/BaseStorage.cs index 4ddee08ada..03e0311eb7 100644 --- a/Wox.Infrastructure/Storage/BaseStorage.cs +++ b/Wox.Infrastructure/Storage/BaseStorage.cs @@ -4,23 +4,18 @@ using System.IO; namespace Wox.Infrastructure.Storage { [Serializable] - public abstract class BaseStorage : IStorage where T : class,IStorage, new() + public abstract class BaseStorage : IStorage where T : class, IStorage, new() { - protected abstract string ConfigFolder { get; } + protected string DirectoryPath { get; } = Path.Combine(WoxDirectroy.Executable, "Config"); - protected string ConfigPath - { - get - { - return Path.Combine(ConfigFolder, ConfigName + FileSuffix); - } - } + protected string FilePath => Path.Combine(DirectoryPath, FileName + FileSuffix); protected abstract string FileSuffix { get; } - protected abstract string ConfigName { get; } + protected abstract string FileName { get; } private static object locker = new object(); + protected static T serializedObject; public event Action AfterLoad; @@ -64,13 +59,13 @@ namespace Wox.Infrastructure.Storage public void Load() { - if (!File.Exists(ConfigPath)) + if (!File.Exists(FilePath)) { - if (!Directory.Exists(ConfigFolder)) + if (!Directory.Exists(DirectoryPath)) { - Directory.CreateDirectory(ConfigFolder); + Directory.CreateDirectory(DirectoryPath); } - File.Create(ConfigPath).Close(); + File.Create(FilePath).Close(); } LoadInternal(); OnAfterLoad(serializedObject); diff --git a/Wox.Infrastructure/Storage/BinaryStorage.cs b/Wox.Infrastructure/Storage/BinaryStorage.cs index fc433b9848..75258df007 100644 --- a/Wox.Infrastructure/Storage/BinaryStorage.cs +++ b/Wox.Infrastructure/Storage/BinaryStorage.cs @@ -28,7 +28,7 @@ namespace Wox.Infrastructure.Storage AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; try { - using (FileStream fileStream = new FileStream(ConfigPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (FileStream fileStream = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { if (fileStream.Length > 0) { @@ -93,7 +93,7 @@ namespace Wox.Infrastructure.Storage { try { - FileStream fileStream = new FileStream(ConfigPath, FileMode.Create); + FileStream fileStream = new FileStream(FilePath, FileMode.Create); BinaryFormatter binaryFormatter = new BinaryFormatter { AssemblyFormat = FormatterAssemblyStyle.Simple diff --git a/Wox.Infrastructure/Storage/JsonStorage.cs b/Wox.Infrastructure/Storage/JsonStorage.cs index 07f6329ef4..16f6278059 100644 --- a/Wox.Infrastructure/Storage/JsonStorage.cs +++ b/Wox.Infrastructure/Storage/JsonStorage.cs @@ -17,7 +17,7 @@ namespace Wox.Infrastructure.Storage protected override void LoadInternal() { - string json = File.ReadAllText(ConfigPath); + string json = File.ReadAllText(FilePath); if (!string.IsNullOrEmpty(json)) { try @@ -42,7 +42,7 @@ namespace Wox.Infrastructure.Storage lock (syncObject) { string json = JsonConvert.SerializeObject(serializedObject, Formatting.Indented); - File.WriteAllText(ConfigPath, json); + File.WriteAllText(FilePath, json); } }); } diff --git a/Wox.UpdateFeedGenerator/ConfigStorage.cs b/Wox.UpdateFeedGenerator/ConfigStorage.cs index 84bd970144..a7dcbc35cf 100644 --- a/Wox.UpdateFeedGenerator/ConfigStorage.cs +++ b/Wox.UpdateFeedGenerator/ConfigStorage.cs @@ -40,14 +40,6 @@ namespace Wox.UpdateFeedGenerator } } - protected override string ConfigFolder - { - get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } - } - - protected override string ConfigName - { - get { return "config"; } - } + protected override string FileName { get; } = "config"; } } diff --git a/Wox/ImageLoader/ImageCacheStroage.cs b/Wox/ImageLoader/ImageCacheStroage.cs index 22240cc0b8..18b441d9ec 100644 --- a/Wox/ImageLoader/ImageCacheStroage.cs +++ b/Wox/ImageLoader/ImageCacheStroage.cs @@ -14,15 +14,7 @@ namespace Wox.ImageLoader private const int maxCached = 200; public Dictionary TopUsedImages = new Dictionary(); - protected override string ConfigFolder - { - get { return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Config"); } - } - - protected override string ConfigName - { - get { return "ImageCache"; } - } + protected override string FileName { get; } = "ImageCache"; public void Add(string path) { diff --git a/Wox/Storage/QueryHistoryStorage.cs b/Wox/Storage/QueryHistoryStorage.cs index d6b65931fd..6fec79789a 100644 --- a/Wox/Storage/QueryHistoryStorage.cs +++ b/Wox/Storage/QueryHistoryStorage.cs @@ -20,15 +20,7 @@ namespace Wox.Storage public static PluginMetadata MetaData { get; } = new PluginMetadata { ID = "Query history", Name = "Query history" }; - protected override string ConfigFolder - { - get { return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Config"); } - } - - protected override string ConfigName - { - get { return "QueryHistory"; } - } + protected override string FileName { get; } = "QueryHistory"; public HistoryItem Previous() { diff --git a/Wox/Storage/TopMostRecordStorage.cs b/Wox/Storage/TopMostRecordStorage.cs index c313d567ef..2ccbe86e58 100644 --- a/Wox/Storage/TopMostRecordStorage.cs +++ b/Wox/Storage/TopMostRecordStorage.cs @@ -11,15 +11,7 @@ namespace Wox.Storage { public Dictionary records = new Dictionary(); - protected override string ConfigFolder - { - get { return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Config"); } - } - - protected override string ConfigName - { - get { return "TopMostRecords"; } - } + protected override string FileName { get; } = "TopMostRecords"; internal bool IsTopMost(Result result) { @@ -50,10 +42,10 @@ namespace Wox.Storage { records.Add(result.OriginQuery.RawQuery, new TopMostRecord { - PluginID = result.PluginID, - Title = result.Title, - SubTitle = result.SubTitle - }); + PluginID = result.PluginID, + Title = result.Title, + SubTitle = result.SubTitle + }); } Save(); diff --git a/Wox/Storage/UserSelectedRecordStorage.cs b/Wox/Storage/UserSelectedRecordStorage.cs index 3f6ac51ca3..ea0289943e 100644 --- a/Wox/Storage/UserSelectedRecordStorage.cs +++ b/Wox/Storage/UserSelectedRecordStorage.cs @@ -12,15 +12,7 @@ namespace Wox.Storage [JsonProperty] private Dictionary records = new Dictionary(); - protected override string ConfigFolder - { - get { return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Config"); } - } - - protected override string ConfigName - { - get { return "UserSelectedRecords"; } - } + protected override string FileName { get; } = "UserSelectedRecords"; public void Add(Result result) { From 8504d0168833f8bd6f24948e29ac4fd7cd3abcde Mon Sep 17 00:00:00 2001 From: bao-qian Date: Thu, 7 Jan 2016 04:47:28 +0000 Subject: [PATCH 06/11] Refactoring directory path for UI resource --- Wox.Core/Resource/Resource.cs | 15 ++++++++++++ Wox.Core/{UI => Resource}/ResourceMerger.cs | 10 ++------ Wox.Core/Theme/Theme.cs | 10 ++++---- Wox.Core/UI/IUIResource.cs | 12 ---------- Wox.Core/Wox.Core.csproj | 5 ++-- Wox.Core/i18n/IInternationalization.cs | 24 ------------------- Wox.Core/i18n/Internationalization.cs | 26 ++++++++++----------- 7 files changed, 37 insertions(+), 65 deletions(-) create mode 100644 Wox.Core/Resource/Resource.cs rename Wox.Core/{UI => Resource}/ResourceMerger.cs (81%) delete mode 100644 Wox.Core/UI/IUIResource.cs delete mode 100644 Wox.Core/i18n/IInternationalization.cs diff --git a/Wox.Core/Resource/Resource.cs b/Wox.Core/Resource/Resource.cs new file mode 100644 index 0000000000..3c03994e72 --- /dev/null +++ b/Wox.Core/Resource/Resource.cs @@ -0,0 +1,15 @@ +using System.IO; +using System.Windows; +using Wox.Infrastructure; + +namespace Wox.Core.UI +{ + public abstract class Resource + { + public string DirectoryName { get; protected set; } + + protected string DirectoryPath => Path.Combine(WoxDirectroy.Executable, DirectoryName); + + public abstract ResourceDictionary GetResourceDictionary(); + } +} diff --git a/Wox.Core/UI/ResourceMerger.cs b/Wox.Core/Resource/ResourceMerger.cs similarity index 81% rename from Wox.Core/UI/ResourceMerger.cs rename to Wox.Core/Resource/ResourceMerger.cs index 9ce07a97ee..255314e623 100644 --- a/Wox.Core/UI/ResourceMerger.cs +++ b/Wox.Core/Resource/ResourceMerger.cs @@ -25,18 +25,12 @@ namespace Wox.Core.UI } } - public static void UpdateResource(Theme.Theme t) + public static void UpdateResource(T t) where T : Resource { - RemoveResource(Theme.Theme.DirectoryName); + RemoveResource(t.DirectoryName); Application.Current.Resources.MergedDictionaries.Add(t.GetResourceDictionary()); } - public static void UpdateResources(Internationalization i) - { - RemoveResource(Internationalization.DirectoryName); - Application.Current.Resources.MergedDictionaries.Add(i.GetResourceDictionary()); - } - internal static void UpdatePluginLanguages() { RemoveResource(PluginManager.DirectoryName); diff --git a/Wox.Core/Theme/Theme.cs b/Wox.Core/Theme/Theme.cs index b54192bd11..28c32c90cb 100644 --- a/Wox.Core/Theme/Theme.cs +++ b/Wox.Core/Theme/Theme.cs @@ -14,14 +14,14 @@ using Wox.Infrastructure.Logger; namespace Wox.Core.Theme { - public class Theme : IUIResource + public class Theme : Resource { - public const string DirectoryName = "Themes"; private static List themeDirectories = new List(); - static Theme() + public Theme() { - themeDirectories.Add(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), DirectoryName)); + DirectoryName = "Themes"; + themeDirectories.Add(DirectoryPath); MakesureThemeDirectoriesExist(); } @@ -67,7 +67,7 @@ namespace Wox.Core.Theme } } - public ResourceDictionary GetResourceDictionary() + public override ResourceDictionary GetResourceDictionary() { var dict = new ResourceDictionary { diff --git a/Wox.Core/UI/IUIResource.cs b/Wox.Core/UI/IUIResource.cs deleted file mode 100644 index 99d89551a6..0000000000 --- a/Wox.Core/UI/IUIResource.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Windows; - -namespace Wox.Core.UI -{ - /// - /// Object implement this interface will have the ability to has its own UI styles - /// - public interface IUIResource - { - ResourceDictionary GetResourceDictionary(); - } -} diff --git a/Wox.Core/Wox.Core.csproj b/Wox.Core/Wox.Core.csproj index 6856a93632..e4f1687c79 100644 --- a/Wox.Core/Wox.Core.csproj +++ b/Wox.Core/Wox.Core.csproj @@ -66,13 +66,12 @@ - - - + + diff --git a/Wox.Core/i18n/IInternationalization.cs b/Wox.Core/i18n/IInternationalization.cs deleted file mode 100644 index 5ab83c1327..0000000000 --- a/Wox.Core/i18n/IInternationalization.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections.Generic; - -namespace Wox.Core.i18n -{ - interface IInternationalization - { - List LoadAvailableLanguages(); - - string GetTranslation(string key); - - /// - /// Get language file for current user selected language - /// if couldn't find the current selected language file, it will first try to load en.xaml - /// if en.xaml couldn't find, return empty string - /// - /// - /// - string GetLanguageFile(string folder); - - void ChangeLanguage(Language language); - - void ChangeLanguage(string languageCode); - } -} diff --git a/Wox.Core/i18n/Internationalization.cs b/Wox.Core/i18n/Internationalization.cs index a8018ad057..fe19a33437 100644 --- a/Wox.Core/i18n/Internationalization.cs +++ b/Wox.Core/i18n/Internationalization.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; using System.Windows; using Wox.Core.UI; using Wox.Core.UserSettings; @@ -12,23 +11,21 @@ using Wox.Plugin; namespace Wox.Core.i18n { - public class Internationalization : IInternationalization, IUIResource + public class Internationalization : Resource { - public const string DirectoryName = "Languages"; - private static readonly string DefaultDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), DirectoryName); - - static Internationalization() + public Internationalization() { + DirectoryName = "Languages"; MakesureThemeDirectoriesExist(); } - private static void MakesureThemeDirectoriesExist() + private void MakesureThemeDirectoriesExist() { - if (!Directory.Exists(DefaultDirectory)) + if (!Directory.Exists(DirectoryPath)) { try { - Directory.CreateDirectory(DefaultDirectory); + Directory.CreateDirectory(DirectoryPath); } catch (Exception e) { @@ -70,14 +67,16 @@ namespace Wox.Core.i18n UserSettingStorage.Instance.Language = language.LanguageCode; UserSettingStorage.Instance.Save(); - ResourceMerger.UpdateResources(this); + ResourceMerger.UpdateResource(this); } - public ResourceDictionary GetResourceDictionary() + + + public override ResourceDictionary GetResourceDictionary() { return new ResourceDictionary { - Source = new Uri(GetLanguageFile(DefaultDirectory), UriKind.Absolute) + Source = new Uri(GetLanguageFile(DirectoryPath), UriKind.Absolute) }; } @@ -124,7 +123,7 @@ namespace Wox.Core.i18n private string GetLanguagePath(Language language) { - string path = Path.Combine(DefaultDirectory, language.LanguageCode + ".xaml"); + string path = Path.Combine(DirectoryPath, language.LanguageCode + ".xaml"); if (File.Exists(path)) { return path; @@ -156,4 +155,5 @@ namespace Wox.Core.i18n } } + } From ec40956721befe41301bced7ed337c8259d1f52b Mon Sep 17 00:00:00 2001 From: bao-qian Date: Thu, 7 Jan 2016 20:04:37 +0000 Subject: [PATCH 07/11] Merge language and theme into resource folder --- Wox.Core/Plugin/PluginManager.cs | 3 +-- Wox.Core/{i18n => Resource}/AvailableLanguages.cs | 2 +- Wox.Core/{Theme => Resource}/FontHelper.cs | 2 +- .../{i18n => Resource}/Internationalization.cs | 3 +-- .../InternationalizationManager.cs | 2 +- Wox.Core/{i18n => Resource}/Language.cs | 2 +- Wox.Core/Resource/Resource.cs | 2 +- Wox.Core/Resource/ResourceMerger.cs | 5 ++--- Wox.Core/{Theme => Resource}/Theme.cs | 4 +--- Wox.Core/{Theme => Resource}/ThemeManager.cs | 2 +- Wox.Core/Updater/UpdaterManager.cs | 2 +- Wox.Core/Wox.Core.csproj | 14 +++++++------- Wox.CrashReporter/ReportWindow.xaml.cs | 2 +- Wox/ActionKeywords.xaml.cs | 2 +- Wox/CustomQueryHotkeySetting.xaml.cs | 2 +- Wox/HotkeyControl.xaml.cs | 2 +- Wox/MainWindow.xaml.cs | 3 +-- Wox/SettingWindow.xaml.cs | 3 +-- Wox/WoxUpdate.xaml.cs | 2 +- 19 files changed, 26 insertions(+), 33 deletions(-) rename Wox.Core/{i18n => Resource}/AvailableLanguages.cs (96%) rename Wox.Core/{Theme => Resource}/FontHelper.cs (98%) rename Wox.Core/{i18n => Resource}/Internationalization.cs (99%) rename Wox.Core/{i18n => Resource}/InternationalizationManager.cs (95%) rename Wox.Core/{i18n => Resource}/Language.cs (91%) rename Wox.Core/{Theme => Resource}/Theme.cs (99%) rename Wox.Core/{Theme => Resource}/ThemeManager.cs (94%) diff --git a/Wox.Core/Plugin/PluginManager.cs b/Wox.Core/Plugin/PluginManager.cs index 5bcabee4fe..7ccdc60a6e 100644 --- a/Wox.Core/Plugin/PluginManager.cs +++ b/Wox.Core/Plugin/PluginManager.cs @@ -4,8 +4,7 @@ using System.IO; using System.Linq; using System.Reflection; using System.Threading; -using Wox.Core.i18n; -using Wox.Core.UI; +using Wox.Core.Resource; using Wox.Core.UserSettings; using Wox.Infrastructure; using Wox.Infrastructure.Exception; diff --git a/Wox.Core/i18n/AvailableLanguages.cs b/Wox.Core/Resource/AvailableLanguages.cs similarity index 96% rename from Wox.Core/i18n/AvailableLanguages.cs rename to Wox.Core/Resource/AvailableLanguages.cs index b0d41c414b..7b6231c861 100644 --- a/Wox.Core/i18n/AvailableLanguages.cs +++ b/Wox.Core/Resource/AvailableLanguages.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace Wox.Core.i18n +namespace Wox.Core.Resource { internal static class AvailableLanguages { diff --git a/Wox.Core/Theme/FontHelper.cs b/Wox.Core/Resource/FontHelper.cs similarity index 98% rename from Wox.Core/Theme/FontHelper.cs rename to Wox.Core/Resource/FontHelper.cs index 8aca0b4363..c7cc54bf67 100644 --- a/Wox.Core/Theme/FontHelper.cs +++ b/Wox.Core/Resource/FontHelper.cs @@ -3,7 +3,7 @@ using System.Linq; using System.Windows; using System.Windows.Media; -namespace Wox.Core.Theme +namespace Wox.Core.Resource { public static class FontHelper { diff --git a/Wox.Core/i18n/Internationalization.cs b/Wox.Core/Resource/Internationalization.cs similarity index 99% rename from Wox.Core/i18n/Internationalization.cs rename to Wox.Core/Resource/Internationalization.cs index fe19a33437..14aad3c1f3 100644 --- a/Wox.Core/i18n/Internationalization.cs +++ b/Wox.Core/Resource/Internationalization.cs @@ -3,13 +3,12 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Windows; -using Wox.Core.UI; using Wox.Core.UserSettings; using Wox.Infrastructure.Exception; using Wox.Infrastructure.Logger; using Wox.Plugin; -namespace Wox.Core.i18n +namespace Wox.Core.Resource { public class Internationalization : Resource { diff --git a/Wox.Core/i18n/InternationalizationManager.cs b/Wox.Core/Resource/InternationalizationManager.cs similarity index 95% rename from Wox.Core/i18n/InternationalizationManager.cs rename to Wox.Core/Resource/InternationalizationManager.cs index 999ae9e327..ffc2c2ecfe 100644 --- a/Wox.Core/i18n/InternationalizationManager.cs +++ b/Wox.Core/Resource/InternationalizationManager.cs @@ -1,4 +1,4 @@ -namespace Wox.Core.i18n +namespace Wox.Core.Resource { public static class InternationalizationManager { diff --git a/Wox.Core/i18n/Language.cs b/Wox.Core/Resource/Language.cs similarity index 91% rename from Wox.Core/i18n/Language.cs rename to Wox.Core/Resource/Language.cs index 6caefeedd1..c0bdc1ccb4 100644 --- a/Wox.Core/i18n/Language.cs +++ b/Wox.Core/Resource/Language.cs @@ -1,4 +1,4 @@ -namespace Wox.Core.i18n +namespace Wox.Core.Resource { public class Language { diff --git a/Wox.Core/Resource/Resource.cs b/Wox.Core/Resource/Resource.cs index 3c03994e72..9ac7f28894 100644 --- a/Wox.Core/Resource/Resource.cs +++ b/Wox.Core/Resource/Resource.cs @@ -2,7 +2,7 @@ using System.Windows; using Wox.Infrastructure; -namespace Wox.Core.UI +namespace Wox.Core.Resource { public abstract class Resource { diff --git a/Wox.Core/Resource/ResourceMerger.cs b/Wox.Core/Resource/ResourceMerger.cs index 255314e623..61f3485ae6 100644 --- a/Wox.Core/Resource/ResourceMerger.cs +++ b/Wox.Core/Resource/ResourceMerger.cs @@ -2,11 +2,10 @@ using System.IO; using System.Linq; using System.Windows; -using Wox.Core.i18n; using Wox.Core.Plugin; using Wox.Plugin; -namespace Wox.Core.UI +namespace Wox.Core.Resource { public static class ResourceMerger { @@ -25,7 +24,7 @@ namespace Wox.Core.UI } } - public static void UpdateResource(T t) where T : Resource + public static void UpdateResource(T t) where T : Core.Resource.Resource { RemoveResource(t.DirectoryName); Application.Current.Resources.MergedDictionaries.Add(t.GetResourceDictionary()); diff --git a/Wox.Core/Theme/Theme.cs b/Wox.Core/Resource/Theme.cs similarity index 99% rename from Wox.Core/Theme/Theme.cs rename to Wox.Core/Resource/Theme.cs index 28c32c90cb..983b7ca55d 100644 --- a/Wox.Core/Theme/Theme.cs +++ b/Wox.Core/Resource/Theme.cs @@ -2,17 +2,15 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; using System.Runtime.InteropServices; using System.Windows; using System.Windows.Controls; using System.Windows.Interop; using System.Windows.Media; -using Wox.Core.UI; using Wox.Core.UserSettings; using Wox.Infrastructure.Logger; -namespace Wox.Core.Theme +namespace Wox.Core.Resource { public class Theme : Resource { diff --git a/Wox.Core/Theme/ThemeManager.cs b/Wox.Core/Resource/ThemeManager.cs similarity index 94% rename from Wox.Core/Theme/ThemeManager.cs rename to Wox.Core/Resource/ThemeManager.cs index 3ad8a0d7d7..ef1414757c 100644 --- a/Wox.Core/Theme/ThemeManager.cs +++ b/Wox.Core/Resource/ThemeManager.cs @@ -1,4 +1,4 @@ -namespace Wox.Core.Theme +namespace Wox.Core.Resource { public class ThemeManager { diff --git a/Wox.Core/Updater/UpdaterManager.cs b/Wox.Core/Updater/UpdaterManager.cs index 9b15e10082..9101332d55 100644 --- a/Wox.Core/Updater/UpdaterManager.cs +++ b/Wox.Core/Updater/UpdaterManager.cs @@ -8,7 +8,7 @@ using NAppUpdate.Framework.Common; using NAppUpdate.Framework.Sources; using NAppUpdate.Framework.Tasks; using Newtonsoft.Json; -using Wox.Core.i18n; +using Wox.Core.Resource; using Wox.Core.UserSettings; using Wox.Infrastructure.Http; using Wox.Infrastructure.Logger; diff --git a/Wox.Core/Wox.Core.csproj b/Wox.Core/Wox.Core.csproj index e4f1687c79..e1e6bdfd74 100644 --- a/Wox.Core/Wox.Core.csproj +++ b/Wox.Core/Wox.Core.csproj @@ -65,11 +65,11 @@ - - - - - + + + + + @@ -82,8 +82,8 @@ - - + + diff --git a/Wox.CrashReporter/ReportWindow.xaml.cs b/Wox.CrashReporter/ReportWindow.xaml.cs index f31585e2fc..2ba0be0991 100644 --- a/Wox.CrashReporter/ReportWindow.xaml.cs +++ b/Wox.CrashReporter/ReportWindow.xaml.cs @@ -3,7 +3,7 @@ using System.Threading; using System.Windows; using System.Windows.Documents; using Exceptionless; -using Wox.Core.i18n; +using Wox.Core.Resource; using Wox.Core.Updater; namespace Wox.CrashReporter diff --git a/Wox/ActionKeywords.xaml.cs b/Wox/ActionKeywords.xaml.cs index 46868ebbcb..aa718ffd12 100644 --- a/Wox/ActionKeywords.xaml.cs +++ b/Wox/ActionKeywords.xaml.cs @@ -1,6 +1,6 @@ using System.Windows; -using Wox.Core.i18n; using Wox.Core.Plugin; +using Wox.Core.Resource; using Wox.Core.UserSettings; using Wox.Infrastructure.Exception; using Wox.Plugin; diff --git a/Wox/CustomQueryHotkeySetting.xaml.cs b/Wox/CustomQueryHotkeySetting.xaml.cs index 8cf21b62d0..7c58babe1c 100644 --- a/Wox/CustomQueryHotkeySetting.xaml.cs +++ b/Wox/CustomQueryHotkeySetting.xaml.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Windows; -using Wox.Core.i18n; +using Wox.Core.Resource; using Wox.Core.UserSettings; namespace Wox diff --git a/Wox/HotkeyControl.xaml.cs b/Wox/HotkeyControl.xaml.cs index ae38b9f904..fd7a1205e1 100644 --- a/Wox/HotkeyControl.xaml.cs +++ b/Wox/HotkeyControl.xaml.cs @@ -5,7 +5,7 @@ using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using NHotkey.Wpf; -using Wox.Core.i18n; +using Wox.Core.Resource; using Wox.Infrastructure.Hotkey; using Wox.Plugin; diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 84e76e8860..c0795c70e6 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -15,9 +15,8 @@ using System.Windows.Input; using System.Windows.Media.Animation; using NHotkey; using NHotkey.Wpf; -using Wox.Core.i18n; using Wox.Core.Plugin; -using Wox.Core.Theme; +using Wox.Core.Resource; using Wox.Core.Updater; using Wox.Core.UserSettings; using Wox.Helper; diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs index 28a481d6df..effdddb618 100644 --- a/Wox/SettingWindow.xaml.cs +++ b/Wox/SettingWindow.xaml.cs @@ -11,9 +11,8 @@ using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using Microsoft.Win32; -using Wox.Core.i18n; using Wox.Core.Plugin; -using Wox.Core.Theme; +using Wox.Core.Resource; using Wox.Core.Updater; using Wox.Core.UserSettings; using Wox.Helper; diff --git a/Wox/WoxUpdate.xaml.cs b/Wox/WoxUpdate.xaml.cs index 3534bac0b2..83f7e57d52 100644 --- a/Wox/WoxUpdate.xaml.cs +++ b/Wox/WoxUpdate.xaml.cs @@ -1,6 +1,6 @@ using System.Windows; using MarkdownSharp; -using Wox.Core.i18n; +using Wox.Core.Resource; using Wox.Core.Updater; namespace Wox From 8ee94d75ca8a33c207b87985c6cddc838af263f2 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Fri, 8 Jan 2016 01:13:36 +0000 Subject: [PATCH 08/11] Refactoring directory path for plugin --- Plugins/Wox.Plugin.Everything/Main.cs | 42 ++--- .../Wox.Plugin.WebSearch/WebSearchStorage.cs | 163 +++++++++++++++++- .../Wox.Plugin.WebSearch.csproj | 3 - Wox.Core/Plugin/PluginManager.cs | 25 ++- Wox.Plugin/PluginMetadata.cs | 5 +- 5 files changed, 196 insertions(+), 42 deletions(-) diff --git a/Plugins/Wox.Plugin.Everything/Main.cs b/Plugins/Wox.Plugin.Everything/Main.cs index dffa1ea87a..b50d92174b 100644 --- a/Plugins/Wox.Plugin.Everything/Main.cs +++ b/Plugins/Wox.Plugin.Everything/Main.cs @@ -13,10 +13,10 @@ namespace Wox.Plugin.Everything { public class Main : IPlugin, IPluginI18n, IContextMenu { - PluginInitContext context; - EverythingAPI api = new EverythingAPI(); - private static List imageExts = new List { ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".ico" }; - private static List executableExts = new List { ".exe" }; + private PluginInitContext _context; + private readonly EverythingAPI _api = new EverythingAPI(); + private static readonly List ImageExts = new List { ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".ico" }; + private static readonly List ExecutableExts = new List { ".exe" }; public List Query(Query query) { @@ -47,7 +47,7 @@ namespace Wox.Plugin.Everything try { - var searchList = api.Search(keyword, maxCount: ContextMenuStorage.Instance.MaxSearchCount).ToList(); + var searchList = _api.Search(keyword, maxCount: ContextMenuStorage.Instance.MaxSearchCount).ToList(); foreach (var s in searchList) { var path = s.FullPath; @@ -57,7 +57,7 @@ namespace Wox.Plugin.Everything r.IcoPath = GetIconPath(s); r.Action = c => { - context.API.HideApp(); + _context.API.HideApp(); Process.Start(new ProcessStartInfo { FileName = path, @@ -74,7 +74,7 @@ namespace Wox.Plugin.Everything StartEverything(); results.Add(new Result { - Title = context.API.GetTranslation("wox_plugin_everything_is_not_running"), + Title = _context.API.GetTranslation("wox_plugin_everything_is_not_running"), IcoPath = "Images\\warning.png" }); } @@ -82,12 +82,12 @@ namespace Wox.Plugin.Everything { results.Add(new Result { - Title = context.API.GetTranslation("wox_plugin_everything_query_error"), + Title = _context.API.GetTranslation("wox_plugin_everything_query_error"), SubTitle = e.Message, Action = _ => { Clipboard.SetText(e.Message + "\r\n" + e.StackTrace); - context.API.ShowMsg(context.API.GetTranslation("wox_plugin_everything_copied"), null, string.Empty); + _context.API.ShowMsg(_context.API.GetTranslation("wox_plugin_everything_copied"), null, string.Empty); return false; }, IcoPath = "Images\\error.png" @@ -95,7 +95,7 @@ namespace Wox.Plugin.Everything } } - api.Reset(); + _api.Reset(); return results; } @@ -109,11 +109,11 @@ namespace Wox.Plugin.Everything } else if (!string.IsNullOrEmpty(ext)) { - if (imageExts.Contains(ext.ToLower())) + if (ImageExts.Contains(ext.ToLower())) { return "Images\\image.png"; } - else if (executableExts.Contains(ext.ToLower())) + else if (ExecutableExts.Contains(ext.ToLower())) { return s.FullPath; } @@ -130,7 +130,7 @@ namespace Wox.Plugin.Everything List defaultContextMenus = new List(); ContextMenu openFolderContextMenu = new ContextMenu { - Name = context.API.GetTranslation("wox_plugin_everything_open_containing_folder"), + Name = _context.API.GetTranslation("wox_plugin_everything_open_containing_folder"), Command = "explorer.exe", Argument = " /select,\"{path}\"", ImagePath = "Images\\folder.png" @@ -142,7 +142,7 @@ namespace Wox.Plugin.Everything public void Init(PluginInitContext context) { - this.context = context; + _context = context; ContextMenuStorage.Instance.API = context.API; LoadLibrary(Path.Combine( @@ -225,7 +225,7 @@ namespace Wox.Plugin.Everything } catch (Exception e) { - context.API.ShowMsg("Start Everything failed"); + _context.API.ShowMsg("Start Everything failed"); } } @@ -250,8 +250,10 @@ namespace Wox.Plugin.Everything private string GetEverythingPath() { - string everythingFolder = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "PortableEverything"); - return Path.Combine(everythingFolder, "Everything.exe"); + string directory = Path.Combine(_context.CurrentPluginMetadata.PluginDirectory, + "PortableEverything", + "Everything.exe"); + return directory; } public string GetLanguagesFolder() @@ -261,12 +263,12 @@ namespace Wox.Plugin.Everything public string GetTranslatedPluginTitle() { - return context.API.GetTranslation("wox_plugin_everything_plugin_name"); + return _context.API.GetTranslation("wox_plugin_everything_plugin_name"); } public string GetTranslatedPluginDescription() { - return context.API.GetTranslation("wox_plugin_everything_plugin_description"); + return _context.API.GetTranslation("wox_plugin_everything_plugin_description"); } public List LoadContextMenus(Result selectedResult) @@ -296,7 +298,7 @@ namespace Wox.Plugin.Everything } catch { - context.API.ShowMsg(string.Format(context.API.GetTranslation("wox_plugin_everything_canot_start"), record.FullPath), string.Empty, string.Empty); + _context.API.ShowMsg(string.Format(_context.API.GetTranslation("wox_plugin_everything_canot_start"), record.FullPath), string.Empty, string.Empty); return false; } return true; diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs index 82e1d61356..824ad6e261 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs @@ -18,5 +18,166 @@ namespace Wox.Plugin.WebSearch public string WebSearchSuggestionSource { get; set; } protected override string FileName { get; } = "settings_plugin_websearch"; + + protected override WebSearchStorage LoadDefault() + { + WebSearches = new List(new List() + { + new WebSearch + { + Title = "Google", + ActionKeyword = "g", + IconPath = "Images\\google.png", + Url = "https://www.google.com/search?q=new WebSearch {q}", + Enabled = true + }, + new WebSearch + { + Title = "Wikipedia", + ActionKeyword = "wiki", + IconPath = "Images\\wiki.png", + Url = "http://en.wikipedia.org/wiki/new WebSearch {q}", + Enabled = true + }, + new WebSearch + { + Title = "FindIcon", + ActionKeyword = "findicon", + IconPath = "Images\\pictures.png", + Url = "http://findicons.com/search/new WebSearch {q}", + Enabled = true + }, + new WebSearch + { + Title = "Facebook", + ActionKeyword = "facebook", + IconPath = "Images\\facebook.png", + Url = "http://www.facebook.com/search/?q=new WebSearch {q}", + Enabled = true + }, + new WebSearch + { + Title = "Twitter", + ActionKeyword = "twitter", + IconPath = "Images\\twitter.png", + Url = "http://twitter.com/search?q=new WebSearch {q}", + Enabled = true + }, + new WebSearch + { + Title = "Google Maps", + ActionKeyword = "maps", + IconPath = "Images\\google_maps.png", + Url = "http://maps.google.com/maps?q=new WebSearch {q}", + Enabled = true + }, + new WebSearch + { + Title = "Google Translate", + ActionKeyword = "translate", + IconPath = "Images\\google_translate.png", + Url = "http://translate.google.com/#auto|en|new WebSearch {q}", + Enabled = true + }, + new WebSearch + { + Title = "Duckduckgo", + ActionKeyword = "duckduckgo", + IconPath = "Images\\duckduckgo.png", + Url = "https://duckduckgo.com/?q=new WebSearch {q}", + Enabled = true + }, + new WebSearch + { + Title = "Github", + ActionKeyword = "github", + IconPath = "Images\\github.png", + Url = "https://github.com/search?q=new WebSearch {q}", + Enabled = true + }, + new WebSearch + { + Title = "Github Gist", + ActionKeyword = "gist", + IconPath = "Images\\gist.png", + Url = "https://gist.github.com/search?q=new WebSearch {q}", + Enabled = true + }, + new WebSearch + { + Title = "Gmail", + ActionKeyword = "gmail", + IconPath = "Images\\gmail.png", + Url = "https://mail.google.com/mail/ca/u/0/#apps/new WebSearch {q}", + Enabled = true + }, + new WebSearch + { + Title = "Google Drive", + ActionKeyword = "drive", + IconPath = "Images\\google_drive.png", + Url = "http://drive.google.com/?hl=en&tab=bo#search/new WebSearch {q}", + Enabled = true + }, + new WebSearch + { + Title = "Wolframalpha", + ActionKeyword = "wolframalpha", + IconPath = "Images\\wolframalpha.png", + Url = "http://www.wolframalpha.com/input/?i=new WebSearch {q}", + Enabled = true + }, + new WebSearch + { + Title = "Stackoverflow", + ActionKeyword = "stackoverflow", + IconPath = "Images\\stackoverflow.png", + Url = "http://stackoverflow.com/search?q=new WebSearch {q}", + Enabled = true + }, + new WebSearch + { + Title = "I'm Feeling Lucky", + ActionKeyword = "lucky", + IconPath = "Images\\google.png", + Url = "http://google.com/search?q=new WebSearch {q}&btnI=I", + Enabled = true + }, + new WebSearch + { + Title = "Google Image", + ActionKeyword = "image", + IconPath = "Images\\google.png", + Url = "https://www.google.com/search?q=new WebSearch {q}&tbm=isch", + Enabled = true + }, + new WebSearch + { + Title = "Youtube", + ActionKeyword = "youtube", + IconPath = "Images\\youtube.png", + Url = "http://www.youtube.com/results?search_query=new WebSearch {q}", + Enabled = true + }, + new WebSearch + { + Title = "Bing", + ActionKeyword = "bing", + IconPath = "Images\\bing.png", + Url = "https://www.bing.com/search?q=new WebSearch {q}", + Enabled = true + }, + new WebSearch + { + Title = "Yahoo", + ActionKeyword = "yahoo", + IconPath = "Images\\yahoo.png", + Url = "http://www.search.yahoo.com/search?p=new WebSearch {q}", + Enabled = true + } + }); + + return this; + } } -} +} \ No newline at end of file diff --git a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj index 44ccaff99c..2150e91aab 100644 --- a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj +++ b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj @@ -136,9 +136,6 @@ Designer PreserveNewest - - PreserveNewest - MSBuild:Compile Designer diff --git a/Wox.Core/Plugin/PluginManager.cs b/Wox.Core/Plugin/PluginManager.cs index 7ccdc60a6e..f3da6bb0ea 100644 --- a/Wox.Core/Plugin/PluginManager.cs +++ b/Wox.Core/Plugin/PluginManager.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; using System.Threading; using Wox.Core.Resource; using Wox.Core.UserSettings; @@ -19,35 +18,33 @@ namespace Wox.Core.Plugin public static class PluginManager { public const string DirectoryName = "Plugins"; - private static IEnumerable contextMenuPlugins; + private static IEnumerable _contextMenuPlugins; /// /// Directories that will hold Wox plugin directory /// - private static List pluginDirectories = new List(); + private static readonly List PluginDirectories = new List(); public static IEnumerable AllPlugins { get; private set; } - public static List GlobalPlugins { get; } = new List(); - public static Dictionary NonGlobalPlugins { get; set; } = new Dictionary(); + public static readonly List GlobalPlugins = new List(); + + public static readonly Dictionary NonGlobalPlugins = new Dictionary(); private static IEnumerable InstantQueryPlugins { get; set; } public static IPublicAPI API { private set; get; } - public static string PluginDirectory - { - get { return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), DirectoryName); } - } + public static readonly string PluginDirectory = Path.Combine(WoxDirectroy.Executable, DirectoryName); private static void SetupPluginDirectories() { - pluginDirectories.Add(PluginDirectory); + PluginDirectories.Add(PluginDirectory); MakesurePluginDirectoriesExist(); } private static void MakesurePluginDirectoriesExist() { - foreach (string pluginDirectory in pluginDirectories) + foreach (string pluginDirectory in PluginDirectories) { if (!Directory.Exists(pluginDirectory)) { @@ -73,7 +70,7 @@ namespace Wox.Core.Plugin SetupPluginDirectories(); API = api; - var metadatas = PluginConfig.Parse(pluginDirectories); + var metadatas = PluginConfig.Parse(PluginDirectories); AllPlugins = (new CSharpPluginLoader().LoadPlugin(metadatas)). Concat(new JsonRPCPluginLoader().LoadPlugin(metadatas)); @@ -102,7 +99,7 @@ namespace Wox.Core.Plugin ThreadPool.QueueUserWorkItem(o => { InstantQueryPlugins = GetPluginsForInterface(); - contextMenuPlugins = GetPluginsForInterface(); + _contextMenuPlugins = GetPluginsForInterface(); foreach (var plugin in AllPlugins) { if (IsGlobalPlugin(plugin.Metadata)) @@ -231,7 +228,7 @@ namespace Wox.Core.Plugin public static List GetContextMenusForPlugin(Result result) { - var pluginPair = contextMenuPlugins.FirstOrDefault(o => o.Metadata.ID == result.PluginID); + var pluginPair = _contextMenuPlugins.FirstOrDefault(o => o.Metadata.ID == result.PluginID); var plugin = (IContextMenu)pluginPair?.Plugin; if (plugin != null) { diff --git a/Wox.Plugin/PluginMetadata.cs b/Wox.Plugin/PluginMetadata.cs index ded0941651..6c6dc5136e 100644 --- a/Wox.Plugin/PluginMetadata.cs +++ b/Wox.Plugin/PluginMetadata.cs @@ -15,10 +15,7 @@ namespace Wox.Plugin public string Website { get; set; } - public string ExecuteFilePath - { - get { return Path.Combine(PluginDirectory, ExecuteFileName); } - } + public string ExecuteFilePath => Path.Combine(PluginDirectory, ExecuteFileName); public string ExecuteFileName { get; set; } From e9ddfa6cf9b8fcb89c8ca3283c576012f1aa55c6 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Fri, 8 Jan 2016 01:55:24 +0000 Subject: [PATCH 09/11] Refactoring directory path for python plugin --- Wox.Core/Plugin/PythonPlugin.cs | 55 +++++++++++++++------------------ 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/Wox.Core/Plugin/PythonPlugin.cs b/Wox.Core/Plugin/PythonPlugin.cs index fac59fa298..a5971a7723 100644 --- a/Wox.Core/Plugin/PythonPlugin.cs +++ b/Wox.Core/Plugin/PythonPlugin.cs @@ -1,41 +1,36 @@ using System.Diagnostics; using System.IO; -using System.Reflection; using Wox.Core.UserSettings; +using Wox.Infrastructure; using Wox.Plugin; namespace Wox.Core.Plugin { internal class PythonPlugin : JsonRPCPlugin { - private static string woxDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - private ProcessStartInfo startInfo; + private static readonly string PythonHome = Path.Combine(WoxDirectroy.Executable, "PythonHome"); + private readonly ProcessStartInfo _startInfo; - public override string SupportedLanguage - { - get { return AllowedLanguage.Python; } - } + public override string SupportedLanguage => AllowedLanguage.Python; public PythonPlugin() { - startInfo = new ProcessStartInfo - { - UseShellExecute = false, - CreateNoWindow = true, - RedirectStandardOutput = true, - RedirectStandardError = true - }; - string additionalPythonPath = string.Format("{0};{1}", - Path.Combine(woxDirectory, "PythonHome\\DLLs"), - Path.Combine(woxDirectory, "PythonHome\\Lib\\site-packages")); - if (!startInfo.EnvironmentVariables.ContainsKey("PYTHONPATH")) + _startInfo = new ProcessStartInfo + { + UseShellExecute = false, + CreateNoWindow = true, + RedirectStandardOutput = true, + RedirectStandardError = true + }; + string additionalPythonPath = $"{Path.Combine(PythonHome, "DLLs")};{Path.Combine(PythonHome, "Lib", "site-packages")}"; + if (!_startInfo.EnvironmentVariables.ContainsKey("PYTHONPATH")) { - startInfo.EnvironmentVariables.Add("PYTHONPATH", additionalPythonPath); + _startInfo.EnvironmentVariables.Add("PYTHONPATH", additionalPythonPath); } else { - startInfo.EnvironmentVariables["PYTHONPATH"] = additionalPythonPath; + _startInfo.EnvironmentVariables["PYTHONPATH"] = additionalPythonPath; } } @@ -43,22 +38,22 @@ namespace Wox.Core.Plugin { JsonRPCServerRequestModel request = new JsonRPCServerRequestModel { - Method = "query", - Parameters = new object[] { query.GetAllRemainingParameter() }, - HttpProxy = HttpProxy.Instance - }; + Method = "query", + Parameters = new object[] { query.GetAllRemainingParameter() }, + HttpProxy = HttpProxy.Instance + }; //Add -B flag to tell python don't write .py[co] files. Because .pyc contains location infos which will prevent python portable - startInfo.FileName = Path.Combine(woxDirectory, "PythonHome\\pythonw.exe"); - startInfo.Arguments = string.Format("-B \"{0}\" \"{1}\"", context.CurrentPluginMetadata.ExecuteFilePath, request); + _startInfo.FileName = Path.Combine(PythonHome, "pythonw.exe"); + _startInfo.Arguments = $"-B \"{context.CurrentPluginMetadata.ExecuteFilePath}\" \"{request}\""; - return Execute(startInfo); + return Execute(_startInfo); } protected override string ExecuteCallback(JsonRPCRequestModel rpcRequest) { - startInfo.FileName = Path.Combine(woxDirectory, "PythonHome\\pythonw.exe"); - startInfo.Arguments = string.Format("-B \"{0}\" \"{1}\"", context.CurrentPluginMetadata.ExecuteFilePath, rpcRequest); - return Execute(startInfo); + _startInfo.FileName = Path.Combine(PythonHome, "pythonw.exe"); + _startInfo.Arguments = $"-B \"{context.CurrentPluginMetadata.ExecuteFilePath}\" \"{rpcRequest}\""; + return Execute(_startInfo); } } } \ No newline at end of file From 6071319acddcace712721aa9e3732eea26318a06 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Fri, 8 Jan 2016 01:57:11 +0000 Subject: [PATCH 10/11] Refactoring directory path for misc --- Wox/MainWindow.xaml.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index c0795c70e6..aa802a3ad6 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -748,7 +748,7 @@ namespace Wox Title = string.Format(executeQueryHistoryTitle,history.Query), SubTitle = string.Format(lastExecuteTime,history.ExecutedDateTime), IcoPath = "Images\\history.png", - PluginDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), + PluginDirectory = WoxDirectroy.Executable, Action = _ =>{ ChangeQuery(history.Query,true); return false; @@ -865,7 +865,7 @@ namespace Wox { return new Result(GetTranslation("cancelTopMostInThisQuery"), "Images\\down.png") { - PluginDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), + PluginDirectory = WoxDirectroy.Executable, Action = _ => { TopMostRecordStorage.Instance.Remove(result); @@ -878,7 +878,7 @@ namespace Wox { return new Result(GetTranslation("setAsTopMostInThisQuery"), "Images\\up.png") { - PluginDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), + PluginDirectory = WoxDirectroy.Executable, Action = _ => { TopMostRecordStorage.Instance.AddOrUpdate(result); From a0f556b2a9881b5bc04b3633493b057dfa08f074 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Fri, 8 Jan 2016 02:18:19 +0000 Subject: [PATCH 11/11] Refactoring directory path for plugins --- Plugins/Wox.Plugin.CMD/CMD.cs | 4 ++-- Plugins/Wox.Plugin.CMD/CMDStorage.cs | 2 -- Plugins/Wox.Plugin.Caculator/Calculator.cs | 5 +++-- Plugins/Wox.Plugin.Caculator/Wox.Plugin.Caculator.csproj | 4 ++++ Plugins/Wox.Plugin.Color/Color.cs | 4 ++-- Plugins/Wox.Plugin.Color/Wox.Plugin.Color.csproj | 4 ++++ Plugins/Wox.Plugin.ControlPanel/ControlPanel.cs | 3 +-- Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs | 2 -- Plugins/Wox.Plugin.Everything/Main.cs | 4 ++-- Plugins/Wox.Plugin.Folder/FolderPlugin.cs | 4 ++-- Plugins/Wox.Plugin.Folder/FolderStorage.cs | 2 -- Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs | 4 ++-- Plugins/Wox.Plugin.PluginManagement/Main.cs | 4 ++-- .../Wox.Plugin.PluginManagement.csproj | 4 ++++ Plugins/Wox.Plugin.Program/ProgramCacheStorage.cs | 2 -- Plugins/Wox.Plugin.Program/ProgramStorage.cs | 2 -- Plugins/Wox.Plugin.Program/Programs.cs | 2 +- Plugins/Wox.Plugin.Sys/Sys.cs | 3 +-- Plugins/Wox.Plugin.Url/UrlPlugin.cs | 4 ++-- Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj | 4 ++++ Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs | 4 ++-- Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs | 6 +++--- Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs | 2 -- 23 files changed, 41 insertions(+), 38 deletions(-) diff --git a/Plugins/Wox.Plugin.CMD/CMD.cs b/Plugins/Wox.Plugin.CMD/CMD.cs index deeca82c5a..d1f6220efb 100644 --- a/Plugins/Wox.Plugin.CMD/CMD.cs +++ b/Plugins/Wox.Plugin.CMD/CMD.cs @@ -3,10 +3,10 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; -using System.Reflection; using System.Windows.Forms; using WindowsInput; using WindowsInput.Native; +using Wox.Infrastructure; using Wox.Infrastructure.Hotkey; using Wox.Infrastructure.Logger; using Control = System.Windows.Controls.Control; @@ -202,7 +202,7 @@ namespace Wox.Plugin.CMD public string GetLanguagesFolder() { - return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages"); + return Path.Combine(WoxDirectroy.Executable, "Languages"); } public string GetTranslatedPluginTitle() diff --git a/Plugins/Wox.Plugin.CMD/CMDStorage.cs b/Plugins/Wox.Plugin.CMD/CMDStorage.cs index c87bf37b48..813e4a2c58 100644 --- a/Plugins/Wox.Plugin.CMD/CMDStorage.cs +++ b/Plugins/Wox.Plugin.CMD/CMDStorage.cs @@ -1,6 +1,4 @@ using System.Collections.Generic; -using System.IO; -using System.Reflection; using Newtonsoft.Json; using Wox.Infrastructure.Storage; diff --git a/Plugins/Wox.Plugin.Caculator/Calculator.cs b/Plugins/Wox.Plugin.Caculator/Calculator.cs index 6dbfb79b53..6a496666fe 100644 --- a/Plugins/Wox.Plugin.Caculator/Calculator.cs +++ b/Plugins/Wox.Plugin.Caculator/Calculator.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.IO; -using System.Reflection; using System.Runtime.InteropServices; using System.Text.RegularExpressions; using System.Windows; +using Wox.Infrastructure; using YAMP; namespace Wox.Plugin.Caculator @@ -95,7 +95,8 @@ namespace Wox.Plugin.Caculator public string GetLanguagesFolder() { - return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages"); + return Path.Combine(WoxDirectroy.Executable, "Languages"); + } public string GetTranslatedPluginTitle() diff --git a/Plugins/Wox.Plugin.Caculator/Wox.Plugin.Caculator.csproj b/Plugins/Wox.Plugin.Caculator/Wox.Plugin.Caculator.csproj index e80e10107d..e5db93265b 100644 --- a/Plugins/Wox.Plugin.Caculator/Wox.Plugin.Caculator.csproj +++ b/Plugins/Wox.Plugin.Caculator/Wox.Plugin.Caculator.csproj @@ -57,6 +57,10 @@ + + {4FD29318-A8AB-4D8F-AA47-60BC241B8DA3} + Wox.Infrastructure + {8451ecdd-2ea4-4966-bb0a-7bbc40138e80} Wox.Plugin diff --git a/Plugins/Wox.Plugin.Color/Color.cs b/Plugins/Wox.Plugin.Color/Color.cs index 2dd5c6d83f..2f45ce7836 100644 --- a/Plugins/Wox.Plugin.Color/Color.cs +++ b/Plugins/Wox.Plugin.Color/Color.cs @@ -4,8 +4,8 @@ using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Linq; -using System.Reflection; using System.Windows; +using Wox.Infrastructure; namespace Wox.Plugin.Color { @@ -111,7 +111,7 @@ namespace Wox.Plugin.Color public string GetLanguagesFolder() { - return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages"); + return Path.Combine(WoxDirectroy.Executable, "Languages"); } public string GetTranslatedPluginTitle() diff --git a/Plugins/Wox.Plugin.Color/Wox.Plugin.Color.csproj b/Plugins/Wox.Plugin.Color/Wox.Plugin.Color.csproj index b2f9af335b..0f10a9eea3 100644 --- a/Plugins/Wox.Plugin.Color/Wox.Plugin.Color.csproj +++ b/Plugins/Wox.Plugin.Color/Wox.Plugin.Color.csproj @@ -55,6 +55,10 @@ + + {4FD29318-A8AB-4D8F-AA47-60BC241B8DA3} + Wox.Infrastructure + {8451ecdd-2ea4-4966-bb0a-7bbc40138e80} Wox.Plugin diff --git a/Plugins/Wox.Plugin.ControlPanel/ControlPanel.cs b/Plugins/Wox.Plugin.ControlPanel/ControlPanel.cs index 84e8d0b334..1d403f468b 100644 --- a/Plugins/Wox.Plugin.ControlPanel/ControlPanel.cs +++ b/Plugins/Wox.Plugin.ControlPanel/ControlPanel.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; -using System.Reflection; using Wox.Infrastructure; namespace Wox.Plugin.ControlPanel @@ -85,7 +84,7 @@ namespace Wox.Plugin.ControlPanel public string GetLanguagesFolder() { - return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages"); + return Path.Combine(WoxDirectroy.Executable, "Languages"); } public string GetTranslatedPluginTitle() diff --git a/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs b/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs index 150f010145..703cbba36f 100644 --- a/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs +++ b/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs @@ -1,6 +1,4 @@ using System.Collections.Generic; -using System.IO; -using System.Reflection; using Wox.Infrastructure.Storage; using JsonProperty = Newtonsoft.Json.JsonPropertyAttribute; diff --git a/Plugins/Wox.Plugin.Everything/Main.cs b/Plugins/Wox.Plugin.Everything/Main.cs index b50d92174b..447c7db7cd 100644 --- a/Plugins/Wox.Plugin.Everything/Main.cs +++ b/Plugins/Wox.Plugin.Everything/Main.cs @@ -3,10 +3,10 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; -using System.Reflection; using System.Runtime.InteropServices; using System.ServiceProcess; using System.Windows; +using Wox.Infrastructure; using Wox.Plugin.Everything.Everything; namespace Wox.Plugin.Everything @@ -258,7 +258,7 @@ namespace Wox.Plugin.Everything public string GetLanguagesFolder() { - return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages"); + return Path.Combine(WoxDirectroy.Executable, "Languages"); } public string GetTranslatedPluginTitle() diff --git a/Plugins/Wox.Plugin.Folder/FolderPlugin.cs b/Plugins/Wox.Plugin.Folder/FolderPlugin.cs index e31e701c38..dc2905accb 100644 --- a/Plugins/Wox.Plugin.Folder/FolderPlugin.cs +++ b/Plugins/Wox.Plugin.Folder/FolderPlugin.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; -using System.Reflection; using System.Windows; using System.Windows.Controls; +using Wox.Infrastructure; namespace Wox.Plugin.Folder { @@ -246,7 +246,7 @@ namespace Wox.Plugin.Folder public string GetLanguagesFolder() { - return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages"); + return Path.Combine(WoxDirectroy.Executable, "Languages"); } public string GetTranslatedPluginTitle() diff --git a/Plugins/Wox.Plugin.Folder/FolderStorage.cs b/Plugins/Wox.Plugin.Folder/FolderStorage.cs index f23273774d..5c63d38c36 100644 --- a/Plugins/Wox.Plugin.Folder/FolderStorage.cs +++ b/Plugins/Wox.Plugin.Folder/FolderStorage.cs @@ -1,6 +1,4 @@ using System.Collections.Generic; -using System.IO; -using System.Reflection; using Newtonsoft.Json; using Wox.Infrastructure.Storage; diff --git a/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs b/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs index 151df63616..be2ec2990e 100644 --- a/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs +++ b/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; using Wox.Core.Plugin; using Wox.Core.UserSettings; +using Wox.Infrastructure; namespace Wox.Plugin.PluginIndicator { @@ -41,7 +41,7 @@ namespace Wox.Plugin.PluginIndicator public string GetLanguagesFolder() { - return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages"); + return Path.Combine(WoxDirectroy.Executable, "Languages"); } public string GetTranslatedPluginTitle() diff --git a/Plugins/Wox.Plugin.PluginManagement/Main.cs b/Plugins/Wox.Plugin.PluginManagement/Main.cs index 45585db05e..3a0b203be9 100644 --- a/Plugins/Wox.Plugin.PluginManagement/Main.cs +++ b/Plugins/Wox.Plugin.PluginManagement/Main.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; -using System.Reflection; using System.Text; using System.Threading; using System.Windows; using Newtonsoft.Json; +using Wox.Infrastructure; namespace Wox.Plugin.PluginManagement { @@ -244,7 +244,7 @@ namespace Wox.Plugin.PluginManagement public string GetLanguagesFolder() { - return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages"); + return Path.Combine(WoxDirectroy.Executable, "Languages"); } public string GetTranslatedPluginTitle() diff --git a/Plugins/Wox.Plugin.PluginManagement/Wox.Plugin.PluginManagement.csproj b/Plugins/Wox.Plugin.PluginManagement/Wox.Plugin.PluginManagement.csproj index 8ee89613dd..5fb37d3273 100644 --- a/Plugins/Wox.Plugin.PluginManagement/Wox.Plugin.PluginManagement.csproj +++ b/Plugins/Wox.Plugin.PluginManagement/Wox.Plugin.PluginManagement.csproj @@ -55,6 +55,10 @@ + + {4FD29318-A8AB-4D8F-AA47-60BC241B8DA3} + Wox.Infrastructure + {8451ecdd-2ea4-4966-bb0a-7bbc40138e80} Wox.Plugin diff --git a/Plugins/Wox.Plugin.Program/ProgramCacheStorage.cs b/Plugins/Wox.Plugin.Program/ProgramCacheStorage.cs index 4f57910fb3..0aab30c17c 100644 --- a/Plugins/Wox.Plugin.Program/ProgramCacheStorage.cs +++ b/Plugins/Wox.Plugin.Program/ProgramCacheStorage.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.IO; -using System.Reflection; using Wox.Infrastructure.Storage; namespace Wox.Plugin.Program diff --git a/Plugins/Wox.Plugin.Program/ProgramStorage.cs b/Plugins/Wox.Plugin.Program/ProgramStorage.cs index a17171f7cd..1cefbe87d8 100644 --- a/Plugins/Wox.Plugin.Program/ProgramStorage.cs +++ b/Plugins/Wox.Plugin.Program/ProgramStorage.cs @@ -1,7 +1,5 @@ using System.Collections.Generic; using System.ComponentModel; -using System.IO; -using System.Reflection; using Newtonsoft.Json; using Wox.Infrastructure.Storage; diff --git a/Plugins/Wox.Plugin.Program/Programs.cs b/Plugins/Wox.Plugin.Program/Programs.cs index 73856909e7..dc74d164ea 100644 --- a/Plugins/Wox.Plugin.Program/Programs.cs +++ b/Plugins/Wox.Plugin.Program/Programs.cs @@ -177,7 +177,7 @@ namespace Wox.Plugin.Program public string GetLanguagesFolder() { - return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages"); + return Path.Combine(WoxDirectroy.Executable, "Languages"); } public string GetTranslatedPluginTitle() { diff --git a/Plugins/Wox.Plugin.Sys/Sys.cs b/Plugins/Wox.Plugin.Sys/Sys.cs index 206072772a..2484911891 100644 --- a/Plugins/Wox.Plugin.Sys/Sys.cs +++ b/Plugins/Wox.Plugin.Sys/Sys.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Reflection; using System.Runtime.InteropServices; using System.Windows; using System.Windows.Forms; @@ -193,7 +192,7 @@ namespace Wox.Plugin.Sys public string GetLanguagesFolder() { - return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages"); + return Path.Combine(WoxDirectroy.Executable, "Languages"); } public string GetTranslatedPluginTitle() diff --git a/Plugins/Wox.Plugin.Url/UrlPlugin.cs b/Plugins/Wox.Plugin.Url/UrlPlugin.cs index 51c8f2ed95..5a19028fc8 100644 --- a/Plugins/Wox.Plugin.Url/UrlPlugin.cs +++ b/Plugins/Wox.Plugin.Url/UrlPlugin.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Reflection; using System.Text.RegularExpressions; +using Wox.Infrastructure; namespace Wox.Plugin.Url { @@ -105,7 +105,7 @@ namespace Wox.Plugin.Url public string GetLanguagesFolder() { - return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages"); + return Path.Combine(WoxDirectroy.Executable, "Languages"); } public string GetTranslatedPluginTitle() diff --git a/Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj b/Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj index 676bf001b5..3f4758e724 100644 --- a/Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj +++ b/Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj @@ -49,6 +49,10 @@ + + {4FD29318-A8AB-4D8F-AA47-60BC241B8DA3} + Wox.Infrastructure + {8451ecdd-2ea4-4966-bb0a-7bbc40138e80} Wox.Plugin diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs index 0e225df03c..10fc03fa2a 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; -using System.Reflection; using System.Windows.Controls; +using Wox.Infrastructure; using Wox.Plugin.WebSearch.Annotations; using Wox.Plugin.WebSearch.SuggestionSources; @@ -92,7 +92,7 @@ namespace Wox.Plugin.WebSearch public string GetLanguagesFolder() { - return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages"); + return Path.Combine(WoxDirectroy.Executable, "Languages"); } public string GetTranslatedPluginTitle() diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs index 7284ce59d8..3551715a84 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs @@ -1,10 +1,10 @@ using System; using System.IO; using System.Linq; -using System.Reflection; using System.Windows; using System.Windows.Media.Imaging; using Microsoft.Win32; +using Wox.Infrastructure; using Wox.Infrastructure.Exception; namespace Wox.Plugin.WebSearch @@ -12,7 +12,7 @@ namespace Wox.Plugin.WebSearch public partial class WebSearchSetting : Window { private const string _imageDirectoryName = "Images"; - private string _pluginDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + private string _pluginDirectory = WoxDirectroy.Executable; private readonly WebSearchesSetting _settingWindow; private bool _isUpdate; private WebSearch _updateWebSearch; @@ -130,7 +130,7 @@ namespace Wox.Plugin.WebSearch if (!Directory.Exists(_pluginDirectory)) { _pluginDirectory = - Path.GetDirectoryName(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); + Path.GetDirectoryName(WoxDirectroy.Executable); } var dlg = new OpenFileDialog diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs index 824ad6e261..5ae244473f 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs @@ -1,6 +1,4 @@ using System.Collections.Generic; -using System.IO; -using System.Reflection; using Newtonsoft.Json; using Wox.Infrastructure.Storage;