mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +02:00
Merge branch 'master' into dev/crutkas/upgradeNuget
This commit is contained in:
@@ -6,13 +6,15 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Microsoft.Win32;
|
||||
using Wox.Plugin;
|
||||
using Wox.Plugin.Logger;
|
||||
|
||||
namespace Wox.Infrastructure.Exception
|
||||
{
|
||||
public class ExceptionFormatter
|
||||
public static class ExceptionFormatter
|
||||
{
|
||||
public static string FormatException(System.Exception exception)
|
||||
{
|
||||
@@ -68,6 +70,8 @@ namespace Wox.Infrastructure.Exception
|
||||
|
||||
sb.AppendLine("## Environment");
|
||||
sb.AppendLine($"* Command Line: {Environment.CommandLine}");
|
||||
|
||||
// Using InvariantCulture since this is internal
|
||||
sb.AppendLine($"* Timestamp: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}");
|
||||
sb.AppendLine($"* Wox version: {Constant.Version}");
|
||||
sb.AppendLine($"* OS Version: {Environment.OSVersion.VersionString}");
|
||||
@@ -110,6 +114,7 @@ namespace Wox.Infrastructure.Exception
|
||||
}
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/hh925568%28v=vs.110%29.aspx
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Suppressing this to enable FxCop. We are logging the exception, and going forward general exceptions should not be caught")]
|
||||
private static List<string> GetFrameworkVersionFromRegistry()
|
||||
{
|
||||
try
|
||||
@@ -119,25 +124,28 @@ namespace Wox.Infrastructure.Exception
|
||||
{
|
||||
foreach (string versionKeyName in ndpKey.GetSubKeyNames())
|
||||
{
|
||||
if (versionKeyName.StartsWith("v"))
|
||||
// Using InvariantCulture since this is internal and involves version key
|
||||
if (versionKeyName.StartsWith("v", StringComparison.InvariantCulture))
|
||||
{
|
||||
RegistryKey versionKey = ndpKey.OpenSubKey(versionKeyName);
|
||||
string name = (string)versionKey.GetValue("Version", string.Empty);
|
||||
string sp = versionKey.GetValue("SP", string.Empty).ToString();
|
||||
string install = versionKey.GetValue("Install", string.Empty).ToString();
|
||||
if (install != string.Empty)
|
||||
if (!string.IsNullOrEmpty(install))
|
||||
{
|
||||
if (sp != string.Empty && install == "1")
|
||||
if (!string.IsNullOrEmpty(sp) && install == "1")
|
||||
{
|
||||
result.Add(string.Format("{0} {1} SP{2}", versionKeyName, name, sp));
|
||||
// Using InvariantCulture since this is internal
|
||||
result.Add(string.Format(CultureInfo.InvariantCulture, "{0} {1} SP{2}", versionKeyName, name, sp));
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Add(string.Format("{0} {1}", versionKeyName, name));
|
||||
// Using InvariantCulture since this is internal
|
||||
result.Add(string.Format(CultureInfo.InvariantCulture, "{0} {1}", versionKeyName, name));
|
||||
}
|
||||
}
|
||||
|
||||
if (name != string.Empty)
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -146,21 +154,23 @@ namespace Wox.Infrastructure.Exception
|
||||
{
|
||||
RegistryKey subKey = versionKey.OpenSubKey(subKeyName);
|
||||
name = (string)subKey.GetValue("Version", string.Empty);
|
||||
if (name != string.Empty)
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
sp = subKey.GetValue("SP", string.Empty).ToString();
|
||||
}
|
||||
|
||||
install = subKey.GetValue("Install", string.Empty).ToString();
|
||||
if (install != string.Empty)
|
||||
if (!string.IsNullOrEmpty(install))
|
||||
{
|
||||
if (sp != string.Empty && install == "1")
|
||||
if (!string.IsNullOrEmpty(sp) && install == "1")
|
||||
{
|
||||
result.Add(string.Format("{0} {1} {2} SP{3}", versionKeyName, subKeyName, name, sp));
|
||||
// Using InvariantCulture since this is internal
|
||||
result.Add(string.Format(CultureInfo.InvariantCulture, "{0} {1} {2} SP{3}", versionKeyName, subKeyName, name, sp));
|
||||
}
|
||||
else if (install == "1")
|
||||
{
|
||||
result.Add(string.Format("{0} {1} {2}", versionKeyName, subKeyName, name));
|
||||
// Using InvariantCulture since this is internal
|
||||
result.Add(string.Format(CultureInfo.InvariantCulture, "{0} {1} {2}", versionKeyName, subKeyName, name));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,8 +201,9 @@ namespace Wox.Infrastructure.Exception
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (System.Exception)
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Log.Exception("Could not get framework version from registry", e, MethodBase.GetCurrentMethod().DeclaringType);
|
||||
return new List<string>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,18 +4,27 @@
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
|
||||
namespace Wox.Infrastructure.FileSystemHelper
|
||||
{
|
||||
public class FileVersionInfoWrapper : IFileVersionInfoWrapper
|
||||
{
|
||||
private readonly IFile _file;
|
||||
|
||||
public FileVersionInfoWrapper()
|
||||
: this(new FileSystem().File)
|
||||
{
|
||||
}
|
||||
|
||||
public FileVersionInfoWrapper(IFile file)
|
||||
{
|
||||
_file = file;
|
||||
}
|
||||
|
||||
public FileVersionInfo GetVersionInfo(string path)
|
||||
{
|
||||
if (File.Exists(path))
|
||||
if (_file.Exists(path))
|
||||
{
|
||||
return FileVersionInfo.GetVersionInfo(path);
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security;
|
||||
using Wox.Plugin.Logger;
|
||||
|
||||
namespace Wox.Infrastructure.FileSystemHelper
|
||||
{
|
||||
public class FileWrapper : IFileWrapper
|
||||
{
|
||||
public FileWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
public string[] ReadAllLines(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
return File.ReadAllLines(path);
|
||||
}
|
||||
catch (System.Exception ex) when (ex is SecurityException || ex is UnauthorizedAccessException || ex is IOException)
|
||||
{
|
||||
Log.Info($"Unable to read File: {path}| {ex.Message}", GetType());
|
||||
|
||||
return new string[] { string.Empty };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
// 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.
|
||||
|
||||
namespace Wox.Infrastructure.FileSystemHelper
|
||||
{
|
||||
public interface IFileWrapper
|
||||
{
|
||||
string[] ReadAllLines(string path);
|
||||
}
|
||||
}
|
||||
@@ -20,11 +20,21 @@ namespace Wox.Infrastructure
|
||||
|
||||
public static FuzzyMatcher Create(string query)
|
||||
{
|
||||
if (query == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(query));
|
||||
}
|
||||
|
||||
return new FuzzyMatcher(query, new MatchOption());
|
||||
}
|
||||
|
||||
public static FuzzyMatcher Create(string query, MatchOption opt)
|
||||
{
|
||||
if (query == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(query));
|
||||
}
|
||||
|
||||
return new FuzzyMatcher(query, opt);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
@@ -14,6 +14,12 @@ namespace Wox.Infrastructure
|
||||
{
|
||||
public static class Helper
|
||||
{
|
||||
private static readonly IFileSystem FileSystem = new FileSystem();
|
||||
private static readonly IPath Path = FileSystem.Path;
|
||||
private static readonly IFile File = FileSystem.File;
|
||||
private static readonly IFileInfoFactory FileInfo = FileSystem.FileInfo;
|
||||
private static readonly IDirectory Directory = FileSystem.Directory;
|
||||
|
||||
/// <summary>
|
||||
/// http://www.yinwang.org/blog-cn/2015/11/21/programming-philosophy
|
||||
/// </summary>
|
||||
@@ -54,8 +60,8 @@ namespace Wox.Infrastructure
|
||||
}
|
||||
else
|
||||
{
|
||||
var time1 = new FileInfo(bundledDataPath).LastWriteTimeUtc;
|
||||
var time2 = new FileInfo(dataPath).LastWriteTimeUtc;
|
||||
var time1 = FileInfo.FromFileName(bundledDataPath).LastWriteTimeUtc;
|
||||
var time2 = FileInfo.FromFileName(dataPath).LastWriteTimeUtc;
|
||||
if (time1 != time2)
|
||||
{
|
||||
File.Copy(bundledDataPath, dataPath, true);
|
||||
@@ -80,6 +86,7 @@ namespace Wox.Infrastructure
|
||||
}
|
||||
|
||||
// Function to run as admin for context menu items
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Suppressing this to enable FxCop. We are logging the exception, and going forward general exceptions should not be caught")]
|
||||
public static void RunAsAdmin(string path)
|
||||
{
|
||||
var info = new ProcessStartInfo
|
||||
|
||||
@@ -82,7 +82,8 @@ namespace Wox.Infrastructure.Hotkey
|
||||
return;
|
||||
}
|
||||
|
||||
List<string> keys = hotkeyString.Replace(" ", string.Empty).Split('+').ToList();
|
||||
// Using InvariantCulture since this is internal and involves key codes
|
||||
List<string> keys = hotkeyString.Replace(" ", string.Empty, StringComparison.InvariantCulture).Split('+').ToList();
|
||||
if (keys.Contains("Alt"))
|
||||
{
|
||||
Alt = true;
|
||||
|
||||
@@ -9,21 +9,21 @@ namespace Wox.Infrastructure.Hotkey
|
||||
/// <summary>
|
||||
/// Key down
|
||||
/// </summary>
|
||||
WM_KEYDOWN = 256,
|
||||
WMKEYDOWN = 256,
|
||||
|
||||
/// <summary>
|
||||
/// Key up
|
||||
/// </summary>
|
||||
WM_KEYUP = 257,
|
||||
WMKEYUP = 257,
|
||||
|
||||
/// <summary>
|
||||
/// System key up
|
||||
/// </summary>
|
||||
WM_SYSKEYUP = 261,
|
||||
WMSYSKEYUP = 261,
|
||||
|
||||
/// <summary>
|
||||
/// System key down
|
||||
/// </summary>
|
||||
WM_SYSKEYDOWN = 260,
|
||||
WMSYSKEYDOWN = 260,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
// 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.
|
||||
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using Wox.Infrastructure.UserSettings;
|
||||
using Wox.Plugin.Logger;
|
||||
|
||||
namespace Wox.Infrastructure.Http
|
||||
{
|
||||
public static class Http
|
||||
{
|
||||
private const string UserAgent = @"Mozilla/5.0 (Trident/7.0; rv:11.0) like Gecko";
|
||||
|
||||
static Http()
|
||||
{
|
||||
// need to be added so it would work on a win10 machine
|
||||
ServicePointManager.Expect100Continue = true;
|
||||
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls
|
||||
| SecurityProtocolType.Tls11
|
||||
| SecurityProtocolType.Tls12;
|
||||
}
|
||||
|
||||
public static HttpProxy Proxy { private get; set; }
|
||||
|
||||
public static IWebProxy WebProxy()
|
||||
{
|
||||
if (Proxy != null && Proxy.Enabled && !string.IsNullOrEmpty(Proxy.Server))
|
||||
{
|
||||
if (string.IsNullOrEmpty(Proxy.UserName) || string.IsNullOrEmpty(Proxy.Password))
|
||||
{
|
||||
var webProxy = new WebProxy(Proxy.Server, Proxy.Port);
|
||||
return webProxy;
|
||||
}
|
||||
else
|
||||
{
|
||||
var webProxy = new WebProxy(Proxy.Server, Proxy.Port)
|
||||
{
|
||||
Credentials = new NetworkCredential(Proxy.UserName, Proxy.Password),
|
||||
};
|
||||
return webProxy;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return WebRequest.GetSystemWebProxy();
|
||||
}
|
||||
}
|
||||
|
||||
public static void Download([NotNull] string url, [NotNull] string filePath)
|
||||
{
|
||||
var client = new WebClient { Proxy = WebProxy() };
|
||||
client.Headers.Add("user-agent", UserAgent);
|
||||
client.DownloadFile(url, filePath);
|
||||
}
|
||||
|
||||
public static async Task<string> Get([NotNull] string url, string encoding = "UTF-8")
|
||||
{
|
||||
Log.Debug($"Url <{url}>", MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
var request = WebRequest.CreateHttp(url);
|
||||
request.Method = "GET";
|
||||
request.Timeout = 1000;
|
||||
request.Proxy = WebProxy();
|
||||
request.UserAgent = UserAgent;
|
||||
var response = await request.GetResponseAsync() as HttpWebResponse;
|
||||
response = response.NonNull();
|
||||
var stream = response.GetResponseStream().NonNull();
|
||||
|
||||
using (var reader = new StreamReader(stream, Encoding.GetEncoding(encoding)))
|
||||
{
|
||||
var content = await reader.ReadToEndAsync();
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
return content;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new HttpRequestException($"Error code <{response.StatusCode}> with content <{content}> returned from <{url}>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
61
src/modules/launcher/Wox.Infrastructure/Http/HttpClient.cs
Normal file
61
src/modules/launcher/Wox.Infrastructure/Http/HttpClient.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using Wox.Infrastructure.UserSettings;
|
||||
using Wox.Plugin.Logger;
|
||||
|
||||
namespace Wox.Infrastructure.Http
|
||||
{
|
||||
public static class HttpClient
|
||||
{
|
||||
private const string UserAgent = @"Mozilla/5.0 (Trident/7.0; rv:11.0) like Gecko";
|
||||
|
||||
public static HttpProxy Proxy { get; set; }
|
||||
|
||||
public static IWebProxy WebProxy()
|
||||
{
|
||||
if (Proxy != null && Proxy.Enabled && !string.IsNullOrEmpty(Proxy.Server))
|
||||
{
|
||||
if (string.IsNullOrEmpty(Proxy.UserName) || string.IsNullOrEmpty(Proxy.Password))
|
||||
{
|
||||
var webProxy = new WebProxy(Proxy.Server, Proxy.Port);
|
||||
return webProxy;
|
||||
}
|
||||
else
|
||||
{
|
||||
var webProxy = new WebProxy(Proxy.Server, Proxy.Port)
|
||||
{
|
||||
Credentials = new NetworkCredential(Proxy.UserName, Proxy.Password),
|
||||
};
|
||||
return webProxy;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return WebRequest.GetSystemWebProxy();
|
||||
}
|
||||
}
|
||||
|
||||
public static void Download([NotNull] Uri url, [NotNull] string filePath)
|
||||
{
|
||||
if (url == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(url));
|
||||
}
|
||||
|
||||
var client = new WebClient { Proxy = WebProxy() };
|
||||
client.Headers.Add("user-agent", UserAgent);
|
||||
client.DownloadFile(url.AbsoluteUri, filePath);
|
||||
client.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
41
src/modules/launcher/Wox.Infrastructure/Image/IShellItem.cs
Normal file
41
src/modules/launcher/Wox.Infrastructure/Image/IShellItem.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Wox.Infrastructure.Image
|
||||
{
|
||||
internal enum SIGDN : uint
|
||||
{
|
||||
NORMALDISPLAY = 0,
|
||||
PARENTRELATIVEPARSING = 0x80018001,
|
||||
PARENTRELATIVEFORADDRESSBAR = 0x8001c001,
|
||||
DESKTOPABSOLUTEPARSING = 0x80028000,
|
||||
PARENTRELATIVEEDITING = 0x80031001,
|
||||
DESKTOPABSOLUTEEDITING = 0x8004c000,
|
||||
FILESYSPATH = 0x80058000,
|
||||
URL = 0x80068000,
|
||||
}
|
||||
|
||||
[ComImport]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
[Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe")]
|
||||
internal interface IShellItem
|
||||
{
|
||||
void BindToHandler(
|
||||
IntPtr pbc,
|
||||
[MarshalAs(UnmanagedType.LPStruct)] Guid bhid,
|
||||
[MarshalAs(UnmanagedType.LPStruct)] Guid riid,
|
||||
out IntPtr ppv);
|
||||
|
||||
void GetParent(out IShellItem ppsi);
|
||||
|
||||
void GetDisplayName(SIGDN sigdnName, out IntPtr ppszName);
|
||||
|
||||
void GetAttributes(uint sfgaoMask, out uint psfgaoAttribs);
|
||||
|
||||
void Compare(IShellItem psi, uint hint, out int piOrder);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ namespace Wox.Infrastructure.Image
|
||||
|
||||
private readonly ConcurrentDictionary<string, ImageSource> _data = new ConcurrentDictionary<string, ImageSource>();
|
||||
|
||||
public ConcurrentDictionary<string, int> Usage { get; set; } = new ConcurrentDictionary<string, int>();
|
||||
public ConcurrentDictionary<string, int> Usage { get; private set; } = new ConcurrentDictionary<string, int>();
|
||||
|
||||
public ImageSource this[string path]
|
||||
{
|
||||
@@ -44,7 +44,8 @@ namespace Wox.Infrastructure.Image
|
||||
// To delete the images from the data dictionary based on the resizing of the Usage Dictionary.
|
||||
foreach (var key in _data.Keys)
|
||||
{
|
||||
if (!Usage.TryGetValue(key, out _) && !(key.Equals(Constant.ErrorIcon) || key.Equals(Constant.DefaultIcon) || key.Equals(Constant.LightThemedErrorIcon) || key.Equals(Constant.LightThemedDefaultIcon)))
|
||||
// Using Ordinal since this is internal
|
||||
if (!Usage.TryGetValue(key, out _) && !(key.Equals(Constant.ErrorIcon, StringComparison.Ordinal) || key.Equals(Constant.DefaultIcon, StringComparison.Ordinal) || key.Equals(Constant.LightThemedErrorIcon, StringComparison.Ordinal) || key.Equals(Constant.LightThemedDefaultIcon, StringComparison.Ordinal)))
|
||||
{
|
||||
_data.TryRemove(key, out _);
|
||||
}
|
||||
|
||||
@@ -4,14 +4,18 @@
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Wox.Plugin.Logger;
|
||||
|
||||
namespace Wox.Infrastructure.Image
|
||||
{
|
||||
public class ImageHashGenerator : IImageHashGenerator
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Suppressing this to enable FxCop. We are logging the exception, and going forward general exceptions should not be caught")]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Security", "CA5350:Do Not Use Weak Cryptographic Algorithms", Justification = "Level of protection needed for the image data does not require a security guarantee")]
|
||||
public string GetHashFromImage(ImageSource imageSource)
|
||||
{
|
||||
if (!(imageSource is BitmapSource image))
|
||||
@@ -38,8 +42,9 @@ namespace Wox.Infrastructure.Image
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Log.Exception($"Failed to get hash from image", e, MethodBase.GetCurrentMethod().DeclaringType);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Globalization;
|
||||
using System.IO.Abstractions;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
@@ -20,6 +21,11 @@ namespace Wox.Infrastructure.Image
|
||||
{
|
||||
public static class ImageLoader
|
||||
{
|
||||
private static readonly IFileSystem FileSystem = new FileSystem();
|
||||
private static readonly IPath Path = FileSystem.Path;
|
||||
private static readonly IFile File = FileSystem.File;
|
||||
private static readonly IDirectory Directory = FileSystem.Directory;
|
||||
|
||||
private static readonly ImageCache ImageCache = new ImageCache();
|
||||
private static readonly ConcurrentDictionary<string, string> GuidToKey = new ConcurrentDictionary<string, string>();
|
||||
|
||||
@@ -113,6 +119,7 @@ namespace Wox.Infrastructure.Image
|
||||
Cache,
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Suppressing this to enable FxCop. We are logging the exception, and going forward general exceptions should not be caught")]
|
||||
private static ImageResult LoadInternal(string path, bool loadFullImage = false)
|
||||
{
|
||||
ImageSource image;
|
||||
@@ -129,6 +136,7 @@ namespace Wox.Infrastructure.Image
|
||||
return new ImageResult(ImageCache[path], ImageType.Cache);
|
||||
}
|
||||
|
||||
// Using OrdinalIgnoreCase since this is internal and used with paths
|
||||
if (path.StartsWith("data:", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var imageSource = new BitmapImage(new Uri(path));
|
||||
@@ -154,7 +162,10 @@ namespace Wox.Infrastructure.Image
|
||||
}
|
||||
else if (File.Exists(path))
|
||||
{
|
||||
var extension = Path.GetExtension(path).ToLower();
|
||||
#pragma warning disable CA1308 // Normalize strings to uppercase. Reason: extension is used with the enum ImageExtensions, which contains all lowercase values
|
||||
// Using InvariantCulture since this is internal
|
||||
var extension = Path.GetExtension(path).ToLower(CultureInfo.InvariantCulture);
|
||||
#pragma warning restore CA1308 // Normalize strings to uppercase
|
||||
if (ImageExtensions.Contains(extension))
|
||||
{
|
||||
type = ImageType.ImageFile;
|
||||
@@ -200,7 +211,7 @@ namespace Wox.Infrastructure.Image
|
||||
return new ImageResult(image, type);
|
||||
}
|
||||
|
||||
private static readonly bool _enableImageHash = true;
|
||||
private const bool _enableImageHash = true;
|
||||
|
||||
public static ImageSource Load(string path, bool loadFullImage = false)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Wox.Infrastructure.Image
|
||||
{
|
||||
internal static class NativeMethods
|
||||
{
|
||||
[DllImport("shell32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
internal static extern int SHCreateItemFromParsingName(
|
||||
[MarshalAs(UnmanagedType.LPWStr)] string path,
|
||||
IntPtr pbc,
|
||||
ref Guid riid,
|
||||
[MarshalAs(UnmanagedType.Interface)] out IShellItem shellItem);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool DeleteObject(IntPtr hObject);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
@@ -22,54 +22,14 @@ namespace Wox.Infrastructure.Image
|
||||
InCacheOnly = 0x10,
|
||||
}
|
||||
|
||||
public class WindowsThumbnailProvider
|
||||
public static class WindowsThumbnailProvider
|
||||
{
|
||||
private static readonly IFileSystem FileSystem = new FileSystem();
|
||||
private static readonly IPath Path = FileSystem.Path;
|
||||
|
||||
// Based on https://stackoverflow.com/questions/21751747/extract-thumbnail-for-any-file-in-windows
|
||||
private const string IShellItem2Guid = "7E9FB0D3-919F-4307-AB2E-9B1860310C93";
|
||||
|
||||
[DllImport("shell32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
internal static extern int SHCreateItemFromParsingName(
|
||||
[MarshalAs(UnmanagedType.LPWStr)] string path,
|
||||
IntPtr pbc,
|
||||
ref Guid riid,
|
||||
[MarshalAs(UnmanagedType.Interface)] out IShellItem shellItem);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool DeleteObject(IntPtr hObject);
|
||||
|
||||
[ComImport]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
[Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe")]
|
||||
internal interface IShellItem
|
||||
{
|
||||
void BindToHandler(
|
||||
IntPtr pbc,
|
||||
[MarshalAs(UnmanagedType.LPStruct)] Guid bhid,
|
||||
[MarshalAs(UnmanagedType.LPStruct)] Guid riid,
|
||||
out IntPtr ppv);
|
||||
|
||||
void GetParent(out IShellItem ppsi);
|
||||
|
||||
void GetDisplayName(SIGDN sigdnName, out IntPtr ppszName);
|
||||
|
||||
void GetAttributes(uint sfgaoMask, out uint psfgaoAttribs);
|
||||
|
||||
void Compare(IShellItem psi, uint hint, out int piOrder);
|
||||
}
|
||||
|
||||
internal enum SIGDN : uint
|
||||
{
|
||||
NORMALDISPLAY = 0,
|
||||
PARENTRELATIVEPARSING = 0x80018001,
|
||||
PARENTRELATIVEFORADDRESSBAR = 0x8001c001,
|
||||
DESKTOPABSOLUTEPARSING = 0x80028000,
|
||||
PARENTRELATIVEEDITING = 0x80031001,
|
||||
DESKTOPABSOLUTEEDITING = 0x8004c000,
|
||||
FILESYSPATH = 0x80058000,
|
||||
URL = 0x80068000,
|
||||
}
|
||||
|
||||
internal enum HResult
|
||||
{
|
||||
Ok = 0x0000,
|
||||
@@ -128,14 +88,14 @@ namespace Wox.Infrastructure.Image
|
||||
finally
|
||||
{
|
||||
// delete HBitmap to avoid memory leaks
|
||||
DeleteObject(hBitmap);
|
||||
NativeMethods.DeleteObject(hBitmap);
|
||||
}
|
||||
}
|
||||
|
||||
private static IntPtr GetHBitmap(string fileName, int width, int height, ThumbnailOptions options)
|
||||
{
|
||||
Guid shellItem2Guid = new Guid(IShellItem2Guid);
|
||||
int retCode = SHCreateItemFromParsingName(fileName, IntPtr.Zero, ref shellItem2Guid, out IShellItem nativeShellItem);
|
||||
int retCode = NativeMethods.SHCreateItemFromParsingName(fileName, IntPtr.Zero, ref shellItem2Guid, out IShellItem nativeShellItem);
|
||||
|
||||
if (retCode != 0)
|
||||
{
|
||||
|
||||
@@ -53,9 +53,9 @@ namespace Wox.Infrastructure
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets matched data to highlight.
|
||||
/// Gets matched data to highlight.
|
||||
/// </summary>
|
||||
public List<int> MatchData { get; set; }
|
||||
public List<int> MatchData { get; private set; }
|
||||
|
||||
public SearchPrecisionScore SearchPrecision { get; set; }
|
||||
|
||||
|
||||
@@ -19,6 +19,11 @@ namespace Wox.Infrastructure
|
||||
/// </summary>
|
||||
public static long Debug(string message, Action action)
|
||||
{
|
||||
if (action == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(action));
|
||||
}
|
||||
|
||||
var stopWatch = new System.Diagnostics.Stopwatch();
|
||||
stopWatch.Start();
|
||||
action();
|
||||
@@ -31,6 +36,11 @@ namespace Wox.Infrastructure
|
||||
|
||||
public static long Normal(string message, Action action)
|
||||
{
|
||||
if (action == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(action));
|
||||
}
|
||||
|
||||
var stopWatch = new System.Diagnostics.Stopwatch();
|
||||
stopWatch.Start();
|
||||
action();
|
||||
@@ -43,6 +53,11 @@ namespace Wox.Infrastructure
|
||||
|
||||
public static void StartCount(string name, Action action)
|
||||
{
|
||||
if (action == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(action));
|
||||
}
|
||||
|
||||
var stopWatch = new System.Diagnostics.Stopwatch();
|
||||
stopWatch.Start();
|
||||
action();
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters;
|
||||
@@ -19,18 +20,28 @@ namespace Wox.Infrastructure.Storage
|
||||
/// </summary>
|
||||
public class BinaryStorage<T> : IStorage<T>
|
||||
{
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
// This storage helper returns whether or not to delete the binary storage items
|
||||
private static readonly int _binaryStorage = 0;
|
||||
private const int _binaryStorage = 0;
|
||||
private StoragePowerToysVersionInfo _storageHelper;
|
||||
|
||||
public BinaryStorage(string filename)
|
||||
: this(filename, new FileSystem())
|
||||
{
|
||||
}
|
||||
|
||||
public BinaryStorage(string filename, IFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
|
||||
const string directoryName = "Cache";
|
||||
var directoryPath = Path.Combine(Constant.DataDirectory, directoryName);
|
||||
var path = _fileSystem.Path;
|
||||
var directoryPath = path.Combine(Constant.DataDirectory, directoryName);
|
||||
Helper.ValidateDirectory(directoryPath);
|
||||
|
||||
const string fileSuffix = ".cache";
|
||||
FilePath = Path.Combine(directoryPath, $"{filename}{fileSuffix}");
|
||||
FilePath = path.Combine(directoryPath, $"{filename}{fileSuffix}");
|
||||
}
|
||||
|
||||
public string FilePath { get; }
|
||||
@@ -42,17 +53,17 @@ namespace Wox.Infrastructure.Storage
|
||||
// Depending on the version number of the previously installed PT Run, delete the cache if it is found to be incompatible
|
||||
if (_storageHelper.ClearCache)
|
||||
{
|
||||
if (File.Exists(FilePath))
|
||||
if (_fileSystem.File.Exists(FilePath))
|
||||
{
|
||||
File.Delete(FilePath);
|
||||
_fileSystem.File.Delete(FilePath);
|
||||
|
||||
Log.Info($"Deleting cached data at <{FilePath}>", GetType());
|
||||
}
|
||||
}
|
||||
|
||||
if (File.Exists(FilePath))
|
||||
if (_fileSystem.File.Exists(FilePath))
|
||||
{
|
||||
if (new FileInfo(FilePath).Length == 0)
|
||||
if (_fileSystem.FileInfo.FromFileName(FilePath).Length == 0)
|
||||
{
|
||||
Log.Error($"Zero length cache file <{FilePath}>", GetType());
|
||||
|
||||
@@ -60,7 +71,7 @@ namespace Wox.Infrastructure.Storage
|
||||
return defaultData;
|
||||
}
|
||||
|
||||
using (var stream = new FileStream(FilePath, FileMode.Open))
|
||||
using (var stream = _fileSystem.FileStream.Create(FilePath, FileMode.Open))
|
||||
{
|
||||
var d = Deserialize(stream, defaultData);
|
||||
return d;
|
||||
@@ -75,7 +86,8 @@ namespace Wox.Infrastructure.Storage
|
||||
}
|
||||
}
|
||||
|
||||
private T Deserialize(FileStream stream, T defaultData)
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Suppressing this to enable FxCop. We are logging the exception, and going forward general exceptions should not be caught")]
|
||||
private T Deserialize(Stream stream, T defaultData)
|
||||
{
|
||||
// http://stackoverflow.com/questions/2120055/binaryformatter-deserialize-gives-serializationexception
|
||||
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.IO;
|
||||
namespace Wox.Infrastructure.Storage
|
||||
{
|
||||
// File System Watcher Wrapper class which implements the IFileSystemWatcherWrapper interface
|
||||
public class FileSystemWatcherWrapper : FileSystemWatcher, IFileSystemWatcherWrapper
|
||||
public sealed class FileSystemWatcherWrapper : FileSystemWatcher, IFileSystemWatcherWrapper
|
||||
{
|
||||
public FileSystemWatcherWrapper()
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace Wox.Infrastructure.Storage
|
||||
event RenamedEventHandler Renamed;
|
||||
|
||||
// Properties of File System watcher
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2227:Collection properties should be read only", Justification = "Abstract properties can not have private set")]
|
||||
Collection<string> Filters { get; set; }
|
||||
|
||||
bool EnableRaisingEvents { get; set; }
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Wox.Infrastructure.Storage
|
||||
|
||||
bool Contains(T item);
|
||||
|
||||
void Set(IList<T> list);
|
||||
void SetList(IList<T> list);
|
||||
|
||||
bool Any();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using Newtonsoft.Json;
|
||||
using Wox.Plugin.Logger;
|
||||
|
||||
@@ -15,6 +16,10 @@ namespace Wox.Infrastructure.Storage
|
||||
/// </summary>
|
||||
public class JsonStorage<T>
|
||||
{
|
||||
private static readonly IFileSystem FileSystem = new FileSystem();
|
||||
private static readonly IPath Path = FileSystem.Path;
|
||||
private static readonly IFile File = FileSystem.File;
|
||||
|
||||
private readonly JsonSerializerSettings _serializerSettings;
|
||||
private T _data;
|
||||
|
||||
@@ -27,7 +32,7 @@ namespace Wox.Infrastructure.Storage
|
||||
public string DirectoryPath { get; set; }
|
||||
|
||||
// This storage helper returns whether or not to delete the json storage items
|
||||
private static readonly int _jsonStorage = 1;
|
||||
private const int _jsonStorage = 1;
|
||||
private StoragePowerToysVersionInfo _storageHelper;
|
||||
|
||||
internal JsonStorage()
|
||||
@@ -106,7 +111,8 @@ namespace Wox.Infrastructure.Storage
|
||||
|
||||
private void BackupOriginFile()
|
||||
{
|
||||
var timestamp = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-fffffff", CultureInfo.CurrentUICulture);
|
||||
// Using InvariantCulture since this is internal
|
||||
var timestamp = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-fffffff", CultureInfo.InvariantCulture);
|
||||
var directory = Path.GetDirectoryName(FilePath).NonNull();
|
||||
var originName = Path.GetFileNameWithoutExtension(FilePath);
|
||||
var backupName = $"{originName}-{timestamp}{FileSuffix}";
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Wox.Infrastructure.Storage
|
||||
{
|
||||
}
|
||||
|
||||
public void Set(IList<T> items)
|
||||
public void SetList(IList<T> items)
|
||||
{
|
||||
// enforce that internal representation
|
||||
try
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Infrastructure.Storage
|
||||
@@ -10,6 +10,9 @@ namespace Wox.Infrastructure.Storage
|
||||
public class PluginJsonStorage<T> : JsonStorage<T>
|
||||
where T : new()
|
||||
{
|
||||
private static readonly IFileSystem FileSystem = new FileSystem();
|
||||
private static readonly IPath Path = FileSystem.Path;
|
||||
|
||||
public PluginJsonStorage()
|
||||
{
|
||||
// C# related, add python related below
|
||||
|
||||
@@ -3,14 +3,17 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
|
||||
namespace Wox.Infrastructure.Storage
|
||||
{
|
||||
public class StoragePowerToysVersionInfo
|
||||
{
|
||||
private static readonly IFileSystem FileSystem = new FileSystem();
|
||||
private static readonly IFile File = FileSystem.File;
|
||||
|
||||
// This detail is accessed by the storage items and is used to decide if the cache must be deleted or not
|
||||
public bool ClearCache { get; set; } = false;
|
||||
public bool ClearCache { get; set; }
|
||||
|
||||
private readonly string currentPowerToysVersion = string.Empty;
|
||||
|
||||
@@ -81,7 +84,7 @@ namespace Wox.Infrastructure.Storage
|
||||
}
|
||||
}
|
||||
|
||||
private string GetFilePath(string associatedFilePath, int type)
|
||||
private static string GetFilePath(string associatedFilePath, int type)
|
||||
{
|
||||
string suffix = string.Empty;
|
||||
string cacheSuffix = ".cache";
|
||||
@@ -102,6 +105,11 @@ namespace Wox.Infrastructure.Storage
|
||||
|
||||
public StoragePowerToysVersionInfo(string associatedFilePath, int type)
|
||||
{
|
||||
if (associatedFilePath == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(associatedFilePath));
|
||||
}
|
||||
|
||||
FilePath = GetFilePath(associatedFilePath, type);
|
||||
|
||||
// Get the previous version of PowerToys and cache Storage details from the CacheDetails.json storage file
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Infrastructure.Storage
|
||||
@@ -10,6 +10,9 @@ namespace Wox.Infrastructure.Storage
|
||||
public class WoxJsonStorage<T> : JsonStorage<T>
|
||||
where T : new()
|
||||
{
|
||||
private static readonly IFileSystem FileSystem = new FileSystem();
|
||||
private static readonly IPath Path = FileSystem.Path;
|
||||
|
||||
public WoxJsonStorage()
|
||||
{
|
||||
var directoryPath = Path.Combine(Constant.DataDirectory, DirectoryName);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -59,9 +60,16 @@ namespace Wox.Infrastructure
|
||||
return new MatchResult(false, UserSettingSearchPrecision);
|
||||
}
|
||||
|
||||
if (opt == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(opt));
|
||||
}
|
||||
|
||||
query = query.Trim();
|
||||
var fullStringToCompareWithoutCase = opt.IgnoreCase ? stringToCompare.ToLower() : stringToCompare;
|
||||
var queryWithoutCase = opt.IgnoreCase ? query.ToLower() : query;
|
||||
|
||||
// Using InvariantCulture since this is internal
|
||||
var fullStringToCompareWithoutCase = opt.IgnoreCase ? stringToCompare.ToUpper(CultureInfo.InvariantCulture) : stringToCompare;
|
||||
var queryWithoutCase = opt.IgnoreCase ? query.ToUpper(CultureInfo.InvariantCulture) : query;
|
||||
|
||||
var querySubstrings = queryWithoutCase.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
int currentQuerySubstringIndex = 0;
|
||||
@@ -160,7 +168,7 @@ namespace Wox.Infrastructure
|
||||
}
|
||||
|
||||
// To get the index of the closest space which preceeds the first matching index
|
||||
private int CalculateClosestSpaceIndex(List<int> spaceIndices, int firstMatchIndex)
|
||||
private static int CalculateClosestSpaceIndex(List<int> spaceIndices, int firstMatchIndex)
|
||||
{
|
||||
if (spaceIndices.Count == 0)
|
||||
{
|
||||
@@ -241,6 +249,7 @@ namespace Wox.Infrastructure
|
||||
}
|
||||
}
|
||||
|
||||
// Using CurrentCultureIgnoreCase since this relates to queries input by user
|
||||
if (string.Equals(query, stringToCompare, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
var bonusForExactMatch = 10;
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Wox.Infrastructure.UserSettings
|
||||
{
|
||||
public class HttpProxy
|
||||
{
|
||||
public bool Enabled { get; set; } = false;
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public string Server { get; set; }
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Wox.Plugin;
|
||||
|
||||
@@ -9,30 +10,34 @@ namespace Wox.Infrastructure.UserSettings
|
||||
{
|
||||
public class PluginSettings : BaseModel
|
||||
{
|
||||
public Dictionary<string, Plugin> Plugins { get; set; } = new Dictionary<string, Plugin>();
|
||||
public Dictionary<string, RunPlugin> Plugins { get; private set; } = new Dictionary<string, RunPlugin>();
|
||||
|
||||
public void UpdatePluginSettings(List<PluginMetadata> metadatas)
|
||||
{
|
||||
if (metadatas == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(metadatas));
|
||||
}
|
||||
|
||||
foreach (var metadata in metadatas)
|
||||
{
|
||||
if (Plugins.ContainsKey(metadata.ID))
|
||||
{
|
||||
var settings = Plugins[metadata.ID];
|
||||
if (settings.ActionKeywords?.Count > 0)
|
||||
if (settings.GetActionKeywords()?.Count > 0)
|
||||
{
|
||||
metadata.SetActionKeywords(settings.ActionKeywords);
|
||||
metadata.ActionKeyword = settings.ActionKeywords[0];
|
||||
metadata.SetActionKeywords(settings.GetActionKeywords());
|
||||
metadata.ActionKeyword = settings.GetActionKeywords()[0];
|
||||
}
|
||||
|
||||
metadata.Disabled = settings.Disabled;
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugins[metadata.ID] = new Plugin
|
||||
Plugins[metadata.ID] = new RunPlugin(metadata.GetActionKeywords())
|
||||
{
|
||||
ID = metadata.ID,
|
||||
Name = metadata.Name,
|
||||
ActionKeywords = metadata.GetActionKeywords(),
|
||||
Disabled = metadata.Disabled,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ using Wox.Plugin;
|
||||
|
||||
namespace Wox.Infrastructure.UserSettings
|
||||
{
|
||||
public class Settings : BaseModel
|
||||
public class PowerToysRunSettings : BaseModel
|
||||
{
|
||||
private string _hotkey = "Alt + Space";
|
||||
private string _previousHotkey = string.Empty;
|
||||
@@ -95,7 +95,7 @@ namespace Wox.Infrastructure.UserSettings
|
||||
}
|
||||
}
|
||||
|
||||
public bool AutoUpdates { get; set; } = false;
|
||||
public bool AutoUpdates { get; set; }
|
||||
|
||||
public double WindowLeft { get; set; }
|
||||
|
||||
@@ -126,13 +126,7 @@ namespace Wox.Infrastructure.UserSettings
|
||||
[JsonProperty(Order = 1)]
|
||||
public PluginSettings PluginSettings { get; set; } = new PluginSettings();
|
||||
|
||||
public ObservableCollection<CustomPluginHotkey> CustomPluginHotkeys { get; set; } = new ObservableCollection<CustomPluginHotkey>();
|
||||
|
||||
[Obsolete]
|
||||
public double Opacity { get; set; } = 1;
|
||||
|
||||
[Obsolete]
|
||||
public OpacityMode OpacityMode { get; set; } = OpacityMode.Normal;
|
||||
public ObservableCollection<CustomPluginHotkey> CustomPluginHotkeys { get; } = new ObservableCollection<CustomPluginHotkey>();
|
||||
|
||||
public bool DontPromptUpdateMsg { get; set; }
|
||||
|
||||
@@ -162,7 +156,7 @@ namespace Wox.Infrastructure.UserSettings
|
||||
|
||||
public bool HideWhenDeactivated { get; set; } = true;
|
||||
|
||||
public bool ClearInputOnLaunch { get; set; } = false;
|
||||
public bool ClearInputOnLaunch { get; set; }
|
||||
|
||||
public bool RememberLastLaunchLocation { get; set; }
|
||||
|
||||
@@ -182,12 +176,4 @@ namespace Wox.Infrastructure.UserSettings
|
||||
Empty,
|
||||
Preserved,
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public enum OpacityMode
|
||||
{
|
||||
Normal = 0,
|
||||
LayeredWindow = 1,
|
||||
DWM = 2,
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,28 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Wox.Infrastructure.UserSettings
|
||||
{
|
||||
public class Plugin
|
||||
public class RunPlugin
|
||||
{
|
||||
public string ID { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public List<string> ActionKeywords { get; set; } // a reference of the action keywords from plugin manager
|
||||
private List<string> _actionKeywords;
|
||||
|
||||
public RunPlugin(List<string> actionKeywords = null)
|
||||
{
|
||||
_actionKeywords = actionKeywords;
|
||||
}
|
||||
|
||||
public List<string> GetActionKeywords()
|
||||
{
|
||||
return _actionKeywords;
|
||||
}
|
||||
|
||||
public void SetActionKeywords(List<string> value)
|
||||
{
|
||||
_actionKeywords = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether used only to save the state of the plugin in settings
|
||||
@@ -56,8 +56,13 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NLog.Schema" Version="4.7.5" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
|
||||
<PackageReference Include="System.IO.Abstractions" Version="12.2.5" />
|
||||
<PackageReference Include="System.Runtime" Version="4.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user