mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 20:57:22 +02:00
Fix unremoved resource bug #711
This commit is contained in:
@@ -86,9 +86,10 @@ namespace Wox.Core.Resource
|
|||||||
|
|
||||||
public override ResourceDictionary GetResourceDictionary()
|
public override ResourceDictionary GetResourceDictionary()
|
||||||
{
|
{
|
||||||
|
var uri = GetLanguageFile(DirectoryPath);
|
||||||
var dictionary = new ResourceDictionary
|
var dictionary = new ResourceDictionary
|
||||||
{
|
{
|
||||||
Source = new Uri(GetLanguageFile(DirectoryPath), UriKind.Absolute)
|
Source = new Uri(uri, UriKind.Absolute)
|
||||||
};
|
};
|
||||||
return dictionary;
|
return dictionary;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Wox.Core.Plugin;
|
using Wox.Core.Plugin;
|
||||||
|
using Wox.Infrastructure;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
using Wox.Infrastructure.Exception;
|
using Wox.Infrastructure.Exception;
|
||||||
using Wox.Infrastructure.Logger;
|
using Wox.Infrastructure.Logger;
|
||||||
@@ -12,18 +14,23 @@ namespace Wox.Core.Resource
|
|||||||
{
|
{
|
||||||
public static class ResourceMerger
|
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)
|
private static void RemoveResource(string directoryName)
|
||||||
{
|
{
|
||||||
directoryName = $"{Path.DirectorySeparatorChar}{directoryName}";
|
|
||||||
var dictionaries = Application.Current.Resources.MergedDictionaries;
|
var dictionaries = Application.Current.Resources.MergedDictionaries;
|
||||||
foreach (var resource in dictionaries)
|
var invalids = dictionaries.Where(dict =>
|
||||||
{
|
{
|
||||||
string currentDirectoryName = Path.GetDirectoryName(resource.Source.AbsolutePath);
|
var dir = Path.GetDirectoryName(dict.Source.AbsolutePath).NonNull();
|
||||||
if (currentDirectoryName == directoryName)
|
var invalid = dir.Contains(directoryName);
|
||||||
{
|
return invalid;
|
||||||
dictionaries.Remove(resource);
|
}).ToList();
|
||||||
break;
|
foreach (var i in invalids)
|
||||||
}
|
{
|
||||||
|
dictionaries.Remove(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,13 +51,15 @@ namespace Wox.Core.Resource
|
|||||||
{
|
{
|
||||||
var internationalization = InternationalizationManager.Instance;
|
var internationalization = InternationalizationManager.Instance;
|
||||||
var folder = Path.Combine(directoryName, internationalization.DirectoryName);
|
var folder = Path.Combine(directoryName, internationalization.DirectoryName);
|
||||||
|
|
||||||
var file = internationalization.GetLanguageFile(folder);
|
var file = internationalization.GetLanguageFile(folder);
|
||||||
if (!string.IsNullOrEmpty(file))
|
if (!string.IsNullOrEmpty(file))
|
||||||
{
|
{
|
||||||
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary
|
var resource = new ResourceDictionary
|
||||||
{
|
{
|
||||||
Source = new Uri(file, UriKind.Absolute)
|
Source = new Uri(file, UriKind.Absolute)
|
||||||
});
|
};
|
||||||
|
Application.Current.Resources.MergedDictionaries.Add(resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -77,9 +77,10 @@ namespace Wox.Core.Resource
|
|||||||
|
|
||||||
public override ResourceDictionary GetResourceDictionary()
|
public override ResourceDictionary GetResourceDictionary()
|
||||||
{
|
{
|
||||||
|
var uri = GetThemePath(Settings.Theme);
|
||||||
var dict = new ResourceDictionary
|
var dict = new ResourceDictionary
|
||||||
{
|
{
|
||||||
Source = new Uri(GetThemePath(Settings.Theme), UriKind.Absolute)
|
Source = new Uri(uri, UriKind.Absolute)
|
||||||
};
|
};
|
||||||
|
|
||||||
Style queryBoxStyle = dict["QueryBoxStyle"] as Style;
|
Style queryBoxStyle = dict["QueryBoxStyle"] as Style;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
</Style>
|
</Style>
|
||||||
<Style x:Key="BaseWindowStyle" TargetType="{x:Type Window}">
|
<Style x:Key="BaseWindowStyle" TargetType="{x:Type Window}">
|
||||||
<Setter Property="Width" Value="800" />
|
<Setter Property="Width" Value="800" />
|
||||||
|
<Setter Property="MaxWidth" Value="800" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style x:Key="BasePendingLineStyle" TargetType="{x:Type Line}">
|
<Style x:Key="BasePendingLineStyle" TargetType="{x:Type Line}">
|
||||||
|
|||||||
Reference in New Issue
Block a user