mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Additional Compatibility code.
This commit is contained in:
parent
b45a855b42
commit
b771a37592
5 changed files with 44 additions and 53 deletions
|
|
@ -63,16 +63,16 @@ namespace ServerManagerTool.Plugin.Discord
|
|||
{
|
||||
get
|
||||
{
|
||||
var assembly = PluginHelper.Instance.GetType().Assembly;
|
||||
var assembly = typeof(PluginHelper).Assembly;
|
||||
if (assembly != null)
|
||||
{
|
||||
var pluginHelperType = assembly.GetType(typeof(PluginHelper).FullName, false, true);
|
||||
if (pluginHelperType != null)
|
||||
{
|
||||
var field = pluginHelperType.GetProperty("LanguageCode");
|
||||
if (field != null)
|
||||
var property = pluginHelperType.GetProperty(nameof(LanguageCode));
|
||||
if (property != null)
|
||||
{
|
||||
return field.GetValue(PluginHelper.Instance).ToString();
|
||||
return property.GetValue(PluginHelper.Instance).ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
using System.Windows;
|
||||
using ServerManagerTool.Plugin.Common;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
|
|
@ -6,6 +8,40 @@ namespace ServerManagerTool.Plugin.Discord
|
|||
{
|
||||
public static class WindowUtils
|
||||
{
|
||||
public static void UpdateResourceDictionary(Window window, string languageCode)
|
||||
{
|
||||
var assembly = typeof(ResourceUtils).Assembly;
|
||||
if (assembly != null)
|
||||
{
|
||||
var resourceUtilsType = assembly.GetType(typeof(ResourceUtils).FullName, false, true);
|
||||
if (resourceUtilsType != null)
|
||||
{
|
||||
var method = resourceUtilsType.GetMethod(nameof(UpdateResourceDictionary), new System.Type[] { typeof(Window), typeof(string) });
|
||||
if (method != null)
|
||||
{
|
||||
method.Invoke(null, new object[] { window, languageCode });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateResourceDictionary(UserControl control, string languageCode)
|
||||
{
|
||||
var assembly = typeof(ResourceUtils).Assembly;
|
||||
if (assembly != null)
|
||||
{
|
||||
var resourceUtilsType = assembly.GetType(typeof(ResourceUtils).FullName, false, true);
|
||||
if (resourceUtilsType != null)
|
||||
{
|
||||
var method = resourceUtilsType.GetMethod(nameof(UpdateResourceDictionary), new System.Type[] { typeof(UserControl), typeof(string) });
|
||||
if (method != null)
|
||||
{
|
||||
method.Invoke(null, new object[] { control, languageCode });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds a parent of a given item on the visual tree.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -23,22 +23,7 @@ namespace ServerManagerTool.Plugin.Discord.Windows
|
|||
internal ConfigProfileWindow(DiscordPlugin plugin, ConfigProfile profile)
|
||||
{
|
||||
InitializeComponent();
|
||||
try
|
||||
{
|
||||
ResourceUtils.UpdateResourceDictionary(this, plugin.LanguageCode);
|
||||
}
|
||||
catch (MissingFieldException)
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
catch (MissingMethodException)
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
WindowUtils.UpdateResourceDictionary(this, plugin.LanguageCode);
|
||||
|
||||
this.Plugin = plugin ?? new DiscordPlugin();
|
||||
this.OriginalProfile = profile;
|
||||
|
|
|
|||
|
|
@ -21,22 +21,7 @@ namespace ServerManagerTool.Plugin.Discord.Windows
|
|||
internal ConfigWindow(DiscordPlugin plugin, DiscordPluginConfig pluginConfig)
|
||||
{
|
||||
InitializeComponent();
|
||||
try
|
||||
{
|
||||
ResourceUtils.UpdateResourceDictionary(this, plugin.LanguageCode);
|
||||
}
|
||||
catch (MissingFieldException)
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
catch (MissingMethodException)
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
WindowUtils.UpdateResourceDictionary(this, plugin.LanguageCode);
|
||||
|
||||
this.Plugin = plugin ?? new DiscordPlugin();
|
||||
this.PluginConfig = pluginConfig ?? new DiscordPluginConfig();
|
||||
|
|
|
|||
|
|
@ -19,22 +19,7 @@ namespace ServerManagerTool.Plugin.Discord.Windows
|
|||
public VersionFeedWindow(DiscordPlugin plugin, string feedUri)
|
||||
{
|
||||
InitializeComponent();
|
||||
try
|
||||
{
|
||||
ResourceUtils.UpdateResourceDictionary(this, plugin.LanguageCode);
|
||||
}
|
||||
catch (MissingFieldException)
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
catch (MissingMethodException)
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
WindowUtils.UpdateResourceDictionary(this, plugin.LanguageCode);
|
||||
|
||||
this.Plugin = plugin ?? new DiscordPlugin();
|
||||
this.feedUri = feedUri;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue