mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
[stylecop] Wox.Core - last amount needed to fully integrate (#5877)
* Looks like it was done * StyleCop enabled for WoxCore
This commit is contained in:
@@ -21,7 +21,7 @@ namespace Wox.Core.Plugin
|
|||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
RedirectStandardError = true
|
RedirectStandardError = true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
|
||||||
|
* like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
|
||||||
|
* "id" and "jsonrpc" in the request, since it's not so useful in our request model.
|
||||||
|
*
|
||||||
|
* When execute a query:
|
||||||
|
* Wox -------JsonRPCServerRequestModel--------> client
|
||||||
|
* Wox <------JsonRPCQueryResponseModel--------- client
|
||||||
|
*
|
||||||
|
* When execute a action (which mean user select an item in reulst item):
|
||||||
|
* Wox -------JsonRPCServerRequestModel--------> client
|
||||||
|
* Wox <------JsonRPCResponseModel-------------- client
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Wox.Core.Plugin
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Json RPC Request(in query response) that client sent to Wox
|
||||||
|
/// </summary>
|
||||||
|
public class JsonRPCClientRequestModel : JsonRPCRequestModel
|
||||||
|
{
|
||||||
|
public bool DontHideAfterAction { get; set; }
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string rpc = base.ToString();
|
||||||
|
return rpc + "}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
29
src/modules/launcher/Wox.Core/Plugin/JsonRPCErrorModel.cs
Normal file
29
src/modules/launcher/Wox.Core/Plugin/JsonRPCErrorModel.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
|
||||||
|
* like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
|
||||||
|
* "id" and "jsonrpc" in the request, since it's not so useful in our request model.
|
||||||
|
*
|
||||||
|
* When execute a query:
|
||||||
|
* Wox -------JsonRPCServerRequestModel--------> client
|
||||||
|
* Wox <------JsonRPCQueryResponseModel--------- client
|
||||||
|
*
|
||||||
|
* When execute a action (which mean user select an item in reulst item):
|
||||||
|
* Wox -------JsonRPCServerRequestModel--------> client
|
||||||
|
* Wox <------JsonRPCResponseModel-------------- client
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Wox.Core.Plugin
|
||||||
|
{
|
||||||
|
public class JsonRPCErrorModel
|
||||||
|
{
|
||||||
|
public int Code { get; set; }
|
||||||
|
|
||||||
|
public string Message { get; set; }
|
||||||
|
|
||||||
|
public string Data { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/modules/launcher/Wox.Core/Plugin/JsonRPCModelBase.cs
Normal file
25
src/modules/launcher/Wox.Core/Plugin/JsonRPCModelBase.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
|
||||||
|
* like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
|
||||||
|
* "id" and "jsonrpc" in the request, since it's not so useful in our request model.
|
||||||
|
*
|
||||||
|
* When execute a query:
|
||||||
|
* Wox -------JsonRPCServerRequestModel--------> client
|
||||||
|
* Wox <------JsonRPCQueryResponseModel--------- client
|
||||||
|
*
|
||||||
|
* When execute a action (which mean user select an item in reulst item):
|
||||||
|
* Wox -------JsonRPCServerRequestModel--------> client
|
||||||
|
* Wox <------JsonRPCResponseModel-------------- client
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Wox.Core.Plugin
|
||||||
|
{
|
||||||
|
public class JsonRPCModelBase
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,11 +19,12 @@ namespace Wox.Core.Plugin
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal abstract class JsonRPCPlugin : IPlugin, IContextMenu
|
internal abstract class JsonRPCPlugin : IPlugin, IContextMenu
|
||||||
{
|
{
|
||||||
protected PluginInitContext context;
|
protected PluginInitContext Context { get; set; }
|
||||||
|
|
||||||
public const string JsonRPC = "JsonRPC";
|
public const string JsonRPC = "JsonRPC";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The language this JsonRPCPlugin support
|
/// Gets or sets the language this JsonRPCPlugin support
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract string SupportedLanguage { get; set; }
|
public abstract string SupportedLanguage { get; set; }
|
||||||
|
|
||||||
@@ -67,21 +68,27 @@ namespace Wox.Core.Plugin
|
|||||||
|
|
||||||
private List<Result> DeserializedResult(string output)
|
private List<Result> DeserializedResult(string output)
|
||||||
{
|
{
|
||||||
if (!String.IsNullOrEmpty(output))
|
if (!string.IsNullOrEmpty(output))
|
||||||
{
|
{
|
||||||
List<Result> results = new List<Result>();
|
List<Result> results = new List<Result>();
|
||||||
|
|
||||||
JsonRPCQueryResponseModel queryResponseModel = JsonConvert.DeserializeObject<JsonRPCQueryResponseModel>(output);
|
JsonRPCQueryResponseModel queryResponseModel = JsonConvert.DeserializeObject<JsonRPCQueryResponseModel>(output);
|
||||||
if (queryResponseModel.Result == null) return null;
|
if (queryResponseModel.Result == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (JsonRPCResult result in queryResponseModel.Result)
|
foreach (JsonRPCResult result in queryResponseModel.Result)
|
||||||
{
|
{
|
||||||
JsonRPCResult result1 = result;
|
JsonRPCResult result1 = result;
|
||||||
result.Action = c =>
|
result.Action = c =>
|
||||||
{
|
{
|
||||||
if (result1.JsonRPCAction == null) return false;
|
if (result1.JsonRPCAction == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(result1.JsonRPCAction.Method))
|
if (!string.IsNullOrEmpty(result1.JsonRPCAction.Method))
|
||||||
{
|
{
|
||||||
if (result1.JsonRPCAction.Method.StartsWith("Wox."))
|
if (result1.JsonRPCAction.Method.StartsWith("Wox."))
|
||||||
{
|
{
|
||||||
@@ -92,7 +99,7 @@ namespace Wox.Core.Plugin
|
|||||||
string actionResponse = ExecuteCallback(result1.JsonRPCAction);
|
string actionResponse = ExecuteCallback(result1.JsonRPCAction);
|
||||||
JsonRPCRequestModel jsonRpcRequestModel = JsonConvert.DeserializeObject<JsonRPCRequestModel>(actionResponse);
|
JsonRPCRequestModel jsonRpcRequestModel = JsonConvert.DeserializeObject<JsonRPCRequestModel>(actionResponse);
|
||||||
if (jsonRpcRequestModel != null
|
if (jsonRpcRequestModel != null
|
||||||
&& !String.IsNullOrEmpty(jsonRpcRequestModel.Method)
|
&& !string.IsNullOrEmpty(jsonRpcRequestModel.Method)
|
||||||
&& jsonRpcRequestModel.Method.StartsWith("Wox."))
|
&& jsonRpcRequestModel.Method.StartsWith("Wox."))
|
||||||
{
|
{
|
||||||
ExecuteWoxAPI(jsonRpcRequestModel.Method.Substring(4), jsonRpcRequestModel.Parameters);
|
ExecuteWoxAPI(jsonRpcRequestModel.Method.Substring(4), jsonRpcRequestModel.Parameters);
|
||||||
@@ -136,18 +143,21 @@ namespace Wox.Core.Plugin
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Execute external program and return the output
|
/// Execute external program and return the output
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="fileName"></param>
|
/// <param name="fileName">file to execute</param>
|
||||||
/// <param name="arguments"></param>
|
/// <param name="arguments">args to pass in to that exe</param>
|
||||||
/// <returns></returns>
|
/// <returns>results</returns>
|
||||||
protected string Execute(string fileName, string arguments)
|
protected string Execute(string fileName, string arguments)
|
||||||
{
|
{
|
||||||
ProcessStartInfo start = new ProcessStartInfo();
|
ProcessStartInfo start = new ProcessStartInfo
|
||||||
start.FileName = fileName;
|
{
|
||||||
start.Arguments = arguments;
|
FileName = fileName,
|
||||||
start.UseShellExecute = false;
|
Arguments = arguments,
|
||||||
start.CreateNoWindow = true;
|
UseShellExecute = false,
|
||||||
start.RedirectStandardOutput = true;
|
CreateNoWindow = true,
|
||||||
start.RedirectStandardError = true;
|
RedirectStandardOutput = true,
|
||||||
|
RedirectStandardError = true,
|
||||||
|
};
|
||||||
|
|
||||||
return Execute(start);
|
return Execute(start);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,7 +216,7 @@ namespace Wox.Core.Plugin
|
|||||||
|
|
||||||
public void Init(PluginInitContext ctx)
|
public void Init(PluginInitContext ctx)
|
||||||
{
|
{
|
||||||
context = ctx;
|
Context = ctx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
|
||||||
|
* like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
|
||||||
|
* "id" and "jsonrpc" in the request, since it's not so useful in our request model.
|
||||||
|
*
|
||||||
|
* When execute a query:
|
||||||
|
* Wox -------JsonRPCServerRequestModel--------> client
|
||||||
|
* Wox <------JsonRPCQueryResponseModel--------- client
|
||||||
|
*
|
||||||
|
* When execute a action (which mean user select an item in reulst item):
|
||||||
|
* Wox -------JsonRPCServerRequestModel--------> client
|
||||||
|
* Wox <------JsonRPCResponseModel-------------- client
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Wox.Core.Plugin
|
||||||
|
{
|
||||||
|
public class JsonRPCQueryResponseModel : JsonRPCResponseModel
|
||||||
|
{
|
||||||
|
public new List<JsonRPCResult> Result { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,38 +16,10 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Wox.Plugin;
|
|
||||||
|
|
||||||
namespace Wox.Core.Plugin
|
namespace Wox.Core.Plugin
|
||||||
{
|
{
|
||||||
public class JsonRPCErrorModel
|
|
||||||
{
|
|
||||||
public int Code { get; set; }
|
|
||||||
|
|
||||||
public string Message { get; set; }
|
|
||||||
|
|
||||||
public string Data { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class JsonRPCModelBase
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class JsonRPCResponseModel : JsonRPCModelBase
|
|
||||||
{
|
|
||||||
public string Result { get; set; }
|
|
||||||
|
|
||||||
public JsonRPCErrorModel Error { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class JsonRPCQueryResponseModel : JsonRPCResponseModel
|
|
||||||
{
|
|
||||||
public new List<JsonRPCResult> Result { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class JsonRPCRequestModel : JsonRPCModelBase
|
public class JsonRPCRequestModel : JsonRPCModelBase
|
||||||
{
|
{
|
||||||
public string Method { get; set; }
|
public string Method { get; set; }
|
||||||
@@ -103,40 +75,4 @@ namespace Wox.Core.Plugin
|
|||||||
.Replace(@"""", @"\\""""");
|
.Replace(@"""", @"\\""""");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Json RPC Request that Wox sent to client
|
|
||||||
/// </summary>
|
|
||||||
public class JsonRPCServerRequestModel : JsonRPCRequestModel
|
|
||||||
{
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
string rpc = base.ToString();
|
|
||||||
return rpc + "}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Json RPC Request(in query response) that client sent to Wox
|
|
||||||
/// </summary>
|
|
||||||
public class JsonRPCClientRequestModel : JsonRPCRequestModel
|
|
||||||
{
|
|
||||||
public bool DontHideAfterAction { get; set; }
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
string rpc = base.ToString();
|
|
||||||
return rpc + "}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represent the json-rpc result item that client send to Wox
|
|
||||||
/// Typically, we will send back this request model to client after user select the result item
|
|
||||||
/// But if the request method starts with "Wox.", we will invoke the public APIs we expose.
|
|
||||||
/// </summary>
|
|
||||||
public class JsonRPCResult : Result
|
|
||||||
{
|
|
||||||
public JsonRPCClientRequestModel JsonRPCAction { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
27
src/modules/launcher/Wox.Core/Plugin/JsonRPCResponseModel.cs
Normal file
27
src/modules/launcher/Wox.Core/Plugin/JsonRPCResponseModel.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
|
||||||
|
* like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
|
||||||
|
* "id" and "jsonrpc" in the request, since it's not so useful in our request model.
|
||||||
|
*
|
||||||
|
* When execute a query:
|
||||||
|
* Wox -------JsonRPCServerRequestModel--------> client
|
||||||
|
* Wox <------JsonRPCQueryResponseModel--------- client
|
||||||
|
*
|
||||||
|
* When execute a action (which mean user select an item in reulst item):
|
||||||
|
* Wox -------JsonRPCServerRequestModel--------> client
|
||||||
|
* Wox <------JsonRPCResponseModel-------------- client
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Wox.Core.Plugin
|
||||||
|
{
|
||||||
|
public class JsonRPCResponseModel : JsonRPCModelBase
|
||||||
|
{
|
||||||
|
public string Result { get; set; }
|
||||||
|
|
||||||
|
public JsonRPCErrorModel Error { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
32
src/modules/launcher/Wox.Core/Plugin/JsonRPCResult.cs
Normal file
32
src/modules/launcher/Wox.Core/Plugin/JsonRPCResult.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
|
||||||
|
* like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
|
||||||
|
* "id" and "jsonrpc" in the request, since it's not so useful in our request model.
|
||||||
|
*
|
||||||
|
* When execute a query:
|
||||||
|
* Wox -------JsonRPCServerRequestModel--------> client
|
||||||
|
* Wox <------JsonRPCQueryResponseModel--------- client
|
||||||
|
*
|
||||||
|
* When execute a action (which mean user select an item in reulst item):
|
||||||
|
* Wox -------JsonRPCServerRequestModel--------> client
|
||||||
|
* Wox <------JsonRPCResponseModel-------------- client
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
using Wox.Plugin;
|
||||||
|
|
||||||
|
namespace Wox.Core.Plugin
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represent the json-rpc result item that client send to Wox
|
||||||
|
/// Typically, we will send back this request model to client after user select the result item
|
||||||
|
/// But if the request method starts with "Wox.", we will invoke the public APIs we expose.
|
||||||
|
/// </summary>
|
||||||
|
public class JsonRPCResult : Result
|
||||||
|
{
|
||||||
|
public JsonRPCClientRequestModel JsonRPCAction { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
/* We basically follow the Json-RPC 2.0 spec (http://www.jsonrpc.org/specification) to invoke methods between Wox and other plugins,
|
||||||
|
* like python or other self-execute program. But, we added additional infos (proxy and so on) into rpc request. Also, we didn't use the
|
||||||
|
* "id" and "jsonrpc" in the request, since it's not so useful in our request model.
|
||||||
|
*
|
||||||
|
* When execute a query:
|
||||||
|
* Wox -------JsonRPCServerRequestModel--------> client
|
||||||
|
* Wox <------JsonRPCQueryResponseModel--------- client
|
||||||
|
*
|
||||||
|
* When execute a action (which mean user select an item in reulst item):
|
||||||
|
* Wox -------JsonRPCServerRequestModel--------> client
|
||||||
|
* Wox <------JsonRPCResponseModel-------------- client
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Wox.Core.Plugin
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Json RPC Request that Wox sent to client
|
||||||
|
/// </summary>
|
||||||
|
public class JsonRPCServerRequestModel : JsonRPCRequestModel
|
||||||
|
{
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string rpc = base.ToString();
|
||||||
|
return rpc + "}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Wox.Infrastructure.Logger;
|
using Wox.Infrastructure.Logger;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
@@ -20,8 +20,8 @@ namespace Wox.Core.Plugin
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parse plugin metadata in giving directories
|
/// Parse plugin metadata in giving directories
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="pluginDirectories"></param>
|
/// <param name="pluginDirectories">directories with plugins</param>
|
||||||
/// <returns></returns>
|
/// <returns>List with plugin meta data</returns>
|
||||||
public static List<PluginMetadata> Parse(string[] pluginDirectories)
|
public static List<PluginMetadata> Parse(string[] pluginDirectories)
|
||||||
{
|
{
|
||||||
PluginMetadatas.Clear();
|
PluginMetadatas.Clear();
|
||||||
|
|||||||
@@ -87,9 +87,7 @@ namespace Wox.Core.Plugin
|
|||||||
// {
|
// {
|
||||||
// Plugins.Initialize();
|
// Plugins.Initialize();
|
||||||
// }
|
// }
|
||||||
if (MessageBox.Show($"You have installed plugin {plugin.Name} successfully.{Environment.NewLine}" +
|
if (MessageBox.Show($"You have installed plugin {plugin.Name} successfully.{Environment.NewLine} Restart Wox to take effect?", "Install plugin", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
|
||||||
"Restart Wox to take effect?",
|
|
||||||
"Install plugin", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
|
|
||||||
{
|
{
|
||||||
PluginManager.API.RestartApp();
|
PluginManager.API.RestartApp();
|
||||||
}
|
}
|
||||||
@@ -119,8 +117,9 @@ namespace Wox.Core.Plugin
|
|||||||
{
|
{
|
||||||
throw new Exception(error);
|
throw new Exception(error);
|
||||||
}
|
}
|
||||||
#endif
|
#else
|
||||||
return null;
|
return null;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!AllowedLanguage.IsAllowed(metadata.Language))
|
if (!AllowedLanguage.IsAllowed(metadata.Language))
|
||||||
@@ -130,8 +129,9 @@ namespace Wox.Core.Plugin
|
|||||||
{
|
{
|
||||||
throw new Exception(error);
|
throw new Exception(error);
|
||||||
}
|
}
|
||||||
#endif
|
#else
|
||||||
return null;
|
return null;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!File.Exists(metadata.ExecuteFilePath))
|
if (!File.Exists(metadata.ExecuteFilePath))
|
||||||
@@ -141,8 +141,9 @@ namespace Wox.Core.Plugin
|
|||||||
{
|
{
|
||||||
throw new Exception(error);
|
throw new Exception(error);
|
||||||
}
|
}
|
||||||
#endif
|
#else
|
||||||
return null;
|
return null;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return metadata;
|
return metadata;
|
||||||
@@ -156,10 +157,15 @@ namespace Wox.Core.Plugin
|
|||||||
/// <param name="overWrite">overwrite</param>
|
/// <param name="overWrite">overwrite</param>
|
||||||
private static void UnZip(string zippedFile, string strDirectory, bool overWrite)
|
private static void UnZip(string zippedFile, string strDirectory, bool overWrite)
|
||||||
{
|
{
|
||||||
if (strDirectory == "")
|
if (strDirectory == string.Empty)
|
||||||
|
{
|
||||||
strDirectory = Directory.GetCurrentDirectory();
|
strDirectory = Directory.GetCurrentDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
if (!strDirectory.EndsWith("\\"))
|
if (!strDirectory.EndsWith("\\"))
|
||||||
strDirectory = strDirectory + "\\";
|
{
|
||||||
|
strDirectory += "\\";
|
||||||
|
}
|
||||||
|
|
||||||
using (ZipInputStream s = new ZipInputStream(File.OpenRead(zippedFile)))
|
using (ZipInputStream s = new ZipInputStream(File.OpenRead(zippedFile)))
|
||||||
{
|
{
|
||||||
@@ -167,18 +173,20 @@ namespace Wox.Core.Plugin
|
|||||||
|
|
||||||
while ((theEntry = s.GetNextEntry()) != null)
|
while ((theEntry = s.GetNextEntry()) != null)
|
||||||
{
|
{
|
||||||
string directoryName = "";
|
string directoryName = string.Empty;
|
||||||
string pathToZip = "";
|
string pathToZip = string.Empty;
|
||||||
pathToZip = theEntry.Name;
|
pathToZip = theEntry.Name;
|
||||||
|
|
||||||
if (pathToZip != "")
|
if (pathToZip != string.Empty)
|
||||||
|
{
|
||||||
directoryName = Path.GetDirectoryName(pathToZip) + "\\";
|
directoryName = Path.GetDirectoryName(pathToZip) + "\\";
|
||||||
|
}
|
||||||
|
|
||||||
string fileName = Path.GetFileName(pathToZip);
|
string fileName = Path.GetFileName(pathToZip);
|
||||||
|
|
||||||
Directory.CreateDirectory(strDirectory + directoryName);
|
Directory.CreateDirectory(strDirectory + directoryName);
|
||||||
|
|
||||||
if (fileName != "")
|
if (fileName != string.Empty)
|
||||||
{
|
{
|
||||||
if ((File.Exists(strDirectory + directoryName + fileName) && overWrite) || (!File.Exists(strDirectory + directoryName + fileName)))
|
if ((File.Exists(strDirectory + directoryName + fileName) && overWrite) || (!File.Exists(strDirectory + directoryName + fileName)))
|
||||||
{
|
{
|
||||||
@@ -190,9 +198,13 @@ namespace Wox.Core.Plugin
|
|||||||
int size = s.Read(data, 0, data.Length);
|
int size = s.Read(data, 0, data.Length);
|
||||||
|
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
|
{
|
||||||
streamWriter.Write(data, 0, size);
|
streamWriter.Write(data, 0, size);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
streamWriter.Close();
|
streamWriter.Close();
|
||||||
|
|||||||
@@ -24,20 +24,20 @@ namespace Wox.Core.Plugin
|
|||||||
private static IEnumerable<PluginPair> _contextMenuPlugins = new List<PluginPair>();
|
private static IEnumerable<PluginPair> _contextMenuPlugins = new List<PluginPair>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Directories that will hold Wox plugin directory
|
/// Gets directories that will hold Wox plugin directory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static List<PluginPair> AllPlugins { get; private set; }
|
public static List<PluginPair> AllPlugins { get; private set; }
|
||||||
|
|
||||||
|
public static IPublicAPI API { get; private set; }
|
||||||
|
|
||||||
public static readonly List<PluginPair> GlobalPlugins = new List<PluginPair>();
|
public static readonly List<PluginPair> GlobalPlugins = new List<PluginPair>();
|
||||||
public static readonly Dictionary<string, PluginPair> NonGlobalPlugins = new Dictionary<string, PluginPair>();
|
public static readonly Dictionary<string, PluginPair> NonGlobalPlugins = new Dictionary<string, PluginPair>();
|
||||||
|
private static readonly string[] Directories = { Constant.PreinstalledDirectory, Constant.PluginsDirectory };
|
||||||
public static IPublicAPI API { private set; get; }
|
|
||||||
|
|
||||||
|
|
||||||
// todo happlebao, this should not be public, the indicator function should be embedded
|
// todo happlebao, this should not be public, the indicator function should be embedded
|
||||||
public static PluginSettings Settings;
|
public static PluginSettings Settings { get; set; }
|
||||||
|
|
||||||
private static List<PluginMetadata> _metadatas;
|
private static List<PluginMetadata> _metadatas;
|
||||||
private static readonly string[] Directories = { Constant.PreinstalledDirectory, Constant.PluginsDirectory };
|
|
||||||
|
|
||||||
private static void ValidateUserDirectory()
|
private static void ValidateUserDirectory()
|
||||||
{
|
{
|
||||||
@@ -74,7 +74,7 @@ namespace Wox.Core.Plugin
|
|||||||
/// because InitializePlugins needs API, so LoadPlugins needs to be called first
|
/// because InitializePlugins needs API, so LoadPlugins needs to be called first
|
||||||
/// todo happlebao The API should be removed
|
/// todo happlebao The API should be removed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="settings"></param>
|
/// <param name="settings">Plugin settings</param>
|
||||||
public static void LoadPlugins(PluginSettings settings)
|
public static void LoadPlugins(PluginSettings settings)
|
||||||
{
|
{
|
||||||
_metadatas = PluginConfig.Parse(Directories);
|
_metadatas = PluginConfig.Parse(Directories);
|
||||||
@@ -86,7 +86,6 @@ namespace Wox.Core.Plugin
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Call initialize for all plugins
|
/// Call initialize for all plugins
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>return the list of failed to init plugins or null for none</returns>
|
|
||||||
public static void InitializePlugins(IPublicAPI api)
|
public static void InitializePlugins(IPublicAPI api)
|
||||||
{
|
{
|
||||||
API = api;
|
API = api;
|
||||||
@@ -100,7 +99,7 @@ namespace Wox.Core.Plugin
|
|||||||
pair.Plugin.Init(new PluginInitContext
|
pair.Plugin.Init(new PluginInitContext
|
||||||
{
|
{
|
||||||
CurrentPluginMetadata = pair.Metadata,
|
CurrentPluginMetadata = pair.Metadata,
|
||||||
API = API
|
API = API,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
pair.Metadata.InitTime += milliseconds;
|
pair.Metadata.InitTime += milliseconds;
|
||||||
@@ -118,7 +117,9 @@ namespace Wox.Core.Plugin
|
|||||||
foreach (var plugin in AllPlugins)
|
foreach (var plugin in AllPlugins)
|
||||||
{
|
{
|
||||||
if (IsGlobalPlugin(plugin.Metadata))
|
if (IsGlobalPlugin(plugin.Metadata))
|
||||||
|
{
|
||||||
GlobalPlugins.Add(plugin);
|
GlobalPlugins.Add(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
// Plugins may have multiple ActionKeywords, eg. WebSearch
|
// Plugins may have multiple ActionKeywords, eg. WebSearch
|
||||||
plugin.Metadata.ActionKeywords.Where(x => x != Query.GlobalPluginWildcardSign)
|
plugin.Metadata.ActionKeywords.Where(x => x != Query.GlobalPluginWildcardSign)
|
||||||
@@ -129,7 +130,7 @@ namespace Wox.Core.Plugin
|
|||||||
if (failedPlugins.Any())
|
if (failedPlugins.Any())
|
||||||
{
|
{
|
||||||
var failed = string.Join(",", failedPlugins.Select(x => x.Metadata.Name));
|
var failed = string.Join(",", failedPlugins.Select(x => x.Metadata.Name));
|
||||||
API.ShowMsg($"Fail to Init Plugins", $"Plugins: {failed} - fail to load and would be disabled, please contact plugin creator for help", "", false);
|
API.ShowMsg($"Fail to Init Plugins", $"Plugins: {failed} - fail to load and would be disabled, please contact plugin creator for help", string.Empty, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,14 +192,15 @@ namespace Wox.Core.Plugin
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// get specified plugin, return null if not found
|
/// get specified plugin, return null if not found
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id">id of plugin</param>
|
||||||
/// <returns></returns>
|
/// <returns>plugin</returns>
|
||||||
public static PluginPair GetPluginForId(string id)
|
public static PluginPair GetPluginForId(string id)
|
||||||
{
|
{
|
||||||
return AllPlugins.FirstOrDefault(o => o.Metadata.ID == id);
|
return AllPlugins.FirstOrDefault(o => o.Metadata.ID == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<PluginPair> GetPluginsForInterface<T>() where T : IFeatures
|
public static IEnumerable<PluginPair> GetPluginsForInterface<T>()
|
||||||
|
where T : IFeatures
|
||||||
{
|
{
|
||||||
return AllPlugins.Where(p => p.Plugin is T);
|
return AllPlugins.Where(p => p.Plugin is T);
|
||||||
}
|
}
|
||||||
@@ -278,7 +280,9 @@ namespace Wox.Core.Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (oldActionkeyword != Query.GlobalPluginWildcardSign)
|
if (oldActionkeyword != Query.GlobalPluginWildcardSign)
|
||||||
|
{
|
||||||
NonGlobalPlugins.Remove(oldActionkeyword);
|
NonGlobalPlugins.Remove(oldActionkeyword);
|
||||||
|
}
|
||||||
|
|
||||||
plugin.Metadata.ActionKeywords.Remove(oldActionkeyword);
|
plugin.Metadata.ActionKeywords.Remove(oldActionkeyword);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ using System.Linq;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.Loader;
|
using System.Runtime.Loader;
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
using Wox.Infrastructure.Logger;
|
|
||||||
using Wox.Infrastructure.UserSettings;
|
using Wox.Infrastructure.UserSettings;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
|
|
||||||
@@ -48,9 +47,10 @@ namespace Wox.Core.Plugin
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.Exception($"|PluginsLoader.CSharpPlugins|Couldn't load assembly for {metadata.Name}", e);
|
Infrastructure.Logger.Log.Exception($"|PluginsLoader.CSharpPlugins|Couldn't load assembly for {metadata.Name}", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var types = assembly.GetTypes();
|
var types = assembly.GetTypes();
|
||||||
Type type;
|
Type type;
|
||||||
try
|
try
|
||||||
@@ -59,9 +59,10 @@ namespace Wox.Core.Plugin
|
|||||||
}
|
}
|
||||||
catch (InvalidOperationException e)
|
catch (InvalidOperationException e)
|
||||||
{
|
{
|
||||||
Log.Exception($"|PluginsLoader.CSharpPlugins|Can't find class implement IPlugin for <{metadata.Name}>", e);
|
Infrastructure.Logger.Log.Exception($"|PluginsLoader.CSharpPlugins|Can't find class implement IPlugin for <{metadata.Name}>", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPlugin plugin;
|
IPlugin plugin;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -69,14 +70,14 @@ namespace Wox.Core.Plugin
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.Exception($"|PluginsLoader.CSharpPlugins|Can't create instance for <{metadata.Name}>", e);
|
Infrastructure.Logger.Log.Exception($"|PluginsLoader.CSharpPlugins|Can't create instance for <{metadata.Name}>", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
PluginPair pair = new PluginPair
|
PluginPair pair = new PluginPair
|
||||||
{
|
{
|
||||||
Plugin = plugin,
|
Plugin = plugin,
|
||||||
Metadata = metadata
|
Metadata = metadata,
|
||||||
};
|
};
|
||||||
plugins.Add(pair);
|
plugins.Add(pair);
|
||||||
});
|
});
|
||||||
@@ -93,7 +94,7 @@ namespace Wox.Core.Plugin
|
|||||||
var plugins = metadatas.Select(metadata => new PluginPair
|
var plugins = metadatas.Select(metadata => new PluginPair
|
||||||
{
|
{
|
||||||
Plugin = new ExecutablePlugin(metadata.ExecuteFilePath),
|
Plugin = new ExecutablePlugin(metadata.ExecuteFilePath),
|
||||||
Metadata = metadata
|
Metadata = metadata,
|
||||||
});
|
});
|
||||||
return plugins;
|
return plugins;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace Wox.Core.Plugin
|
|||||||
|
|
||||||
// Obsolete value initialisation
|
// Obsolete value initialisation
|
||||||
ActionName = actionKeyword,
|
ActionName = actionKeyword,
|
||||||
ActionParameters = actionParameters
|
ActionParameters = actionParameters,
|
||||||
};
|
};
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
|
|||||||
@@ -8,24 +8,41 @@ namespace Wox.Core.Resource
|
|||||||
{
|
{
|
||||||
internal static class AvailableLanguages
|
internal static class AvailableLanguages
|
||||||
{
|
{
|
||||||
public static Language English = new Language("en", "English");
|
public static Language English { get; set; } = new Language("en", "English");
|
||||||
public static Language Chinese = new Language("zh-cn", "中文");
|
|
||||||
public static Language Chinese_TW = new Language("zh-tw", "中文(繁体)");
|
public static Language Chinese { get; set; } = new Language("zh-cn", "中文");
|
||||||
public static Language Ukrainian = new Language("uk-UA", "Українська");
|
|
||||||
public static Language Russian = new Language("ru", "Русский");
|
public static Language Chinese_TW { get; set; } = new Language("zh-tw", "中文(繁体)");
|
||||||
public static Language French = new Language("fr", "Français");
|
|
||||||
public static Language Japanese = new Language("ja", "日本語");
|
public static Language Ukrainian { get; set; } = new Language("uk-UA", "Українська");
|
||||||
public static Language Dutch = new Language("nl", "Dutch");
|
|
||||||
public static Language Polish = new Language("pl", "Polski");
|
public static Language Russian { get; set; } = new Language("ru", "Русский");
|
||||||
public static Language Danish = new Language("da", "Dansk");
|
|
||||||
public static Language German = new Language("de", "Deutsch");
|
public static Language French { get; set; } = new Language("fr", "Français");
|
||||||
public static Language Korean = new Language("ko", "한국어");
|
|
||||||
public static Language Serbian = new Language("sr", "Srpski");
|
public static Language Japanese { get; set; } = new Language("ja", "日本語");
|
||||||
public static Language Portuguese_BR = new Language("pt-br", "Português (Brasil)");
|
|
||||||
public static Language Italian = new Language("it", "Italiano");
|
public static Language Dutch { get; set; } = new Language("nl", "Dutch");
|
||||||
public static Language Norwegian_Bokmal = new Language("nb-NO", "Norsk Bokmål");
|
|
||||||
public static Language Slovak = new Language("sk", "Slovenský");
|
public static Language Polish { get; set; } = new Language("pl", "Polski");
|
||||||
public static Language Turkish = new Language("tr", "Türkçe");
|
|
||||||
|
public static Language Danish { get; set; } = new Language("da", "Dansk");
|
||||||
|
|
||||||
|
public static Language German { get; set; } = new Language("de", "Deutsch");
|
||||||
|
|
||||||
|
public static Language Korean { get; set; } = new Language("ko", "한국어");
|
||||||
|
|
||||||
|
public static Language Serbian { get; set; } = new Language("sr", "Srpski");
|
||||||
|
|
||||||
|
public static Language Portuguese_BR { get; set; } = new Language("pt-br", "Português (Brasil)");
|
||||||
|
|
||||||
|
public static Language Italian { get; set; } = new Language("it", "Italiano");
|
||||||
|
|
||||||
|
public static Language Norwegian_Bokmal { get; set; } = new Language("nb-NO", "Norsk Bokmål");
|
||||||
|
|
||||||
|
public static Language Slovak { get; set; } = new Language("sk", "Slovenský");
|
||||||
|
|
||||||
|
public static Language Turkish { get; set; } = new Language("tr", "Türkçe");
|
||||||
|
|
||||||
public static List<Language> GetAvailableLanguages()
|
public static List<Language> GetAvailableLanguages()
|
||||||
{
|
{
|
||||||
@@ -48,7 +65,7 @@ namespace Wox.Core.Resource
|
|||||||
Italian,
|
Italian,
|
||||||
Norwegian_Bokmal,
|
Norwegian_Bokmal,
|
||||||
Slovak,
|
Slovak,
|
||||||
Turkish
|
Turkish,
|
||||||
};
|
};
|
||||||
return languages;
|
return languages;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,15 +11,18 @@ namespace Wox.Core.Resource
|
|||||||
{
|
{
|
||||||
public static class FontHelper
|
public static class FontHelper
|
||||||
{
|
{
|
||||||
static FontWeightConverter fontWeightConverter = new FontWeightConverter();
|
private static readonly FontWeightConverter _fontWeightConverter = new FontWeightConverter();
|
||||||
|
|
||||||
public static FontWeight GetFontWeightFromInvariantStringOrNormal(string value)
|
public static FontWeight GetFontWeightFromInvariantStringOrNormal(string value)
|
||||||
{
|
{
|
||||||
if (value == null) return FontWeights.Normal;
|
if (value == null)
|
||||||
|
{
|
||||||
|
return FontWeights.Normal;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return (FontWeight)fontWeightConverter.ConvertFromInvariantString(value);
|
return (FontWeight)_fontWeightConverter.ConvertFromInvariantString(value);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -27,15 +30,18 @@ namespace Wox.Core.Resource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static FontStyleConverter fontStyleConverter = new FontStyleConverter();
|
private static readonly FontStyleConverter _fontStyleConverter = new FontStyleConverter();
|
||||||
|
|
||||||
public static FontStyle GetFontStyleFromInvariantStringOrNormal(string value)
|
public static FontStyle GetFontStyleFromInvariantStringOrNormal(string value)
|
||||||
{
|
{
|
||||||
if (value == null) return FontStyles.Normal;
|
if (value == null)
|
||||||
|
{
|
||||||
|
return FontStyles.Normal;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return (FontStyle)fontStyleConverter.ConvertFromInvariantString(value);
|
return (FontStyle)_fontStyleConverter.ConvertFromInvariantString(value);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -43,14 +49,18 @@ namespace Wox.Core.Resource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static FontStretchConverter fontStretchConverter = new FontStretchConverter();
|
private static readonly FontStretchConverter _fontStretchConverter = new FontStretchConverter();
|
||||||
|
|
||||||
public static FontStretch GetFontStretchFromInvariantStringOrNormal(string value)
|
public static FontStretch GetFontStretchFromInvariantStringOrNormal(string value)
|
||||||
{
|
{
|
||||||
if (value == null) return FontStretches.Normal;
|
if (value == null)
|
||||||
|
{
|
||||||
|
return FontStretches.Normal;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return (FontStretch)fontStretchConverter.ConvertFromInvariantString(value);
|
return (FontStretch)_fontStretchConverter.ConvertFromInvariantString(value);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -62,9 +72,9 @@ namespace Wox.Core.Resource
|
|||||||
{
|
{
|
||||||
return family.FamilyTypefaces.OrderBy(o =>
|
return family.FamilyTypefaces.OrderBy(o =>
|
||||||
{
|
{
|
||||||
return Math.Abs(o.Stretch.ToOpenTypeStretch() - FontStretches.Normal.ToOpenTypeStretch()) * 100 +
|
return (Math.Abs(o.Stretch.ToOpenTypeStretch() - FontStretches.Normal.ToOpenTypeStretch()) * 100) +
|
||||||
Math.Abs(o.Weight.ToOpenTypeWeight() - FontWeights.Normal.ToOpenTypeWeight()) +
|
Math.Abs(o.Weight.ToOpenTypeWeight() - FontWeights.Normal.ToOpenTypeWeight()) +
|
||||||
(o.Style == FontStyles.Normal ? 0 : o.Style == FontStyles.Oblique ? 1 : 2) * 1000;
|
((o.Style == FontStyles.Normal ? 0 : o.Style == FontStyles.Oblique ? 1 : 2) * 1000);
|
||||||
}).FirstOrDefault() ?? family.FamilyTypefaces.FirstOrDefault();
|
}).FirstOrDefault() ?? family.FamilyTypefaces.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,13 +108,19 @@ namespace Wox.Core.Resource
|
|||||||
var languageToSet = GetLanguageByLanguageCode(languageCodeToSet);
|
var languageToSet = GetLanguageByLanguageCode(languageCodeToSet);
|
||||||
|
|
||||||
if (Settings.ShouldUsePinyin)
|
if (Settings.ShouldUsePinyin)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (languageToSet != AvailableLanguages.Chinese && languageToSet != AvailableLanguages.Chinese_TW)
|
if (languageToSet != AvailableLanguages.Chinese && languageToSet != AvailableLanguages.Chinese_TW)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (MessageBox.Show("Do you want to turn on search with Pinyin?", string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
|
if (MessageBox.Show("Do you want to turn on search with Pinyin?", string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -143,7 +149,7 @@ namespace Wox.Core.Resource
|
|||||||
{
|
{
|
||||||
var r = new ResourceDictionary
|
var r = new ResourceDictionary
|
||||||
{
|
{
|
||||||
Source = new Uri(f, UriKind.Absolute)
|
Source = new Uri(f, UriKind.Absolute),
|
||||||
};
|
};
|
||||||
dicts.Add(r);
|
dicts.Add(r);
|
||||||
_oldResources.Add(r);
|
_oldResources.Add(r);
|
||||||
@@ -174,8 +180,11 @@ namespace Wox.Core.Resource
|
|||||||
{
|
{
|
||||||
foreach (var p in PluginManager.GetPluginsForInterface<IPluginI18n>())
|
foreach (var p in PluginManager.GetPluginsForInterface<IPluginI18n>())
|
||||||
{
|
{
|
||||||
var pluginI18N = p.Plugin as IPluginI18n;
|
if (!(p.Plugin is IPluginI18n pluginI18N))
|
||||||
if (pluginI18N == null) return;
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
p.Metadata.Name = pluginI18N.GetTranslatedPluginTitle();
|
p.Metadata.Name = pluginI18N.GetTranslatedPluginTitle();
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
<ProjectReference Include="..\Wox.Infrastructure\Wox.Infrastructure.csproj" />
|
<ProjectReference Include="..\Wox.Infrastructure\Wox.Infrastructure.csproj" />
|
||||||
<ProjectReference Include="..\Wox.Plugin\Wox.Plugin.csproj" />
|
<ProjectReference Include="..\Wox.Plugin\Wox.Plugin.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!--<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\..\..\codeAnalysis\GlobalSuppressions.cs">
|
<Compile Include="..\..\..\codeAnalysis\GlobalSuppressions.cs">
|
||||||
<Link>GlobalSuppressions.cs</Link>
|
<Link>GlobalSuppressions.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -81,5 +81,5 @@
|
|||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>-->
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user