diff --git a/Wox.Core/UserSettings/UserSettingStorage.cs b/Wox.Core/UserSettings/UserSettingStorage.cs
index 5f7c243c74..0e6d8a94e2 100644
--- a/Wox.Core/UserSettings/UserSettingStorage.cs
+++ b/Wox.Core/UserSettings/UserSettingStorage.cs
@@ -6,6 +6,7 @@ using Newtonsoft.Json;
using Wox.Infrastructure.Storage;
using Wox.Plugin;
using System.Drawing;
+using System.Reflection;
namespace Wox.Core.UserSettings
{
@@ -14,6 +15,10 @@ namespace Wox.Core.UserSettings
[JsonProperty]
public bool DontPromptUpdateMsg { get; set; }
+ [JsonProperty]
+ public int ActivateTimes { get; set; }
+
+
[JsonProperty]
public bool EnableUpdateLog { get; set; }
@@ -140,15 +145,7 @@ namespace Wox.Core.UserSettings
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");
- }
+ get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); }
}
protected override string ConfigName
@@ -156,6 +153,15 @@ namespace Wox.Core.UserSettings
get { return "config"; }
}
+ public void IncreaseActivateTimes()
+ {
+ ActivateTimes++;
+ if (ActivateTimes % 15 == 0)
+ {
+ Save();
+ }
+ }
+
protected override UserSettingStorage LoadDefault()
{
DontPromptUpdateMsg = false;
diff --git a/Wox.Core/Wox.Core.csproj b/Wox.Core/Wox.Core.csproj
index b9b40bb80a..570038c14c 100644
--- a/Wox.Core/Wox.Core.csproj
+++ b/Wox.Core/Wox.Core.csproj
@@ -83,8 +83,8 @@
-
-
+
+
diff --git a/Wox.Infrastructure/Storage/BinaryStorage.cs b/Wox.Infrastructure/Storage/BinaryStorage.cs
index 7561ba1149..7651ca770c 100644
--- a/Wox.Infrastructure/Storage/BinaryStorage.cs
+++ b/Wox.Infrastructure/Storage/BinaryStorage.cs
@@ -6,6 +6,7 @@ using System.Reflection;
using System.Runtime.Serialization.Formatters;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
+using System.Threading;
using Wox.Infrastructure.Logger;
namespace Wox.Infrastructure.Storage
@@ -18,6 +19,7 @@ namespace Wox.Infrastructure.Storage
[Serializable]
public abstract class BinaryStorage : BaseStorage where T : class, IStorage, new()
{
+ private static object syncObject = new object();
protected override string FileSuffix
{
get { return ".dat"; }
@@ -87,25 +89,31 @@ namespace Wox.Infrastructure.Storage
protected override void SaveInternal()
{
- try
+ ThreadPool.QueueUserWorkItem(o =>
{
- FileStream fileStream = new FileStream(ConfigPath, FileMode.Create);
- BinaryFormatter binaryFormatter = new BinaryFormatter
+ lock (syncObject)
{
- AssemblyFormat = FormatterAssemblyStyle.Simple
- };
- binaryFormatter.Serialize(fileStream, serializedObject);
- fileStream.Close();
- }
- catch (Exception e)
- {
- Log.Error(e.Message);
+ try
+ {
+ FileStream fileStream = new FileStream(ConfigPath, FileMode.Create);
+ BinaryFormatter binaryFormatter = new BinaryFormatter
+ {
+ AssemblyFormat = FormatterAssemblyStyle.Simple
+ };
+ binaryFormatter.Serialize(fileStream, serializedObject);
+ fileStream.Close();
+ }
+ catch (Exception e)
+ {
+ Log.Error(e);
#if (DEBUG)
- {
- throw;
- }
+ {
+ throw;
+ }
#endif
- }
+ }
+ }
+ });
}
}
}
diff --git a/Wox.Infrastructure/Storage/JsonStorage.cs b/Wox.Infrastructure/Storage/JsonStorage.cs
index 4a4525bd3e..ca6c0fea09 100644
--- a/Wox.Infrastructure/Storage/JsonStorage.cs
+++ b/Wox.Infrastructure/Storage/JsonStorage.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
+using System.Threading;
using Newtonsoft.Json;
namespace Wox.Infrastructure.Storage
@@ -12,6 +13,7 @@ namespace Wox.Infrastructure.Storage
///
public abstract class JsonStrorage : BaseStorage where T : class, IStorage, new()
{
+ private static object syncObject = new object();
protected override string FileSuffix
{
get { return ".json"; }
@@ -39,8 +41,14 @@ namespace Wox.Infrastructure.Storage
protected override void SaveInternal()
{
- string json = JsonConvert.SerializeObject(serializedObject, Formatting.Indented);
- File.WriteAllText(ConfigPath, json);
+ ThreadPool.QueueUserWorkItem(o =>
+ {
+ lock (syncObject)
+ {
+ string json = JsonConvert.SerializeObject(serializedObject, Formatting.Indented);
+ File.WriteAllText(ConfigPath, json);
+ }
+ });
}
}
}
diff --git a/Wox/ActionKeyword.xaml b/Wox/ActionKeyword.xaml
index 27ed9ad171..bdc7b6000a 100644
--- a/Wox/ActionKeyword.xaml
+++ b/Wox/ActionKeyword.xaml
@@ -6,15 +6,16 @@
ResizeMode="NoResize"
Loaded="ActionKeyword_OnLoaded"
WindowStartupLocation="CenterScreen"
- Height="200" Width="674.766">
+ Height="200" Width="600">
+
-
+
@@ -24,8 +25,10 @@
+
+
-
+
diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs
index e4c43d99d7..9b8b5f78be 100644
--- a/Wox/SettingWindow.xaml.cs
+++ b/Wox/SettingWindow.xaml.cs
@@ -21,6 +21,7 @@ using Microsoft.Win32;
using Wox.Core.i18n;
using Wox.Core.Theme;
using Wox.Core.UserSettings;
+using Wox.Core.Version;
namespace Wox
{
@@ -216,7 +217,10 @@ namespace Wox
#region About
- tbVersion.Text = ConfigurationManager.AppSettings["version"];
+ tbVersion.Text = VersionManager.Instance.CurrentVersion.ToString();
+ string activateTimes = string.Format(InternationalizationManager.Instance.GetTranslation("about_activate_times"),
+ UserSettingStorage.Instance.ActivateTimes);
+ tbActivatedTimes.Text = activateTimes;
#endregion
diff --git a/Wox/Storage/UserSelectedRecordStorage.cs b/Wox/Storage/UserSelectedRecordStorage.cs
index fa41090989..cc3fe9cd17 100644
--- a/Wox/Storage/UserSelectedRecordStorage.cs
+++ b/Wox/Storage/UserSelectedRecordStorage.cs
@@ -4,6 +4,7 @@ using Newtonsoft.Json;
using Wox.Infrastructure.Storage;
using Wox.Plugin;
using System.IO;
+using System.Reflection;
namespace Wox.Storage
{
@@ -14,15 +15,7 @@ namespace Wox.Storage
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");
- }
+ get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); }
}
protected override string ConfigName
diff --git a/appveyor.yml b/appveyor.yml
index 49f53ee273..76871e1456 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -15,7 +15,7 @@ build:
after_test:
- ps: .\deploy\nuget\pack.ps1
- cmd: .\deploy\UpdateGenerator\build.bat
- - cmd: .\deploy\Cleanup.bat
+ #- cmd: .\deploy\Cleanup.bat
deploy:
provider: NuGet