mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-15 12:09:18 +08:00
99d9d14d3b
1. Rename 2. Fix progress bar: progress bar should not be loaded when only white spaces typed
53 lines
1.9 KiB
C#
53 lines
1.9 KiB
C#
using System;
|
|
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 resourceDirectoryName)
|
|
{
|
|
var mergedDictionaries = Application.Current.Resources.MergedDictionaries;
|
|
foreach (var resource in mergedDictionaries)
|
|
{
|
|
int directoryPosition = resource.Source.Segments.Length - 2;
|
|
string currentDirectoryName = resource.Source.Segments[directoryPosition];
|
|
if (currentDirectoryName == resourceDirectoryName)
|
|
{
|
|
mergedDictionaries.Remove(resource);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void ApplyThemeResource(Theme.Theme t)
|
|
{
|
|
RemoveResource(Theme.Theme.DirectoryName);
|
|
Application.Current.Resources.MergedDictionaries.Add(t.GetResourceDictionary());
|
|
}
|
|
|
|
public static void ApplyLanguageResources(Internationalization i)
|
|
{
|
|
RemoveResource(Internationalization.DirectoryName);
|
|
Application.Current.Resources.MergedDictionaries.Add(i.GetResourceDictionary());
|
|
}
|
|
|
|
internal static void ApplyPluginLanguages()
|
|
{
|
|
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)
|
|
});
|
|
}
|
|
}
|
|
}
|
|
} |