Added globalization to the Main Window Start Mode setting in the Global Settings.

This commit is contained in:
Brett Hewitson 2021-11-30 11:55:02 +10:00
parent ae4241e757
commit 01f0cc2bb6
5 changed files with 45 additions and 26 deletions

View file

@ -2,6 +2,7 @@
using NLog;
using ServerManagerTool.Common;
using ServerManagerTool.Common.Lib;
using ServerManagerTool.Common.Model;
using ServerManagerTool.Common.Utils;
using System;
using System.Collections.Generic;
@ -28,7 +29,7 @@ namespace ServerManagerTool
public static readonly DependencyProperty AppInstanceProperty = DependencyProperty.Register(nameof(AppInstance), typeof(App), typeof(GlobalSettingsControl), new PropertyMetadata(null));
public static readonly DependencyProperty IsAdministratorProperty = DependencyProperty.Register(nameof(IsAdministrator), typeof(bool), typeof(GlobalSettingsControl), new PropertyMetadata(false));
public static readonly DependencyProperty WindowStatesProperty = DependencyProperty.Register(nameof(WindowStates), typeof(List<WindowState>), typeof(GlobalSettingsControl), new PropertyMetadata(new List<WindowState>()));
public static readonly DependencyProperty WindowStatesProperty = DependencyProperty.Register(nameof(WindowStates), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
public GlobalSettingsControl()
{
@ -38,10 +39,11 @@ namespace ServerManagerTool
this.IsAdministrator = SecurityUtils.IsAdministrator();
this.Version = GetDeployedVersion();
this.WindowStates = new List<WindowState>();
foreach (var windowState in Enum.GetValues(typeof(WindowState)))
this.WindowStates = new ComboBoxItemList();
foreach (WindowState windowState in Enum.GetValues(typeof(WindowState)))
{
this.WindowStates.Add((WindowState)windowState);
var displayMember = _globalizer.GetResourceString($"WindowState_{windowState}") ?? windowState.ToString();
this.WindowStates.Add(new Common.Model.ComboBoxItem(windowState.ToString(), displayMember));
}
InitializeComponent();
@ -74,9 +76,9 @@ namespace ServerManagerTool
set { SetValue(IsAdministratorProperty, value); }
}
public List<WindowState> WindowStates
public ComboBoxItemList WindowStates
{
get { return (List<WindowState>)GetValue(WindowStatesProperty); }
get { return (ComboBoxItemList)GetValue(WindowStatesProperty); }
set { SetValue(WindowStatesProperty, value); }
}