mirror of
https://github.com/Tribufu/ServerManagers
synced 2026-08-08 12:11:05 +00:00
Globalisation Changes
This commit is contained in:
parent
4a80b089b4
commit
034d7401d1
15 changed files with 410 additions and 51 deletions
|
|
@ -1,11 +1,11 @@
|
|||
<Window x:Class="ServerManagerTool.Plugin.Discord.Windows.ConfigProfileWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:pc="clr-namespace:ServerManagerTool.Plugin.Common;assembly=ServerManager.Plugin.Common"
|
||||
Name="ConfigProfileUI" Title="{DynamicResource ConfigProfileWindow_Title}"
|
||||
Icon="/ServerManager.Plugin.Discord;component/Art/favicon.ico"
|
||||
Width="640" Height="520" MinWidth="640" MinHeight="480" ResizeMode="CanResizeWithGrip" WindowStyle="ToolWindow" WindowStartupLocation="CenterOwner" ShowInTaskbar="False" Closing="ConfigProfileWindow_Closing">
|
||||
Width="640" Height="520" MinWidth="640" MinHeight="480" ResizeMode="CanResizeWithGrip" WindowStyle="ToolWindow" WindowStartupLocation="CenterOwner" ShowInTaskbar="False"
|
||||
Closing="ConfigProfileWindow_Closing">
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
|
|
@ -18,12 +18,6 @@
|
|||
<GradientStop Color="#FFEAE8E6"/>
|
||||
</LinearGradientBrush>
|
||||
|
||||
<ObjectDataProvider x:Key="AlertTypes" MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
|
||||
<ObjectDataProvider.MethodParameters>
|
||||
<x:Type TypeName="pc:AlertType" />
|
||||
</ObjectDataProvider.MethodParameters>
|
||||
</ObjectDataProvider>
|
||||
|
||||
<Style x:Key="GroupBoxStyle" TargetType="GroupBox" BasedOn="{StaticResource {x:Type GroupBox}}">
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BeigeBorder}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
|
||||
|
|
@ -212,7 +206,7 @@
|
|||
</DataGridTemplateColumn.Header>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<ComboBox IsEditable="False" ItemsSource="{Binding Source={StaticResource AlertTypes}}" SelectedValue="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" PreviewMouseWheel="ComboBox_PreviewMouseWheel"/>
|
||||
<ComboBox IsEditable="False" ItemsSource="{Binding AlertTypeList, ElementName=ConfigProfileUI}" SelectedValue="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" SelectedValuePath="ValueMember" DisplayMemberPath="DisplayMember" PreviewMouseWheel="ComboBox_PreviewMouseWheel"/>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using ServerManagerTool.Plugin.Common;
|
||||
using ServerManagerTool.Plugin.Common.Events;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
|
|
@ -16,26 +17,43 @@ namespace ServerManagerTool.Plugin.Discord.Windows
|
|||
/// </summary>
|
||||
public partial class ConfigProfileWindow : Window
|
||||
{
|
||||
private static readonly DependencyProperty AlertsListProperty = DependencyProperty.Register(nameof(AlertTypeList), typeof(ComboBoxItemList), typeof(ConfigProfileWindow));
|
||||
private static readonly DependencyProperty ProfileProperty = DependencyProperty.Register(nameof(Profile), typeof(ConfigProfile), typeof(ConfigProfileWindow));
|
||||
private static readonly DependencyProperty ProfileListProperty = DependencyProperty.Register(nameof(ProfileList), typeof(ComboBoxItemList), typeof(ConfigProfileWindow));
|
||||
|
||||
internal ConfigProfileWindow(DiscordPlugin plugin, ConfigProfile profile)
|
||||
{
|
||||
InitializeComponent();
|
||||
try
|
||||
{
|
||||
ResourceUtils.UpdateResourceDictionary(this, PluginHelper.Instance.LanguageCode);
|
||||
PluginHelper.Instance.ResourceDictionaryChanged += OnResourceDictionaryChanged;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
|
||||
this.Plugin = plugin ?? new DiscordPlugin();
|
||||
this.OriginalProfile = profile;
|
||||
this.Profile = profile.Clone();
|
||||
this.Profile.CommitChanges();
|
||||
|
||||
RefreshAlertTypeList();
|
||||
RefreshProfileList();
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
if (plugin.BetaEnabled)
|
||||
Title = $"{Title} {ResourceUtils.GetResourceString(this.Resources, "Global_BetaModeLabel")}";
|
||||
|
||||
this.DataContext = this;
|
||||
}
|
||||
|
||||
private ComboBoxItemList AlertTypeList
|
||||
{
|
||||
get { return GetValue(AlertsListProperty) as ComboBoxItemList; }
|
||||
set { SetValue(AlertsListProperty, value); }
|
||||
}
|
||||
|
||||
private ConfigProfile OriginalProfile
|
||||
{
|
||||
get;
|
||||
|
|
@ -70,6 +88,16 @@ 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)
|
||||
|
|
@ -277,6 +305,37 @@ 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();
|
||||
|
||||
foreach (AlertType alertType in Enum.GetValues(typeof(AlertType)))
|
||||
{
|
||||
newList.Add(new ComboBoxItem
|
||||
{
|
||||
ValueMember = alertType.ToString(),
|
||||
DisplayMember = ResourceUtils.GetResourceString(this.Resources, $"AlertType_{alertType}") ?? alertType.ToString(),
|
||||
});
|
||||
}
|
||||
|
||||
newList.Sort(i => i.DisplayMember);
|
||||
this.AlertTypeList = newList;
|
||||
}
|
||||
|
||||
private void RefreshProfileList()
|
||||
{
|
||||
var newList = new ComboBoxItemList();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
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;
|
||||
|
|
@ -20,11 +24,20 @@ namespace ServerManagerTool.Plugin.Discord.Windows
|
|||
|
||||
internal ConfigWindow(DiscordPlugin plugin, DiscordPluginConfig pluginConfig)
|
||||
{
|
||||
InitializeComponent();
|
||||
try
|
||||
{
|
||||
ResourceUtils.UpdateResourceDictionary(this, PluginHelper.Instance.LanguageCode);
|
||||
PluginHelper.Instance.ResourceDictionaryChanged += OnResourceDictionaryChanged;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
|
||||
this.Plugin = plugin ?? new DiscordPlugin();
|
||||
this.PluginConfig = pluginConfig ?? new DiscordPluginConfig();
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
if (plugin.BetaEnabled)
|
||||
Title = $"{Title} {ResourceUtils.GetResourceString(this.Resources, "Global_BetaModeLabel")}";
|
||||
|
||||
|
|
@ -65,6 +78,16 @@ 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)
|
||||
|
|
@ -268,6 +291,18 @@ 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="Window_Loaded"
|
||||
Loaded="VersionFeedWindow_Loaded" Closing="VersionFeedWindow_Closing"
|
||||
Icon="../Art/favicon.ico" Title="{DynamicResource VersionFeedWindow_Title}">
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using ServerManagerTool.Plugin.Common;
|
||||
using ServerManagerTool.Plugin.Common.Events;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
|
@ -18,11 +19,20 @@ namespace ServerManagerTool.Plugin.Discord.Windows
|
|||
|
||||
public VersionFeedWindow(DiscordPlugin plugin, string feedUri)
|
||||
{
|
||||
InitializeComponent();
|
||||
try
|
||||
{
|
||||
ResourceUtils.UpdateResourceDictionary(this, PluginHelper.Instance.LanguageCode);
|
||||
PluginHelper.Instance.ResourceDictionaryChanged += OnResourceDictionaryChanged;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// do nothing, most likely they are using an older version of a server manager
|
||||
}
|
||||
|
||||
this.Plugin = plugin ?? new DiscordPlugin();
|
||||
this.feedUri = feedUri;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
this.DataContext = this;
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +54,20 @@ namespace ServerManagerTool.Plugin.Discord.Windows
|
|||
set { SetValue(SelectedFeedEntryProperty, value); }
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
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
|
||||
{
|
||||
|
|
@ -77,5 +100,17 @@ 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