This commit is contained in:
qianlifeng
2015-01-06 09:44:42 +08:00
62 changed files with 342 additions and 222 deletions

View File

@@ -2,13 +2,20 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Windows.Forms;
using WindowsInput;
using WindowsInput.Native;
using Wox.Infrastructure.Hotkey;
using Control = System.Windows.Controls.Control; using Control = System.Windows.Controls.Control;
namespace Wox.Plugin.CMD namespace Wox.Plugin.CMD
{ {
public class CMD : IPlugin, ISettingProvider public class CMD : IPlugin, ISettingProvider
{ {
private readonly GlobalHotkey globalHotkey = new GlobalHotkey();
private PluginInitContext context; private PluginInitContext context;
private bool WinRStroked;
private readonly KeyboardSimulator keyboardSimulator = new KeyboardSimulator(new InputSimulator());
public List<Result> Query(Query query) public List<Result> Query(Query query)
{ {
@@ -166,6 +173,33 @@ namespace Wox.Plugin.CMD
public void Init(PluginInitContext context) public void Init(PluginInitContext context)
{ {
this.context = 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() public Control CreateSettingPanel()

View File

@@ -1,6 +1,5 @@
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using Wox.Infrastructure.Storage.UserSettings;
namespace Wox.Plugin.CMD namespace Wox.Plugin.CMD
{ {
@@ -13,30 +12,30 @@ namespace Wox.Plugin.CMD
private void CMDSetting_OnLoaded(object sender, RoutedEventArgs re) private void CMDSetting_OnLoaded(object sender, RoutedEventArgs re)
{ {
cbReplaceWinR.IsChecked = UserSettingStorage.Instance.ReplaceWinR; cbReplaceWinR.IsChecked = CMDStorage.Instance.ReplaceWinR;
cbLeaveCmdOpen.IsChecked = UserSettingStorage.Instance.LeaveCmdOpen; cbLeaveCmdOpen.IsChecked = CMDStorage.Instance.LeaveCmdOpen;
cbLeaveCmdOpen.Checked += (o, e) => cbLeaveCmdOpen.Checked += (o, e) =>
{ {
UserSettingStorage.Instance.LeaveCmdOpen = true; CMDStorage.Instance.LeaveCmdOpen = true;
UserSettingStorage.Instance.Save(); CMDStorage.Instance.Save();
}; };
cbLeaveCmdOpen.Unchecked += (o, e) => cbLeaveCmdOpen.Unchecked += (o, e) =>
{ {
UserSettingStorage.Instance.LeaveCmdOpen = false; CMDStorage.Instance.LeaveCmdOpen = false;
UserSettingStorage.Instance.Save(); CMDStorage.Instance.Save();
}; };
cbReplaceWinR.Checked += (o, e) => cbReplaceWinR.Checked += (o, e) =>
{ {
UserSettingStorage.Instance.ReplaceWinR = true; CMDStorage.Instance.ReplaceWinR = true;
UserSettingStorage.Instance.Save(); CMDStorage.Instance.Save();
}; };
cbReplaceWinR.Unchecked += (o, e) => cbReplaceWinR.Unchecked += (o, e) =>
{ {
UserSettingStorage.Instance.ReplaceWinR = false; CMDStorage.Instance.ReplaceWinR = false;
UserSettingStorage.Instance.Save(); CMDStorage.Instance.Save();
}; };
} }
} }

View File

@@ -1,19 +1,38 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Wox.Infrastructure.Storage; using Wox.Infrastructure.Storage;
using System.IO;
namespace Wox.Plugin.CMD namespace Wox.Plugin.CMD
{ {
public class CMDStorage : JsonStrorage<CMDStorage> public class CMDStorage : JsonStrorage<CMDStorage>
{ {
[JsonProperty]
public bool ReplaceWinR { get; set; }
[JsonProperty]
public bool LeaveCmdOpen { get; set; }
[JsonProperty] [JsonProperty]
public Dictionary<string, int> CMDHistory = new Dictionary<string, int>(); public Dictionary<string, int> CMDHistory = new Dictionary<string, int>();
protected override string ConfigFolder
{
get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); }
}
protected override string ConfigName protected override string ConfigName
{ {
get { return "CMDHistory"; } get { return "CMDHistory"; }
} }
protected override CMDStorage LoadDefault()
{
ReplaceWinR = true;
return this;
}
public void AddCmdHistory(string cmdName) public void AddCmdHistory(string cmdName)
{ {
if (CMDHistory.ContainsKey(cmdName)) if (CMDHistory.ContainsKey(cmdName))

View File

@@ -44,11 +44,15 @@
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
<Reference Include="WindowsInput">
<HintPath>..\..\packages\InputSimulator.1.0.4.0\lib\net20\WindowsInput.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CMD.cs" /> <Compile Include="CMD.cs" />

View File

@@ -1,11 +1,10 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Wox.Infrastructure.Storage.UserSettings namespace Wox.Plugin.Folder
{ {
[Serializable]
public class FolderLink public class FolderLink
{ {
[JsonProperty] [JsonProperty]

View File

@@ -4,7 +4,6 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using Wox.Infrastructure.Storage.UserSettings;
using Control = System.Windows.Controls.Control; using Control = System.Windows.Controls.Control;
namespace Wox.Plugin.Folder namespace Wox.Plugin.Folder
@@ -24,10 +23,10 @@ namespace Wox.Plugin.Folder
this.context = context; this.context = context;
this.context.API.BackKeyDownEvent += ApiBackKeyDownEvent; this.context.API.BackKeyDownEvent += ApiBackKeyDownEvent;
InitialDriverList(); InitialDriverList();
if (UserSettingStorage.Instance.FolderLinks == null) if (FolderStorage.Instance.FolderLinks == null)
{ {
UserSettingStorage.Instance.FolderLinks = new List<FolderLink>(); FolderStorage.Instance.FolderLinks = new List<FolderLink>();
UserSettingStorage.Instance.Save(); FolderStorage.Instance.Save();
} }
} }
@@ -56,7 +55,7 @@ namespace Wox.Plugin.Folder
if(string.IsNullOrEmpty(query.RawQuery)) return new List<Result>(); if(string.IsNullOrEmpty(query.RawQuery)) return new List<Result>();
string input = query.RawQuery.ToLower(); string input = query.RawQuery.ToLower();
List<FolderLink> userFolderLinks = UserSettingStorage.Instance.FolderLinks.Where( List<FolderLink> userFolderLinks = FolderStorage.Instance.FolderLinks.Where(
x => x.Nickname.StartsWith(input, StringComparison.OrdinalIgnoreCase)).ToList(); x => x.Nickname.StartsWith(input, StringComparison.OrdinalIgnoreCase)).ToList();
List<Result> results = List<Result> results =
userFolderLinks.Select( userFolderLinks.Select(

View File

@@ -2,33 +2,36 @@
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Forms; using System.Windows.Forms;
using Wox.Infrastructure.Storage.UserSettings;
using MessageBox = System.Windows.MessageBox; using MessageBox = System.Windows.MessageBox;
using UserControl = System.Windows.Controls.UserControl; using UserControl = System.Windows.Controls.UserControl;
namespace Wox.Plugin.Folder { namespace Wox.Plugin.Folder
{
/// <summary> /// <summary>
/// Interaction logic for FileSystemSettings.xaml /// Interaction logic for FileSystemSettings.xaml
/// </summary> /// </summary>
public partial class FileSystemSettings : UserControl { public partial class FileSystemSettings : UserControl
public FileSystemSettings() { {
InitializeComponent(); public FileSystemSettings()
lbxFolders.ItemsSource = UserSettingStorage.Instance.FolderLinks; {
} 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; var selectedFolder = lbxFolders.SelectedItem as FolderLink;
if (selectedFolder != null) if (selectedFolder != null)
{ {
UserSettingStorage.Instance.FolderLinks.Remove(selectedFolder); FolderStorage.Instance.FolderLinks.Remove(selectedFolder);
lbxFolders.Items.Refresh(); lbxFolders.Items.Refresh();
} }
else else
{ {
MessageBox.Show("Please select a folder link!"); MessageBox.Show("Please select a folder link!");
} }
} }
private void btnEdit_Click(object sender, RoutedEventArgs e) private void btnEdit_Click(object sender, RoutedEventArgs e)
{ {
@@ -39,10 +42,10 @@ namespace Wox.Plugin.Folder {
folderBrowserDialog.SelectedPath = selectedFolder.Path; folderBrowserDialog.SelectedPath = selectedFolder.Path;
if (folderBrowserDialog.ShowDialog() == DialogResult.OK) 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; link.Path = folderBrowserDialog.SelectedPath;
UserSettingStorage.Instance.Save(); FolderStorage.Instance.Save();
} }
lbxFolders.Items.Refresh(); lbxFolders.Items.Refresh();
@@ -51,24 +54,28 @@ namespace Wox.Plugin.Folder {
{ {
MessageBox.Show("Please select a folder link!"); MessageBox.Show("Please select a folder link!");
} }
} }
private void btnAdd_Click(object sender, RoutedEventArgs e) { 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 System.Windows.Forms.FolderBrowserDialog();
var newFolder = new FolderLink() { if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
Path = folderBrowserDialog.SelectedPath {
}; var newFolder = new FolderLink()
{
Path = folderBrowserDialog.SelectedPath
};
if (UserSettingStorage.Instance.FolderLinks == null) { if (FolderStorage.Instance.FolderLinks == null)
UserSettingStorage.Instance.FolderLinks = new List<FolderLink>(); {
} FolderStorage.Instance.FolderLinks = new List<FolderLink>();
}
UserSettingStorage.Instance.FolderLinks.Add(newFolder); FolderStorage.Instance.FolderLinks.Add(newFolder);
UserSettingStorage.Instance.Save(); FolderStorage.Instance.Save();
} }
lbxFolders.Items.Refresh(); lbxFolders.Items.Refresh();
} }
} }
} }

View File

@@ -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<FolderStorage>
{
[JsonProperty]
public List<FolderLink> FolderLinks { get; set; }
protected override string ConfigFolder
{
get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); }
}
protected override string ConfigName
{
get { return "setting"; }
}
}
}

View File

@@ -36,6 +36,10 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\log4net.2.0.3\lib\net35-full\log4net.dll</HintPath> <HintPath>..\..\packages\log4net.2.0.3\lib\net35-full\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
<Reference Include="System" /> <Reference Include="System" />
@@ -48,10 +52,12 @@
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="FolderLink.cs" />
<Compile Include="FolderPlugin.cs" /> <Compile Include="FolderPlugin.cs" />
<Compile Include="FolderPluginSettings.xaml.cs"> <Compile Include="FolderPluginSettings.xaml.cs">
<DependentUpon>FolderPluginSettings.xaml</DependentUpon> <DependentUpon>FolderPluginSettings.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="FolderStorage.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="log4net" version="2.0.3" targetFramework="net35" /> <package id="log4net" version="2.0.3" targetFramework="net35" />
<package id="Newtonsoft.Json" version="6.0.7" targetFramework="net35" />
</packages> </packages>

View File

@@ -1,7 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Wox.Core.Plugin; using Wox.Core.Plugin;
using Wox.Infrastructure.Storage.UserSettings; using Wox.Core.UserSettings;
namespace Wox.Plugin.PluginIndicator namespace Wox.Plugin.PluginIndicator
{ {

View File

@@ -34,7 +34,7 @@
<ItemGroup> <ItemGroup>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Newtonsoft.Json.6.0.5\lib\net35\Newtonsoft.Json.dll</HintPath> <HintPath>..\..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Newtonsoft.Json" version="6.0.5" targetFramework="net35" /> <package id="Newtonsoft.Json" version="6.0.7" targetFramework="net35" />
</packages> </packages>

View File

@@ -2,7 +2,6 @@
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using Wox.Infrastructure.Storage.UserSettings;
namespace Wox.Plugin.Program namespace Wox.Plugin.Program
{ {
@@ -21,7 +20,7 @@ namespace Wox.Plugin.Program
} }
watchedPath.Add(path); watchedPath.Add(path);
foreach (string fileType in UserSettingStorage.Instance.ProgramSuffixes.Split(';')) foreach (string fileType in ProgramStorage.Instance.ProgramSuffixes.Split(';'))
{ {
FileSystemWatcher watcher = new FileSystemWatcher FileSystemWatcher watcher = new FileSystemWatcher
{ {

View File

@@ -1,5 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Wox.Infrastructure.Storage; using Wox.Infrastructure.Storage;
namespace Wox.Plugin.Program namespace Wox.Plugin.Program
@@ -9,6 +11,11 @@ namespace Wox.Plugin.Program
{ {
public List<Program> Programs = new List<Program>(); public List<Program> Programs = new List<Program>();
protected override string ConfigFolder
{
get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); }
}
protected override string ConfigName protected override string ConfigName
{ {
get { return "ProgramIndexCache"; } get { return "ProgramIndexCache"; }

View File

@@ -2,7 +2,6 @@
using System.Threading; using System.Threading;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using Wox.Infrastructure.Storage.UserSettings;
namespace Wox.Plugin.Program namespace Wox.Plugin.Program
{ {
@@ -19,7 +18,7 @@ namespace Wox.Plugin.Program
private void Setting_Loaded(object sender, RoutedEventArgs e) private void Setting_Loaded(object sender, RoutedEventArgs e)
{ {
programSourceView.ItemsSource = UserSettingStorage.Instance.ProgramSources; programSourceView.ItemsSource = ProgramStorage.Instance.ProgramSources;
} }
private void ReIndexing() private void ReIndexing()
@@ -40,13 +39,13 @@ namespace Wox.Plugin.Program
{ {
string path = folderBrowserDialog.SelectedPath; string path = folderBrowserDialog.SelectedPath;
UserSettingStorage.Instance.ProgramSources.Add(new ProgramSource() ProgramStorage.Instance.ProgramSources.Add(new ProgramSource()
{ {
Location = path, Location = path,
Type = "FileSystemProgramSource", Type = "FileSystemProgramSource",
Enabled = true Enabled = true
}); });
UserSettingStorage.Instance.Save(); ProgramStorage.Instance.Save();
ReIndexing(); ReIndexing();
} }
} }
@@ -59,8 +58,8 @@ namespace Wox.Plugin.Program
if (MessageBox.Show("Are your sure to delete " + selectedProgramSource.Location, "Delete ProgramSource", if (MessageBox.Show("Are your sure to delete " + selectedProgramSource.Location, "Delete ProgramSource",
MessageBoxButton.YesNo) == MessageBoxResult.Yes) MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{ {
UserSettingStorage.Instance.ProgramSources.Remove(selectedProgramSource); ProgramStorage.Instance.ProgramSources.Remove(selectedProgramSource);
UserSettingStorage.Instance.Save(); ProgramStorage.Instance.Save();
ReIndexing(); ReIndexing();
} }
} }
@@ -81,7 +80,7 @@ namespace Wox.Plugin.Program
{ {
string path = folderBrowserDialog.SelectedPath; string path = folderBrowserDialog.SelectedPath;
selectedProgramSource.Location = path; selectedProgramSource.Location = path;
UserSettingStorage.Instance.Save(); ProgramStorage.Instance.Save();
ReIndexing(); ReIndexing();
} }
} }

View File

@@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Wox.Infrastructure.Storage.UserSettings namespace Wox.Plugin.Program
{ {
[Serializable] [Serializable]
public class ProgramSource public class ProgramSource

View File

@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Wox.Infrastructure.Storage.UserSettings;
namespace Wox.Plugin.Program.ProgramSources namespace Wox.Plugin.Program.ProgramSources
{ {

View File

@@ -1,7 +1,6 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using Wox.Infrastructure.Storage.UserSettings;
namespace Wox.Plugin.Program.ProgramSources namespace Wox.Plugin.Program.ProgramSources
{ {

View File

@@ -2,7 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Wox.Infrastructure.Storage.UserSettings;
using Log = Wox.Infrastructure.Logger.Log; using Log = Wox.Infrastructure.Logger.Log;
namespace Wox.Plugin.Program.ProgramSources namespace Wox.Plugin.Program.ProgramSources
@@ -39,7 +38,7 @@ namespace Wox.Plugin.Program.ProgramSources
{ {
foreach (string file in Directory.GetFiles(path)) 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); Program p = CreateEntry(file);
list.Add(p); list.Add(p);

View File

@@ -1,5 +1,4 @@
using System; using System;
using Wox.Infrastructure.Storage.UserSettings;
namespace Wox.Plugin.Program.ProgramSources namespace Wox.Plugin.Program.ProgramSources
{ {

View File

@@ -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<ProgramStorage>
{
[JsonProperty]
public List<ProgramSource> 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<ProgramSource>();
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"; }
}
}
}

View File

@@ -1,5 +1,4 @@
using System.Windows; using System.Windows;
using Wox.Infrastructure.Storage.UserSettings;
namespace Wox.Plugin.Program namespace Wox.Plugin.Program
{ {
@@ -12,7 +11,7 @@ namespace Wox.Plugin.Program
{ {
InitializeComponent(); InitializeComponent();
tbSuffixes.Text = UserSettingStorage.Instance.ProgramSuffixes; tbSuffixes.Text = ProgramStorage.Instance.ProgramSuffixes;
} }
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
@@ -23,7 +22,7 @@ namespace Wox.Plugin.Program
return; return;
} }
UserSettingStorage.Instance.ProgramSuffixes = tbSuffixes.Text; ProgramStorage.Instance.ProgramSuffixes = tbSuffixes.Text;
MessageBox.Show("Sucessfully update file suffixes"); MessageBox.Show("Sucessfully update file suffixes");
} }
} }

View File

@@ -1,10 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using Wox.Infrastructure; using Wox.Infrastructure;
using Wox.Infrastructure.Storage.UserSettings;
using Wox.Plugin.Program.ProgramSources; using Wox.Plugin.Program.ProgramSources;
namespace Wox.Plugin.Program namespace Wox.Plugin.Program
@@ -90,10 +89,10 @@ namespace Wox.Plugin.Program
{ {
List<ProgramSource> programSources = new List<ProgramSource>(); List<ProgramSource> programSources = new List<ProgramSource>();
programSources.AddRange(LoadDeaultProgramSources()); programSources.AddRange(LoadDeaultProgramSources());
if (UserSettingStorage.Instance.ProgramSources != null && if (ProgramStorage.Instance.ProgramSources != null &&
UserSettingStorage.Instance.ProgramSources.Count(o => o.Enabled) > 0) 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(); sources.Clear();

View File

@@ -59,10 +59,12 @@
<Compile Include="ProgramSetting.xaml.cs"> <Compile Include="ProgramSetting.xaml.cs">
<DependentUpon>ProgramSetting.xaml</DependentUpon> <DependentUpon>ProgramSetting.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="ProgramSource.cs" />
<Compile Include="ProgramSources\AppPathsProgramSource.cs" /> <Compile Include="ProgramSources\AppPathsProgramSource.cs" />
<Compile Include="ProgramSources\CommonStartMenuProgramSource.cs" /> <Compile Include="ProgramSources\CommonStartMenuProgramSource.cs" />
<Compile Include="ProgramSources\FileSystemProgramSource.cs" /> <Compile Include="ProgramSources\FileSystemProgramSource.cs" />
<Compile Include="ProgramSources\UserStartMenuProgramSource.cs" /> <Compile Include="ProgramSources\UserStartMenuProgramSource.cs" />
<Compile Include="ProgramStorage.cs" />
<Compile Include="ProgramSuffixes.xaml.cs"> <Compile Include="ProgramSuffixes.xaml.cs">
<DependentUpon>ProgramSuffixes.xaml</DependentUpon> <DependentUpon>ProgramSuffixes.xaml</DependentUpon>
</Compile> </Compile>

View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Wox.Core.UserSettings;
using Wox.Infrastructure.Http; using Wox.Infrastructure.Http;
namespace Wox.Plugin.WebSearch.SuggestionSources namespace Wox.Plugin.WebSearch.SuggestionSources
@@ -14,7 +15,7 @@ namespace Wox.Plugin.WebSearch.SuggestionSources
public override List<string> GetSuggestions(string query) public override List<string> 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<string>(); if (string.IsNullOrEmpty(result)) return new List<string>();
Match match = reg.Match(result); Match match = reg.Match(result);
@@ -23,9 +24,9 @@ namespace Wox.Plugin.WebSearch.SuggestionSources
JContainer json = null; JContainer json = null;
try try
{ {
json =JsonConvert.DeserializeObject(match.Groups[1].Value) as JContainer; json = JsonConvert.DeserializeObject(match.Groups[1].Value) as JContainer;
} }
catch{} catch { }
if (json != null) if (json != null)
{ {

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Wox.Core.UserSettings;
using Wox.Infrastructure.Http; using Wox.Infrastructure.Http;
namespace Wox.Plugin.WebSearch.SuggestionSources namespace Wox.Plugin.WebSearch.SuggestionSources
@@ -11,7 +12,7 @@ namespace Wox.Plugin.WebSearch.SuggestionSources
{ {
public override List<string> GetSuggestions(string query) public override List<string> 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<string>(); if (string.IsNullOrEmpty(result)) return new List<string>();
try try

View File

@@ -2,7 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using Wox.Infrastructure.Storage.UserSettings; using Wox.Core.UserSettings;
using Wox.Plugin.WebSearch.SuggestionSources; using Wox.Plugin.WebSearch.SuggestionSources;
namespace Wox.Plugin.WebSearch namespace Wox.Plugin.WebSearch
@@ -15,7 +15,7 @@ namespace Wox.Plugin.WebSearch
{ {
List<Result> results = new List<Result>(); List<Result> results = new List<Result>();
Infrastructure.Storage.UserSettings.WebSearch webSearch = Core.UserSettings.WebSearch webSearch =
UserSettingStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionWord == query.ActionName && o.Enabled); UserSettingStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionWord == query.ActionName && o.Enabled);
if (webSearch != null) if (webSearch != null)

View File

@@ -5,7 +5,7 @@ using System.Reflection;
using System.Windows; using System.Windows;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using Microsoft.Win32; using Microsoft.Win32;
using Wox.Infrastructure.Storage.UserSettings; using Wox.Core.UserSettings;
namespace Wox.Plugin.WebSearch 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 string defaultWebSearchImageDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Images\\websearch");
private WebSearchesSetting settingWindow; private WebSearchesSetting settingWindow;
private bool update; private bool update;
private Infrastructure.Storage.UserSettings.WebSearch updateWebSearch; private Core.UserSettings.WebSearch updateWebSearch;
public WebSearchSetting(WebSearchesSetting settingWidow) public WebSearchSetting(WebSearchesSetting settingWidow)
{ {
@@ -22,7 +22,7 @@ namespace Wox.Plugin.WebSearch
InitializeComponent(); InitializeComponent();
} }
public void UpdateItem(Infrastructure.Storage.UserSettings.WebSearch webSearch) public void UpdateItem(Core.UserSettings.WebSearch webSearch)
{ {
updateWebSearch = UserSettingStorage.Instance.WebSearches.FirstOrDefault(o => o == webSearch); updateWebSearch = UserSettingStorage.Instance.WebSearches.FirstOrDefault(o => o == webSearch);
if (updateWebSearch == null || string.IsNullOrEmpty(updateWebSearch.Url)) 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."); MessageBox.Show("ActionWord has existed, please input a new one.");
return; return;
} }
UserSettingStorage.Instance.WebSearches.Add(new Infrastructure.Storage.UserSettings.WebSearch() UserSettingStorage.Instance.WebSearches.Add(new Core.UserSettings.WebSearch()
{ {
ActionWord = action, ActionWord = action,
Enabled = cbEnable.IsChecked ?? false, Enabled = cbEnable.IsChecked ?? false,

View File

@@ -2,7 +2,7 @@
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using Wox.Infrastructure.Storage.UserSettings; using Wox.Core.UserSettings;
namespace Wox.Plugin.WebSearch namespace Wox.Plugin.WebSearch
{ {
@@ -54,7 +54,7 @@ namespace Wox.Plugin.WebSearch
private void btnDeleteWebSearch_OnClick(object sender, RoutedEventArgs e) 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 (selectedWebSearch != null)
{ {
if (MessageBox.Show("Are your sure to delete " + selectedWebSearch.Title, "Delete WebSearch", 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) 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) if (selectedWebSearch != null)
{ {
WebSearchSetting webSearch = new WebSearchSetting(this); WebSearchSetting webSearch = new WebSearchSetting(this);

View File

@@ -77,6 +77,10 @@
<WCFMetadata Include="Service References\" /> <WCFMetadata Include="Service References\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\Wox.Core\Wox.Core.csproj">
<Project>{B749F0DB-8E75-47DB-9E5E-265D16D0C0D2}</Project>
<Name>Wox.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\Wox.Infrastructure\Wox.Infrastructure.csproj"> <ProjectReference Include="..\..\Wox.Infrastructure\Wox.Infrastructure.csproj">
<Project>{4fd29318-a8ab-4d8f-aa47-60bc241b8da3}</Project> <Project>{4fd29318-a8ab-4d8f-aa47-60bc241b8da3}</Project>
<Name>Wox.Infrastructure</Name> <Name>Wox.Infrastructure</Name>

View File

@@ -5,8 +5,8 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using Newtonsoft.Json; using Newtonsoft.Json;
using Wox.Core.Exception; using Wox.Core.Exception;
using Wox.Core.UserSettings;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
using Wox.Infrastructure.Storage.UserSettings;
using Wox.Plugin; using Wox.Plugin;
namespace Wox.Core.Plugin namespace Wox.Core.Plugin

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
using Wox.Core.Exception; using Wox.Core.Exception;
using Wox.Core.UserSettings;
using Wox.Infrastructure; using Wox.Infrastructure;
using Wox.Infrastructure.Http; using Wox.Infrastructure.Http;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;

View File

@@ -1,6 +1,7 @@
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using Wox.Core.UserSettings;
using Wox.Infrastructure.Http; using Wox.Infrastructure.Http;
using Wox.Plugin; using Wox.Plugin;

View File

@@ -1,7 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using Wox.Infrastructure.Storage.UserSettings; using Wox.Core.UserSettings;
using Wox.Plugin; using Wox.Plugin;
//using Wox.Plugin.SystemPlugins; //using Wox.Plugin.SystemPlugins;

View File

@@ -2,8 +2,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using Wox.Core.UserSettings;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
using Wox.Infrastructure.Storage.UserSettings;
using Wox.Plugin; using Wox.Plugin;
namespace Wox.Core.Plugin.QueryDispatcher namespace Wox.Core.Plugin.QueryDispatcher

View File

@@ -7,8 +7,8 @@ using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
using Wox.Core.UI; using Wox.Core.UI;
using Wox.Core.UserSettings;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
using Wox.Infrastructure.Storage.UserSettings;
namespace Wox.Core.Theme namespace Wox.Core.Theme
{ {

View File

@@ -1,10 +1,8 @@
using System; 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 class CustomizedPluginConfig
{ {
public string ID { get; set; } public string ID { get; set; }

View File

@@ -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 public class HttpProxy : IHttpProxy
{ {

View File

@@ -1,5 +1,8 @@
namespace Wox.Infrastructure.Storage.UserSettings using System;
namespace Wox.Core.UserSettings
{ {
[Serializable]
public class CustomPluginHotkey public class CustomPluginHotkey
{ {
public string Hotkey { get; set; } public string Hotkey { get; set; }

View File

@@ -1,10 +1,13 @@
using System.Collections.Generic; using System;
using System.Drawing; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using Newtonsoft.Json; 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<UserSettingStorage> public class UserSettingStorage : JsonStrorage<UserSettingStorage>
{ {
@@ -44,9 +47,6 @@ namespace Wox.Infrastructure.Storage.UserSettings
[JsonProperty] [JsonProperty]
public string ResultItemFontStretch { get; set; } public string ResultItemFontStretch { get; set; }
[JsonProperty]
public bool ReplaceWinR { get; set; }
[JsonProperty] [JsonProperty]
public List<WebSearch> WebSearches { get; set; } public List<WebSearch> WebSearches { get; set; }
@@ -56,12 +56,6 @@ namespace Wox.Infrastructure.Storage.UserSettings
[JsonProperty] [JsonProperty]
public double WindowTop { get; set; } public double WindowTop { get; set; }
[JsonProperty]
public List<ProgramSource> ProgramSources { get; set; }
[JsonProperty]
public List<FolderLink> FolderLinks { get; set; }
public List<CustomizedPluginConfig> CustomizedPluginConfigs { get; set; } public List<CustomizedPluginConfig> CustomizedPluginConfigs { get; set; }
[JsonProperty] [JsonProperty]
@@ -73,9 +67,6 @@ namespace Wox.Infrastructure.Storage.UserSettings
[JsonProperty] [JsonProperty]
public double Opacity { get; set; } public double Opacity { get; set; }
[JsonProperty]
public string ProgramSuffixes { get; set; }
[JsonProperty] [JsonProperty]
public OpacityMode OpacityMode { get; set; } public OpacityMode OpacityMode { get; set; }
@@ -144,6 +135,19 @@ namespace Wox.Infrastructure.Storage.UserSettings
return webSearches; 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 protected override string ConfigName
{ {
get { return "config"; } get { return "config"; }
@@ -154,9 +158,7 @@ namespace Wox.Infrastructure.Storage.UserSettings
DontPromptUpdateMsg = false; DontPromptUpdateMsg = false;
Theme = "Dark"; Theme = "Dark";
Language = "en"; Language = "en";
ReplaceWinR = true;
WebSearches = LoadDefaultWebSearches(); WebSearches = LoadDefaultWebSearches();
ProgramSources = new List<ProgramSource>();
CustomizedPluginConfigs = new List<CustomizedPluginConfig>(); CustomizedPluginConfigs = new List<CustomizedPluginConfig>();
Hotkey = "Alt + Space"; Hotkey = "Alt + Space";
QueryBoxFont = FontFamily.GenericSansSerif.Name; QueryBoxFont = FontFamily.GenericSansSerif.Name;
@@ -175,10 +177,6 @@ namespace Wox.Infrastructure.Storage.UserSettings
{ {
storage.CustomizedPluginConfigs = new List<CustomizedPluginConfig>(); storage.CustomizedPluginConfigs = new List<CustomizedPluginConfig>();
} }
if (string.IsNullOrEmpty(storage.ProgramSuffixes))
{
storage.ProgramSuffixes = "lnk;exe;appref-ms;bat";
}
if (storage.QueryBoxFont == null) if (storage.QueryBoxFont == null)
{ {
storage.QueryBoxFont = FontFamily.GenericSansSerif.Name; storage.QueryBoxFont = FontFamily.GenericSansSerif.Name;

View File

@@ -1,5 +1,8 @@
namespace Wox.Infrastructure.Storage.UserSettings using System;
namespace Wox.Core.UserSettings
{ {
[Serializable]
public class WebSearch public class WebSearch
{ {
public string Title { get; set; } public string Title { get; set; }

View File

@@ -44,6 +44,7 @@
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
@@ -58,6 +59,7 @@
<Compile Include="Exception\WoxHttpException.cs" /> <Compile Include="Exception\WoxHttpException.cs" />
<Compile Include="Exception\WoxI18nException.cs" /> <Compile Include="Exception\WoxI18nException.cs" />
<Compile Include="Exception\WoxJsonRPCException.cs" /> <Compile Include="Exception\WoxJsonRPCException.cs" />
<Compile Include="UserSettings\HttpProxy.cs" />
<Compile Include="i18n\AvailableLanguages.cs" /> <Compile Include="i18n\AvailableLanguages.cs" />
<Compile Include="i18n\IInternationalization.cs" /> <Compile Include="i18n\IInternationalization.cs" />
<Compile Include="i18n\Internationalization.cs" /> <Compile Include="i18n\Internationalization.cs" />
@@ -83,6 +85,10 @@
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Theme\FontHelper.cs" /> <Compile Include="Theme\FontHelper.cs" />
<Compile Include="Theme\Theme.cs" /> <Compile Include="Theme\Theme.cs" />
<Compile Include="UserSettings\CustomizedPluginConfig.cs" />
<Compile Include="UserSettings\PluginHotkey.cs" />
<Compile Include="UserSettings\UserSettingStorage.cs" />
<Compile Include="UserSettings\WebSearch.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Plugin\README.md" /> <None Include="Plugin\README.md" />

View File

@@ -7,8 +7,8 @@ using System.Text;
using System.Windows; using System.Windows;
using Wox.Core.Exception; using Wox.Core.Exception;
using Wox.Core.UI; using Wox.Core.UI;
using Wox.Core.UserSettings;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
using Wox.Infrastructure.Storage.UserSettings;
namespace Wox.Core.i18n namespace Wox.Core.i18n
{ {

View File

@@ -6,7 +6,6 @@ using System.Reflection;
using System.Windows; using System.Windows;
using Wox.Core.UI; using Wox.Core.UI;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
using Wox.Infrastructure.Storage.UserSettings;
namespace Wox.Core.i18n namespace Wox.Core.i18n
{ {

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Drawing;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Text; using System.Text;
@@ -8,9 +9,9 @@ namespace Wox.Infrastructure.Http
{ {
public class HttpRequest 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) private static string Get(string url, string encoding, IHttpProxy proxy)

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices.ComTypes; using System.Runtime.InteropServices.ComTypes;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
@@ -12,24 +13,7 @@ namespace Wox.Infrastructure.Storage
[Serializable] [Serializable]
public abstract class BaseStorage<T> : IStorage where T : class,IStorage, new() public abstract class BaseStorage<T> : IStorage where T : class,IStorage, new()
{ {
private string configFolder; protected abstract string ConfigFolder { get; }
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 string ConfigPath protected string ConfigPath
{ {

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Runtime.Serialization.Formatters;
using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization.Formatters.Binary;
using System.Text; using System.Text;
using Wox.Infrastructure.Logger; using Wox.Infrastructure.Logger;
@@ -30,7 +31,10 @@ namespace Wox.Infrastructure.Storage
{ {
using (FileStream fileStream = new FileStream(ConfigPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) 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; serializedObject = binaryFormatter.Deserialize(fileStream) as T;
if (serializedObject == null) if (serializedObject == null)
{ {
@@ -79,7 +83,10 @@ namespace Wox.Infrastructure.Storage
try try
{ {
FileStream fileStream = new FileStream(ConfigPath, FileMode.Create); FileStream fileStream = new FileStream(ConfigPath, FileMode.Create);
BinaryFormatter binaryFormatter = new BinaryFormatter(); BinaryFormatter binaryFormatter = new BinaryFormatter
{
AssemblyFormat = FormatterAssemblyStyle.Simple
};
binaryFormatter.Serialize(fileStream, serializedObject); binaryFormatter.Serialize(fileStream, serializedObject);
fileStream.Close(); fileStream.Close();
} }

View File

@@ -4,7 +4,6 @@ using System.Linq;
using System.Text; using System.Text;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.IO; using System.IO;
using Wox.Infrastructure.Storage.UserSettings;
namespace Wox.Infrastructure namespace Wox.Infrastructure
{ {
@@ -78,7 +77,7 @@ namespace Wox.Infrastructure
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode)] [DllImport("shlwapi.dll", CharSet = CharSet.Unicode)]
static extern bool UrlIs(string pszUrl, int UrlIs); 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 cmd = command;
string args = null; string args = null;
@@ -103,7 +102,7 @@ namespace Wox.Infrastructure
startDir = dir; startDir = dir;
} }
if (UserSettingStorage.Instance.LeaveCmdOpen && File.Exists(cmd)) if (leaveCmdOpen && File.Exists(cmd))
{ {
bool needsCommandLine; bool needsCommandLine;

View File

@@ -41,7 +41,7 @@
<Reference Include="Microsoft.VisualBasic" /> <Reference Include="Microsoft.VisualBasic" />
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.5\lib\net35\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
@@ -59,18 +59,11 @@
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Http\HttpProxy.cs" />
<Compile Include="Logger\Log.cs" /> <Compile Include="Logger\Log.cs" />
<Compile Include="PeHeaderReader.cs" /> <Compile Include="PeHeaderReader.cs" />
<Compile Include="Storage\BinaryStorage.cs" /> <Compile Include="Storage\BinaryStorage.cs" />
<Compile Include="Storage\IStorage.cs" /> <Compile Include="Storage\IStorage.cs" />
<Compile Include="Storage\JsonStorage.cs" /> <Compile Include="Storage\JsonStorage.cs" />
<Compile Include="Storage\UserSettings\CustomizedPluginConfig.cs" />
<Compile Include="Storage\UserSettings\FolderLink.cs" />
<Compile Include="Storage\UserSettings\PluginHotkey.cs" />
<Compile Include="Storage\UserSettings\ProgramSource.cs" />
<Compile Include="Storage\UserSettings\UserSettingStorage.cs" />
<Compile Include="Storage\UserSettings\WebSearch.cs" />
<Compile Include="Timeit.cs" /> <Compile Include="Timeit.cs" />
<Compile Include="Unidecoder.Characters.cs" /> <Compile Include="Unidecoder.Characters.cs" />
<Compile Include="Http\HttpRequest.cs" /> <Compile Include="Http\HttpRequest.cs" />
@@ -91,9 +84,6 @@
<Name>Wox.Plugin</Name> <Name>Wox.Plugin</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" /> <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="log4net" version="2.0.3" targetFramework="net35" /> <package id="log4net" version="2.0.3" targetFramework="net35" />
<package id="Newtonsoft.Json" version="6.0.5" targetFramework="net35" /> <package id="Newtonsoft.Json" version="6.0.7" targetFramework="net35" />
<package id="protobuf-net" version="2.0.0.668" targetFramework="net35" /> <package id="protobuf-net" version="2.0.0.668" targetFramework="net35" />
<package id="ServiceStack.Text" version="3.9.71" targetFramework="net35" /> <package id="ServiceStack.Text" version="3.9.71" targetFramework="net35" />
</packages> </packages>

View File

@@ -13,7 +13,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Shapes; using System.Windows.Shapes;
using Wox.Core.i18n; using Wox.Core.i18n;
using Wox.Core.Plugin; using Wox.Core.Plugin;
using Wox.Infrastructure.Storage.UserSettings; using Wox.Core.UserSettings;
using Wox.Plugin; using Wox.Plugin;
using MessageBox = System.Windows.MessageBox; using MessageBox = System.Windows.MessageBox;

View File

@@ -1,6 +1,6 @@
using System; using System;
using System.Globalization; using System.Globalization;
using Wox.Infrastructure.Storage.UserSettings; using Wox.Core.UserSettings;
namespace Wox.Converters namespace Wox.Converters
{ {

View File

@@ -2,7 +2,7 @@
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using Wox.Core.i18n; using Wox.Core.i18n;
using Wox.Infrastructure.Storage.UserSettings; using Wox.Core.UserSettings;
namespace Wox namespace Wox
{ {

View File

@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Wox.Infrastructure.Storage; using Wox.Infrastructure.Storage;
@@ -13,6 +14,19 @@ namespace Wox.ImageLoader
private const int maxCached = 200; private const int maxCached = 200;
public Dictionary<string, int> TopUsedImages = new Dictionary<string, int>(); public Dictionary<string, int> TopUsedImages = new Dictionary<string, int>();
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 protected override string ConfigName
{ {
get { return "ImageCache"; } get { return "ImageCache"; }

View File

@@ -17,11 +17,11 @@ using NHotkey.Wpf;
using Wox.Core.i18n; using Wox.Core.i18n;
using Wox.Core.Plugin; using Wox.Core.Plugin;
using Wox.Core.Theme; using Wox.Core.Theme;
using Wox.Core.UserSettings;
using Wox.Helper; using Wox.Helper;
using Wox.Infrastructure; using Wox.Infrastructure;
using Wox.Infrastructure.Hotkey; using Wox.Infrastructure.Hotkey;
using Wox.Infrastructure.Storage; using Wox.Infrastructure.Storage;
using Wox.Infrastructure.Storage.UserSettings;
using Wox.Plugin; using Wox.Plugin;
using Wox.Storage; using Wox.Storage;
using Wox.Update; using Wox.Update;
@@ -52,16 +52,15 @@ namespace Wox
public static bool initialized = false; public static bool initialized = false;
private static readonly List<Result> waitShowResultList = new List<Result>(); private static readonly List<Result> waitShowResultList = new List<Result>();
private readonly GlobalHotkey globalHotkey = new GlobalHotkey();
private readonly KeyboardSimulator keyboardSimulator = new KeyboardSimulator(new InputSimulator());
private readonly Storyboard progressBarStoryboard = new Storyboard(); private readonly Storyboard progressBarStoryboard = new Storyboard();
private bool WinRStroked;
private NotifyIcon notifyIcon; private NotifyIcon notifyIcon;
private bool queryHasReturn; private bool queryHasReturn;
private string lastQuery; private string lastQuery;
private ToolTip toolTip = new ToolTip(); private ToolTip toolTip = new ToolTip();
private bool ignoreTextChange = false; private bool ignoreTextChange = false;
private readonly GlobalHotkey globalHotkey = new GlobalHotkey();
#endregion #endregion
#region Public API #region Public API
@@ -181,7 +180,6 @@ namespace Wox
SetHotkey(UserSettingStorage.Instance.Hotkey, OnHotkey); SetHotkey(UserSettingStorage.Instance.Hotkey, OnHotkey);
SetCustomPluginHotkey(); SetCustomPluginHotkey();
globalHotkey.hookedKeyboardCallback += KListener_hookedKeyboardCallback;
Closing += MainWindow_Closing; Closing += MainWindow_Closing;
//since MainWIndow implement IPublicAPI, so we need to finish ctor MainWindow object before //since MainWIndow implement IPublicAPI, so we need to finish ctor MainWindow object before
@@ -449,40 +447,6 @@ namespace Wox
} }
} }
private bool KListener_hookedKeyboardCallback(KeyEvent keyevent, int vkcode, SpecialKeyState state)
{
if (UserSettingStorage.Instance.ReplaceWinR)
{
//todo:need refactoring. move those codes to CMD file or expose events
if (keyevent == KeyEvent.WM_KEYDOWN && vkcode == (int)Keys.R && state.WinPressed)
{
WinRStroked = true;
Dispatcher.BeginInvoke(new Action(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()
{
ShowWox(false);
if (!tbQuery.Text.StartsWith(">"))
{
pnlResult.Clear();
ChangeQuery(">");
}
tbQuery.CaretIndex = tbQuery.Text.Length;
tbQuery.SelectionStart = 1;
tbQuery.SelectionLength = tbQuery.Text.Length - 1;
}
private void updateCmdMode() private void updateCmdMode()
{ {
var currentSelectedItem = pnlResult.GetActiveResult(); var currentSelectedItem = pnlResult.GetActiveResult();

View File

@@ -2,9 +2,10 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wox="clr-namespace:Wox" xmlns:wox="clr-namespace:Wox"
xmlns:UserSettings="clr-namespace:Wox.Infrastructure.Storage.UserSettings;assembly=Wox.Infrastructure" x:Class="Wox.SettingWindow" x:Class="Wox.SettingWindow"
xmlns:woxPlugin="clr-namespace:Wox.Plugin;assembly=Wox.Plugin" xmlns:woxPlugin="clr-namespace:Wox.Plugin;assembly=Wox.Plugin"
xmlns:converters="clr-namespace:Wox.Converters" xmlns:converters="clr-namespace:Wox.Converters"
xmlns:userSettings="clr-namespace:Wox.Core.UserSettings;assembly=Wox.Core"
Icon="Images\app.png" Icon="Images\app.png"
Title="Wox Settings" Title="Wox Settings"
ResizeMode="NoResize" ResizeMode="NoResize"
@@ -188,9 +189,9 @@
<StackPanel Orientation="Horizontal" Margin="2"> <StackPanel Orientation="Horizontal" Margin="2">
<TextBlock Text="{DynamicResource windowMode}" /> <TextBlock Text="{DynamicResource windowMode}" />
<ComboBox Name="CbOpacityMode" Margin="14 0 0 0" SelectionChanged="CbOpacityMode_OnSelectionChanged" Width="160"> <ComboBox Name="CbOpacityMode" Margin="14 0 0 0" SelectionChanged="CbOpacityMode_OnSelectionChanged" Width="160">
<UserSettings:OpacityMode>Normal</UserSettings:OpacityMode> <userSettings:OpacityMode>Normal</userSettings:OpacityMode>
<UserSettings:OpacityMode>LayeredWindow</UserSettings:OpacityMode> <userSettings:OpacityMode>LayeredWindow</userSettings:OpacityMode>
<UserSettings:OpacityMode>DWM</UserSettings:OpacityMode> <userSettings:OpacityMode>DWM</userSettings:OpacityMode>
<ComboBox.ItemTemplate> <ComboBox.ItemTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding Converter={converters:OpacityModeConverter}}" /> <TextBlock Text="{Binding Converter={converters:OpacityModeConverter}}" />

View File

@@ -12,7 +12,6 @@ using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using IWshRuntimeLibrary; using IWshRuntimeLibrary;
using Wox.Core.Plugin; using Wox.Core.Plugin;
using Wox.Infrastructure.Storage.UserSettings;
using Wox.Plugin; using Wox.Plugin;
using Wox.Helper; using Wox.Helper;
using Wox.Update; using Wox.Update;
@@ -22,6 +21,7 @@ using MessageBox = System.Windows.MessageBox;
using System.Windows.Data; using System.Windows.Data;
using Wox.Core.i18n; using Wox.Core.i18n;
using Wox.Core.Theme; using Wox.Core.Theme;
using Wox.Core.UserSettings;
namespace Wox namespace Wox
{ {

View File

@@ -1,7 +1,9 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using Newtonsoft.Json; using Newtonsoft.Json;
using Wox.Infrastructure.Storage; using Wox.Infrastructure.Storage;
using Wox.Plugin; using Wox.Plugin;
using System.IO;
namespace Wox.Storage namespace Wox.Storage
{ {
@@ -10,6 +12,19 @@ namespace Wox.Storage
[JsonProperty] [JsonProperty]
private Dictionary<string, int> records = new Dictionary<string, int>(); private Dictionary<string, int> records = new Dictionary<string, int>();
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 protected override string ConfigName
{ {
get { return "UserSelectedRecords"; } get { return "UserSelectedRecords"; }

View File

@@ -6,6 +6,7 @@ using System.Linq;
using System.Net; using System.Net;
using System.Text; using System.Text;
using Newtonsoft.Json; using Newtonsoft.Json;
using Wox.Core.UserSettings;
using Wox.Helper; using Wox.Helper;
using Wox.Infrastructure; using Wox.Infrastructure;
using Wox.Infrastructure.Http; using Wox.Infrastructure.Http;
@@ -26,7 +27,7 @@ namespace Wox.Update
public Release CheckUpgrade(bool forceCheck = false) public Release CheckUpgrade(bool forceCheck = false)
{ {
if (checkedUpdate && !forceCheck) return newRelease; if (checkedUpdate && !forceCheck) return newRelease;
string json = HttpRequest.Get(updateURL); string json = HttpRequest.Get(updateURL,HttpProxy.Instance);
if (string.IsNullOrEmpty(json)) return null; if (string.IsNullOrEmpty(json)) return null;
try try

View File

@@ -60,15 +60,6 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Accessibility" /> <Reference Include="Accessibility" />
<Reference Include="Exceptionless">
<HintPath>..\packages\Exceptionless.1.5.2121\lib\net35\Exceptionless.dll</HintPath>
</Reference>
<Reference Include="Exceptionless.Models">
<HintPath>..\packages\Exceptionless.1.5.2121\lib\net35\Exceptionless.Models.dll</HintPath>
</Reference>
<Reference Include="Exceptionless.Wpf">
<HintPath>..\packages\Exceptionless.Wpf.1.5.2121\lib\net35\Exceptionless.Wpf.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL"> <Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath> <HintPath>..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
@@ -79,7 +70,7 @@
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.5\lib\net35\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="NHotkey"> <Reference Include="NHotkey">
<HintPath>..\packages\NHotkey.1.1.0.0\lib\NHotkey.dll</HintPath> <HintPath>..\packages\NHotkey.1.1.0.0\lib\NHotkey.dll</HintPath>

View File

@@ -2,7 +2,7 @@
<packages> <packages>
<package id="InputSimulator" version="1.0.4.0" targetFramework="net35" /> <package id="InputSimulator" version="1.0.4.0" targetFramework="net35" />
<package id="log4net" version="2.0.3" targetFramework="net35" /> <package id="log4net" version="2.0.3" targetFramework="net35" />
<package id="Newtonsoft.Json" version="6.0.5" targetFramework="net35" /> <package id="Newtonsoft.Json" version="6.0.7" targetFramework="net35" />
<package id="NHotkey" version="1.1.0.0" targetFramework="net35" /> <package id="NHotkey" version="1.1.0.0" targetFramework="net35" />
<package id="NHotkey.Wpf" version="1.1.0.0" targetFramework="net35" /> <package id="NHotkey.Wpf" version="1.1.0.0" targetFramework="net35" />
<package id="SharpZipLib" version="0.86.0" targetFramework="net35" /> <package id="SharpZipLib" version="0.86.0" targetFramework="net35" />