diff --git a/Wox.Core/Resource/Internationalization.cs b/Wox.Core/Resource/Internationalization.cs
index 03fbbb6d46..cc839b8c9e 100644
--- a/Wox.Core/Resource/Internationalization.cs
+++ b/Wox.Core/Resource/Internationalization.cs
@@ -86,9 +86,10 @@ namespace Wox.Core.Resource
public override ResourceDictionary GetResourceDictionary()
{
+ var uri = GetLanguageFile(DirectoryPath);
var dictionary = new ResourceDictionary
{
- Source = new Uri(GetLanguageFile(DirectoryPath), UriKind.Absolute)
+ Source = new Uri(uri, UriKind.Absolute)
};
return dictionary;
}
diff --git a/Wox.Core/Resource/ResourceMerger.cs b/Wox.Core/Resource/ResourceMerger.cs
index fe677b01ab..035f2164e1 100644
--- a/Wox.Core/Resource/ResourceMerger.cs
+++ b/Wox.Core/Resource/ResourceMerger.cs
@@ -1,9 +1,11 @@
using System;
+using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows;
using Wox.Core.Plugin;
+using Wox.Infrastructure;
using Wox.Plugin;
using Wox.Infrastructure.Exception;
using Wox.Infrastructure.Logger;
@@ -12,18 +14,23 @@ namespace Wox.Core.Resource
{
public static class ResourceMerger
{
+ static ResourceMerger()
+ {
+ // remove all dictionaries defined in xaml e.g.g App.xaml
+ Application.Current.Resources.MergedDictionaries.Clear();
+ }
private static void RemoveResource(string directoryName)
{
- directoryName = $"{Path.DirectorySeparatorChar}{directoryName}";
var dictionaries = Application.Current.Resources.MergedDictionaries;
- foreach (var resource in dictionaries)
+ var invalids = dictionaries.Where(dict =>
{
- string currentDirectoryName = Path.GetDirectoryName(resource.Source.AbsolutePath);
- if (currentDirectoryName == directoryName)
- {
- dictionaries.Remove(resource);
- break;
- }
+ var dir = Path.GetDirectoryName(dict.Source.AbsolutePath).NonNull();
+ var invalid = dir.Contains(directoryName);
+ return invalid;
+ }).ToList();
+ foreach (var i in invalids)
+ {
+ dictionaries.Remove(i);
}
}
@@ -44,13 +51,15 @@ namespace Wox.Core.Resource
{
var internationalization = InternationalizationManager.Instance;
var folder = Path.Combine(directoryName, internationalization.DirectoryName);
+
var file = internationalization.GetLanguageFile(folder);
if (!string.IsNullOrEmpty(file))
{
- Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary
+ var resource = new ResourceDictionary
{
Source = new Uri(file, UriKind.Absolute)
- });
+ };
+ Application.Current.Resources.MergedDictionaries.Add(resource);
}
}
else
diff --git a/Wox.Core/Resource/Theme.cs b/Wox.Core/Resource/Theme.cs
index 81328add68..5a3ff86ac4 100644
--- a/Wox.Core/Resource/Theme.cs
+++ b/Wox.Core/Resource/Theme.cs
@@ -77,9 +77,10 @@ namespace Wox.Core.Resource
public override ResourceDictionary GetResourceDictionary()
{
+ var uri = GetThemePath(Settings.Theme);
var dict = new ResourceDictionary
{
- Source = new Uri(GetThemePath(Settings.Theme), UriKind.Absolute)
+ Source = new Uri(uri, UriKind.Absolute)
};
Style queryBoxStyle = dict["QueryBoxStyle"] as Style;
diff --git a/Wox/Themes/Base.xaml b/Wox/Themes/Base.xaml
index ff2be6c569..a2367250c6 100644
--- a/Wox/Themes/Base.xaml
+++ b/Wox/Themes/Base.xaml
@@ -20,6 +20,7 @@