Move some user settings to its own dll (cmd,folder plugin and etc)

This commit is contained in:
qianlifeng
2015-01-05 22:41:17 +08:00
parent 6162904c59
commit ce451e4dd4
62 changed files with 342 additions and 222 deletions

View File

@@ -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;

View File

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

View File

@@ -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
{

View File

@@ -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"; }

View File

@@ -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();

View File

@@ -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}}" />

View File

@@ -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
{

View File

@@ -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"; }

View File

@@ -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

View File

@@ -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>

View File

@@ -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" />