mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 03:36:44 +02:00
Merge branch 'V1.2.0' of https://github.com/qianlifeng/Wox into V1.2.0
This commit is contained in:
@@ -8,7 +8,13 @@
|
||||
</appSettings>
|
||||
<log4net>
|
||||
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
|
||||
<file value="log.txt"/>
|
||||
<file type="log4net.Util.PatternString">
|
||||
<converter>
|
||||
<name value="WoxLogPathConverter" />
|
||||
<type value="Wox.Helper.WoxLogPathConverter,Wox" />
|
||||
</converter>
|
||||
<conversionPattern value="%WoxLogPathConverter{log}\\log.txt" />
|
||||
</file>
|
||||
<appendToFile value="true"/>
|
||||
<rollingStyle value="Date"/>
|
||||
<datePattern value="yyyyMMdd-HH:mm:ss"/>
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Helper;
|
||||
|
||||
namespace Wox.CommandArgs
|
||||
@@ -25,7 +26,7 @@ namespace Wox.CommandArgs
|
||||
MessageBox.Show("Plugin " + path + " didn't exist");
|
||||
return;
|
||||
}
|
||||
PluginInstaller.Install(path);
|
||||
PluginManager.InstallPlugin(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Wox.CommandArgs
|
||||
|
||||
public void Execute(IList<string> args)
|
||||
{
|
||||
PluginManager.Init();
|
||||
PluginManager.Init(App.Window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Commands
|
||||
{
|
||||
public abstract class BaseCommand
|
||||
{
|
||||
public abstract void Dispatch(Query query);
|
||||
|
||||
protected void UpdateResultView(List<Result> results)
|
||||
{
|
||||
App.Window.OnUpdateResultView(results);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Helper;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Commands
|
||||
{
|
||||
internal static class CommandFactory
|
||||
{
|
||||
private static PluginCommand pluginCmd = new PluginCommand();
|
||||
private static SystemCommand systemCmd = new SystemCommand();
|
||||
|
||||
public static void DispatchCommand(Query query)
|
||||
{
|
||||
if (PluginManager.HitThirdpartyKeyword(query))
|
||||
{
|
||||
pluginCmd.Dispatch(query);
|
||||
}
|
||||
else
|
||||
{
|
||||
systemCmd.Dispatch(query);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure.Logger;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Commands
|
||||
{
|
||||
public class PluginCommand : BaseCommand
|
||||
{
|
||||
public override void Dispatch(Query query)
|
||||
{
|
||||
PluginPair thirdPlugin = PluginManager.AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == query.ActionName);
|
||||
if (thirdPlugin != null && !string.IsNullOrEmpty(thirdPlugin.Metadata.ActionKeyword))
|
||||
{
|
||||
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == thirdPlugin.Metadata.ID);
|
||||
if (customizedPluginConfig != null && customizedPluginConfig.Disabled)
|
||||
{
|
||||
//need to stop the loading animation
|
||||
UpdateResultView(null);
|
||||
return;
|
||||
}
|
||||
|
||||
ThreadPool.QueueUserWorkItem(t =>
|
||||
{
|
||||
try
|
||||
{
|
||||
List<Result> results = thirdPlugin.Plugin.Query(query) ?? new List<Result>();
|
||||
App.Window.PushResults(query,thirdPlugin.Metadata,results);
|
||||
}
|
||||
catch (Exception queryException)
|
||||
{
|
||||
Log.Error(string.Format("Plugin {0} query failed: {1}", thirdPlugin.Metadata.Name,
|
||||
queryException.Message));
|
||||
#if (DEBUG)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
using Wox.Plugin;
|
||||
using Wox.Plugin.SystemPlugins;
|
||||
|
||||
namespace Wox.Commands
|
||||
{
|
||||
public class SystemCommand : BaseCommand
|
||||
{
|
||||
private IEnumerable<PluginPair> allSytemPlugins = PluginManager.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.System);
|
||||
|
||||
public override void Dispatch(Query query)
|
||||
{
|
||||
var queryPlugins = allSytemPlugins;
|
||||
if (UserSettingStorage.Instance.WebSearches.Exists(o => o.ActionWord == query.ActionName && o.Enabled))
|
||||
{
|
||||
//websearch mode
|
||||
queryPlugins = new List<PluginPair>()
|
||||
{
|
||||
allSytemPlugins.First(o => ((ISystemPlugin)o.Plugin).ID == "565B73353DBF4806919830B9202EE3BF")
|
||||
};
|
||||
}
|
||||
|
||||
foreach (PluginPair pair in queryPlugins)
|
||||
{
|
||||
PluginPair pair1 = pair;
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
{
|
||||
List<Result> results = pair1.Plugin.Query(query);
|
||||
results.ForEach(o => { o.AutoAjustScore = true; });
|
||||
|
||||
App.Window.PushResults(query, pair1.Metadata, results);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Threading;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace Wox.Converters
|
||||
{
|
||||
public class AsyncTask : INotifyPropertyChanged
|
||||
{
|
||||
public AsyncTask(Func<object> valueFunc)
|
||||
{
|
||||
LoadValue(valueFunc);
|
||||
}
|
||||
|
||||
private void LoadValue(Func<object> valueFunc)
|
||||
{
|
||||
var frame = new DispatcherFrame();
|
||||
ThreadPool.QueueUserWorkItem(delegate
|
||||
{
|
||||
|
||||
object returnValue =
|
||||
AsyncValue = valueFunc();
|
||||
if (PropertyChanged != null)
|
||||
PropertyChanged(this, new PropertyChangedEventArgs("AsyncValue"));
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public object AsyncValue
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ using System.Windows.Forms;
|
||||
using System.Windows.Threading;
|
||||
using System.Xml;
|
||||
using Microsoft.Win32;
|
||||
using Wox.Core.Exception;
|
||||
using Wox.Infrastructure.Logger;
|
||||
|
||||
namespace Wox.Helper.ErrorReporting
|
||||
@@ -16,10 +17,9 @@ namespace Wox.Helper.ErrorReporting
|
||||
{
|
||||
public static void UnhandledExceptionHandle(object sender, System.UnhandledExceptionEventArgs e)
|
||||
{
|
||||
if (System.Diagnostics.Debugger.IsAttached) return;
|
||||
|
||||
string error = CreateExceptionReport("System.AppDomain.UnhandledException", e.ExceptionObject);
|
||||
if (Debugger.IsAttached) return;
|
||||
|
||||
string error = ExceptionFormatter.FormatExcpetion(e.ExceptionObject);
|
||||
//e.IsTerminating is always true in most times, so try to avoid use this property
|
||||
//http://stackoverflow.com/questions/10982443/what-causes-the-unhandledexceptioneventargs-isterminating-flag-to-be-true-or-fal
|
||||
Log.Error(error);
|
||||
@@ -31,211 +31,22 @@ namespace Wox.Helper.ErrorReporting
|
||||
if (Debugger.IsAttached) return;
|
||||
|
||||
e.Handled = true;
|
||||
string error = CreateExceptionReport("System.Windows.Application.DispatcherUnhandledException", e.Exception);
|
||||
string error = ExceptionFormatter.FormatExcpetion(e.Exception);
|
||||
|
||||
Log.Error(error);
|
||||
TryShowErrorMessageBox(error, e.Exception);
|
||||
}
|
||||
|
||||
public static void ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
|
||||
{
|
||||
if (Debugger.IsAttached) return;
|
||||
|
||||
string error = CreateExceptionReport("System.Windows.Forms.Application.ThreadException", e.Exception);
|
||||
string error = ExceptionFormatter.FormatExcpetion(e.Exception);
|
||||
|
||||
Log.Fatal(error);
|
||||
TryShowErrorMessageBox(error, e.Exception);
|
||||
}
|
||||
|
||||
private static string CreateExceptionReport(string ev, object exceptionObject)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("## Exception");
|
||||
sb.AppendLine();
|
||||
sb.AppendLine("```");
|
||||
|
||||
var ex = exceptionObject as Exception;
|
||||
if (ex != null)
|
||||
{
|
||||
var exlist = new List<StringBuilder>();
|
||||
|
||||
while (ex != null)
|
||||
{
|
||||
var exsb = new StringBuilder();
|
||||
exsb.Append(ex.GetType().FullName);
|
||||
exsb.Append(": ");
|
||||
exsb.AppendLine(ex.Message);
|
||||
if (ex.Source != null)
|
||||
{
|
||||
exsb.Append(" Source: ");
|
||||
exsb.AppendLine(ex.Source);
|
||||
}
|
||||
if (ex.TargetSite != null)
|
||||
{
|
||||
exsb.Append(" TargetAssembly: ");
|
||||
exsb.AppendLine(ex.TargetSite.Module.Assembly.ToString());
|
||||
exsb.Append(" TargetModule: ");
|
||||
exsb.AppendLine(ex.TargetSite.Module.ToString());
|
||||
exsb.Append(" TargetSite: ");
|
||||
exsb.AppendLine(ex.TargetSite.ToString());
|
||||
}
|
||||
exsb.AppendLine(ex.StackTrace);
|
||||
exlist.Add(exsb);
|
||||
|
||||
ex = ex.InnerException;
|
||||
}
|
||||
|
||||
foreach (var result in exlist.Select(o => o.ToString()).Reverse())
|
||||
{
|
||||
sb.AppendLine(result);
|
||||
}
|
||||
sb.AppendLine("```");
|
||||
sb.AppendLine();
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendLine(exceptionObject.GetType().FullName);
|
||||
sb.AppendLine(new StackTrace().ToString());
|
||||
sb.AppendLine("```");
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
sb.AppendLine("## Environment");
|
||||
sb.AppendLine();
|
||||
sb.Append("* Command Line: ");
|
||||
sb.AppendLine(Environment.CommandLine);
|
||||
sb.Append("* Exception Handle: ");
|
||||
sb.AppendLine(ev);
|
||||
sb.Append("* Timestamp: ");
|
||||
sb.AppendLine(XmlConvert.ToString(DateTime.Now));
|
||||
sb.Append("* IntPtr Length: ");
|
||||
sb.AppendLine(IntPtr.Size.ToString());
|
||||
sb.Append("* System Version: ");
|
||||
sb.AppendLine(Environment.OSVersion.VersionString);
|
||||
sb.Append("* CLR Version: ");
|
||||
sb.AppendLine(Environment.Version.ToString());
|
||||
sb.AppendLine("* Installed .NET Framework: ");
|
||||
foreach (var result in GetFrameworkVersionFromRegistry())
|
||||
{
|
||||
sb.Append(" * ");
|
||||
sb.AppendLine(result);
|
||||
}
|
||||
|
||||
sb.AppendLine();
|
||||
sb.AppendLine("## Assemblies - " + System.AppDomain.CurrentDomain.FriendlyName);
|
||||
sb.AppendLine();
|
||||
foreach (var ass in System.AppDomain.CurrentDomain.GetAssemblies().OrderBy(o => o.GlobalAssemblyCache ? 100 : 0))
|
||||
{
|
||||
sb.Append("* ");
|
||||
sb.Append(ass.FullName);
|
||||
sb.Append(" (");
|
||||
sb.Append(SyntaxSugars.CallOrRescueDefault(() => ass.Location, "not supported"));
|
||||
sb.AppendLine(")");
|
||||
}
|
||||
|
||||
var process = System.Diagnostics.Process.GetCurrentProcess();
|
||||
sb.AppendLine();
|
||||
sb.AppendLine("## Modules - " + process.ProcessName);
|
||||
sb.AppendLine();
|
||||
foreach (ProcessModule mod in process.Modules)
|
||||
{
|
||||
sb.Append("* ");
|
||||
sb.Append(mod.FileName);
|
||||
sb.Append(" (");
|
||||
sb.Append(mod.FileVersionInfo.FileDescription);
|
||||
sb.Append(", ");
|
||||
sb.Append(mod.FileVersionInfo.FileVersion);
|
||||
sb.Append(", ");
|
||||
sb.Append(mod.FileVersionInfo.ProductName);
|
||||
sb.Append(", ");
|
||||
sb.Append(mod.FileVersionInfo.ProductVersion);
|
||||
sb.Append(", ");
|
||||
sb.Append(mod.FileVersionInfo.CompanyName);
|
||||
sb.Append("), ");
|
||||
sb.Append(string.Format("0x{0:X16}", mod.BaseAddress.ToInt64()));
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
sb.AppendLine();
|
||||
sb.AppendLine("## Threads - " + process.Threads.Count);
|
||||
sb.AppendLine();
|
||||
foreach (ProcessThread th in process.Threads)
|
||||
{
|
||||
sb.Append("* ");
|
||||
sb.AppendLine(string.Format("{0}, {1} {2}, Started: {3}, StartAddress: 0x{4:X16}", th.Id, th.ThreadState, th.PriorityLevel, th.StartTime, th.StartAddress.ToInt64()));
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/hh925568%28v=vs.110%29.aspx
|
||||
private static List<string> GetFrameworkVersionFromRegistry()
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = new List<string>();
|
||||
using (RegistryKey ndpKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\"))
|
||||
{
|
||||
foreach (string versionKeyName in ndpKey.GetSubKeyNames())
|
||||
{
|
||||
if (versionKeyName.StartsWith("v"))
|
||||
{
|
||||
RegistryKey versionKey = ndpKey.OpenSubKey(versionKeyName);
|
||||
string name = (string)versionKey.GetValue("Version", "");
|
||||
string sp = versionKey.GetValue("SP", "").ToString();
|
||||
string install = versionKey.GetValue("Install", "").ToString();
|
||||
if (install != "")
|
||||
if (sp != "" && install == "1")
|
||||
result.Add(string.Format("{0} {1} SP{2}", versionKeyName, name, sp));
|
||||
else
|
||||
result.Add(string.Format("{0} {1}", versionKeyName, name));
|
||||
|
||||
if (name != "")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
foreach (string subKeyName in versionKey.GetSubKeyNames())
|
||||
{
|
||||
RegistryKey subKey = versionKey.OpenSubKey(subKeyName);
|
||||
name = (string)subKey.GetValue("Version", "");
|
||||
if (name != "")
|
||||
sp = subKey.GetValue("SP", "").ToString();
|
||||
install = subKey.GetValue("Install", "").ToString();
|
||||
if (install != "")
|
||||
{
|
||||
if (sp != "" && install == "1")
|
||||
result.Add(string.Format("{0} {1} {2} SP{3}", versionKeyName, subKeyName, name, sp));
|
||||
else if (install == "1")
|
||||
result.Add(string.Format("{0} {1} {2}", versionKeyName, subKeyName, name));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
using (RegistryKey ndpKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\"))
|
||||
{
|
||||
int releaseKey = (int)ndpKey.GetValue("Release");
|
||||
{
|
||||
if (releaseKey == 378389)
|
||||
result.Add("v4.5");
|
||||
|
||||
if (releaseKey == 378675)
|
||||
result.Add("v4.5.1 installed with Windows 8.1");
|
||||
|
||||
if (releaseKey == 378758)
|
||||
result.Add("4.5.1 installed on Windows 8, Windows 7 SP1, or Windows Vista SP2");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static bool TryShowErrorMessageBox(string error, object exceptionObject)
|
||||
{
|
||||
var title = "Wox - Unhandled Exception";
|
||||
@@ -271,11 +82,13 @@ namespace Wox.Helper.ErrorReporting
|
||||
var dialog = new WPFErrorReportingDialog(error, title, exceptionObject);
|
||||
dialog.ShowDialog();
|
||||
}
|
||||
|
||||
private static void ShowWPFMessageBox(string error, string title)
|
||||
{
|
||||
System.Windows.MessageBox.Show(error, title, MessageBoxButton.OK, MessageBoxImage.Error,
|
||||
MessageBoxResult.OK, System.Windows.MessageBoxOptions.None);
|
||||
}
|
||||
|
||||
private static void ShowWindowsFormsMessageBox(string error, string title)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show(error, title, MessageBoxButtons.OK,
|
||||
|
||||
@@ -1,216 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using ICSharpCode.SharpZipLib.Zip;
|
||||
using Newtonsoft.Json;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Helper
|
||||
{
|
||||
public class PluginInstaller
|
||||
{
|
||||
public static void Install(string path)
|
||||
{
|
||||
if (File.Exists(path))
|
||||
{
|
||||
string tempFoler = Path.Combine(Path.GetTempPath(), "wox\\plugins");
|
||||
if (Directory.Exists(tempFoler))
|
||||
{
|
||||
Directory.Delete(tempFoler, true);
|
||||
}
|
||||
UnZip(path, tempFoler, true);
|
||||
|
||||
string iniPath = Path.Combine(tempFoler, "plugin.json");
|
||||
if (!File.Exists(iniPath))
|
||||
{
|
||||
MessageBox.Show("Install failed: plugin config is missing");
|
||||
return;
|
||||
}
|
||||
|
||||
PluginMetadata plugin = GetMetadataFromJson(tempFoler);
|
||||
if (plugin == null || plugin.Name == null)
|
||||
{
|
||||
MessageBox.Show("Install failed: plugin config is invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
string pluginFolerPath = Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Plugins");
|
||||
if (!Directory.Exists(pluginFolerPath))
|
||||
{
|
||||
Directory.CreateDirectory(pluginFolerPath);
|
||||
}
|
||||
|
||||
string newPluginName = plugin.Name
|
||||
.Replace("/", "_")
|
||||
.Replace("\\", "_")
|
||||
.Replace(":", "_")
|
||||
.Replace("<", "_")
|
||||
.Replace(">", "_")
|
||||
.Replace("?", "_")
|
||||
.Replace("*", "_")
|
||||
.Replace("|", "_")
|
||||
+ "-" + Guid.NewGuid();
|
||||
string newPluginPath = Path.Combine(pluginFolerPath,newPluginName);
|
||||
string content = string.Format(
|
||||
"Do you want to install following plugin?\r\n\r\nName: {0}\r\nVersion: {1}\r\nAuthor: {2}",
|
||||
plugin.Name, plugin.Version, plugin.Author);
|
||||
PluginPair existingPlugin = PluginManager.GetPlugin(plugin.ID);
|
||||
|
||||
if (existingPlugin != null)
|
||||
{
|
||||
content = string.Format(
|
||||
"Do you want to update following plugin?\r\n\r\nName: {0}\r\nOld Version: {1}\r\nNew Version: {2}\r\nAuthor: {3}",
|
||||
plugin.Name, existingPlugin.Metadata.Version, plugin.Version, plugin.Author);
|
||||
}
|
||||
|
||||
MessageBoxResult result = MessageBox.Show(content, "Install plugin",
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
if (existingPlugin != null && Directory.Exists(existingPlugin.Metadata.PluginDirectory))
|
||||
{
|
||||
//when plugin is in use, we can't delete them. That's why we need to make plugin folder a random name
|
||||
File.Create(Path.Combine(existingPlugin.Metadata.PluginDirectory, "NeedDelete.txt")).Close();
|
||||
}
|
||||
|
||||
UnZip(path, newPluginPath, true);
|
||||
Directory.Delete(tempFoler, true);
|
||||
|
||||
//exsiting plugins may be has loaded by application,
|
||||
//if we try to delelte those kind of plugins, we will get a error that indicate the
|
||||
//file is been used now.
|
||||
//current solution is to restart wox. Ugly.
|
||||
//if (MainWindow.Initialized)
|
||||
//{
|
||||
// Plugins.Init();
|
||||
//}
|
||||
if (MessageBox.Show("You have installed plugin " + plugin.Name + " successfully.\r\n Restart Wox to take effect?", "Install plugin",
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
|
||||
{
|
||||
ProcessStartInfo Info = new ProcessStartInfo();
|
||||
Info.Arguments = "/C ping 127.0.0.1 -n 1 && \"" +
|
||||
System.Windows.Forms.Application.ExecutablePath + "\"";
|
||||
Info.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
Info.CreateNoWindow = true;
|
||||
Info.FileName = "cmd.exe";
|
||||
Process.Start(Info);
|
||||
App.Window.CloseApp();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static PluginMetadata GetMetadataFromJson(string pluginDirectory)
|
||||
{
|
||||
string configPath = Path.Combine(pluginDirectory, "plugin.json");
|
||||
PluginMetadata metadata;
|
||||
|
||||
if (!File.Exists(configPath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
metadata = JsonConvert.DeserializeObject<PluginMetadata>(File.ReadAllText(configPath));
|
||||
metadata.PluginType = PluginType.ThirdParty;
|
||||
metadata.PluginDirectory = pluginDirectory;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
string error = string.Format("Parse plugin config {0} failed: json format is not valid", configPath);
|
||||
#if (DEBUG)
|
||||
{
|
||||
throw new Exception(error);
|
||||
}
|
||||
#endif
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (!AllowedLanguage.IsAllowed(metadata.Language))
|
||||
{
|
||||
string error = string.Format("Parse plugin config {0} failed: invalid language {1}", configPath,
|
||||
metadata.Language);
|
||||
#if (DEBUG)
|
||||
{
|
||||
throw new Exception(error);
|
||||
}
|
||||
#endif
|
||||
return null;
|
||||
}
|
||||
if (!File.Exists(metadata.ExecuteFilePath))
|
||||
{
|
||||
string error = string.Format("Parse plugin config {0} failed: ExecuteFile {1} didn't exist", configPath,
|
||||
metadata.ExecuteFilePath);
|
||||
#if (DEBUG)
|
||||
{
|
||||
throw new Exception(error);
|
||||
}
|
||||
#endif
|
||||
return null;
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// unzip
|
||||
/// </summary>
|
||||
/// <param name="zipedFile">The ziped file.</param>
|
||||
/// <param name="strDirectory">The STR directory.</param>
|
||||
/// <param name="overWrite">overwirte</param>
|
||||
private static void UnZip(string zipedFile, string strDirectory, bool overWrite)
|
||||
{
|
||||
if (strDirectory == "")
|
||||
strDirectory = Directory.GetCurrentDirectory();
|
||||
if (!strDirectory.EndsWith("\\"))
|
||||
strDirectory = strDirectory + "\\";
|
||||
|
||||
using (ZipInputStream s = new ZipInputStream(File.OpenRead(zipedFile)))
|
||||
{
|
||||
ZipEntry theEntry;
|
||||
|
||||
while ((theEntry = s.GetNextEntry()) != null)
|
||||
{
|
||||
string directoryName = "";
|
||||
string pathToZip = "";
|
||||
pathToZip = theEntry.Name;
|
||||
|
||||
if (pathToZip != "")
|
||||
directoryName = Path.GetDirectoryName(pathToZip) + "\\";
|
||||
|
||||
string fileName = Path.GetFileName(pathToZip);
|
||||
|
||||
Directory.CreateDirectory(strDirectory + directoryName);
|
||||
|
||||
if (fileName != "")
|
||||
{
|
||||
if ((File.Exists(strDirectory + directoryName + fileName) && overWrite) || (!File.Exists(strDirectory + directoryName + fileName)))
|
||||
{
|
||||
using (FileStream streamWriter = File.Create(strDirectory + directoryName + fileName))
|
||||
{
|
||||
byte[] data = new byte[2048];
|
||||
while (true)
|
||||
{
|
||||
int size = s.Read(data, 0, data.Length);
|
||||
|
||||
if (size > 0)
|
||||
streamWriter.Write(data, 0, size);
|
||||
else
|
||||
break;
|
||||
}
|
||||
streamWriter.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
17
Wox/Helper/WoxLogPathConverter.cs
Normal file
17
Wox/Helper/WoxLogPathConverter.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Wox.Helper
|
||||
{
|
||||
public class WoxLogPathConverter : log4net.Util.PatternConverter
|
||||
{
|
||||
protected override void Convert(TextWriter writer, object state)
|
||||
{
|
||||
string userProfilePath = Environment.GetEnvironmentVariable("USERPROFILE");
|
||||
writer.Write(Path.Combine(userProfilePath, ".Wox"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,8 @@ namespace Wox.ImageLoader
|
||||
[Serializable]
|
||||
public class ImageCacheStroage : BinaryStorage<ImageCacheStroage>
|
||||
{
|
||||
public int counter = 0;
|
||||
public const int maxCached = 200;
|
||||
private int counter = 0;
|
||||
private const int maxCached = 200;
|
||||
public Dictionary<string, int> TopUsedImages = new Dictionary<string, int>();
|
||||
|
||||
protected override string ConfigName
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace Wox.ImageLoader
|
||||
public class ImageLoader
|
||||
{
|
||||
private static readonly Dictionary<string, ImageSource> imageCache = new Dictionary<string, ImageSource>();
|
||||
private static object locker = new object();
|
||||
|
||||
private static readonly List<string> imageExts = new List<string>
|
||||
{
|
||||
@@ -54,23 +53,20 @@ namespace Wox.ImageLoader
|
||||
{
|
||||
//ImageCacheStroage.Instance.TopUsedImages can be changed during foreach, so we need to make a copy
|
||||
var imageList = new Dictionary<string, int>(ImageCacheStroage.Instance.TopUsedImages);
|
||||
using (new Timeit(string.Format("Preload {0} images",imageList.Count)))
|
||||
using (new Timeit(string.Format("Preload {0} images", imageList.Count)))
|
||||
{
|
||||
foreach (var image in imageList)
|
||||
{
|
||||
ImageSource img = Load(image.Key, false);
|
||||
if (img != null)
|
||||
if (!imageCache.ContainsKey(image.Key))
|
||||
{
|
||||
img.Freeze(); //to make it copy to UI thread
|
||||
if (!imageCache.ContainsKey(image.Key))
|
||||
ImageSource img = Load(image.Key, false);
|
||||
if (img != null)
|
||||
{
|
||||
lock (locker)
|
||||
img.Freeze(); //to make it copy to UI thread
|
||||
if (!imageCache.ContainsKey(image.Key))
|
||||
{
|
||||
if (!imageCache.ContainsKey(image.Key))
|
||||
{
|
||||
KeyValuePair<string, int> copyedImg = image;
|
||||
App.Window.Dispatcher.Invoke(new Action(() => imageCache.Add(copyedImg.Key, img)));
|
||||
}
|
||||
KeyValuePair<string, int> copyedImg = image;
|
||||
App.Window.Dispatcher.Invoke(new Action(() => imageCache.Add(copyedImg.Key, img)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,7 +74,7 @@ namespace Wox.ImageLoader
|
||||
}
|
||||
}
|
||||
|
||||
public static ImageSource Load(string path,bool addToCache = true)
|
||||
public static ImageSource Load(string path, bool addToCache = true)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path)) return null;
|
||||
if (addToCache)
|
||||
@@ -112,13 +108,7 @@ namespace Wox.ImageLoader
|
||||
{
|
||||
if (!imageCache.ContainsKey(path))
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
if (!imageCache.ContainsKey(path))
|
||||
{
|
||||
imageCache.Add(path, img);
|
||||
}
|
||||
}
|
||||
imageCache.Add(path, img);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ using WindowsInput;
|
||||
using WindowsInput.Native;
|
||||
using NHotkey;
|
||||
using NHotkey.Wpf;
|
||||
using Wox.Commands;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure;
|
||||
@@ -22,6 +21,7 @@ using Wox.Infrastructure.Hotkey;
|
||||
using Wox.Infrastructure.Storage;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
using Wox.Plugin;
|
||||
using Wox.Storage;
|
||||
using Wox.Update;
|
||||
using Application = System.Windows.Application;
|
||||
using Brushes = System.Windows.Media.Brushes;
|
||||
@@ -37,6 +37,7 @@ using Path = System.IO.Path;
|
||||
using Rectangle = System.Drawing.Rectangle;
|
||||
using TextBox = System.Windows.Controls.TextBox;
|
||||
using ToolTip = System.Windows.Controls.ToolTip;
|
||||
using Wox.Infrastructure.Logger;
|
||||
|
||||
namespace Wox
|
||||
{
|
||||
@@ -122,12 +123,12 @@ namespace Wox
|
||||
|
||||
public void InstallPlugin(string path)
|
||||
{
|
||||
Dispatcher.Invoke(new Action(() => PluginInstaller.Install(path)));
|
||||
Dispatcher.Invoke(new Action(() => PluginManager.InstallPlugin(path)));
|
||||
}
|
||||
|
||||
public void ReloadPlugins()
|
||||
{
|
||||
Dispatcher.Invoke(new Action(PluginManager.Init));
|
||||
Dispatcher.Invoke(new Action(()=> PluginManager.Init(this)));
|
||||
}
|
||||
|
||||
public List<PluginPair> GetAllPlugins()
|
||||
@@ -172,14 +173,8 @@ namespace Wox
|
||||
pnlResult.RightMouseClickEvent += pnlResult_RightMouseClickEvent;
|
||||
|
||||
ThreadPool.SetMaxThreads(30, 10);
|
||||
try
|
||||
{
|
||||
SetTheme(UserSettingStorage.Instance.Theme);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
SetTheme(UserSettingStorage.Instance.Theme = "Dark");
|
||||
}
|
||||
ThemeManager.ChangeTheme(UserSettingStorage.Instance.Theme);
|
||||
|
||||
|
||||
SetHotkey(UserSettingStorage.Instance.Hotkey, OnHotkey);
|
||||
SetCustomPluginHotkey();
|
||||
@@ -192,7 +187,7 @@ namespace Wox
|
||||
ThreadPool.QueueUserWorkItem(o =>
|
||||
{
|
||||
Thread.Sleep(50);
|
||||
PluginManager.Init();
|
||||
PluginManager.Init(this);
|
||||
});
|
||||
ThreadPool.QueueUserWorkItem(o =>
|
||||
{
|
||||
@@ -357,9 +352,9 @@ namespace Wox
|
||||
}, TimeSpan.FromMilliseconds(100), null);
|
||||
queryHasReturn = false;
|
||||
var q = new Query(lastQuery);
|
||||
CommandFactory.DispatchCommand(q);
|
||||
PluginManager.Query(q);
|
||||
BackToResultMode();
|
||||
if (PluginManager.HitThirdpartyKeyword(q))
|
||||
if (PluginManager.IsUserPluginQuery(q))
|
||||
{
|
||||
Dispatcher.DelayInvoke("ShowProgressbar", originQuery =>
|
||||
{
|
||||
@@ -676,44 +671,6 @@ namespace Wox
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTheme(string themeName)
|
||||
{
|
||||
var dict = new ResourceDictionary
|
||||
{
|
||||
Source = new Uri(Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Themes\\" + themeName + ".xaml"), UriKind.Absolute)
|
||||
};
|
||||
|
||||
|
||||
Style queryBoxStyle = dict["QueryBoxStyle"] as Style;
|
||||
if (queryBoxStyle != null)
|
||||
{
|
||||
queryBoxStyle.Setters.Add(new Setter(TextBox.FontFamilyProperty, new FontFamily(UserSettingStorage.Instance.QueryBoxFont)));
|
||||
queryBoxStyle.Setters.Add(new Setter(TextBox.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(UserSettingStorage.Instance.QueryBoxFontStyle)));
|
||||
queryBoxStyle.Setters.Add(new Setter(TextBox.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(UserSettingStorage.Instance.QueryBoxFontWeight)));
|
||||
queryBoxStyle.Setters.Add(new Setter(TextBox.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(UserSettingStorage.Instance.QueryBoxFontStretch)));
|
||||
}
|
||||
|
||||
Style resultItemStyle = dict["ItemTitleStyle"] as Style;
|
||||
Style resultSubItemStyle = dict["ItemSubTitleStyle"] as Style;
|
||||
Style resultItemSelectedStyle = dict["ItemTitleSelectedStyle"] as Style;
|
||||
Style resultSubItemSelectedStyle = dict["ItemSubTitleSelectedStyle"] as Style;
|
||||
if (resultItemStyle != null && resultSubItemStyle != null && resultSubItemSelectedStyle != null && resultItemSelectedStyle != null)
|
||||
{
|
||||
Setter fontFamily = new Setter(TextBlock.FontFamilyProperty, new FontFamily(UserSettingStorage.Instance.ResultItemFont));
|
||||
Setter fontStyle = new Setter(TextBlock.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontStyle));
|
||||
Setter fontWeight = new Setter(TextBlock.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontWeight));
|
||||
Setter fontStretch = new Setter(TextBlock.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontStretch));
|
||||
|
||||
Setter[] setters = new Setter[] { fontFamily, fontStyle, fontWeight, fontStretch };
|
||||
Array.ForEach(new Style[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle }, o => Array.ForEach(setters, p => o.Setters.Add(p)));
|
||||
}
|
||||
|
||||
Application.Current.Resources.MergedDictionaries.Clear();
|
||||
Application.Current.Resources.MergedDictionaries.Add(dict);
|
||||
|
||||
this.Opacity = this.AllowsTransparency ? UserSettingStorage.Instance.Opacity : 1;
|
||||
}
|
||||
|
||||
public bool ShellRun(string cmd, bool runAsAdministrator = false)
|
||||
{
|
||||
try
|
||||
@@ -739,7 +696,7 @@ namespace Wox
|
||||
string[] files = (string[])e.Data.GetData(System.Windows.DataFormats.FileDrop);
|
||||
if (files[0].ToLower().EndsWith(".wox"))
|
||||
{
|
||||
PluginInstaller.Install(files[0]);
|
||||
PluginManager.InstallPlugin(files[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -172,8 +172,7 @@ namespace Wox
|
||||
}
|
||||
|
||||
//PreviewPanel
|
||||
App.Window.SetTheme(UserSettingStorage.Instance.Theme);
|
||||
|
||||
ThemeManager.ChangeTheme(UserSettingStorage.Instance.Theme);
|
||||
#endregion
|
||||
|
||||
#region Plugin
|
||||
@@ -195,7 +194,7 @@ namespace Wox
|
||||
new CollectionContainer
|
||||
{
|
||||
Collection =
|
||||
PluginManager.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.ThirdParty)
|
||||
PluginManager.AllPlugins.Where(o => o.Metadata.PluginType == PluginType.User)
|
||||
}
|
||||
};
|
||||
lbPlugins.ItemsSource = plugins;
|
||||
@@ -366,7 +365,7 @@ namespace Wox
|
||||
private void ThemeComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
string themeName = themeComboBox.SelectedItem.ToString();
|
||||
MainWindow.SetTheme(themeName);
|
||||
ThemeManager.ChangeTheme(themeName);
|
||||
UserSettingStorage.Instance.Theme = themeName;
|
||||
UserSettingStorage.Instance.Save();
|
||||
}
|
||||
@@ -379,7 +378,7 @@ namespace Wox
|
||||
this.cbQueryBoxFontFaces.SelectedItem = ((FontFamily)cbQueryBoxFont.SelectedItem).ChooseRegularFamilyTypeface();
|
||||
|
||||
UserSettingStorage.Instance.Save();
|
||||
App.Window.SetTheme(UserSettingStorage.Instance.Theme);
|
||||
ThemeManager.ChangeTheme(UserSettingStorage.Instance.Theme);
|
||||
}
|
||||
|
||||
private void CbQueryBoxFontFaces_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
@@ -399,7 +398,7 @@ namespace Wox
|
||||
UserSettingStorage.Instance.QueryBoxFontWeight = typeface.Weight.ToString();
|
||||
UserSettingStorage.Instance.QueryBoxFontStyle = typeface.Style.ToString();
|
||||
UserSettingStorage.Instance.Save();
|
||||
App.Window.SetTheme(UserSettingStorage.Instance.Theme);
|
||||
ThemeManager.ChangeTheme(UserSettingStorage.Instance.Theme);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,7 +410,7 @@ namespace Wox
|
||||
this.cbResultItemFontFaces.SelectedItem = ((FontFamily)cbResultItemFont.SelectedItem).ChooseRegularFamilyTypeface();
|
||||
|
||||
UserSettingStorage.Instance.Save();
|
||||
App.Window.SetTheme(UserSettingStorage.Instance.Theme);
|
||||
ThemeManager.ChangeTheme(UserSettingStorage.Instance.Theme);
|
||||
}
|
||||
|
||||
private void CbResultItemFontFaces_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
@@ -422,8 +421,6 @@ namespace Wox
|
||||
{
|
||||
if (cbResultItemFontFaces.Items.Count > 0)
|
||||
cbResultItemFontFaces.SelectedIndex = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -431,7 +428,7 @@ namespace Wox
|
||||
UserSettingStorage.Instance.ResultItemFontWeight = typeface.Weight.ToString();
|
||||
UserSettingStorage.Instance.ResultItemFontStyle = typeface.Style.ToString();
|
||||
UserSettingStorage.Instance.Save();
|
||||
App.Window.SetTheme(UserSettingStorage.Instance.Theme);
|
||||
ThemeManager.ChangeTheme(UserSettingStorage.Instance.Theme);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,7 +442,7 @@ namespace Wox
|
||||
else
|
||||
PreviewMainPanel.Opacity = 1;
|
||||
|
||||
App.Window.SetTheme(UserSettingStorage.Instance.Theme);
|
||||
ThemeManager.ChangeTheme(UserSettingStorage.Instance.Theme);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
40
Wox/Storage/UserSelectedRecordStorage.cs
Normal file
40
Wox/Storage/UserSelectedRecordStorage.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using Wox.Infrastructure.Storage;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Storage
|
||||
{
|
||||
public class UserSelectedRecordStorage : JsonStrorage<UserSelectedRecordStorage>
|
||||
{
|
||||
[JsonProperty]
|
||||
private Dictionary<string, int> records = new Dictionary<string, int>();
|
||||
|
||||
protected override string ConfigName
|
||||
{
|
||||
get { return "UserSelectedRecords"; }
|
||||
}
|
||||
|
||||
public void Add(Result result)
|
||||
{
|
||||
if (records.ContainsKey(result.ToString()))
|
||||
{
|
||||
records[result.ToString()] += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
records.Add(result.ToString(), 1);
|
||||
}
|
||||
Save();
|
||||
}
|
||||
|
||||
public int GetSelectedCount(Result result)
|
||||
{
|
||||
if (records.ContainsKey(result.ToString()))
|
||||
{
|
||||
return records[result.ToString()];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
111
Wox/ThemeManager.cs
Normal file
111
Wox/ThemeManager.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure.Logger;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
|
||||
namespace Wox
|
||||
{
|
||||
internal class ThemeManager
|
||||
{
|
||||
private static List<string> themeDirectories = new List<string>();
|
||||
|
||||
static ThemeManager()
|
||||
{
|
||||
themeDirectories.Add(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Themes"));
|
||||
|
||||
string userProfilePath = Environment.GetEnvironmentVariable("USERPROFILE");
|
||||
if (userProfilePath != null)
|
||||
{
|
||||
themeDirectories.Add(Path.Combine(Path.Combine(userProfilePath, ".Wox"), "Themes"));
|
||||
}
|
||||
|
||||
MakesureThemeDirectoriesExist();
|
||||
}
|
||||
|
||||
private static void MakesureThemeDirectoriesExist()
|
||||
{
|
||||
foreach (string pluginDirectory in themeDirectories)
|
||||
{
|
||||
if (!Directory.Exists(pluginDirectory))
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(pluginDirectory);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Log.Error(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ChangeTheme(string themeName)
|
||||
{
|
||||
string themePath = GetThemePath(themeName);
|
||||
if (string.IsNullOrEmpty(themePath))
|
||||
{
|
||||
themePath = GetThemePath("Dark");
|
||||
if (string.IsNullOrEmpty(themePath))
|
||||
{
|
||||
throw new Exception("Change theme failed");
|
||||
}
|
||||
}
|
||||
|
||||
var dict = new ResourceDictionary
|
||||
{
|
||||
Source = new Uri(themePath, UriKind.Absolute)
|
||||
};
|
||||
|
||||
Style queryBoxStyle = dict["QueryBoxStyle"] as Style;
|
||||
if (queryBoxStyle != null)
|
||||
{
|
||||
queryBoxStyle.Setters.Add(new Setter(TextBox.FontFamilyProperty, new FontFamily(UserSettingStorage.Instance.QueryBoxFont)));
|
||||
queryBoxStyle.Setters.Add(new Setter(TextBox.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(UserSettingStorage.Instance.QueryBoxFontStyle)));
|
||||
queryBoxStyle.Setters.Add(new Setter(TextBox.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(UserSettingStorage.Instance.QueryBoxFontWeight)));
|
||||
queryBoxStyle.Setters.Add(new Setter(TextBox.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(UserSettingStorage.Instance.QueryBoxFontStretch)));
|
||||
}
|
||||
|
||||
Style resultItemStyle = dict["ItemTitleStyle"] as Style;
|
||||
Style resultSubItemStyle = dict["ItemSubTitleStyle"] as Style;
|
||||
Style resultItemSelectedStyle = dict["ItemTitleSelectedStyle"] as Style;
|
||||
Style resultSubItemSelectedStyle = dict["ItemSubTitleSelectedStyle"] as Style;
|
||||
if (resultItemStyle != null && resultSubItemStyle != null && resultSubItemSelectedStyle != null && resultItemSelectedStyle != null)
|
||||
{
|
||||
Setter fontFamily = new Setter(TextBlock.FontFamilyProperty, new FontFamily(UserSettingStorage.Instance.ResultItemFont));
|
||||
Setter fontStyle = new Setter(TextBlock.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontStyle));
|
||||
Setter fontWeight = new Setter(TextBlock.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontWeight));
|
||||
Setter fontStretch = new Setter(TextBlock.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontStretch));
|
||||
|
||||
Setter[] setters = new Setter[] { fontFamily, fontStyle, fontWeight, fontStretch };
|
||||
Array.ForEach(new Style[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle }, o => Array.ForEach(setters, p => o.Setters.Add(p)));
|
||||
}
|
||||
|
||||
Application.Current.Resources.MergedDictionaries.Clear();
|
||||
Application.Current.Resources.MergedDictionaries.Add(dict);
|
||||
|
||||
}
|
||||
|
||||
private static string GetThemePath(string themeName)
|
||||
{
|
||||
foreach (string themeDirectory in themeDirectories)
|
||||
{
|
||||
string path = Path.Combine(themeDirectory, themeName + ".xaml");
|
||||
if (File.Exists(path))
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,7 +104,10 @@
|
||||
<Reference Include="WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Helper\WoxLogPathConverter.cs" />
|
||||
<Compile Include="ImageLoader\ImageCacheStroage.cs" />
|
||||
<Compile Include="Storage\UserSelectedRecordStorage.cs" />
|
||||
<Compile Include="ThemeManager.cs" />
|
||||
<Compile Include="Update\NewVersionWindow.xaml.cs">
|
||||
<DependentUpon>NewVersionWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -124,11 +127,6 @@
|
||||
<Compile Include="CommandArgs\PluginDebuggerCommandArg.cs" />
|
||||
<Compile Include="CommandArgs\QueryCommandArg.cs" />
|
||||
<Compile Include="CommandArgs\ReloadPluginCommandArg.cs" />
|
||||
<Compile Include="Commands\BaseCommand.cs" />
|
||||
<Compile Include="Commands\CommandFactory.cs" />
|
||||
<Compile Include="Commands\PluginCommand.cs" />
|
||||
<Compile Include="Commands\SystemCommand.cs" />
|
||||
<Compile Include="Converters\AsyncConverter.cs" />
|
||||
<Compile Include="Converters\ConvertorBase.cs" />
|
||||
<Compile Include="Helper\DataWebRequestFactory.cs" />
|
||||
<Compile Include="Helper\ErrorReporting\ErrorReporting.cs" />
|
||||
@@ -148,7 +146,6 @@
|
||||
</Compile>
|
||||
<Compile Include="Helper\DispatcherExtensions.cs" />
|
||||
<Compile Include="Helper\DWMDropShadow.cs" />
|
||||
<Compile Include="Helper\PluginInstaller.cs" />
|
||||
<Compile Include="HotkeyControl.xaml.cs">
|
||||
<DependentUpon>HotkeyControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -205,11 +202,6 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<None Include="Themes\Dark.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Themes\Light.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
@@ -230,6 +222,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Page Include="Themes\Dark.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Update\NewVersionWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
Reference in New Issue
Block a user