mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
New Globalisation Changes
This commit is contained in:
parent
034d7401d1
commit
d4859e0722
10 changed files with 23 additions and 103 deletions
|
|
@ -18,6 +18,7 @@ using System.Linq;
|
|||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Xml;
|
||||
|
|
@ -312,6 +313,7 @@ namespace ServerManagerTool
|
|||
PluginHelper.Instance.BetaEnabled = this.BetaVersion;
|
||||
PluginHelper.Instance.LoadPlugins(installPath, true);
|
||||
PluginHelper.Instance.SetFetchProfileCallback(FetchProfiles);
|
||||
OnResourceDictionaryChanged(Thread.CurrentThread.CurrentCulture.Name);
|
||||
|
||||
// check if we are starting ASM for the old server restart - no longer supported
|
||||
if (e.Args.Any(a => a.StartsWith(Constants.ARG_AUTORESTART, StringComparison.OrdinalIgnoreCase)))
|
||||
|
|
@ -458,6 +460,11 @@ namespace ServerManagerTool
|
|||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public void OnResourceDictionaryChanged(string languageCode)
|
||||
{
|
||||
PluginHelper.Instance.OnResourceDictionaryChanged(languageCode);
|
||||
}
|
||||
|
||||
public static void ReconfigureLogging()
|
||||
{
|
||||
string logDir = Path.Combine(Config.Default.DataDir, Config.Default.LogsDir);
|
||||
|
|
|
|||
|
|
@ -306,6 +306,8 @@ namespace ServerManagerTool
|
|||
CurrentConfig.CultureName = AvailableLanguages.Instance.SelectedLanguage;
|
||||
|
||||
PopulateWindowsStatesComboBox();
|
||||
|
||||
App.Instance.OnResourceDictionaryChanged(CurrentConfig.CultureName);
|
||||
}
|
||||
|
||||
private void StyleSelectionComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ using System.Linq;
|
|||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using WPFSharp.Globalizer;
|
||||
|
|
@ -304,6 +305,7 @@ namespace ServerManagerTool
|
|||
PluginHelper.Instance.BetaEnabled = this.BetaVersion;
|
||||
PluginHelper.Instance.LoadPlugins(installPath, true);
|
||||
PluginHelper.Instance.SetFetchProfileCallback(FetchProfiles);
|
||||
OnResourceDictionaryChanged(Thread.CurrentThread.CurrentCulture.Name);
|
||||
|
||||
// check if we are starting server manager for server shutdown
|
||||
if (e.Args.Any(a => a.StartsWith(Constants.ARG_AUTOSHUTDOWN1, StringComparison.OrdinalIgnoreCase)))
|
||||
|
|
@ -438,6 +440,11 @@ namespace ServerManagerTool
|
|||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public void OnResourceDictionaryChanged(string languageCode)
|
||||
{
|
||||
PluginHelper.Instance.OnResourceDictionaryChanged(languageCode);
|
||||
}
|
||||
|
||||
public static void ReconfigureLogging()
|
||||
{
|
||||
string logDir = Path.Combine(Config.Default.DataPath, Config.Default.LogsRelativePath);
|
||||
|
|
|
|||
|
|
@ -315,6 +315,8 @@ namespace ServerManagerTool
|
|||
Config.CultureName = AvailableLanguages.Instance.SelectedLanguage;
|
||||
|
||||
PopulateWindowsStatesComboBox();
|
||||
|
||||
App.Instance.OnResourceDictionaryChanged(Config.CultureName);
|
||||
}
|
||||
|
||||
private void StyleSelectionComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace ServerManagerTool.Plugin.Common.Events
|
||||
{
|
||||
public class ResourceDictionaryChangedEventArgs : EventArgs
|
||||
{
|
||||
public ResourceDictionaryChangedEventArgs(string languageCode)
|
||||
{
|
||||
LanguageCode = languageCode;
|
||||
}
|
||||
|
||||
public string LanguageCode;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
using ServerManagerTool.Plugin.Common.Delegates;
|
||||
using ServerManagerTool.Plugin.Common.Events;
|
||||
using ServerManagerTool.Plugin.Common.Lib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -26,8 +25,6 @@ namespace ServerManagerTool.Plugin.Common
|
|||
private FetchProfilesDelegate _fetchProfilesCallback;
|
||||
private bool _disposed;
|
||||
|
||||
public EventHandler<ResourceDictionaryChangedEventArgs> ResourceDictionaryChanged;
|
||||
|
||||
private PluginHelper()
|
||||
{
|
||||
BetaEnabled = false;
|
||||
|
|
@ -250,7 +247,6 @@ namespace ServerManagerTool.Plugin.Common
|
|||
public void OnResourceDictionaryChanged(string languageCode)
|
||||
{
|
||||
LanguageCode = languageCode;
|
||||
ResourceDictionaryChanged?.Invoke(this, new ResourceDictionaryChangedEventArgs(languageCode));
|
||||
}
|
||||
|
||||
internal void OpenConfigForm(string pluginCode, Window owner)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using ServerManagerTool.Plugin.Common;
|
||||
using ServerManagerTool.Plugin.Common.Events;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
|
|
@ -27,9 +26,8 @@ namespace ServerManagerTool.Plugin.Discord.Windows
|
|||
try
|
||||
{
|
||||
ResourceUtils.UpdateResourceDictionary(this, PluginHelper.Instance.LanguageCode);
|
||||
PluginHelper.Instance.ResourceDictionaryChanged += OnResourceDictionaryChanged;
|
||||
}
|
||||
catch
|
||||
catch (Exception)
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
|
|
@ -88,16 +86,6 @@ namespace ServerManagerTool.Plugin.Discord.Windows
|
|||
if (MessageBox.Show(ResourceUtils.GetResourceString(this.Resources, "ConfigProfileWindow_CloseLabel"), ResourceUtils.GetResourceString(this.Resources, "ConfigProfileWindow_CloseTitle"), MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
|
||||
e.Cancel = true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!e.Cancel)
|
||||
PluginHelper.Instance.ResourceDictionaryChanged -= OnResourceDictionaryChanged;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
private void ComboBox_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
|
|
@ -305,20 +293,6 @@ namespace ServerManagerTool.Plugin.Discord.Windows
|
|||
expression?.UpdateSource();
|
||||
}
|
||||
|
||||
private void OnResourceDictionaryChanged(object sender, ResourceDictionaryChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
ResourceUtils.UpdateResourceDictionary(this, PluginHelper.Instance.LanguageCode);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
|
||||
RefreshAlertTypeList();
|
||||
}
|
||||
|
||||
private void RefreshAlertTypeList()
|
||||
{
|
||||
var newList = new ComboBoxItemList();
|
||||
|
|
@ -356,7 +330,7 @@ namespace ServerManagerTool.Plugin.Discord.Windows
|
|||
});
|
||||
}
|
||||
}
|
||||
catch
|
||||
catch (Exception)
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
using ServerManagerTool.Plugin.Common;
|
||||
using ServerManagerTool.Plugin.Common.Events;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
@ -28,9 +24,8 @@ namespace ServerManagerTool.Plugin.Discord.Windows
|
|||
try
|
||||
{
|
||||
ResourceUtils.UpdateResourceDictionary(this, PluginHelper.Instance.LanguageCode);
|
||||
PluginHelper.Instance.ResourceDictionaryChanged += OnResourceDictionaryChanged;
|
||||
}
|
||||
catch
|
||||
catch (Exception)
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
|
|
@ -78,16 +73,6 @@ namespace ServerManagerTool.Plugin.Discord.Windows
|
|||
if (MessageBox.Show(ResourceUtils.GetResourceString(this.Resources, "ConfigWindow_CloseLabel"), ResourceUtils.GetResourceString(this.Resources, "ConfigWindow_CloseTitle"), MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
|
||||
e.Cancel = true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!e.Cancel)
|
||||
PluginHelper.Instance.ResourceDictionaryChanged -= OnResourceDictionaryChanged;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
}
|
||||
|
||||
private void ConfigWindow_Loaded(object sender, RoutedEventArgs e)
|
||||
|
|
@ -291,18 +276,6 @@ namespace ServerManagerTool.Plugin.Discord.Windows
|
|||
PluginConfig?.CommitChanges();
|
||||
}
|
||||
|
||||
private void OnResourceDictionaryChanged(object sender, ResourceDictionaryChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
ResourceUtils.UpdateResourceDictionary(this, PluginHelper.Instance.LanguageCode);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
}
|
||||
|
||||
#region Drag and Drop
|
||||
|
||||
private static readonly DependencyProperty DraggedItemProperty = DependencyProperty.Register(nameof(DraggedItem), typeof(ConfigProfile), typeof(ConfigWindow), new PropertyMetadata(null));
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
xmlns:local="clr-namespace:ServerManagerTool.Plugin.Discord"
|
||||
xmlns:pc="clr-namespace:ServerManagerTool.Plugin.Common;assembly=ServerManager.Plugin.Common"
|
||||
MinWidth="400" MinHeight="400" Width="640" Height="480" WindowStyle="ToolWindow" WindowStartupLocation="CenterOwner" ShowInTaskbar="False" ResizeMode="CanResizeWithGrip"
|
||||
Loaded="VersionFeedWindow_Loaded" Closing="VersionFeedWindow_Closing"
|
||||
Loaded="VersionFeedWindow_Loaded"
|
||||
Icon="../Art/favicon.ico" Title="{DynamicResource VersionFeedWindow_Title}">
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using ServerManagerTool.Plugin.Common;
|
||||
using ServerManagerTool.Plugin.Common.Events;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
|
@ -23,9 +22,8 @@ namespace ServerManagerTool.Plugin.Discord.Windows
|
|||
try
|
||||
{
|
||||
ResourceUtils.UpdateResourceDictionary(this, PluginHelper.Instance.LanguageCode);
|
||||
PluginHelper.Instance.ResourceDictionaryChanged += OnResourceDictionaryChanged;
|
||||
}
|
||||
catch
|
||||
catch (Exception)
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
|
|
@ -54,19 +52,6 @@ namespace ServerManagerTool.Plugin.Discord.Windows
|
|||
set { SetValue(SelectedFeedEntryProperty, value); }
|
||||
}
|
||||
|
||||
private void VersionFeedWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!e.Cancel)
|
||||
PluginHelper.Instance.ResourceDictionaryChanged -= OnResourceDictionaryChanged;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
}
|
||||
|
||||
private void VersionFeedWindow_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
|
|
@ -100,17 +85,5 @@ namespace ServerManagerTool.Plugin.Discord.Windows
|
|||
|
||||
SelectedFeedEntry = FeedEntries.OrderByDescending(e => e.Updated).FirstOrDefault();
|
||||
}
|
||||
|
||||
private void OnResourceDictionaryChanged(object sender, ResourceDictionaryChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
ResourceUtils.UpdateResourceDictionary(this, PluginHelper.Instance.LanguageCode);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue