2015-01-05 22:41:17 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2015-10-31 07:17:34 +08:00
|
|
|
|
using System.Drawing;
|
2014-01-29 22:44:57 +08:00
|
|
|
|
using System.IO;
|
2015-11-09 11:20:02 +08:00
|
|
|
|
using System.Linq;
|
2015-10-31 07:17:34 +08:00
|
|
|
|
using System.Reflection;
|
2014-03-23 16:17:41 +08:00
|
|
|
|
using Newtonsoft.Json;
|
2015-01-05 22:41:17 +08:00
|
|
|
|
using Wox.Infrastructure.Storage;
|
2015-11-09 11:20:02 +08:00
|
|
|
|
using Wox.Plugin;
|
2014-01-29 22:44:57 +08:00
|
|
|
|
|
2015-01-05 22:41:17 +08:00
|
|
|
|
namespace Wox.Core.UserSettings
|
2014-01-29 22:44:57 +08:00
|
|
|
|
{
|
2014-12-15 22:58:49 +08:00
|
|
|
|
public class UserSettingStorage : JsonStrorage<UserSettingStorage>
|
2014-01-29 22:44:57 +08:00
|
|
|
|
{
|
2014-12-14 23:16:29 +08:00
|
|
|
|
[JsonProperty]
|
|
|
|
|
public bool DontPromptUpdateMsg { get; set; }
|
|
|
|
|
|
2015-01-23 21:52:46 +08:00
|
|
|
|
[JsonProperty]
|
|
|
|
|
public int ActivateTimes { get; set; }
|
|
|
|
|
|
|
|
|
|
|
2015-01-21 23:00:56 +08:00
|
|
|
|
[JsonProperty]
|
|
|
|
|
public bool EnableUpdateLog { get; set; }
|
|
|
|
|
|
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
|
|
|
|
|
2015-01-02 16:16:09 +08:00
|
|
|
|
[JsonProperty]
|
|
|
|
|
public string Language { get; set; }
|
|
|
|
|
|
2014-03-23 16:17:41 +08:00
|
|
|
|
[JsonProperty]
|
2014-01-29 22:44:57 +08:00
|
|
|
|
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
|
|
|
|
|
2014-03-25 13:25:43 +08:00
|
|
|
|
[JsonProperty]
|
|
|
|
|
public string QueryBoxFontStyle { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty]
|
|
|
|
|
public string QueryBoxFontWeight { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty]
|
|
|
|
|
public string QueryBoxFontStretch { get; set; }
|
|
|
|
|
|
2014-03-23 16:17:41 +08:00
|
|
|
|
[JsonProperty]
|
2016-02-21 23:19:42 +08:00
|
|
|
|
public string ResultFont { get; set; }
|
2014-03-23 16:17:41 +08:00
|
|
|
|
|
2014-03-25 13:25:43 +08:00
|
|
|
|
[JsonProperty]
|
2016-02-21 23:19:42 +08:00
|
|
|
|
public string ResultFontStyle { get; set; }
|
2014-03-25 13:25:43 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty]
|
2016-02-21 23:19:42 +08:00
|
|
|
|
public string ResultFontWeight { get; set; }
|
2014-03-25 13:25:43 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty]
|
2016-02-21 23:19:42 +08:00
|
|
|
|
public string ResultFontStretch { get; set; }
|
2014-03-25 13:25:43 +08:00
|
|
|
|
|
2014-06-16 14:06:24 +08:00
|
|
|
|
[JsonProperty]
|
|
|
|
|
public double WindowLeft { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty]
|
|
|
|
|
public double WindowTop { get; set; }
|
|
|
|
|
|
2014-07-01 22:19:46 +08:00
|
|
|
|
public List<CustomizedPluginConfig> CustomizedPluginConfigs { 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]
|
2014-02-07 22:10:00 +08:00
|
|
|
|
public bool StartWoxOnSystemStartup { get; set; }
|
2014-03-23 16:17:41 +08:00
|
|
|
|
|
2015-01-26 22:50:38 +08:00
|
|
|
|
[Obsolete]
|
2014-03-26 17:34:19 +08:00
|
|
|
|
[JsonProperty]
|
|
|
|
|
public double Opacity { get; set; }
|
|
|
|
|
|
2015-01-26 22:50:38 +08:00
|
|
|
|
[Obsolete]
|
2014-03-26 17:34:19 +08:00
|
|
|
|
[JsonProperty]
|
|
|
|
|
public OpacityMode OpacityMode { get; set; }
|
|
|
|
|
|
2014-07-18 20:00:55 +08:00
|
|
|
|
[JsonProperty]
|
|
|
|
|
public bool LeaveCmdOpen { get; set; }
|
2014-04-11 05:44:57 +08:00
|
|
|
|
|
2014-04-13 10:08:33 +08:00
|
|
|
|
[JsonProperty]
|
|
|
|
|
public bool HideWhenDeactive { get; set; }
|
|
|
|
|
|
2015-02-20 21:45:42 +08:00
|
|
|
|
[JsonProperty]
|
|
|
|
|
public bool RememberLastLaunchLocation { get; set; }
|
|
|
|
|
|
2015-10-08 06:17:37 +08:00
|
|
|
|
[JsonProperty]
|
2015-10-08 07:02:36 +08:00
|
|
|
|
public bool IgnoreHotkeysOnFullscreen { get; set; }
|
2015-10-08 06:17:37 +08:00
|
|
|
|
|
2014-07-18 20:00:55 +08:00
|
|
|
|
[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; }
|
|
|
|
|
|
2015-07-13 03:13:30 +08:00
|
|
|
|
[JsonProperty]
|
|
|
|
|
public int MaxResultsToShow { get; set; }
|
|
|
|
|
|
2016-01-07 10:31:17 +08:00
|
|
|
|
protected override string FileName { get; } = "Settings";
|
2015-11-10 13:36:08 +08:00
|
|
|
|
|
2015-01-23 21:52:46 +08:00
|
|
|
|
public void IncreaseActivateTimes()
|
|
|
|
|
{
|
|
|
|
|
ActivateTimes++;
|
2015-11-09 11:20:02 +08:00
|
|
|
|
if (ActivateTimes % 15 == 0)
|
2015-01-23 21:52:46 +08:00
|
|
|
|
{
|
|
|
|
|
Save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-15 22:58:49 +08:00
|
|
|
|
protected override UserSettingStorage LoadDefault()
|
2014-03-23 18:14:46 +08:00
|
|
|
|
{
|
2014-12-14 23:16:29 +08:00
|
|
|
|
DontPromptUpdateMsg = false;
|
2014-03-23 18:14:46 +08:00
|
|
|
|
Theme = "Dark";
|
2015-01-04 18:14:50 +08:00
|
|
|
|
Language = "en";
|
2014-07-01 22:19:46 +08:00
|
|
|
|
CustomizedPluginConfigs = new List<CustomizedPluginConfig>();
|
2014-03-23 18:14:46 +08:00
|
|
|
|
Hotkey = "Alt + Space";
|
|
|
|
|
QueryBoxFont = FontFamily.GenericSansSerif.Name;
|
2016-02-21 23:19:42 +08:00
|
|
|
|
ResultFont = FontFamily.GenericSansSerif.Name;
|
2014-03-26 17:34:19 +08:00
|
|
|
|
Opacity = 1;
|
2014-07-18 20:00:55 +08:00
|
|
|
|
OpacityMode = OpacityMode.Normal;
|
|
|
|
|
LeaveCmdOpen = false;
|
2014-04-13 10:08:33 +08:00
|
|
|
|
HideWhenDeactive = false;
|
2015-02-10 23:48:09 +08:00
|
|
|
|
CustomPluginHotkeys = new List<CustomPluginHotkey>();
|
2015-02-20 21:45:42 +08:00
|
|
|
|
RememberLastLaunchLocation = false;
|
2015-07-13 03:13:30 +08:00
|
|
|
|
MaxResultsToShow = 6;
|
2014-08-17 15:57:25 +08:00
|
|
|
|
return this;
|
2014-03-23 18:14:46 +08:00
|
|
|
|
}
|
2014-03-26 17:34:19 +08:00
|
|
|
|
|
2014-12-15 22:58:49 +08:00
|
|
|
|
protected override void OnAfterLoad(UserSettingStorage storage)
|
2014-07-01 22:19:46 +08:00
|
|
|
|
{
|
|
|
|
|
if (storage.CustomizedPluginConfigs == null)
|
|
|
|
|
{
|
|
|
|
|
storage.CustomizedPluginConfigs = new List<CustomizedPluginConfig>();
|
|
|
|
|
}
|
2014-12-27 12:34:51 +08:00
|
|
|
|
if (storage.QueryBoxFont == null)
|
|
|
|
|
{
|
|
|
|
|
storage.QueryBoxFont = FontFamily.GenericSansSerif.Name;
|
|
|
|
|
}
|
2016-02-21 23:19:42 +08:00
|
|
|
|
if (storage.ResultFont == null)
|
2014-12-27 12:34:51 +08:00
|
|
|
|
{
|
2016-02-21 23:19:42 +08:00
|
|
|
|
storage.ResultFont = FontFamily.GenericSansSerif.Name;
|
2014-12-27 12:34:51 +08:00
|
|
|
|
}
|
2015-01-02 16:16:09 +08:00
|
|
|
|
if (storage.Language == null)
|
|
|
|
|
{
|
2015-01-04 18:14:50 +08:00
|
|
|
|
storage.Language = "en";
|
2015-01-02 16:16:09 +08:00
|
|
|
|
}
|
2014-07-01 22:19:46 +08:00
|
|
|
|
}
|
2015-11-09 11:20:02 +08:00
|
|
|
|
|
|
|
|
|
public void UpdateActionKeyword(PluginMetadata metadata)
|
|
|
|
|
{
|
|
|
|
|
var customizedPluginConfig = CustomizedPluginConfigs.FirstOrDefault(o => o.ID == metadata.ID);
|
|
|
|
|
if (customizedPluginConfig == null)
|
|
|
|
|
{
|
2016-01-07 05:34:42 +08:00
|
|
|
|
CustomizedPluginConfigs.Add(new CustomizedPluginConfig
|
2015-11-09 11:20:02 +08:00
|
|
|
|
{
|
|
|
|
|
Disabled = false,
|
|
|
|
|
ID = metadata.ID,
|
|
|
|
|
Name = metadata.Name,
|
|
|
|
|
ActionKeywords = metadata.ActionKeywords
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
customizedPluginConfig.ActionKeywords = metadata.ActionKeywords;
|
|
|
|
|
}
|
|
|
|
|
Save();
|
|
|
|
|
}
|
2014-03-26 17:34:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum OpacityMode
|
|
|
|
|
{
|
|
|
|
|
Normal = 0,
|
|
|
|
|
LayeredWindow = 1,
|
|
|
|
|
DWM = 2
|
2014-01-29 22:44:57 +08:00
|
|
|
|
}
|
2015-07-17 15:08:39 +08:00
|
|
|
|
}
|