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

This commit is contained in:
Brett Hewitson 2021-11-30 11:54:54 +10:00
parent 1e38a9e2f9
commit ae4241e757
5 changed files with 17 additions and 7 deletions

View file

@ -51,6 +51,12 @@
<sys:String x:Key="ProcessorAffinity_All">All</sys:String> <sys:String x:Key="ProcessorAffinity_All">All</sys:String>
<!--#endregion--> <!--#endregion-->
<!--#region Processor Window States -->
<sys:String x:Key="WindowState_Normal">Normal</sys:String>
<sys:String x:Key="WindowState_Minimized">Minimized</sys:String>
<sys:String x:Key="WindowState_Maximized">Maximized</sys:String>
<!--#endregion-->
<!--#region Application --> <!--#region Application -->
<sys:String x:Key="Application_RunAsAdministratorTitle">Run as Administrator</sys:String> <sys:String x:Key="Application_RunAsAdministratorTitle">Run as Administrator</sys:String>
<sys:String x:Key="Application_RunAsAdministratorLabel">This application requires administration priviledges to access ALL functionality. Would you like to Run as Administrator?</sys:String> <sys:String x:Key="Application_RunAsAdministratorLabel">This application requires administration priviledges to access ALL functionality. Would you like to Run as Administrator?</sys:String>

View file

@ -19,6 +19,7 @@
<u style="font-size: .9em;">CHANGE</u> <u style="font-size: .9em;">CHANGE</u>
<br/> <br/>
<ul> <ul>
<li>Added globalization to the Main Window Start Mode setting in the Global Settings.</li>
<li>zh-CN Translation file updated.</li> <li>zh-CN Translation file updated.</li>
</ul> </ul>
</p> </p>

View file

@ -19,6 +19,7 @@
<u style="font-size: .9em;">CHANGE</u> <u style="font-size: .9em;">CHANGE</u>
<br/> <br/>
<ul> <ul>
<li>Added globalization to the Main Window Start Mode setting in the Global Settings.</li>
<li>zh-CN Translation file updated.</li> <li>zh-CN Translation file updated.</li>
</ul> </ul>
</p> </p>

View file

@ -94,7 +94,7 @@
<CheckBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_RunAsAdministratorLabel}" IsChecked="{Binding CurrentConfig.RunAsAdministratorPrompt, Mode=TwoWay}" HorizontalAlignment="Left"/> <CheckBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_RunAsAdministratorLabel}" IsChecked="{Binding CurrentConfig.RunAsAdministratorPrompt, Mode=TwoWay}" HorizontalAlignment="Left"/>
<Label Grid.Row="2" Grid.Column="0" Margin="1" Content="{DynamicResource GlobalSettings_StartModeLabel}" VerticalAlignment="Center"/> <Label Grid.Row="2" Grid.Column="0" Margin="1" Content="{DynamicResource GlobalSettings_StartModeLabel}" VerticalAlignment="Center"/>
<ComboBox Grid.Row="2" Grid.Column="1" Margin="5" ItemsSource="{Binding ElementName=GlobalSettings, Path=WindowStates}" SelectedValue="{Binding CurrentConfig.MainWindow_WindowState}" PreviewMouseWheel="ComboBox_PreviewMouseWheel"/> <ComboBox Grid.Row="2" Grid.Column="1" Margin="5" ItemsSource="{Binding ElementName=GlobalSettings, Path=WindowStates}" SelectedValue="{Binding CurrentConfig.MainWindow_WindowState}" SelectedValuePath="ValueMember" DisplayMemberPath="DisplayMember" PreviewMouseWheel="ComboBox_PreviewMouseWheel"/>
<CheckBox Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_MinimizeToTrayLabel}" IsChecked="{Binding CurrentConfig.MainWindow_MinimizeToTray, Mode=TwoWay}" HorizontalAlignment="Left" VerticalAlignment="Center"/> <CheckBox Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_MinimizeToTrayLabel}" IsChecked="{Binding CurrentConfig.MainWindow_MinimizeToTray, Mode=TwoWay}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
<CheckBox Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_ManageFirewallLabel}" IsChecked="{Binding CurrentConfig.ManageFirewallAutomatically, Mode=TwoWay}" HorizontalAlignment="Left"/> <CheckBox Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_ManageFirewallLabel}" IsChecked="{Binding CurrentConfig.ManageFirewallAutomatically, Mode=TwoWay}" HorizontalAlignment="Left"/>

View file

@ -2,6 +2,7 @@
using NLog; using NLog;
using ServerManagerTool.Common; using ServerManagerTool.Common;
using ServerManagerTool.Common.Lib; using ServerManagerTool.Common.Lib;
using ServerManagerTool.Common.Model;
using ServerManagerTool.Common.Utils; using ServerManagerTool.Common.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -29,7 +30,7 @@ namespace ServerManagerTool
public static readonly DependencyProperty IsAdministratorProperty = DependencyProperty.Register(nameof(IsAdministrator), typeof(bool), typeof(GlobalSettingsControl), new PropertyMetadata(false)); public static readonly DependencyProperty IsAdministratorProperty = DependencyProperty.Register(nameof(IsAdministrator), typeof(bool), typeof(GlobalSettingsControl), new PropertyMetadata(false));
public static readonly DependencyProperty CurrentConfigProperty = DependencyProperty.Register(nameof(CurrentConfig), typeof(Config), typeof(GlobalSettingsControl), new PropertyMetadata(null)); public static readonly DependencyProperty CurrentConfigProperty = DependencyProperty.Register(nameof(CurrentConfig), typeof(Config), typeof(GlobalSettingsControl), new PropertyMetadata(null));
public static readonly DependencyProperty CommonConfigProperty = DependencyProperty.Register(nameof(CommonConfig), typeof(CommonConfig), typeof(GlobalSettingsControl), new PropertyMetadata(null)); public static readonly DependencyProperty CommonConfigProperty = DependencyProperty.Register(nameof(CommonConfig), typeof(CommonConfig), typeof(GlobalSettingsControl), new PropertyMetadata(null));
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() public GlobalSettingsControl()
{ {
@ -39,10 +40,11 @@ namespace ServerManagerTool
this.CommonConfig = CommonConfig.Default; this.CommonConfig = CommonConfig.Default;
this.DataContext = this; this.DataContext = this;
this.WindowStates = new List<WindowState>(); this.WindowStates = new ComboBoxItemList();
foreach (var windowState in Enum.GetValues(typeof(WindowState))) 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(); InitializeComponent();
@ -75,9 +77,9 @@ namespace ServerManagerTool
set { SetValue(IsAdministratorProperty, value); } 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); } set { SetValue(WindowStatesProperty, value); }
} }