PowerToys/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs

112 lines
3.2 KiB
C#
Raw Normal View History

using System.Collections.Generic;
2014-03-23 16:17:41 +08:00
using System.Drawing;
using System.IO;
using System.Windows.Forms;
2014-03-23 16:17:41 +08:00
using Newtonsoft.Json;
2014-03-23 16:17:41 +08:00
namespace Wox.Infrastructure.Storage.UserSettings
{
2014-03-23 16:17:41 +08:00
public class UserSettingStorage : BaseStorage<UserSettingStorage>
{
2014-03-23 16:17:41 +08:00
[JsonProperty]
2014-02-22 11:55:48 +08:00
public string Hotkey { get; set; }
2014-03-23 16:17:41 +08:00
[JsonProperty]
public string Theme { get; set; }
2014-03-23 16:17:41 +08:00
[JsonProperty]
2014-03-19 22:17:01 +08:00
public string QueryBoxFont { get; set; }
2014-03-23 16:17:41 +08:00
[JsonProperty]
2014-03-19 22:17:01 +08:00
public string ResultItemFont { get; set; }
2014-03-23 16:17:41 +08:00
[JsonProperty]
public bool ReplaceWinR { get; set; }
2014-03-23 16:17:41 +08:00
[JsonProperty]
public List<WebSearch> WebSearches { get; set; }
2014-03-23 16:17:41 +08:00
[JsonProperty]
public List<ProgramSource> ProgramSources { get; set; }
2014-03-23 16:17:41 +08:00
[JsonProperty]
2014-02-22 15:52:20 +08:00
public List<CustomPluginHotkey> CustomPluginHotkeys { get; set; }
2014-03-23 16:17:41 +08:00
[JsonProperty]
public bool StartWoxOnSystemStartup { get; set; }
2014-03-23 16:17:41 +08:00
[JsonProperty]
2014-03-19 01:27:59 +08:00
public bool EnablePythonPlugins { get; set; }
2014-03-23 16:17:41 +08:00
public UserSettingStorage()
2014-03-19 01:27:59 +08:00
{
EnablePythonPlugins = true;
2014-03-23 16:17:41 +08:00
Theme = "Dark";
ReplaceWinR = true;
WebSearches = LoadDefaultWebSearches();
ProgramSources = LoadDefaultProgramSources();
Hotkey = "Alt + Space";
QueryBoxFont = FontFamily.GenericSansSerif.Name;
ResultItemFont = FontFamily.GenericSansSerif.Name;
2014-03-19 01:27:59 +08:00
}
2014-02-02 16:15:34 +08:00
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);
2014-03-23 16:17:41 +08:00
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);
return webSearches;
}
public List<ProgramSource> LoadDefaultProgramSources()
{
var list = new List<ProgramSource>();
list.Add(new ProgramSource()
{
2014-03-19 20:16:20 +08:00
BonusPoints = 0,
Enabled = true,
Type = "CommonStartMenuProgramSource"
});
list.Add(new ProgramSource()
{
2014-03-19 20:16:20 +08:00
BonusPoints = 0,
Enabled = true,
Type = "UserStartMenuProgramSource"
});
list.Add(new ProgramSource()
{
2014-03-19 20:16:20 +08:00
BonusPoints = -10,
Enabled = true,
Type = "AppPathsProgramSource"
});
return list;
}
2014-03-23 16:17:41 +08:00
protected override string ConfigName
{
get { return "config"; }
}
}
}