mirror of
https://github.com/tribufu/ServerManagers
synced 2026-06-01 09:42:39 +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
|
get
|
||||||
{
|
{
|
||||||
var assembly = PluginHelper.Instance.GetType().Assembly;
|
var assembly = typeof(PluginHelper).Assembly;
|
||||||
if (assembly != null)
|
if (assembly != null)
|
||||||
{
|
{
|
||||||
var pluginHelperType = assembly.GetType(typeof(PluginHelper).FullName, false, true);
|
var pluginHelperType = assembly.GetType(typeof(PluginHelper).FullName, false, true);
|
||||||
if (pluginHelperType != null)
|
if (pluginHelperType != null)
|
||||||
{
|
{
|
||||||
var field = pluginHelperType.GetProperty("LanguageCode");
|
var property = pluginHelperType.GetProperty(nameof(LanguageCode));
|
||||||
if (field != null)
|
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.Data;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
||||||
|
|
@ -6,6 +8,40 @@ namespace ServerManagerTool.Plugin.Discord
|
||||||
{
|
{
|
||||||
public static class WindowUtils
|
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>
|
/// <summary>
|
||||||
/// Finds a parent of a given item on the visual tree.
|
/// Finds a parent of a given item on the visual tree.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -23,22 +23,7 @@ namespace ServerManagerTool.Plugin.Discord.Windows
|
||||||
internal ConfigProfileWindow(DiscordPlugin plugin, ConfigProfile profile)
|
internal ConfigProfileWindow(DiscordPlugin plugin, ConfigProfile profile)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
try
|
WindowUtils.UpdateResourceDictionary(this, plugin.LanguageCode);
|
||||||
{
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Plugin = plugin ?? new DiscordPlugin();
|
this.Plugin = plugin ?? new DiscordPlugin();
|
||||||
this.OriginalProfile = profile;
|
this.OriginalProfile = profile;
|
||||||
|
|
|
||||||
|
|
@ -21,22 +21,7 @@ namespace ServerManagerTool.Plugin.Discord.Windows
|
||||||
internal ConfigWindow(DiscordPlugin plugin, DiscordPluginConfig pluginConfig)
|
internal ConfigWindow(DiscordPlugin plugin, DiscordPluginConfig pluginConfig)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
try
|
WindowUtils.UpdateResourceDictionary(this, plugin.LanguageCode);
|
||||||
{
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Plugin = plugin ?? new DiscordPlugin();
|
this.Plugin = plugin ?? new DiscordPlugin();
|
||||||
this.PluginConfig = pluginConfig ?? new DiscordPluginConfig();
|
this.PluginConfig = pluginConfig ?? new DiscordPluginConfig();
|
||||||
|
|
|
||||||
|
|
@ -19,22 +19,7 @@ namespace ServerManagerTool.Plugin.Discord.Windows
|
||||||
public VersionFeedWindow(DiscordPlugin plugin, string feedUri)
|
public VersionFeedWindow(DiscordPlugin plugin, string feedUri)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
try
|
WindowUtils.UpdateResourceDictionary(this, plugin.LanguageCode);
|
||||||
{
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Plugin = plugin ?? new DiscordPlugin();
|
this.Plugin = plugin ?? new DiscordPlugin();
|
||||||
this.feedUri = feedUri;
|
this.feedUri = feedUri;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue