Fixed Window State being cleared when changing Languages.

This commit is contained in:
Brett Hewitson 2022-03-03 13:31:11 +10:00
parent ec1751cc20
commit eb23acc64e
4 changed files with 30 additions and 16 deletions

View file

@ -64,11 +64,11 @@
<CheckBox Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_CheckIfServerManagerRunningOnStartupLabel}" IsChecked="{Binding Config.CheckIfServerManagerRunningOnStartup, Mode=TwoWay}" HorizontalAlignment="Left"/>
<Label Grid.Row="2" Grid.Column="0" Margin="1" Content="{DynamicResource GlobalSettings_StartModeLabel}" VerticalAlignment="Center"/>
<ComboBox Name="WindowStateMainWindowComboBox" Grid.Row="2" Grid.Column="1" Margin="5" ItemsSource="{Binding ElementName=GlobalSettings, Path=WindowStates}" SelectedValue="{Binding Config.MainWindow_WindowState}" SelectedValuePath="ValueMember" DisplayMemberPath="DisplayMember" PreviewMouseWheel="ComboBox_PreviewMouseWheel"/>
<ComboBox Name="WindowStateMainWindowComboBox" Grid.Row="2" Grid.Column="1" Margin="5" ItemsSource="{Binding ElementName=GlobalSettings, Path=WindowStatesMainWindow}" SelectedValue="{Binding Config.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 Config.MainWindow_MinimizeToTray, Mode=TwoWay}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
<Label Grid.Row="3" Grid.Column="0" Margin="1" Content="{DynamicResource GlobalSettings_StartModeServerMonitorLabel}" VerticalAlignment="Center"/>
<ComboBox Name="WindowStateServerMonitorComboBox" Grid.Row="3" Grid.Column="1" Margin="5" ItemsSource="{Binding ElementName=GlobalSettings, Path=WindowStates}" SelectedValue="{Binding Config.ServerMonitorWindow_WindowState}" SelectedValuePath="ValueMember" DisplayMemberPath="DisplayMember" PreviewMouseWheel="ComboBox_PreviewMouseWheel"/>
<ComboBox Name="WindowStateServerMonitorComboBox" Grid.Row="3" Grid.Column="1" Margin="5" ItemsSource="{Binding ElementName=GlobalSettings, Path=WindowStatesServerMonitor}" SelectedValue="{Binding Config.ServerMonitorWindow_WindowState}" SelectedValuePath="ValueMember" DisplayMemberPath="DisplayMember" PreviewMouseWheel="ComboBox_PreviewMouseWheel"/>
<CheckBox Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_ManageFirewallLabel}" IsChecked="{Binding Config.ManageFirewallAutomatically, Mode=TwoWay}" HorizontalAlignment="Left"/>
<CheckBox Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_ManagePublicIPLabel}" IsChecked="{Binding Config.ManagePublicIPAutomatically, Mode=TwoWay}" HorizontalAlignment="Left"/>

View file

@ -33,7 +33,8 @@ namespace ServerManagerTool
public static readonly DependencyProperty IsAdministratorProperty = DependencyProperty.Register(nameof(IsAdministrator), typeof(bool), typeof(GlobalSettingsControl), new PropertyMetadata(false));
public static readonly DependencyProperty ConfigProperty = DependencyProperty.Register(nameof(Config), 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 WindowStatesProperty = DependencyProperty.Register(nameof(WindowStates), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
public static readonly DependencyProperty WindowStatesMainWindowProperty = DependencyProperty.Register(nameof(WindowStatesMainWindow), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
public static readonly DependencyProperty WindowStatesServerMonitorProperty = DependencyProperty.Register(nameof(WindowStatesServerMonitor), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
public static readonly DependencyProperty DiscordBotLogLevelsProperty = DependencyProperty.Register(nameof(DiscordBotLogLevels), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
public static readonly DependencyProperty DiscordBotWhitelistProperty = DependencyProperty.Register(nameof(DiscordBotWhitelist), typeof(List<DiscordBotWhitelistItem>), typeof(GlobalSettingsControl), new PropertyMetadata(null));
@ -91,10 +92,16 @@ namespace ServerManagerTool
set { SetValue(IsAdministratorProperty, value); }
}
public ComboBoxItemList WindowStates
public ComboBoxItemList WindowStatesMainWindow
{
get { return (ComboBoxItemList)GetValue(WindowStatesProperty); }
set { SetValue(WindowStatesProperty, value); }
get { return (ComboBoxItemList)GetValue(WindowStatesMainWindowProperty); }
set { SetValue(WindowStatesMainWindowProperty, value); }
}
public ComboBoxItemList WindowStatesServerMonitor
{
get { return (ComboBoxItemList)GetValue(WindowStatesServerMonitorProperty); }
set { SetValue(WindowStatesServerMonitorProperty, value); }
}
public ComboBoxItemList DiscordBotLogLevels
@ -502,7 +509,7 @@ namespace ServerManagerTool
comboBoxList.Add(new Common.Model.ComboBoxItem(windowState.ToString(), displayMember));
}
this.WindowStates = comboBoxList;
this.WindowStatesMainWindow = comboBoxList;
if (this.WindowStateMainWindowComboBox != null)
{
this.WindowStateMainWindowComboBox.SelectedValue = selectedValue;
@ -520,7 +527,7 @@ namespace ServerManagerTool
comboBoxList.Add(new Common.Model.ComboBoxItem(windowState.ToString(), displayMember));
}
this.WindowStates = comboBoxList;
this.WindowStatesServerMonitor = comboBoxList;
if (this.WindowStateServerMonitorComboBox != null)
{
this.WindowStateServerMonitorComboBox.SelectedValue = selectedValue;

View file

@ -68,11 +68,11 @@
<CheckBox Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_CheckIfServerManagerRunningOnStartupLabel}" IsChecked="{Binding Config.CheckIfServerManagerRunningOnStartup, Mode=TwoWay}" HorizontalAlignment="Left"/>
<Label Grid.Row="2" Grid.Column="0" Margin="1" Content="{DynamicResource GlobalSettings_StartModeLabel}" VerticalAlignment="Center"/>
<ComboBox Name="WindowStateMainWindowComboBox" Grid.Row="2" Grid.Column="1" Margin="5" ItemsSource="{Binding ElementName=GlobalSettings, Path=WindowStates}" SelectedValue="{Binding Config.MainWindow_WindowState}" SelectedValuePath="ValueMember" DisplayMemberPath="DisplayMember" PreviewMouseWheel="ComboBox_PreviewMouseWheel"/>
<ComboBox Name="WindowStateMainWindowComboBox" Grid.Row="2" Grid.Column="1" Margin="5" ItemsSource="{Binding ElementName=GlobalSettings, Path=WindowStatesMainWindow}" SelectedValue="{Binding Config.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 Config.MainWindow_MinimizeToTray, Mode=TwoWay}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
<Label Grid.Row="3" Grid.Column="0" Margin="1" Content="{DynamicResource GlobalSettings_StartModeServerMonitorLabel}" VerticalAlignment="Center"/>
<ComboBox Name="WindowStateServerMonitorComboBox" Grid.Row="3" Grid.Column="1" Margin="5" ItemsSource="{Binding ElementName=GlobalSettings, Path=WindowStates}" SelectedValue="{Binding Config.ServerMonitorWindow_WindowState}" SelectedValuePath="ValueMember" DisplayMemberPath="DisplayMember" PreviewMouseWheel="ComboBox_PreviewMouseWheel"/>
<ComboBox Name="WindowStateServerMonitorComboBox" Grid.Row="3" Grid.Column="1" Margin="5" ItemsSource="{Binding ElementName=GlobalSettings, Path=WindowStatesServerMonitor}" SelectedValue="{Binding Config.ServerMonitorWindow_WindowState}" SelectedValuePath="ValueMember" DisplayMemberPath="DisplayMember" PreviewMouseWheel="ComboBox_PreviewMouseWheel"/>
<CheckBox Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_ManageFirewallLabel}" IsChecked="{Binding Config.ManageFirewallAutomatically, Mode=TwoWay}" HorizontalAlignment="Left"/>
<CheckBox Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_ManagePublicIPLabel}" IsChecked="{Binding Config.ManagePublicIPAutomatically, Mode=TwoWay}" HorizontalAlignment="Left"/>

View file

@ -31,7 +31,8 @@ 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(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
public static readonly DependencyProperty WindowStatesMainWindowProperty = DependencyProperty.Register(nameof(WindowStatesMainWindow), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
public static readonly DependencyProperty WindowStatesServerMonitorProperty = DependencyProperty.Register(nameof(WindowStatesServerMonitor), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
public static readonly DependencyProperty DiscordBotLogLevelsProperty = DependencyProperty.Register(nameof(DiscordBotLogLevels), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
public static readonly DependencyProperty DiscordBotWhitelistProperty = DependencyProperty.Register(nameof(DiscordBotWhitelist), typeof(List<DiscordBotWhitelistItem>), typeof(GlobalSettingsControl), new PropertyMetadata(null));
@ -83,10 +84,16 @@ namespace ServerManagerTool
set { SetValue(IsAdministratorProperty, value); }
}
public ComboBoxItemList WindowStates
public ComboBoxItemList WindowStatesMainWindow
{
get { return (ComboBoxItemList)GetValue(WindowStatesProperty); }
set { SetValue(WindowStatesProperty, value); }
get { return (ComboBoxItemList)GetValue(WindowStatesMainWindowProperty); }
set { SetValue(WindowStatesMainWindowProperty, value); }
}
public ComboBoxItemList WindowStatesServerMonitor
{
get { return (ComboBoxItemList)GetValue(WindowStatesServerMonitorProperty); }
set { SetValue(WindowStatesServerMonitorProperty, value); }
}
public string Version
@ -504,7 +511,7 @@ namespace ServerManagerTool
windowStates.Add(new Common.Model.ComboBoxItem(windowState.ToString(), displayMember));
}
this.WindowStates = windowStates;
this.WindowStatesMainWindow = windowStates;
if (this.WindowStateMainWindowComboBox != null)
{
this.WindowStateMainWindowComboBox.SelectedValue = selectedValue;
@ -522,7 +529,7 @@ namespace ServerManagerTool
comboBoxList.Add(new Common.Model.ComboBoxItem(windowState.ToString(), displayMember));
}
this.WindowStates = comboBoxList;
this.WindowStatesServerMonitor = comboBoxList;
if (this.WindowStateServerMonitorComboBox != null)
{
this.WindowStateServerMonitorComboBox.SelectedValue = selectedValue;