mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
Merge
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Infrastructure.Http
|
||||
{
|
||||
public class HttpProxy : IHttpProxy
|
||||
{
|
||||
private static readonly HttpProxy instance = new HttpProxy();
|
||||
|
||||
private HttpProxy()
|
||||
{
|
||||
}
|
||||
|
||||
public static HttpProxy Instance
|
||||
{
|
||||
get { return instance; }
|
||||
}
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get { return UserSettingStorage.Instance.ProxyEnabled; }
|
||||
}
|
||||
|
||||
public string Server
|
||||
{
|
||||
get { return UserSettingStorage.Instance.ProxyServer; }
|
||||
}
|
||||
|
||||
public int Port
|
||||
{
|
||||
get { return UserSettingStorage.Instance.ProxyPort; }
|
||||
}
|
||||
|
||||
public string UserName
|
||||
{
|
||||
get { return UserSettingStorage.Instance.ProxyUserName; }
|
||||
}
|
||||
|
||||
public string Password
|
||||
{
|
||||
get { return UserSettingStorage.Instance.ProxyPassword; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
@@ -8,9 +9,9 @@ namespace Wox.Infrastructure.Http
|
||||
{
|
||||
public class HttpRequest
|
||||
{
|
||||
public static string Get(string url, string encoding = "UTF-8")
|
||||
public static string Get(string url, IHttpProxy proxy, string encoding = "UTF-8")
|
||||
{
|
||||
return Get(url, encoding, HttpProxy.Instance);
|
||||
return Get(url, encoding, proxy);
|
||||
}
|
||||
|
||||
private static string Get(string url, string encoding, IHttpProxy proxy)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
@@ -12,24 +13,7 @@ namespace Wox.Infrastructure.Storage
|
||||
[Serializable]
|
||||
public abstract class BaseStorage<T> : IStorage where T : class,IStorage, new()
|
||||
{
|
||||
private string configFolder;
|
||||
|
||||
private string ConfigFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(configFolder))
|
||||
{
|
||||
string userProfilePath = Environment.GetEnvironmentVariable("USERPROFILE");
|
||||
if (userProfilePath == null)
|
||||
{
|
||||
throw new ArgumentException("Environment variable USERPROFILE is empty");
|
||||
}
|
||||
configFolder = Path.Combine(Path.Combine(userProfilePath, ".Wox"), "Config");
|
||||
}
|
||||
return configFolder;
|
||||
}
|
||||
}
|
||||
protected abstract string ConfigFolder { get; }
|
||||
|
||||
protected string ConfigPath
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization.Formatters;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Text;
|
||||
using Wox.Infrastructure.Logger;
|
||||
@@ -30,7 +31,10 @@ namespace Wox.Infrastructure.Storage
|
||||
{
|
||||
using (FileStream fileStream = new FileStream(ConfigPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
{
|
||||
BinaryFormatter binaryFormatter = new BinaryFormatter();
|
||||
BinaryFormatter binaryFormatter = new BinaryFormatter
|
||||
{
|
||||
AssemblyFormat = FormatterAssemblyStyle.Simple
|
||||
};
|
||||
serializedObject = binaryFormatter.Deserialize(fileStream) as T;
|
||||
if (serializedObject == null)
|
||||
{
|
||||
@@ -79,7 +83,10 @@ namespace Wox.Infrastructure.Storage
|
||||
try
|
||||
{
|
||||
FileStream fileStream = new FileStream(ConfigPath, FileMode.Create);
|
||||
BinaryFormatter binaryFormatter = new BinaryFormatter();
|
||||
BinaryFormatter binaryFormatter = new BinaryFormatter
|
||||
{
|
||||
AssemblyFormat = FormatterAssemblyStyle.Simple
|
||||
};
|
||||
binaryFormatter.Serialize(fileStream, serializedObject);
|
||||
fileStream.Close();
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Wox.Infrastructure.Storage.UserSettings
|
||||
{
|
||||
public class CustomizedPluginConfig
|
||||
{
|
||||
public string ID { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Actionword { get; set; }
|
||||
|
||||
public bool Disabled { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Wox.Infrastructure.Storage.UserSettings
|
||||
{
|
||||
public class FolderLink
|
||||
{
|
||||
[JsonProperty]
|
||||
public string Path { get; set; }
|
||||
|
||||
public string Nickname
|
||||
{
|
||||
get { return Path.Split(new char[] { System.IO.Path.DirectorySeparatorChar }, StringSplitOptions.None).Last(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace Wox.Infrastructure.Storage.UserSettings
|
||||
{
|
||||
public class CustomPluginHotkey
|
||||
{
|
||||
public string Hotkey { get; set; }
|
||||
public string ActionKeyword { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Wox.Infrastructure.Storage.UserSettings
|
||||
{
|
||||
[Serializable]
|
||||
public class ProgramSource
|
||||
{
|
||||
public string Location { get; set; }
|
||||
public string Type { get; set; }
|
||||
public int BonusPoints { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public Dictionary<string, string> Meta { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return (this.Type ?? "") + ":" + this.Location ?? "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Wox.Infrastructure.Storage.UserSettings
|
||||
{
|
||||
public class UserSettingStorage : JsonStrorage<UserSettingStorage>
|
||||
{
|
||||
[JsonProperty]
|
||||
public bool DontPromptUpdateMsg { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public string Hotkey { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public string Language { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public string Theme { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public string QueryBoxFont { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public string QueryBoxFontStyle { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public string QueryBoxFontWeight { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public string QueryBoxFontStretch { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public string ResultItemFont { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public string ResultItemFontStyle { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public string ResultItemFontWeight { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public string ResultItemFontStretch { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public bool ReplaceWinR { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public List<WebSearch> WebSearches { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public double WindowLeft { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public double WindowTop { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public List<ProgramSource> ProgramSources { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public List<FolderLink> FolderLinks { get; set; }
|
||||
|
||||
public List<CustomizedPluginConfig> CustomizedPluginConfigs { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public List<CustomPluginHotkey> CustomPluginHotkeys { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public bool StartWoxOnSystemStartup { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public double Opacity { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public string ProgramSuffixes { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public OpacityMode OpacityMode { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public bool EnableWebSearchSuggestion { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public string WebSearchSuggestionSource { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public bool LeaveCmdOpen { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public bool HideWhenDeactive { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public string ProxyServer { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public bool ProxyEnabled { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public int ProxyPort { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public string ProxyUserName { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public string ProxyPassword { get; set; }
|
||||
|
||||
public List<WebSearch> LoadDefaultWebSearches()
|
||||
{
|
||||
List<WebSearch> webSearches = new List<WebSearch>();
|
||||
|
||||
WebSearch googleWebSearch = new WebSearch()
|
||||
{
|
||||
Title = "Google",
|
||||
ActionWord = "g",
|
||||
IconPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\websearch\google.png",
|
||||
Url = "https://www.google.com/search?q={q}",
|
||||
Enabled = true
|
||||
};
|
||||
webSearches.Add(googleWebSearch);
|
||||
|
||||
|
||||
WebSearch wikiWebSearch = new WebSearch()
|
||||
{
|
||||
Title = "Wikipedia",
|
||||
ActionWord = "wiki",
|
||||
IconPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\websearch\wiki.png",
|
||||
Url = "http://en.wikipedia.org/wiki/{q}",
|
||||
Enabled = true
|
||||
};
|
||||
webSearches.Add(wikiWebSearch);
|
||||
|
||||
WebSearch findIcon = new WebSearch()
|
||||
{
|
||||
Title = "FindIcon",
|
||||
ActionWord = "findicon",
|
||||
IconPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\websearch\pictures.png",
|
||||
Url = "http://findicons.com/search/{q}",
|
||||
Enabled = true
|
||||
};
|
||||
webSearches.Add(findIcon);
|
||||
|
||||
return webSearches;
|
||||
}
|
||||
|
||||
protected override string ConfigName
|
||||
{
|
||||
get { return "config"; }
|
||||
}
|
||||
|
||||
protected override UserSettingStorage LoadDefault()
|
||||
{
|
||||
DontPromptUpdateMsg = false;
|
||||
Theme = "Dark";
|
||||
Language = "en";
|
||||
ReplaceWinR = true;
|
||||
WebSearches = LoadDefaultWebSearches();
|
||||
ProgramSources = new List<ProgramSource>();
|
||||
CustomizedPluginConfigs = new List<CustomizedPluginConfig>();
|
||||
Hotkey = "Alt + Space";
|
||||
QueryBoxFont = FontFamily.GenericSansSerif.Name;
|
||||
ResultItemFont = FontFamily.GenericSansSerif.Name;
|
||||
Opacity = 1;
|
||||
OpacityMode = OpacityMode.Normal;
|
||||
LeaveCmdOpen = false;
|
||||
HideWhenDeactive = false;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
protected override void OnAfterLoad(UserSettingStorage storage)
|
||||
{
|
||||
if (storage.CustomizedPluginConfigs == null)
|
||||
{
|
||||
storage.CustomizedPluginConfigs = new List<CustomizedPluginConfig>();
|
||||
}
|
||||
if (string.IsNullOrEmpty(storage.ProgramSuffixes))
|
||||
{
|
||||
storage.ProgramSuffixes = "lnk;exe;appref-ms;bat";
|
||||
}
|
||||
if (storage.QueryBoxFont == null)
|
||||
{
|
||||
storage.QueryBoxFont = FontFamily.GenericSansSerif.Name;
|
||||
}
|
||||
if (storage.ResultItemFont == null)
|
||||
{
|
||||
storage.ResultItemFont = FontFamily.GenericSansSerif.Name;
|
||||
}
|
||||
if (storage.Language == null)
|
||||
{
|
||||
storage.Language = "en";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum OpacityMode
|
||||
{
|
||||
Normal = 0,
|
||||
LayeredWindow = 1,
|
||||
DWM = 2
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace Wox.Infrastructure.Storage.UserSettings
|
||||
{
|
||||
public class WebSearch
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string ActionWord { get; set; }
|
||||
public string IconPath { get; set; }
|
||||
public string Url { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.IO;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
|
||||
namespace Wox.Infrastructure
|
||||
{
|
||||
@@ -78,7 +77,7 @@ namespace Wox.Infrastructure
|
||||
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode)]
|
||||
static extern bool UrlIs(string pszUrl, int UrlIs);
|
||||
|
||||
static void ShellExecCmdLine(IntPtr hInstance, IntPtr hwnd, string command, string startDir, global::System.Diagnostics.ProcessWindowStyle nShow, ShellExecCmdLineFlags dwSeclFlags,bool runAsAdministrator = false)
|
||||
static void ShellExecCmdLine(IntPtr hInstance, IntPtr hwnd, string command, string startDir, global::System.Diagnostics.ProcessWindowStyle nShow, ShellExecCmdLineFlags dwSeclFlags,bool runAsAdministrator = false,bool leaveCmdOpen = false)
|
||||
{
|
||||
string cmd = command;
|
||||
string args = null;
|
||||
@@ -103,7 +102,7 @@ namespace Wox.Infrastructure
|
||||
startDir = dir;
|
||||
}
|
||||
|
||||
if (UserSettingStorage.Instance.LeaveCmdOpen && File.Exists(cmd))
|
||||
if (leaveCmdOpen && File.Exists(cmd))
|
||||
{
|
||||
bool needsCommandLine;
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Newtonsoft.Json.6.0.5\lib\net35\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath>..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
@@ -59,18 +59,11 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Http\HttpProxy.cs" />
|
||||
<Compile Include="Logger\Log.cs" />
|
||||
<Compile Include="PeHeaderReader.cs" />
|
||||
<Compile Include="Storage\BinaryStorage.cs" />
|
||||
<Compile Include="Storage\IStorage.cs" />
|
||||
<Compile Include="Storage\JsonStorage.cs" />
|
||||
<Compile Include="Storage\UserSettings\CustomizedPluginConfig.cs" />
|
||||
<Compile Include="Storage\UserSettings\FolderLink.cs" />
|
||||
<Compile Include="Storage\UserSettings\PluginHotkey.cs" />
|
||||
<Compile Include="Storage\UserSettings\ProgramSource.cs" />
|
||||
<Compile Include="Storage\UserSettings\UserSettingStorage.cs" />
|
||||
<Compile Include="Storage\UserSettings\WebSearch.cs" />
|
||||
<Compile Include="Timeit.cs" />
|
||||
<Compile Include="Unidecoder.Characters.cs" />
|
||||
<Compile Include="Http\HttpRequest.cs" />
|
||||
@@ -91,9 +84,6 @@
|
||||
<Name>Wox.Plugin</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Service References\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="log4net" version="2.0.3" targetFramework="net35" />
|
||||
<package id="Newtonsoft.Json" version="6.0.5" targetFramework="net35" />
|
||||
<package id="Newtonsoft.Json" version="6.0.7" targetFramework="net35" />
|
||||
<package id="protobuf-net" version="2.0.0.668" targetFramework="net35" />
|
||||
<package id="ServiceStack.Text" version="3.9.71" targetFramework="net35" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user