diff --git a/Plugins/Wox.Plugin.CMD/CMD.cs b/Plugins/Wox.Plugin.CMD/CMD.cs index 938815e1da..b86d6cde87 100644 --- a/Plugins/Wox.Plugin.CMD/CMD.cs +++ b/Plugins/Wox.Plugin.CMD/CMD.cs @@ -2,13 +2,20 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Windows.Forms; +using WindowsInput; +using WindowsInput.Native; +using Wox.Infrastructure.Hotkey; using Control = System.Windows.Controls.Control; namespace Wox.Plugin.CMD { public class CMD : IPlugin, ISettingProvider { + private readonly GlobalHotkey globalHotkey = new GlobalHotkey(); private PluginInitContext context; + private bool WinRStroked; + private readonly KeyboardSimulator keyboardSimulator = new KeyboardSimulator(new InputSimulator()); public List Query(Query query) { @@ -166,6 +173,33 @@ namespace Wox.Plugin.CMD public void Init(PluginInitContext context) { this.context = context; + globalHotkey.hookedKeyboardCallback += KListener_hookedKeyboardCallback; + } + + private bool KListener_hookedKeyboardCallback(KeyEvent keyevent, int vkcode, SpecialKeyState state) + { + if (CMDStorage.Instance.ReplaceWinR) + { + if (keyevent == KeyEvent.WM_KEYDOWN && vkcode == (int)Keys.R && state.WinPressed) + { + WinRStroked = true; + OnWinRPressed(); + return false; + } + if (keyevent == KeyEvent.WM_KEYUP && WinRStroked && vkcode == (int)Keys.LWin) + { + WinRStroked = false; + keyboardSimulator.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.CONTROL); + return false; + } + } + return true; + } + + private void OnWinRPressed() + { + context.API.ShowApp(); + context.API.ChangeQuery(">"); } public Control CreateSettingPanel() diff --git a/Plugins/Wox.Plugin.CMD/CMDSetting.xaml.cs b/Plugins/Wox.Plugin.CMD/CMDSetting.xaml.cs index ab50e0d059..6b93c30abe 100644 --- a/Plugins/Wox.Plugin.CMD/CMDSetting.xaml.cs +++ b/Plugins/Wox.Plugin.CMD/CMDSetting.xaml.cs @@ -1,6 +1,5 @@ using System.Windows; using System.Windows.Controls; -using Wox.Infrastructure.Storage.UserSettings; namespace Wox.Plugin.CMD { @@ -13,30 +12,30 @@ namespace Wox.Plugin.CMD private void CMDSetting_OnLoaded(object sender, RoutedEventArgs re) { - cbReplaceWinR.IsChecked = UserSettingStorage.Instance.ReplaceWinR; - cbLeaveCmdOpen.IsChecked = UserSettingStorage.Instance.LeaveCmdOpen; + cbReplaceWinR.IsChecked = CMDStorage.Instance.ReplaceWinR; + cbLeaveCmdOpen.IsChecked = CMDStorage.Instance.LeaveCmdOpen; cbLeaveCmdOpen.Checked += (o, e) => { - UserSettingStorage.Instance.LeaveCmdOpen = true; - UserSettingStorage.Instance.Save(); + CMDStorage.Instance.LeaveCmdOpen = true; + CMDStorage.Instance.Save(); }; cbLeaveCmdOpen.Unchecked += (o, e) => { - UserSettingStorage.Instance.LeaveCmdOpen = false; - UserSettingStorage.Instance.Save(); + CMDStorage.Instance.LeaveCmdOpen = false; + CMDStorage.Instance.Save(); }; cbReplaceWinR.Checked += (o, e) => { - UserSettingStorage.Instance.ReplaceWinR = true; - UserSettingStorage.Instance.Save(); + CMDStorage.Instance.ReplaceWinR = true; + CMDStorage.Instance.Save(); }; cbReplaceWinR.Unchecked += (o, e) => { - UserSettingStorage.Instance.ReplaceWinR = false; - UserSettingStorage.Instance.Save(); + CMDStorage.Instance.ReplaceWinR = false; + CMDStorage.Instance.Save(); }; } } diff --git a/Plugins/Wox.Plugin.CMD/CMDStorage.cs b/Plugins/Wox.Plugin.CMD/CMDStorage.cs index f3ae1d6c70..1d719d17cd 100644 --- a/Plugins/Wox.Plugin.CMD/CMDStorage.cs +++ b/Plugins/Wox.Plugin.CMD/CMDStorage.cs @@ -1,19 +1,38 @@ using System.Collections.Generic; +using System.Reflection; using Newtonsoft.Json; using Wox.Infrastructure.Storage; +using System.IO; namespace Wox.Plugin.CMD { public class CMDStorage : JsonStrorage { + [JsonProperty] + public bool ReplaceWinR { get; set; } + + [JsonProperty] + public bool LeaveCmdOpen { get; set; } + [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 CMDStorage LoadDefault() + { + ReplaceWinR = true; + return this; + } + public void AddCmdHistory(string cmdName) { if (CMDHistory.ContainsKey(cmdName)) diff --git a/Plugins/Wox.Plugin.CMD/Wox.Plugin.CMD.csproj b/Plugins/Wox.Plugin.CMD/Wox.Plugin.CMD.csproj index 64bb3df4c0..4269f3e1b9 100644 --- a/Plugins/Wox.Plugin.CMD/Wox.Plugin.CMD.csproj +++ b/Plugins/Wox.Plugin.CMD/Wox.Plugin.CMD.csproj @@ -44,11 +44,15 @@ + + + ..\..\packages\InputSimulator.1.0.4.0\lib\net20\WindowsInput.dll + diff --git a/Wox.Infrastructure/Storage/UserSettings/FolderLink.cs b/Plugins/Wox.Plugin.Folder/FolderLink.cs similarity index 77% rename from Wox.Infrastructure/Storage/UserSettings/FolderLink.cs rename to Plugins/Wox.Plugin.Folder/FolderLink.cs index 69bb68b871..4f7fb440c4 100644 --- a/Wox.Infrastructure/Storage/UserSettings/FolderLink.cs +++ b/Plugins/Wox.Plugin.Folder/FolderLink.cs @@ -1,11 +1,10 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using Newtonsoft.Json; -namespace Wox.Infrastructure.Storage.UserSettings +namespace Wox.Plugin.Folder { + [Serializable] public class FolderLink { [JsonProperty] diff --git a/Plugins/Wox.Plugin.Folder/FolderPlugin.cs b/Plugins/Wox.Plugin.Folder/FolderPlugin.cs index 91a4db8708..3b8ddaeca1 100644 --- a/Plugins/Wox.Plugin.Folder/FolderPlugin.cs +++ b/Plugins/Wox.Plugin.Folder/FolderPlugin.cs @@ -4,7 +4,6 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Windows; -using Wox.Infrastructure.Storage.UserSettings; using Control = System.Windows.Controls.Control; namespace Wox.Plugin.Folder @@ -24,10 +23,10 @@ namespace Wox.Plugin.Folder this.context = context; this.context.API.BackKeyDownEvent += ApiBackKeyDownEvent; InitialDriverList(); - if (UserSettingStorage.Instance.FolderLinks == null) + if (FolderStorage.Instance.FolderLinks == null) { - UserSettingStorage.Instance.FolderLinks = new List(); - UserSettingStorage.Instance.Save(); + FolderStorage.Instance.FolderLinks = new List(); + FolderStorage.Instance.Save(); } } @@ -56,7 +55,7 @@ namespace Wox.Plugin.Folder if(string.IsNullOrEmpty(query.RawQuery)) return new List(); string input = query.RawQuery.ToLower(); - List userFolderLinks = UserSettingStorage.Instance.FolderLinks.Where( + List userFolderLinks = FolderStorage.Instance.FolderLinks.Where( x => x.Nickname.StartsWith(input, StringComparison.OrdinalIgnoreCase)).ToList(); List results = userFolderLinks.Select( diff --git a/Plugins/Wox.Plugin.Folder/FolderPluginSettings.xaml.cs b/Plugins/Wox.Plugin.Folder/FolderPluginSettings.xaml.cs index eedcfd8d51..44a80da0a1 100644 --- a/Plugins/Wox.Plugin.Folder/FolderPluginSettings.xaml.cs +++ b/Plugins/Wox.Plugin.Folder/FolderPluginSettings.xaml.cs @@ -2,33 +2,36 @@ using System.Linq; using System.Windows; using System.Windows.Forms; -using Wox.Infrastructure.Storage.UserSettings; using MessageBox = System.Windows.MessageBox; using UserControl = System.Windows.Controls.UserControl; -namespace Wox.Plugin.Folder { +namespace Wox.Plugin.Folder +{ - /// - /// Interaction logic for FileSystemSettings.xaml - /// - public partial class FileSystemSettings : UserControl { - public FileSystemSettings() { - InitializeComponent(); - lbxFolders.ItemsSource = UserSettingStorage.Instance.FolderLinks; - } + /// + /// Interaction logic for FileSystemSettings.xaml + /// + public partial class FileSystemSettings : UserControl + { + public FileSystemSettings() + { + InitializeComponent(); + lbxFolders.ItemsSource = FolderStorage.Instance.FolderLinks; + } - private void btnDelete_Click(object sender, RoutedEventArgs e) { + private void btnDelete_Click(object sender, RoutedEventArgs e) + { var selectedFolder = lbxFolders.SelectedItem as FolderLink; if (selectedFolder != null) { - UserSettingStorage.Instance.FolderLinks.Remove(selectedFolder); + FolderStorage.Instance.FolderLinks.Remove(selectedFolder); lbxFolders.Items.Refresh(); } else { MessageBox.Show("Please select a folder link!"); } - } + } private void btnEdit_Click(object sender, RoutedEventArgs e) { @@ -39,10 +42,10 @@ namespace Wox.Plugin.Folder { folderBrowserDialog.SelectedPath = selectedFolder.Path; if (folderBrowserDialog.ShowDialog() == DialogResult.OK) { - var link = UserSettingStorage.Instance.FolderLinks.First(x => x.Path == selectedFolder.Path); + var link = FolderStorage.Instance.FolderLinks.First(x => x.Path == selectedFolder.Path); link.Path = folderBrowserDialog.SelectedPath; - UserSettingStorage.Instance.Save(); + FolderStorage.Instance.Save(); } lbxFolders.Items.Refresh(); @@ -51,24 +54,28 @@ namespace Wox.Plugin.Folder { { MessageBox.Show("Please select a folder link!"); } - } + } - private void btnAdd_Click(object sender, RoutedEventArgs e) { - var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog(); - if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { - var newFolder = new FolderLink() { - Path = folderBrowserDialog.SelectedPath - }; + private void btnAdd_Click(object sender, RoutedEventArgs e) + { + var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog(); + if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + var newFolder = new FolderLink() + { + Path = folderBrowserDialog.SelectedPath + }; - if (UserSettingStorage.Instance.FolderLinks == null) { - UserSettingStorage.Instance.FolderLinks = new List(); - } + if (FolderStorage.Instance.FolderLinks == null) + { + FolderStorage.Instance.FolderLinks = new List(); + } - UserSettingStorage.Instance.FolderLinks.Add(newFolder); - UserSettingStorage.Instance.Save(); - } + FolderStorage.Instance.FolderLinks.Add(newFolder); + FolderStorage.Instance.Save(); + } - lbxFolders.Items.Refresh(); - } - } + lbxFolders.Items.Refresh(); + } + } } diff --git a/Plugins/Wox.Plugin.Folder/FolderStorage.cs b/Plugins/Wox.Plugin.Folder/FolderStorage.cs new file mode 100644 index 0000000000..e22d560983 --- /dev/null +++ b/Plugins/Wox.Plugin.Folder/FolderStorage.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using Newtonsoft.Json; +using Wox.Infrastructure.Storage; +using System.IO; + +namespace Wox.Plugin.Folder +{ + public class FolderStorage : JsonStrorage + { + [JsonProperty] + public List FolderLinks { get; set; } + protected override string ConfigFolder + { + get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } + } + + protected override string ConfigName + { + get { return "setting"; } + } + } +} diff --git a/Plugins/Wox.Plugin.Folder/Wox.Plugin.Folder.csproj b/Plugins/Wox.Plugin.Folder/Wox.Plugin.Folder.csproj index ad948613c7..283f2e25b9 100644 --- a/Plugins/Wox.Plugin.Folder/Wox.Plugin.Folder.csproj +++ b/Plugins/Wox.Plugin.Folder/Wox.Plugin.Folder.csproj @@ -36,6 +36,10 @@ False ..\..\packages\log4net.2.0.3\lib\net35-full\log4net.dll + + False + ..\..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll + @@ -48,10 +52,12 @@ + FolderPluginSettings.xaml + diff --git a/Plugins/Wox.Plugin.Folder/packages.config b/Plugins/Wox.Plugin.Folder/packages.config index 7eb67aa24b..6c533b9f5c 100644 --- a/Plugins/Wox.Plugin.Folder/packages.config +++ b/Plugins/Wox.Plugin.Folder/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs b/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs index 030d7e957a..124ef26669 100644 --- a/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs +++ b/Plugins/Wox.Plugin.PluginIndicator/PluginIndicator.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; using Wox.Core.Plugin; -using Wox.Infrastructure.Storage.UserSettings; +using Wox.Core.UserSettings; namespace Wox.Plugin.PluginIndicator { diff --git a/Plugins/Wox.Plugin.PluginManagement/Wox.Plugin.PluginManagement.csproj b/Plugins/Wox.Plugin.PluginManagement/Wox.Plugin.PluginManagement.csproj index d8b2be74aa..dd7ef42499 100644 --- a/Plugins/Wox.Plugin.PluginManagement/Wox.Plugin.PluginManagement.csproj +++ b/Plugins/Wox.Plugin.PluginManagement/Wox.Plugin.PluginManagement.csproj @@ -34,7 +34,7 @@ False - ..\..\packages\Newtonsoft.Json.6.0.5\lib\net35\Newtonsoft.Json.dll + ..\..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll diff --git a/Plugins/Wox.Plugin.PluginManagement/packages.config b/Plugins/Wox.Plugin.PluginManagement/packages.config index f4c35941d3..4185726464 100644 --- a/Plugins/Wox.Plugin.PluginManagement/packages.config +++ b/Plugins/Wox.Plugin.PluginManagement/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Program/FileChangeWatcher.cs b/Plugins/Wox.Plugin.Program/FileChangeWatcher.cs index f6845e0908..303970fd38 100644 --- a/Plugins/Wox.Plugin.Program/FileChangeWatcher.cs +++ b/Plugins/Wox.Plugin.Program/FileChangeWatcher.cs @@ -2,7 +2,6 @@ using System.Diagnostics; using System.IO; using System.Threading; -using Wox.Infrastructure.Storage.UserSettings; namespace Wox.Plugin.Program { @@ -21,7 +20,7 @@ namespace Wox.Plugin.Program } watchedPath.Add(path); - foreach (string fileType in UserSettingStorage.Instance.ProgramSuffixes.Split(';')) + foreach (string fileType in ProgramStorage.Instance.ProgramSuffixes.Split(';')) { FileSystemWatcher watcher = new FileSystemWatcher { diff --git a/Plugins/Wox.Plugin.Program/ProgramCacheStorage.cs b/Plugins/Wox.Plugin.Program/ProgramCacheStorage.cs index b1baf51a16..f1b3a138cc 100644 --- a/Plugins/Wox.Plugin.Program/ProgramCacheStorage.cs +++ b/Plugins/Wox.Plugin.Program/ProgramCacheStorage.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.IO; +using System.Reflection; using Wox.Infrastructure.Storage; namespace Wox.Plugin.Program @@ -9,6 +11,11 @@ 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"; } diff --git a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs index 4c103c7b8e..a9fd75a5e2 100644 --- a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs +++ b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs @@ -2,7 +2,6 @@ using System.Threading; using System.Windows; using System.Windows.Controls; -using Wox.Infrastructure.Storage.UserSettings; namespace Wox.Plugin.Program { @@ -19,7 +18,7 @@ namespace Wox.Plugin.Program private void Setting_Loaded(object sender, RoutedEventArgs e) { - programSourceView.ItemsSource = UserSettingStorage.Instance.ProgramSources; + programSourceView.ItemsSource = ProgramStorage.Instance.ProgramSources; } private void ReIndexing() @@ -40,13 +39,13 @@ namespace Wox.Plugin.Program { string path = folderBrowserDialog.SelectedPath; - UserSettingStorage.Instance.ProgramSources.Add(new ProgramSource() + ProgramStorage.Instance.ProgramSources.Add(new ProgramSource() { Location = path, Type = "FileSystemProgramSource", Enabled = true }); - UserSettingStorage.Instance.Save(); + ProgramStorage.Instance.Save(); ReIndexing(); } } @@ -59,8 +58,8 @@ namespace Wox.Plugin.Program if (MessageBox.Show("Are your sure to delete " + selectedProgramSource.Location, "Delete ProgramSource", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { - UserSettingStorage.Instance.ProgramSources.Remove(selectedProgramSource); - UserSettingStorage.Instance.Save(); + ProgramStorage.Instance.ProgramSources.Remove(selectedProgramSource); + ProgramStorage.Instance.Save(); ReIndexing(); } } @@ -81,7 +80,7 @@ namespace Wox.Plugin.Program { string path = folderBrowserDialog.SelectedPath; selectedProgramSource.Location = path; - UserSettingStorage.Instance.Save(); + ProgramStorage.Instance.Save(); ReIndexing(); } } diff --git a/Wox.Infrastructure/Storage/UserSettings/ProgramSource.cs b/Plugins/Wox.Plugin.Program/ProgramSource.cs similarity index 90% rename from Wox.Infrastructure/Storage/UserSettings/ProgramSource.cs rename to Plugins/Wox.Plugin.Program/ProgramSource.cs index 8e77dc9d10..99548b89e0 100644 --- a/Wox.Infrastructure/Storage/UserSettings/ProgramSource.cs +++ b/Plugins/Wox.Plugin.Program/ProgramSource.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace Wox.Infrastructure.Storage.UserSettings +namespace Wox.Plugin.Program { [Serializable] public class ProgramSource diff --git a/Plugins/Wox.Plugin.Program/ProgramSources/AppPathsProgramSource.cs b/Plugins/Wox.Plugin.Program/ProgramSources/AppPathsProgramSource.cs index ec2bec0512..5b50d72df1 100644 --- a/Plugins/Wox.Plugin.Program/ProgramSources/AppPathsProgramSource.cs +++ b/Plugins/Wox.Plugin.Program/ProgramSources/AppPathsProgramSource.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using Wox.Infrastructure.Storage.UserSettings; namespace Wox.Plugin.Program.ProgramSources { diff --git a/Plugins/Wox.Plugin.Program/ProgramSources/CommonStartMenuProgramSource.cs b/Plugins/Wox.Plugin.Program/ProgramSources/CommonStartMenuProgramSource.cs index 16f13dead1..4cd741ae40 100644 --- a/Plugins/Wox.Plugin.Program/ProgramSources/CommonStartMenuProgramSource.cs +++ b/Plugins/Wox.Plugin.Program/ProgramSources/CommonStartMenuProgramSource.cs @@ -1,7 +1,6 @@ using System; using System.Runtime.InteropServices; using System.Text; -using Wox.Infrastructure.Storage.UserSettings; namespace Wox.Plugin.Program.ProgramSources { diff --git a/Plugins/Wox.Plugin.Program/ProgramSources/FileSystemProgramSource.cs b/Plugins/Wox.Plugin.Program/ProgramSources/FileSystemProgramSource.cs index dc24fead6b..cb62dc8316 100644 --- a/Plugins/Wox.Plugin.Program/ProgramSources/FileSystemProgramSource.cs +++ b/Plugins/Wox.Plugin.Program/ProgramSources/FileSystemProgramSource.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using Wox.Infrastructure.Storage.UserSettings; using Log = Wox.Infrastructure.Logger.Log; namespace Wox.Plugin.Program.ProgramSources @@ -39,7 +38,7 @@ namespace Wox.Plugin.Program.ProgramSources { foreach (string file in Directory.GetFiles(path)) { - if (UserSettingStorage.Instance.ProgramSuffixes.Split(';').Any(o => file.EndsWith("." + o))) + if (ProgramStorage.Instance.ProgramSuffixes.Split(';').Any(o => file.EndsWith("." + o))) { Program p = CreateEntry(file); list.Add(p); diff --git a/Plugins/Wox.Plugin.Program/ProgramSources/UserStartMenuProgramSource.cs b/Plugins/Wox.Plugin.Program/ProgramSources/UserStartMenuProgramSource.cs index 9b3298f820..6c248feac1 100644 --- a/Plugins/Wox.Plugin.Program/ProgramSources/UserStartMenuProgramSource.cs +++ b/Plugins/Wox.Plugin.Program/ProgramSources/UserStartMenuProgramSource.cs @@ -1,5 +1,4 @@ using System; -using Wox.Infrastructure.Storage.UserSettings; namespace Wox.Plugin.Program.ProgramSources { diff --git a/Plugins/Wox.Plugin.Program/ProgramStorage.cs b/Plugins/Wox.Plugin.Program/ProgramStorage.cs new file mode 100644 index 0000000000..d6607c768c --- /dev/null +++ b/Plugins/Wox.Plugin.Program/ProgramStorage.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using Newtonsoft.Json; +using Wox.Infrastructure.Storage; + +namespace Wox.Plugin.Program +{ + public class ProgramStorage : JsonStrorage + { + [JsonProperty] + public List ProgramSources { get; set; } + + [JsonProperty] + public string ProgramSuffixes { get; set; } + + protected override string ConfigFolder + { + get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } + } + + protected override ProgramStorage LoadDefault() + { + ProgramSources = new List(); + return this; + } + + protected override void OnAfterLoad(ProgramStorage storage) + { + if (string.IsNullOrEmpty(storage.ProgramSuffixes)) + { + storage.ProgramSuffixes = "lnk;exe;appref-ms;bat"; + } + } + + protected override string ConfigName + { + get { return "setting"; } + } + } +} diff --git a/Plugins/Wox.Plugin.Program/ProgramSuffixes.xaml.cs b/Plugins/Wox.Plugin.Program/ProgramSuffixes.xaml.cs index 209e9f9c17..2d2c6d572b 100644 --- a/Plugins/Wox.Plugin.Program/ProgramSuffixes.xaml.cs +++ b/Plugins/Wox.Plugin.Program/ProgramSuffixes.xaml.cs @@ -1,5 +1,4 @@ using System.Windows; -using Wox.Infrastructure.Storage.UserSettings; namespace Wox.Plugin.Program { @@ -12,7 +11,7 @@ namespace Wox.Plugin.Program { InitializeComponent(); - tbSuffixes.Text = UserSettingStorage.Instance.ProgramSuffixes; + tbSuffixes.Text = ProgramStorage.Instance.ProgramSuffixes; } private void ButtonBase_OnClick(object sender, RoutedEventArgs e) @@ -23,7 +22,7 @@ namespace Wox.Plugin.Program return; } - UserSettingStorage.Instance.ProgramSuffixes = tbSuffixes.Text; + ProgramStorage.Instance.ProgramSuffixes = tbSuffixes.Text; MessageBox.Show("Sucessfully update file suffixes"); } } diff --git a/Plugins/Wox.Plugin.Program/Programs.cs b/Plugins/Wox.Plugin.Program/Programs.cs index 7b6e90dcf9..321bd075d4 100644 --- a/Plugins/Wox.Plugin.Program/Programs.cs +++ b/Plugins/Wox.Plugin.Program/Programs.cs @@ -1,10 +1,9 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using Wox.Infrastructure; -using Wox.Infrastructure.Storage.UserSettings; using Wox.Plugin.Program.ProgramSources; namespace Wox.Plugin.Program @@ -90,10 +89,10 @@ namespace Wox.Plugin.Program { List programSources = new List(); programSources.AddRange(LoadDeaultProgramSources()); - if (UserSettingStorage.Instance.ProgramSources != null && - UserSettingStorage.Instance.ProgramSources.Count(o => o.Enabled) > 0) + if (ProgramStorage.Instance.ProgramSources != null && + ProgramStorage.Instance.ProgramSources.Count(o => o.Enabled) > 0) { - programSources.AddRange(UserSettingStorage.Instance.ProgramSources.Where(o => o.Enabled)); + programSources.AddRange(ProgramStorage.Instance.ProgramSources.Where(o => o.Enabled)); } sources.Clear(); diff --git a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj index 4b64f865ff..0b2087ce8f 100644 --- a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj +++ b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj @@ -59,10 +59,12 @@ ProgramSetting.xaml + + ProgramSuffixes.xaml diff --git a/Plugins/Wox.Plugin.WebSearch/SuggestionSources/Baidu.cs b/Plugins/Wox.Plugin.WebSearch/SuggestionSources/Baidu.cs index 6603b59ba2..40a24c6b61 100644 --- a/Plugins/Wox.Plugin.WebSearch/SuggestionSources/Baidu.cs +++ b/Plugins/Wox.Plugin.WebSearch/SuggestionSources/Baidu.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text.RegularExpressions; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Wox.Core.UserSettings; using Wox.Infrastructure.Http; namespace Wox.Plugin.WebSearch.SuggestionSources @@ -14,7 +15,7 @@ namespace Wox.Plugin.WebSearch.SuggestionSources public override List GetSuggestions(string query) { - var result = HttpRequest.Get("http://suggestion.baidu.com/su?json=1&wd=" + Uri.EscapeUriString(query), "GB2312"); + var result = HttpRequest.Get("http://suggestion.baidu.com/su?json=1&wd=" + Uri.EscapeUriString(query), HttpProxy.Instance, "GB2312"); if (string.IsNullOrEmpty(result)) return new List(); Match match = reg.Match(result); @@ -23,9 +24,9 @@ namespace Wox.Plugin.WebSearch.SuggestionSources JContainer json = null; try { - json =JsonConvert.DeserializeObject(match.Groups[1].Value) as JContainer; + json = JsonConvert.DeserializeObject(match.Groups[1].Value) as JContainer; } - catch{} + catch { } if (json != null) { diff --git a/Plugins/Wox.Plugin.WebSearch/SuggestionSources/Google.cs b/Plugins/Wox.Plugin.WebSearch/SuggestionSources/Google.cs index b74a278a2e..b09b8d8fc7 100644 --- a/Plugins/Wox.Plugin.WebSearch/SuggestionSources/Google.cs +++ b/Plugins/Wox.Plugin.WebSearch/SuggestionSources/Google.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Wox.Core.UserSettings; using Wox.Infrastructure.Http; namespace Wox.Plugin.WebSearch.SuggestionSources @@ -11,7 +12,7 @@ namespace Wox.Plugin.WebSearch.SuggestionSources { public override List GetSuggestions(string query) { - var result = HttpRequest.Get("https://www.google.com/complete/search?output=chrome&q=" + Uri.EscapeUriString(query)); + var result = HttpRequest.Get("https://www.google.com/complete/search?output=chrome&q=" + Uri.EscapeUriString(query),HttpProxy.Instance); if (string.IsNullOrEmpty(result)) return new List(); try diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs index 87156b69db..6b24eead6d 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using Wox.Infrastructure.Storage.UserSettings; +using Wox.Core.UserSettings; using Wox.Plugin.WebSearch.SuggestionSources; namespace Wox.Plugin.WebSearch @@ -15,7 +15,7 @@ namespace Wox.Plugin.WebSearch { List results = new List(); - Infrastructure.Storage.UserSettings.WebSearch webSearch = + Core.UserSettings.WebSearch webSearch = UserSettingStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionWord == query.ActionName && o.Enabled); if (webSearch != null) diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs index 01e25d5155..c237a5f5bf 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs @@ -5,7 +5,7 @@ using System.Reflection; using System.Windows; using System.Windows.Media.Imaging; using Microsoft.Win32; -using Wox.Infrastructure.Storage.UserSettings; +using Wox.Core.UserSettings; namespace Wox.Plugin.WebSearch { @@ -14,7 +14,7 @@ namespace Wox.Plugin.WebSearch private string defaultWebSearchImageDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Images\\websearch"); private WebSearchesSetting settingWindow; private bool update; - private Infrastructure.Storage.UserSettings.WebSearch updateWebSearch; + private Core.UserSettings.WebSearch updateWebSearch; public WebSearchSetting(WebSearchesSetting settingWidow) { @@ -22,7 +22,7 @@ namespace Wox.Plugin.WebSearch InitializeComponent(); } - public void UpdateItem(Infrastructure.Storage.UserSettings.WebSearch webSearch) + public void UpdateItem(Core.UserSettings.WebSearch webSearch) { updateWebSearch = UserSettingStorage.Instance.WebSearches.FirstOrDefault(o => o == webSearch); if (updateWebSearch == null || string.IsNullOrEmpty(updateWebSearch.Url)) @@ -89,7 +89,7 @@ namespace Wox.Plugin.WebSearch MessageBox.Show("ActionWord has existed, please input a new one."); return; } - UserSettingStorage.Instance.WebSearches.Add(new Infrastructure.Storage.UserSettings.WebSearch() + UserSettingStorage.Instance.WebSearches.Add(new Core.UserSettings.WebSearch() { ActionWord = action, Enabled = cbEnable.IsChecked ?? false, diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchesSetting.xaml.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchesSetting.xaml.cs index 8f8efb114b..a6d18d1b55 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchesSetting.xaml.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchesSetting.xaml.cs @@ -2,7 +2,7 @@ using System.Linq; using System.Windows; using System.Windows.Controls; -using Wox.Infrastructure.Storage.UserSettings; +using Wox.Core.UserSettings; namespace Wox.Plugin.WebSearch { @@ -54,7 +54,7 @@ namespace Wox.Plugin.WebSearch private void btnDeleteWebSearch_OnClick(object sender, RoutedEventArgs e) { - Infrastructure.Storage.UserSettings.WebSearch selectedWebSearch = webSearchView.SelectedItem as Infrastructure.Storage.UserSettings.WebSearch; + Core.UserSettings.WebSearch selectedWebSearch = webSearchView.SelectedItem as Core.UserSettings.WebSearch; if (selectedWebSearch != null) { if (MessageBox.Show("Are your sure to delete " + selectedWebSearch.Title, "Delete WebSearch", @@ -72,7 +72,7 @@ namespace Wox.Plugin.WebSearch private void btnEditWebSearch_OnClick(object sender, RoutedEventArgs e) { - Infrastructure.Storage.UserSettings.WebSearch selectedWebSearch = webSearchView.SelectedItem as Infrastructure.Storage.UserSettings.WebSearch; + Core.UserSettings.WebSearch selectedWebSearch = webSearchView.SelectedItem as Core.UserSettings.WebSearch; if (selectedWebSearch != null) { WebSearchSetting webSearch = new WebSearchSetting(this); diff --git a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj index f40eaa65f0..8ca2c7ed37 100644 --- a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj +++ b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj @@ -77,6 +77,10 @@ + + {B749F0DB-8E75-47DB-9E5E-265D16D0C0D2} + Wox.Core + {4fd29318-a8ab-4d8f-aa47-60bc241b8da3} Wox.Infrastructure diff --git a/Wox.Core/Plugin/PluginConfig.cs b/Wox.Core/Plugin/PluginConfig.cs index 28cfecb969..6c96ef7773 100644 --- a/Wox.Core/Plugin/PluginConfig.cs +++ b/Wox.Core/Plugin/PluginConfig.cs @@ -5,8 +5,8 @@ using System.Linq; using System.Reflection; using Newtonsoft.Json; using Wox.Core.Exception; +using Wox.Core.UserSettings; using Wox.Infrastructure.Logger; -using Wox.Infrastructure.Storage.UserSettings; using Wox.Plugin; namespace Wox.Core.Plugin diff --git a/Wox.Core/Plugin/PluginManager.cs b/Wox.Core/Plugin/PluginManager.cs index ce988cd334..f1badfc1d0 100644 --- a/Wox.Core/Plugin/PluginManager.cs +++ b/Wox.Core/Plugin/PluginManager.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Reflection; using System.Threading; using Wox.Core.Exception; +using Wox.Core.UserSettings; using Wox.Infrastructure; using Wox.Infrastructure.Http; using Wox.Infrastructure.Logger; diff --git a/Wox.Core/Plugin/PythonPlugin.cs b/Wox.Core/Plugin/PythonPlugin.cs index 7704ea7a3d..20487de0a2 100644 --- a/Wox.Core/Plugin/PythonPlugin.cs +++ b/Wox.Core/Plugin/PythonPlugin.cs @@ -1,6 +1,7 @@ using System.Diagnostics; using System.IO; using System.Reflection; +using Wox.Core.UserSettings; using Wox.Infrastructure.Http; using Wox.Plugin; diff --git a/Wox.Core/Plugin/QueryDispatcher/SystemPluginQueryDispatcher.cs b/Wox.Core/Plugin/QueryDispatcher/SystemPluginQueryDispatcher.cs index e8bcb896a5..155e6a006e 100644 --- a/Wox.Core/Plugin/QueryDispatcher/SystemPluginQueryDispatcher.cs +++ b/Wox.Core/Plugin/QueryDispatcher/SystemPluginQueryDispatcher.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading; -using Wox.Infrastructure.Storage.UserSettings; +using Wox.Core.UserSettings; using Wox.Plugin; //using Wox.Plugin.SystemPlugins; diff --git a/Wox.Core/Plugin/QueryDispatcher/UserPluginQueryDispatcher.cs b/Wox.Core/Plugin/QueryDispatcher/UserPluginQueryDispatcher.cs index 3b96d2c3a8..1f742366ca 100644 --- a/Wox.Core/Plugin/QueryDispatcher/UserPluginQueryDispatcher.cs +++ b/Wox.Core/Plugin/QueryDispatcher/UserPluginQueryDispatcher.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Threading; +using Wox.Core.UserSettings; using Wox.Infrastructure.Logger; -using Wox.Infrastructure.Storage.UserSettings; using Wox.Plugin; namespace Wox.Core.Plugin.QueryDispatcher diff --git a/Wox.Core/Theme/Theme.cs b/Wox.Core/Theme/Theme.cs index c10f1a4526..97dd656df1 100644 --- a/Wox.Core/Theme/Theme.cs +++ b/Wox.Core/Theme/Theme.cs @@ -7,8 +7,8 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Media; using Wox.Core.UI; +using Wox.Core.UserSettings; using Wox.Infrastructure.Logger; -using Wox.Infrastructure.Storage.UserSettings; namespace Wox.Core.Theme { diff --git a/Wox.Infrastructure/Storage/UserSettings/CustomizedPluginConfig.cs b/Wox.Core/UserSettings/CustomizedPluginConfig.cs similarity index 66% rename from Wox.Infrastructure/Storage/UserSettings/CustomizedPluginConfig.cs rename to Wox.Core/UserSettings/CustomizedPluginConfig.cs index e7f021843e..c8e224f89d 100644 --- a/Wox.Infrastructure/Storage/UserSettings/CustomizedPluginConfig.cs +++ b/Wox.Core/UserSettings/CustomizedPluginConfig.cs @@ -1,10 +1,8 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -namespace Wox.Infrastructure.Storage.UserSettings +namespace Wox.Core.UserSettings { + [Serializable] public class CustomizedPluginConfig { public string ID { get; set; } diff --git a/Wox.Infrastructure/Http/HttpProxy.cs b/Wox.Core/UserSettings/HttpProxy.cs similarity index 89% rename from Wox.Infrastructure/Http/HttpProxy.cs rename to Wox.Core/UserSettings/HttpProxy.cs index 21ce2ded02..cfe6ca40ed 100644 --- a/Wox.Infrastructure/Http/HttpProxy.cs +++ b/Wox.Core/UserSettings/HttpProxy.cs @@ -1,7 +1,6 @@ -using Wox.Infrastructure.Storage.UserSettings; -using Wox.Plugin; +using Wox.Plugin; -namespace Wox.Infrastructure.Http +namespace Wox.Core.UserSettings { public class HttpProxy : IHttpProxy { diff --git a/Wox.Infrastructure/Storage/UserSettings/PluginHotkey.cs b/Wox.Core/UserSettings/PluginHotkey.cs similarity index 67% rename from Wox.Infrastructure/Storage/UserSettings/PluginHotkey.cs rename to Wox.Core/UserSettings/PluginHotkey.cs index 1547a213d1..892816f8b9 100644 --- a/Wox.Infrastructure/Storage/UserSettings/PluginHotkey.cs +++ b/Wox.Core/UserSettings/PluginHotkey.cs @@ -1,5 +1,8 @@ -namespace Wox.Infrastructure.Storage.UserSettings +using System; + +namespace Wox.Core.UserSettings { + [Serializable] public class CustomPluginHotkey { public string Hotkey { get; set; } diff --git a/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs b/Wox.Core/UserSettings/UserSettingStorage.cs similarity index 89% rename from Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs rename to Wox.Core/UserSettings/UserSettingStorage.cs index 1dd42a4044..100d7c4fde 100644 --- a/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs +++ b/Wox.Core/UserSettings/UserSettingStorage.cs @@ -1,10 +1,13 @@ -using System.Collections.Generic; -using System.Drawing; +using System; +using System.Collections.Generic; using System.IO; using System.Windows.Forms; using Newtonsoft.Json; +using Wox.Infrastructure.Storage; +using Wox.Plugin; +using System.Drawing; -namespace Wox.Infrastructure.Storage.UserSettings +namespace Wox.Core.UserSettings { public class UserSettingStorage : JsonStrorage { @@ -44,9 +47,6 @@ namespace Wox.Infrastructure.Storage.UserSettings [JsonProperty] public string ResultItemFontStretch { get; set; } - [JsonProperty] - public bool ReplaceWinR { get; set; } - [JsonProperty] public List WebSearches { get; set; } @@ -56,12 +56,6 @@ namespace Wox.Infrastructure.Storage.UserSettings [JsonProperty] public double WindowTop { get; set; } - [JsonProperty] - public List ProgramSources { get; set; } - - [JsonProperty] - public List FolderLinks { get; set; } - public List CustomizedPluginConfigs { get; set; } [JsonProperty] @@ -73,9 +67,6 @@ namespace Wox.Infrastructure.Storage.UserSettings [JsonProperty] public double Opacity { get; set; } - [JsonProperty] - public string ProgramSuffixes { get; set; } - [JsonProperty] public OpacityMode OpacityMode { get; set; } @@ -144,6 +135,19 @@ namespace Wox.Infrastructure.Storage.UserSettings return webSearches; } + protected override string ConfigFolder + { + get + { + string userProfilePath = Environment.GetEnvironmentVariable("USERPROFILE"); + if (userProfilePath == null) + { + throw new ArgumentException("Environment variable USERPROFILE is empty"); + } + return Path.Combine(Path.Combine(userProfilePath, ".Wox"), "Config"); + } + } + protected override string ConfigName { get { return "config"; } @@ -154,9 +158,7 @@ namespace Wox.Infrastructure.Storage.UserSettings DontPromptUpdateMsg = false; Theme = "Dark"; Language = "en"; - ReplaceWinR = true; WebSearches = LoadDefaultWebSearches(); - ProgramSources = new List(); CustomizedPluginConfigs = new List(); Hotkey = "Alt + Space"; QueryBoxFont = FontFamily.GenericSansSerif.Name; @@ -175,10 +177,6 @@ namespace Wox.Infrastructure.Storage.UserSettings { storage.CustomizedPluginConfigs = new List(); } - if (string.IsNullOrEmpty(storage.ProgramSuffixes)) - { - storage.ProgramSuffixes = "lnk;exe;appref-ms;bat"; - } if (storage.QueryBoxFont == null) { storage.QueryBoxFont = FontFamily.GenericSansSerif.Name; diff --git a/Wox.Infrastructure/Storage/UserSettings/WebSearch.cs b/Wox.Core/UserSettings/WebSearch.cs similarity index 78% rename from Wox.Infrastructure/Storage/UserSettings/WebSearch.cs rename to Wox.Core/UserSettings/WebSearch.cs index 5b6eb0e5d2..aa28a2ff80 100644 --- a/Wox.Infrastructure/Storage/UserSettings/WebSearch.cs +++ b/Wox.Core/UserSettings/WebSearch.cs @@ -1,5 +1,8 @@ -namespace Wox.Infrastructure.Storage.UserSettings +using System; + +namespace Wox.Core.UserSettings { + [Serializable] public class WebSearch { public string Title { get; set; } diff --git a/Wox.Core/Wox.Core.csproj b/Wox.Core/Wox.Core.csproj index e9160ad1ca..21cad4e12b 100644 --- a/Wox.Core/Wox.Core.csproj +++ b/Wox.Core/Wox.Core.csproj @@ -44,6 +44,7 @@ + @@ -58,6 +59,7 @@ + @@ -83,6 +85,10 @@ + + + + diff --git a/Wox.Core/i18n/Internationalization.cs b/Wox.Core/i18n/Internationalization.cs index b61a65bcaf..90342c7343 100644 --- a/Wox.Core/i18n/Internationalization.cs +++ b/Wox.Core/i18n/Internationalization.cs @@ -7,8 +7,8 @@ using System.Text; using System.Windows; using Wox.Core.Exception; using Wox.Core.UI; +using Wox.Core.UserSettings; using Wox.Infrastructure.Logger; -using Wox.Infrastructure.Storage.UserSettings; namespace Wox.Core.i18n { diff --git a/Wox.Core/i18n/InternationalizationManager.cs b/Wox.Core/i18n/InternationalizationManager.cs index 55ef73add4..a1f0a9049c 100644 --- a/Wox.Core/i18n/InternationalizationManager.cs +++ b/Wox.Core/i18n/InternationalizationManager.cs @@ -6,7 +6,6 @@ using System.Reflection; using System.Windows; using Wox.Core.UI; using Wox.Infrastructure.Logger; -using Wox.Infrastructure.Storage.UserSettings; namespace Wox.Core.i18n { diff --git a/Wox.Infrastructure/Http/HttpRequest.cs b/Wox.Infrastructure/Http/HttpRequest.cs index eda68b9014..eaec09f0f1 100644 --- a/Wox.Infrastructure/Http/HttpRequest.cs +++ b/Wox.Infrastructure/Http/HttpRequest.cs @@ -1,4 +1,5 @@ using System; +using System.Drawing; using System.IO; using System.Net; using System.Text; @@ -8,9 +9,9 @@ namespace Wox.Infrastructure.Http { public class HttpRequest { - public static string Get(string url, string encoding = "UTF-8") + public static string Get(string url, IHttpProxy proxy, string encoding = "UTF-8") { - return Get(url, encoding, HttpProxy.Instance); + return Get(url, encoding, proxy); } private static string Get(string url, string encoding, IHttpProxy proxy) diff --git a/Wox.Infrastructure/Storage/BaseStorage.cs b/Wox.Infrastructure/Storage/BaseStorage.cs index 1b6c7c078e..3db9bfee70 100644 --- a/Wox.Infrastructure/Storage/BaseStorage.cs +++ b/Wox.Infrastructure/Storage/BaseStorage.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Reflection; using System.Runtime.InteropServices.ComTypes; using System.Text; using System.Windows.Forms; @@ -12,24 +13,7 @@ namespace Wox.Infrastructure.Storage [Serializable] public abstract class BaseStorage : IStorage where T : class,IStorage, new() { - private string configFolder; - - private string ConfigFolder - { - get - { - if (string.IsNullOrEmpty(configFolder)) - { - string userProfilePath = Environment.GetEnvironmentVariable("USERPROFILE"); - if (userProfilePath == null) - { - throw new ArgumentException("Environment variable USERPROFILE is empty"); - } - configFolder = Path.Combine(Path.Combine(userProfilePath, ".Wox"), "Config"); - } - return configFolder; - } - } + protected abstract string ConfigFolder { get; } protected string ConfigPath { diff --git a/Wox.Infrastructure/Storage/BinaryStorage.cs b/Wox.Infrastructure/Storage/BinaryStorage.cs index c0e8be63cf..4cfddb1b47 100644 --- a/Wox.Infrastructure/Storage/BinaryStorage.cs +++ b/Wox.Infrastructure/Storage/BinaryStorage.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Runtime.Serialization.Formatters; using System.Runtime.Serialization.Formatters.Binary; using System.Text; using Wox.Infrastructure.Logger; @@ -27,7 +28,10 @@ namespace Wox.Infrastructure.Storage { using (FileStream fileStream = new FileStream(ConfigPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { - BinaryFormatter binaryFormatter = new BinaryFormatter(); + BinaryFormatter binaryFormatter = new BinaryFormatter + { + AssemblyFormat = FormatterAssemblyStyle.Simple + }; serializedObject = binaryFormatter.Deserialize(fileStream) as T; if (serializedObject == null) { @@ -51,7 +55,10 @@ namespace Wox.Infrastructure.Storage try { FileStream fileStream = new FileStream(ConfigPath, FileMode.Create); - BinaryFormatter binaryFormatter = new BinaryFormatter(); + BinaryFormatter binaryFormatter = new BinaryFormatter + { + AssemblyFormat = FormatterAssemblyStyle.Simple + }; binaryFormatter.Serialize(fileStream, serializedObject); fileStream.Close(); } diff --git a/Wox.Infrastructure/WindowsShellRun.cs b/Wox.Infrastructure/WindowsShellRun.cs index f8ec456b4a..ba5d2673ab 100644 --- a/Wox.Infrastructure/WindowsShellRun.cs +++ b/Wox.Infrastructure/WindowsShellRun.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Text; using System.Runtime.InteropServices; using System.IO; -using Wox.Infrastructure.Storage.UserSettings; namespace Wox.Infrastructure { @@ -78,7 +77,7 @@ namespace Wox.Infrastructure [DllImport("shlwapi.dll", CharSet = CharSet.Unicode)] static extern bool UrlIs(string pszUrl, int UrlIs); - static void ShellExecCmdLine(IntPtr hInstance, IntPtr hwnd, string command, string startDir, global::System.Diagnostics.ProcessWindowStyle nShow, ShellExecCmdLineFlags dwSeclFlags,bool runAsAdministrator = false) + static void ShellExecCmdLine(IntPtr hInstance, IntPtr hwnd, string command, string startDir, global::System.Diagnostics.ProcessWindowStyle nShow, ShellExecCmdLineFlags dwSeclFlags,bool runAsAdministrator = false,bool leaveCmdOpen = false) { string cmd = command; string args = null; @@ -103,7 +102,7 @@ namespace Wox.Infrastructure startDir = dir; } - if (UserSettingStorage.Instance.LeaveCmdOpen && File.Exists(cmd)) + if (leaveCmdOpen && File.Exists(cmd)) { bool needsCommandLine; diff --git a/Wox.Infrastructure/Wox.Infrastructure.csproj b/Wox.Infrastructure/Wox.Infrastructure.csproj index aff1b89b88..4c23af6316 100644 --- a/Wox.Infrastructure/Wox.Infrastructure.csproj +++ b/Wox.Infrastructure/Wox.Infrastructure.csproj @@ -41,7 +41,7 @@ False - ..\packages\Newtonsoft.Json.6.0.5\lib\net35\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll @@ -59,18 +59,11 @@ - - - - - - - @@ -91,9 +84,6 @@ Wox.Plugin - - -