mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 19:49:15 +08:00
38791e50ea
1. Refactoring blur, see discussion in : 7f8bb80 2. Releated issue: #330
54 lines
1.9 KiB
C#
54 lines
1.9 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using Wox.Core.i18n;
|
|
using Wox.Core.Plugin;
|
|
using Wox.Plugin;
|
|
|
|
namespace Wox.Core.UI
|
|
{
|
|
public static class ResourceMerger
|
|
{
|
|
private static void RemoveResource(string directoryName)
|
|
{
|
|
directoryName = $"{Path.DirectorySeparatorChar}{directoryName}";
|
|
var dictionaries = Application.Current.Resources.MergedDictionaries;
|
|
foreach (var resource in dictionaries)
|
|
{
|
|
string currentDirectoryName = Path.GetDirectoryName(resource.Source.AbsolutePath);
|
|
if (currentDirectoryName == directoryName)
|
|
{
|
|
dictionaries.Remove(resource);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void UpdateResource(Theme.Theme t)
|
|
{
|
|
RemoveResource(Theme.Theme.DirectoryName);
|
|
Application.Current.Resources.MergedDictionaries.Add(t.GetResourceDictionary());
|
|
}
|
|
|
|
public static void UpdateResources(Internationalization i)
|
|
{
|
|
RemoveResource(Internationalization.DirectoryName);
|
|
Application.Current.Resources.MergedDictionaries.Add(i.GetResourceDictionary());
|
|
}
|
|
|
|
internal static void UpdatePluginLanguages()
|
|
{
|
|
RemoveResource(PluginManager.DirectoryName);
|
|
foreach (var languageFile in PluginManager.GetPluginsForInterface<IPluginI18n>().
|
|
Select(plugin => InternationalizationManager.Instance.GetLanguageFile(((IPluginI18n)plugin.Plugin).GetLanguagesFolder())).
|
|
Where(file => !string.IsNullOrEmpty(file)))
|
|
{
|
|
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary
|
|
{
|
|
Source = new Uri(languageFile, UriKind.Absolute)
|
|
});
|
|
}
|
|
}
|
|
}
|
|
} |