mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-18 14:41:21 +08:00
Move some user settings to its own dll (cmd,folder plugin and etc)
This commit is contained in:
parent
6162904c59
commit
ce451e4dd4
@ -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<Result> 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()
|
||||
|
@ -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();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -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<CMDStorage>
|
||||
{
|
||||
[JsonProperty]
|
||||
public bool ReplaceWinR { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public bool LeaveCmdOpen { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public Dictionary<string, int> CMDHistory = new Dictionary<string, int>();
|
||||
|
||||
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))
|
||||
|
@ -44,11 +44,15 @@
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="WindowsInput">
|
||||
<HintPath>..\..\packages\InputSimulator.1.0.4.0\lib\net20\WindowsInput.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CMD.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]
|
@ -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<FolderLink>();
|
||||
UserSettingStorage.Instance.Save();
|
||||
FolderStorage.Instance.FolderLinks = new List<FolderLink>();
|
||||
FolderStorage.Instance.Save();
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,7 +55,7 @@ namespace Wox.Plugin.Folder
|
||||
if(string.IsNullOrEmpty(query.RawQuery)) return new List<Result>();
|
||||
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();
|
||||
List<Result> results =
|
||||
userFolderLinks.Select(
|
||||
|
@ -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
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for FileSystemSettings.xaml
|
||||
/// </summary>
|
||||
public partial class FileSystemSettings : UserControl {
|
||||
public FileSystemSettings() {
|
||||
InitializeComponent();
|
||||
lbxFolders.ItemsSource = UserSettingStorage.Instance.FolderLinks;
|
||||
}
|
||||
/// <summary>
|
||||
/// Interaction logic for FileSystemSettings.xaml
|
||||
/// </summary>
|
||||
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<FolderLink>();
|
||||
}
|
||||
if (FolderStorage.Instance.FolderLinks == null)
|
||||
{
|
||||
FolderStorage.Instance.FolderLinks = new List<FolderLink>();
|
||||
}
|
||||
|
||||
UserSettingStorage.Instance.FolderLinks.Add(newFolder);
|
||||
UserSettingStorage.Instance.Save();
|
||||
}
|
||||
FolderStorage.Instance.FolderLinks.Add(newFolder);
|
||||
FolderStorage.Instance.Save();
|
||||
}
|
||||
|
||||
lbxFolders.Items.Refresh();
|
||||
}
|
||||
}
|
||||
lbxFolders.Items.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
26
Plugins/Wox.Plugin.Folder/FolderStorage.cs
Normal file
26
Plugins/Wox.Plugin.Folder/FolderStorage.cs
Normal 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"; }
|
||||
}
|
||||
}
|
||||
}
|
@ -36,6 +36,10 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\packages\log4net.2.0.3\lib\net35-full\log4net.dll</HintPath>
|
||||
</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="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
@ -48,10 +52,12 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="FolderLink.cs" />
|
||||
<Compile Include="FolderPlugin.cs" />
|
||||
<Compile Include="FolderPluginSettings.xaml.cs">
|
||||
<DependentUpon>FolderPluginSettings.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="FolderStorage.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="log4net" version="2.0.3" targetFramework="net35" />
|
||||
<package id="Newtonsoft.Json" version="6.0.7" targetFramework="net35" />
|
||||
</packages>
|
@ -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
|
||||
{
|
||||
|
@ -34,7 +34,7 @@
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<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 Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="6.0.5" targetFramework="net35" />
|
||||
<package id="Newtonsoft.Json" version="6.0.7" targetFramework="net35" />
|
||||
</packages>
|
@ -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
|
||||
{
|
||||
|
@ -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<Program> Programs = new List<Program>();
|
||||
|
||||
protected override string ConfigFolder
|
||||
{
|
||||
get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); }
|
||||
}
|
||||
|
||||
protected override string ConfigName
|
||||
{
|
||||
get { return "ProgramIndexCache"; }
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Wox.Infrastructure.Storage.UserSettings
|
||||
namespace Wox.Plugin.Program
|
||||
{
|
||||
[Serializable]
|
||||
public class ProgramSource
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
|
||||
namespace Wox.Plugin.Program.ProgramSources
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
|
||||
namespace Wox.Plugin.Program.ProgramSources
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
|
||||
namespace Wox.Plugin.Program.ProgramSources
|
||||
{
|
||||
|
44
Plugins/Wox.Plugin.Program/ProgramStorage.cs
Normal file
44
Plugins/Wox.Plugin.Program/ProgramStorage.cs
Normal 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"; }
|
||||
}
|
||||
}
|
||||
}
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -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<ProgramSource> programSources = new List<ProgramSource>();
|
||||
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();
|
||||
|
@ -59,10 +59,12 @@
|
||||
<Compile Include="ProgramSetting.xaml.cs">
|
||||
<DependentUpon>ProgramSetting.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ProgramSource.cs" />
|
||||
<Compile Include="ProgramSources\AppPathsProgramSource.cs" />
|
||||
<Compile Include="ProgramSources\CommonStartMenuProgramSource.cs" />
|
||||
<Compile Include="ProgramSources\FileSystemProgramSource.cs" />
|
||||
<Compile Include="ProgramSources\UserStartMenuProgramSource.cs" />
|
||||
<Compile Include="ProgramStorage.cs" />
|
||||
<Compile Include="ProgramSuffixes.xaml.cs">
|
||||
<DependentUpon>ProgramSuffixes.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -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<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>();
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -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<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>();
|
||||
|
||||
try
|
||||
|
@ -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<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);
|
||||
|
||||
if (webSearch != null)
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -77,6 +77,10 @@
|
||||
<WCFMetadata Include="Service References\" />
|
||||
</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">
|
||||
<Project>{4fd29318-a8ab-4d8f-aa47-60bc241b8da3}</Project>
|
||||
<Name>Wox.Infrastructure</Name>
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Wox.Core.UserSettings;
|
||||
using Wox.Infrastructure.Http;
|
||||
using Wox.Plugin;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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; }
|
@ -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
|
||||
{
|
@ -1,5 +1,8 @@
|
||||
namespace Wox.Infrastructure.Storage.UserSettings
|
||||
using System;
|
||||
|
||||
namespace Wox.Core.UserSettings
|
||||
{
|
||||
[Serializable]
|
||||
public class CustomPluginHotkey
|
||||
{
|
||||
public string Hotkey { get; set; }
|
@ -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<UserSettingStorage>
|
||||
{
|
||||
@ -44,9 +47,6 @@ namespace Wox.Infrastructure.Storage.UserSettings
|
||||
[JsonProperty]
|
||||
public string ResultItemFontStretch { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public bool ReplaceWinR { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public List<WebSearch> WebSearches { get; set; }
|
||||
|
||||
@ -56,12 +56,6 @@ namespace Wox.Infrastructure.Storage.UserSettings
|
||||
[JsonProperty]
|
||||
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; }
|
||||
|
||||
[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<ProgramSource>();
|
||||
CustomizedPluginConfigs = new List<CustomizedPluginConfig>();
|
||||
Hotkey = "Alt + Space";
|
||||
QueryBoxFont = FontFamily.GenericSansSerif.Name;
|
||||
@ -175,10 +177,6 @@ namespace Wox.Infrastructure.Storage.UserSettings
|
||||
{
|
||||
storage.CustomizedPluginConfigs = new List<CustomizedPluginConfig>();
|
||||
}
|
||||
if (string.IsNullOrEmpty(storage.ProgramSuffixes))
|
||||
{
|
||||
storage.ProgramSuffixes = "lnk;exe;appref-ms;bat";
|
||||
}
|
||||
if (storage.QueryBoxFont == null)
|
||||
{
|
||||
storage.QueryBoxFont = FontFamily.GenericSansSerif.Name;
|
@ -1,5 +1,8 @@
|
||||
namespace Wox.Infrastructure.Storage.UserSettings
|
||||
using System;
|
||||
|
||||
namespace Wox.Core.UserSettings
|
||||
{
|
||||
[Serializable]
|
||||
public class WebSearch
|
||||
{
|
||||
public string Title { get; set; }
|
@ -44,6 +44,7 @@
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
@ -58,6 +59,7 @@
|
||||
<Compile Include="Exception\WoxHttpException.cs" />
|
||||
<Compile Include="Exception\WoxI18nException.cs" />
|
||||
<Compile Include="Exception\WoxJsonRPCException.cs" />
|
||||
<Compile Include="UserSettings\HttpProxy.cs" />
|
||||
<Compile Include="i18n\AvailableLanguages.cs" />
|
||||
<Compile Include="i18n\IInternationalization.cs" />
|
||||
<Compile Include="i18n\Internationalization.cs" />
|
||||
@ -83,6 +85,10 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Theme\FontHelper.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>
|
||||
<None Include="Plugin\README.md" />
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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<T> : 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
|
||||
{
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<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 Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
@ -59,18 +59,11 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Http\HttpProxy.cs" />
|
||||
<Compile Include="Logger\Log.cs" />
|
||||
<Compile Include="PeHeaderReader.cs" />
|
||||
<Compile Include="Storage\BinaryStorage.cs" />
|
||||
<Compile Include="Storage\IStorage.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="Unidecoder.Characters.cs" />
|
||||
<Compile Include="Http\HttpRequest.cs" />
|
||||
@ -91,9 +84,6 @@
|
||||
<Name>Wox.Plugin</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Service References\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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.
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<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="ServiceStack.Text" version="3.9.71" targetFramework="net35" />
|
||||
</packages>
|
@ -13,7 +13,7 @@ using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using Wox.Core.i18n;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
using Wox.Core.UserSettings;
|
||||
using Wox.Plugin;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
using Wox.Core.UserSettings;
|
||||
|
||||
namespace Wox.Converters
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using Wox.Core.i18n;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
using Wox.Core.UserSettings;
|
||||
|
||||
namespace Wox
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Wox.Infrastructure.Storage;
|
||||
@ -13,6 +14,19 @@ namespace Wox.ImageLoader
|
||||
private const int maxCached = 200;
|
||||
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
|
||||
{
|
||||
get { return "ImageCache"; }
|
||||
|
@ -17,11 +17,11 @@ using NHotkey.Wpf;
|
||||
using Wox.Core.i18n;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Core.Theme;
|
||||
using Wox.Core.UserSettings;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Hotkey;
|
||||
using Wox.Infrastructure.Storage;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
using Wox.Plugin;
|
||||
using Wox.Storage;
|
||||
using Wox.Update;
|
||||
@ -52,16 +52,15 @@ namespace Wox
|
||||
public static bool initialized = false;
|
||||
|
||||
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 bool WinRStroked;
|
||||
private NotifyIcon notifyIcon;
|
||||
private bool queryHasReturn;
|
||||
private string lastQuery;
|
||||
private ToolTip toolTip = new ToolTip();
|
||||
|
||||
private bool ignoreTextChange = false;
|
||||
private readonly GlobalHotkey globalHotkey = new GlobalHotkey();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public API
|
||||
@ -181,7 +180,6 @@ namespace Wox
|
||||
SetHotkey(UserSettingStorage.Instance.Hotkey, OnHotkey);
|
||||
SetCustomPluginHotkey();
|
||||
|
||||
globalHotkey.hookedKeyboardCallback += KListener_hookedKeyboardCallback;
|
||||
|
||||
Closing += MainWindow_Closing;
|
||||
//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()
|
||||
{
|
||||
var currentSelectedItem = pnlResult.GetActiveResult();
|
||||
|
@ -2,9 +2,10 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
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:converters="clr-namespace:Wox.Converters"
|
||||
xmlns:userSettings="clr-namespace:Wox.Core.UserSettings;assembly=Wox.Core"
|
||||
Icon="Images\app.png"
|
||||
Title="Wox Settings"
|
||||
ResizeMode="NoResize"
|
||||
@ -188,9 +189,9 @@
|
||||
<StackPanel Orientation="Horizontal" Margin="2">
|
||||
<TextBlock Text="{DynamicResource windowMode}" />
|
||||
<ComboBox Name="CbOpacityMode" Margin="14 0 0 0" SelectionChanged="CbOpacityMode_OnSelectionChanged" Width="160">
|
||||
<UserSettings:OpacityMode>Normal</UserSettings:OpacityMode>
|
||||
<UserSettings:OpacityMode>LayeredWindow</UserSettings:OpacityMode>
|
||||
<UserSettings:OpacityMode>DWM</UserSettings:OpacityMode>
|
||||
<userSettings:OpacityMode>Normal</userSettings:OpacityMode>
|
||||
<userSettings:OpacityMode>LayeredWindow</userSettings:OpacityMode>
|
||||
<userSettings:OpacityMode>DWM</userSettings:OpacityMode>
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Converter={converters:OpacityModeConverter}}" />
|
||||
|
@ -12,7 +12,6 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using IWshRuntimeLibrary;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
using Wox.Plugin;
|
||||
using Wox.Helper;
|
||||
using Wox.Update;
|
||||
@ -22,6 +21,7 @@ using MessageBox = System.Windows.MessageBox;
|
||||
using System.Windows.Data;
|
||||
using Wox.Core.i18n;
|
||||
using Wox.Core.Theme;
|
||||
using Wox.Core.UserSettings;
|
||||
|
||||
namespace Wox
|
||||
{
|
||||
|
@ -1,7 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using Wox.Infrastructure.Storage;
|
||||
using Wox.Plugin;
|
||||
using System.IO;
|
||||
|
||||
namespace Wox.Storage
|
||||
{
|
||||
@ -10,6 +12,19 @@ namespace Wox.Storage
|
||||
[JsonProperty]
|
||||
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
|
||||
{
|
||||
get { return "UserSelectedRecords"; }
|
||||
|
@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using Wox.Core.UserSettings;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Http;
|
||||
@ -26,7 +27,7 @@ namespace Wox.Update
|
||||
public Release CheckUpgrade(bool forceCheck = false)
|
||||
{
|
||||
if (checkedUpdate && !forceCheck) return newRelease;
|
||||
string json = HttpRequest.Get(updateURL);
|
||||
string json = HttpRequest.Get(updateURL,HttpProxy.Instance);
|
||||
if (string.IsNullOrEmpty(json)) return null;
|
||||
|
||||
try
|
||||
|
@ -60,15 +60,6 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<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">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
@ -79,7 +70,7 @@
|
||||
</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.5\lib\net35\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath>..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHotkey">
|
||||
<HintPath>..\packages\NHotkey.1.1.0.0\lib\NHotkey.dll</HintPath>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<packages>
|
||||
<package id="InputSimulator" version="1.0.4.0" 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.Wpf" version="1.1.0.0" targetFramework="net35" />
|
||||
<package id="SharpZipLib" version="0.86.0" targetFramework="net35" />
|
||||
|
Loading…
Reference in New Issue
Block a user