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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,16 @@
using System;
namespace Wox.Core.UserSettings
{
[Serializable]
public class CustomizedPluginConfig
{
public string ID { get; set; }
public string Name { get; set; }
public string Actionword { get; set; }
public bool Disabled { get; set; }
}
}

View File

@@ -0,0 +1,43 @@
using Wox.Plugin;
namespace Wox.Core.UserSettings
{
public class HttpProxy : IHttpProxy
{
private static readonly HttpProxy instance = new HttpProxy();
private HttpProxy()
{
}
public static HttpProxy Instance
{
get { return instance; }
}
public bool Enabled
{
get { return UserSettingStorage.Instance.ProxyEnabled; }
}
public string Server
{
get { return UserSettingStorage.Instance.ProxyServer; }
}
public int Port
{
get { return UserSettingStorage.Instance.ProxyPort; }
}
public string UserName
{
get { return UserSettingStorage.Instance.ProxyUserName; }
}
public string Password
{
get { return UserSettingStorage.Instance.ProxyPassword; }
}
}
}

View File

@@ -0,0 +1,11 @@
using System;
namespace Wox.Core.UserSettings
{
[Serializable]
public class CustomPluginHotkey
{
public string Hotkey { get; set; }
public string ActionKeyword { get; set; }
}
}

View File

@@ -0,0 +1,201 @@
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.Core.UserSettings
{
public class UserSettingStorage : JsonStrorage<UserSettingStorage>
{
[JsonProperty]
public bool DontPromptUpdateMsg { get; set; }
[JsonProperty]
public string Hotkey { get; set; }
[JsonProperty]
public string Language { get; set; }
[JsonProperty]
public string Theme { get; set; }
[JsonProperty]
public string QueryBoxFont { get; set; }
[JsonProperty]
public string QueryBoxFontStyle { get; set; }
[JsonProperty]
public string QueryBoxFontWeight { get; set; }
[JsonProperty]
public string QueryBoxFontStretch { get; set; }
[JsonProperty]
public string ResultItemFont { get; set; }
[JsonProperty]
public string ResultItemFontStyle { get; set; }
[JsonProperty]
public string ResultItemFontWeight { get; set; }
[JsonProperty]
public string ResultItemFontStretch { get; set; }
[JsonProperty]
public List<WebSearch> WebSearches { get; set; }
[JsonProperty]
public double WindowLeft { get; set; }
[JsonProperty]
public double WindowTop { get; set; }
public List<CustomizedPluginConfig> CustomizedPluginConfigs { get; set; }
[JsonProperty]
public List<CustomPluginHotkey> CustomPluginHotkeys { get; set; }
[JsonProperty]
public bool StartWoxOnSystemStartup { get; set; }
[JsonProperty]
public double Opacity { get; set; }
[JsonProperty]
public OpacityMode OpacityMode { get; set; }
[JsonProperty]
public bool EnableWebSearchSuggestion { get; set; }
[JsonProperty]
public string WebSearchSuggestionSource { get; set; }
[JsonProperty]
public bool LeaveCmdOpen { get; set; }
[JsonProperty]
public bool HideWhenDeactive { get; set; }
[JsonProperty]
public string ProxyServer { get; set; }
[JsonProperty]
public bool ProxyEnabled { get; set; }
[JsonProperty]
public int ProxyPort { get; set; }
[JsonProperty]
public string ProxyUserName { get; set; }
[JsonProperty]
public string ProxyPassword { get; set; }
public List<WebSearch> LoadDefaultWebSearches()
{
List<WebSearch> webSearches = new List<WebSearch>();
WebSearch googleWebSearch = new WebSearch()
{
Title = "Google",
ActionWord = "g",
IconPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\websearch\google.png",
Url = "https://www.google.com/search?q={q}",
Enabled = true
};
webSearches.Add(googleWebSearch);
WebSearch wikiWebSearch = new WebSearch()
{
Title = "Wikipedia",
ActionWord = "wiki",
IconPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\websearch\wiki.png",
Url = "http://en.wikipedia.org/wiki/{q}",
Enabled = true
};
webSearches.Add(wikiWebSearch);
WebSearch findIcon = new WebSearch()
{
Title = "FindIcon",
ActionWord = "findicon",
IconPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\websearch\pictures.png",
Url = "http://findicons.com/search/{q}",
Enabled = true
};
webSearches.Add(findIcon);
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"; }
}
protected override UserSettingStorage LoadDefault()
{
DontPromptUpdateMsg = false;
Theme = "Dark";
Language = "en";
WebSearches = LoadDefaultWebSearches();
CustomizedPluginConfigs = new List<CustomizedPluginConfig>();
Hotkey = "Alt + Space";
QueryBoxFont = FontFamily.GenericSansSerif.Name;
ResultItemFont = FontFamily.GenericSansSerif.Name;
Opacity = 1;
OpacityMode = OpacityMode.Normal;
LeaveCmdOpen = false;
HideWhenDeactive = false;
return this;
}
protected override void OnAfterLoad(UserSettingStorage storage)
{
if (storage.CustomizedPluginConfigs == null)
{
storage.CustomizedPluginConfigs = new List<CustomizedPluginConfig>();
}
if (storage.QueryBoxFont == null)
{
storage.QueryBoxFont = FontFamily.GenericSansSerif.Name;
}
if (storage.ResultItemFont == null)
{
storage.ResultItemFont = FontFamily.GenericSansSerif.Name;
}
if (storage.Language == null)
{
storage.Language = "en";
}
}
}
public enum OpacityMode
{
Normal = 0,
LayeredWindow = 1,
DWM = 2
}
}

View File

@@ -0,0 +1,14 @@
using System;
namespace Wox.Core.UserSettings
{
[Serializable]
public class WebSearch
{
public string Title { get; set; }
public string ActionWord { get; set; }
public string IconPath { get; set; }
public string Url { get; set; }
public bool Enabled { get; set; }
}
}

View File

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

View File

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

View File

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