Changed the Window States when the language is changed.

This commit is contained in:
Brett Hewitson 2021-11-30 13:05:07 +10:00
parent 2680464911
commit 19a9db6490
9 changed files with 326 additions and 47 deletions

View file

@ -5,7 +5,6 @@ using ServerManagerTool.Common.Lib;
using ServerManagerTool.Common.Model;
using ServerManagerTool.Common.Utils;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
@ -39,12 +38,7 @@ namespace ServerManagerTool
this.IsAdministrator = SecurityUtils.IsAdministrator();
this.Version = GetDeployedVersion();
this.WindowStates = new ComboBoxItemList();
foreach (WindowState windowState in Enum.GetValues(typeof(WindowState)))
{
var displayMember = _globalizer.GetResourceString($"WindowState_{windowState}") ?? windowState.ToString();
this.WindowStates.Add(new Common.Model.ComboBoxItem(windowState.ToString(), displayMember));
}
PopulateWindowsStatesComboBox();
InitializeComponent();
WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
@ -319,6 +313,8 @@ namespace ServerManagerTool
private void LanguageSelectionComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Config.CultureName = AvailableLanguages.Instance.SelectedLanguage;
PopulateWindowsStatesComboBox();
}
private void StyleSelectionComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
@ -400,5 +396,23 @@ namespace ServerManagerTool
App.Current.Shutdown(exitCode);
}
}
private void PopulateWindowsStatesComboBox()
{
var selectedValue = this.WindowStateComboBox?.SelectedValue ?? Config.MainWindow_WindowState;
var windowStates = new ComboBoxItemList();
foreach (WindowState windowState in Enum.GetValues(typeof(WindowState)))
{
var displayMember = _globalizer.GetResourceString($"WindowState_{windowState}") ?? windowState.ToString();
windowStates.Add(new Common.Model.ComboBoxItem(windowState.ToString(), displayMember));
}
this.WindowStates = windowStates;
if (this.WindowStateComboBox != null)
{
this.WindowStateComboBox.SelectedValue = selectedValue;
}
}
}
}