1. Main window now stored the Left and Top positions.

2. Added global setting to set the start mode of the Main Window.
This commit is contained in:
Brett Hewitson 2021-11-23 15:26:06 +10:00
parent 229ee09049
commit 34582ca91b
20 changed files with 286 additions and 58 deletions

View file

@ -792,6 +792,15 @@
<setting name="MOTDHeight" serializeAs="String">
<value>100</value>
</setting>
<setting name="MainWindow_WindowState" serializeAs="String">
<value>Normal</value>
</setting>
<setting name="MainWindow_Left" serializeAs="String">
<value>50</value>
</setting>
<setting name="MainWindow_Top" serializeAs="String">
<value>50</value>
</setting>
</ServerManagerTool.Config>
</userSettings>
</configuration>

View file

@ -2767,5 +2767,41 @@ namespace ServerManagerTool {
this["MOTDHeight"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Normal")]
public global::System.Windows.WindowState MainWindow_WindowState {
get {
return ((global::System.Windows.WindowState)(this["MainWindow_WindowState"]));
}
set {
this["MainWindow_WindowState"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("50")]
public double MainWindow_Left {
get {
return ((double)(this["MainWindow_Left"]));
}
set {
this["MainWindow_Left"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("50")]
public double MainWindow_Top {
get {
return ((double)(this["MainWindow_Top"]));
}
set {
this["MainWindow_Top"] = value;
}
}
}
}

View file

@ -767,5 +767,14 @@
<Setting Name="MOTDHeight" Type="System.Windows.GridLength" Scope="User">
<Value Profile="(Default)">100</Value>
</Setting>
<Setting Name="MainWindow_WindowState" Type="System.Windows.WindowState" Scope="User">
<Value Profile="(Default)">Normal</Value>
</Setting>
<Setting Name="MainWindow_Left" Type="System.Double" Scope="User">
<Value Profile="(Default)">50</Value>
</Setting>
<Setting Name="MainWindow_Top" Type="System.Double" Scope="User">
<Value Profile="(Default)">50</Value>
</Setting>
</Settings>
</SettingsFile>

View file

@ -421,6 +421,7 @@
<sys:String x:Key="GlobalSettings_ResetButtonLabel">Reset</sys:String>
<sys:String x:Key="GlobalSettings_ResetButtonTooltip">This will reset ALL the user global settings for the server manager. The server manager will be closed if successful.</sys:String>
<sys:String x:Key="GlobalSettings_RunAsAdministratorLabel">Enable Run as Administrator Prompt on Startup</sys:String>
<sys:String x:Key="GlobalSettings_StartModeLabel">Main Window Start Mode:</sys:String>
<sys:String x:Key="GlobalSettings_MinimizeToTrayLabel">Minimize To Tray</sys:String>
<sys:String x:Key="GlobalSettings_ManageFirewallLabel">Manage firewall settings automatically</sys:String>
<sys:String x:Key="GlobalSettings_ManagePublicIPLabel">Manage Public IP automatically</sys:String>

View file

@ -7,6 +7,30 @@
<link href="http://arkservermanager.freeforums.net/" />
<updated>2021-11-23T00:00:00Z</updated>
<entry>
<id>urn:uuid:50F06456-861E-483C-82BB-6072A428C652</id>
<title>1.1.408 (1.1.408.1)</title>
<summary>1.1.408.1</summary>
<link href="" />
<updated>2021-11-24T00:00:00Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
<p>
<u style="font-size: .9em;">NEW</u>
<br/>
<ul>
<li>Global Settings - Added option to set the Main Window start mode - Normal, Maximized, Minimized.</li>
<li>Main Window - now sotres the Left and Top positions of the window, when in Normal mode. Will restore the window position when started. Defaults to 50,50.</li>
</ul>
</p>
</div>
</content>
<author>
<name>bletch</name>
<email>bletch1971@hotmail.com</email>
</author>
</entry>
<entry>
<id>urn:uuid:2FF0893A-1412-4062-BF87-058F14E787FC</id>
<title>1.1.407 (1.1.407.2)</title>

View file

@ -5,45 +5,22 @@
<title>Ark Server Manager Version Feed</title>
<subtitle>This is the Ark Server Manager beta version feed.</subtitle>
<link href="http://arkservermanager.freeforums.net/" />
<updated>2021-11-23T00:00:00Z</updated>
<updated>2021-11-24T00:00:00Z</updated>
<entry>
<id>urn:uuid:CCE4B82B-122A-4BBF-A79F-934B79E41382</id>
<title>1.1.407 (1.1.407.2)</title>
<summary>1.1.407.2</summary>
<id>urn:uuid:50F06456-861E-483C-82BB-6072A428C652</id>
<title>1.1.408 (1.1.408.1)</title>
<summary>1.1.408.1</summary>
<link href="" />
<updated>2021-11-23T00:00:00Z</updated>
<updated>2021-11-24T00:00:00Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
<p>
<u style="font-size: .9em;">CHANGES</u>
<u style="font-size: .9em;">NEW</u>
<br/>
<ul>
<li>zh-CN Translation file updated.</li>
</ul>
</p>
</div>
</content>
<author>
<name>bletch</name>
<email>bletch1971@hotmail.com</email>
</author>
</entry>
<entry>
<id>urn:uuid:2FF0893A-1412-4062-BF87-058F14E787FC</id>
<title>1.1.407 (1.1.407.1)</title>
<summary>1.1.407.1</summary>
<link href="" />
<updated>2021-11-21T00:00:00Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
<p>
<u style="font-size: .9em;">CHANGES</u>
<br/>
<ul>
<li>Server Status checks - a few code tweaks to the server status checks.</li>
<li>pt-BR Translation file updated.</li>
<li>Global Settings - Added option to set the Main Window start mode - Normal, Maximized, Minimized.</li>
<li>Main Window - now sotres the Left and Top positions of the window, when in Normal mode. Will restore the window position when started. Defaults to 50,50.</li>
</ul>
</p>
</div>

View file

@ -7,7 +7,8 @@
xmlns:cc="clr-namespace:ServerManagerTool.Common.Converters;assembly=ServerManager.Common"
xmlns:globcntrls="clr-namespace:WPFSharp.Globalizer.Controls;assembly=WPFSharp.Globalizer"
mc:Ignorable="d"
d:DesignWidth="800">
d:DesignWidth="800"
x:Name="GlobalSettings">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
@ -47,8 +48,8 @@
</ContentControl>
</ResourceDictionary>
</UserControl.Resources>
<Grid Margin="3">
<Grid Margin="3" Background="{StaticResource BeigeGradient}">
<ScrollViewer VerticalScrollBarVisibility="Visible">
<Grid>
<Grid.RowDefinitions>
@ -74,6 +75,7 @@
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
@ -90,10 +92,13 @@
</DockPanel>
<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="2" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_MinimizeToTrayLabel}" IsChecked="{Binding CurrentConfig.MainWindow_MinimizeToTray, Mode=TwoWay}" HorizontalAlignment="Left"/>
<CheckBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_ManageFirewallLabel}" IsChecked="{Binding CurrentConfig.ManageFirewallAutomatically, Mode=TwoWay}" HorizontalAlignment="Left"/>
<CheckBox Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_ManagePublicIPLabel}" IsChecked="{Binding CurrentConfig.ManagePublicIPAutomatically, Mode=TwoWay}" HorizontalAlignment="Left"/>
<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"/>
<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="2" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_ManagePublicIPLabel}" IsChecked="{Binding CurrentConfig.ManagePublicIPAutomatically, Mode=TwoWay}" HorizontalAlignment="Left"/>
<Label Grid.Row="4" Grid.Column="0" Margin="1" Content="{DynamicResource GlobalSettings_DataDirectoryLabel}" VerticalAlignment="Center"/>
<TextBox Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" Margin="1" Text="{Binding CurrentConfig.DataDir, Mode=TwoWay}" IsReadOnly="True" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" />

View file

@ -4,6 +4,7 @@ using ServerManagerTool.Common;
using ServerManagerTool.Common.Lib;
using ServerManagerTool.Common.Utils;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
@ -11,6 +12,7 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Xml;
using WPFSharp.Globalizer;
@ -27,6 +29,7 @@ namespace ServerManagerTool
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 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 GlobalSettingsControl()
{
@ -36,6 +39,12 @@ namespace ServerManagerTool
this.CommonConfig = CommonConfig.Default;
this.DataContext = this;
this.WindowStates = new List<WindowState>();
foreach (var windowState in Enum.GetValues(typeof(WindowState)))
{
this.WindowStates.Add((WindowState)windowState);
}
InitializeComponent();
WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
@ -66,6 +75,12 @@ namespace ServerManagerTool
set { SetValue(IsAdministratorProperty, value); }
}
public List<WindowState> WindowStates
{
get { return (List<WindowState>)GetValue(WindowStatesProperty); }
set { SetValue(WindowStatesProperty, value); }
}
private string GetDeployedVersion()
{
XmlDocument xmlDoc = new XmlDocument();
@ -278,6 +293,18 @@ namespace ServerManagerTool
}
}
private void ComboBox_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
var comboBox = sender as ComboBox;
if (comboBox == null)
return;
if (comboBox.IsDropDownOpen)
return;
e.Handled = true;
}
private void LanguageSelectionComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
CurrentConfig.CultureName = AvailableLanguages.Instance.SelectedLanguage;

View file

@ -9,8 +9,8 @@
xmlns:cvr="clr-namespace:ServerManagerTool.Common.ValidationRules;assembly=ServerManager.Common"
xmlns:com="clr-namespace:ServerManagerTool.Common;assembly=ServerManager.Common"
xmlns:enum="clr-namespace:ServerManagerTool.Enums"
MinWidth="900" MinHeight="600" Width="1100" Height="900" Left="50" Top="50"
Loaded="Window_Loaded" SizeChanged="Window_SizeChanged" StateChanged="Window_StateChanged"
MinWidth="900" MinHeight="600" Width="1100" Height="900" Left="50" Top="50" WindowState="Normal"
Loaded="Window_Loaded" SizeChanged="Window_SizeChanged" StateChanged="Window_StateChanged" LocationChanged="Window_LocationChanged"
Name="Main" Icon="../Art/favicon.ico" Title="{DynamicResource MainWindow_Title}">
<Window.Resources>
<ResourceDictionary>

View file

@ -159,8 +159,11 @@ namespace ServerManagerTool
}
}
this.Left = Config.Default.MainWindow_Left;
this.Top = Config.Default.MainWindow_Top;
this.Height = Config.Default.MainWindow_Height;
this.Width = Config.Default.MainWindow_Width;
this.WindowState = Config.Default.MainWindow_WindowState;
// hook into the language change event
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent += ResourceDictionaryChangedEvent;
@ -204,6 +207,15 @@ namespace ServerManagerTool
this.Activate();
}
private void Window_LocationChanged(object sender, EventArgs e)
{
if (this.WindowState == WindowState.Normal)
{
Config.Default.MainWindow_Left = Math.Max(0D, this.Left);
Config.Default.MainWindow_Top = Math.Max(0D, this.Top);
}
}
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (this.WindowState != WindowState.Minimized)

View file

@ -552,6 +552,15 @@
<setting name="ManagePublicIPAutomatically" serializeAs="String">
<value>True</value>
</setting>
<setting name="MainWindow_Left" serializeAs="String">
<value>50</value>
</setting>
<setting name="MainWindow_Top" serializeAs="String">
<value>50</value>
</setting>
<setting name="MainWindow_WindowState" serializeAs="String">
<value>Normal</value>
</setting>
</ServerManagerTool.Config>
</userSettings>
</configuration>

View file

@ -1896,5 +1896,41 @@ namespace ServerManagerTool {
this["ManagePublicIPAutomatically"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("50")]
public double MainWindow_Left {
get {
return ((double)(this["MainWindow_Left"]));
}
set {
this["MainWindow_Left"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("50")]
public double MainWindow_Top {
get {
return ((double)(this["MainWindow_Top"]));
}
set {
this["MainWindow_Top"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Normal")]
public global::System.Windows.WindowState MainWindow_WindowState {
get {
return ((global::System.Windows.WindowState)(this["MainWindow_WindowState"]));
}
set {
this["MainWindow_WindowState"] = value;
}
}
}
}

View file

@ -527,5 +527,14 @@
<Setting Name="ManagePublicIPAutomatically" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="MainWindow_Left" Type="System.Double" Scope="User">
<Value Profile="(Default)">50</Value>
</Setting>
<Setting Name="MainWindow_Top" Type="System.Double" Scope="User">
<Value Profile="(Default)">50</Value>
</Setting>
<Setting Name="MainWindow_WindowState" Type="System.Windows.WindowState" Scope="User">
<Value Profile="(Default)">Normal</Value>
</Setting>
</Settings>
</SettingsFile>

View file

@ -623,6 +623,7 @@
<sys:String x:Key="GlobalSettings_ResetButtonLabel">Reset</sys:String>
<sys:String x:Key="GlobalSettings_ResetButtonTooltip">This will reset ALL the user global settings for the server manager. The server manager will be closed if successful.</sys:String>
<sys:String x:Key="GlobalSettings_RunAsAdministratorLabel">Enable Run as Administrator Prompt on Startup</sys:String>
<sys:String x:Key="GlobalSettings_StartModeLabel">Main Window Start Mode:</sys:String>
<sys:String x:Key="GlobalSettings_MinimizeToTrayLabel">Minimize To Tray</sys:String>
<sys:String x:Key="GlobalSettings_ManageFirewallLabel">Manage firewall settings automatically</sys:String>
<sys:String x:Key="GlobalSettings_ManagePublicIPLabel">Manage Public IP automatically</sys:String>

View file

@ -5,7 +5,31 @@
<title>Conan Server Manager Version Feed</title>
<subtitle>This is the Conan Server Manager release version feed.</subtitle>
<link href="http://servermanagers.freeforums.net/" />
<updated>2021-11-21T00:00:00Z</updated>
<updated>2021-11-24T00:00:00Z</updated>
<entry>
<id>urn:uuid:80B2DFDC-E9BE-4B56-A1FE-DD57E64647D1</id>
<title>1.1.53 (1.1.53.1)</title>
<summary>1.1.53.1</summary>
<link href="" />
<updated>2021-11-24T00:00:00Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
<p>
<u style="font-size: .9em;">NEW</u>
<br/>
<ul>
<li>Global Settings - Added option to set the Main Window start mode - Normal, Maximized, Minimized.</li>
<li>Main Window - now sotres the Left and Top positions of the window, when in Normal mode. Will restore the window position when started. Defaults to 50,50.</li>
</ul>
</p>
</div>
</content>
<author>
<name>bletch</name>
<email>bletch1971@hotmail.com</email>
</author>
</entry>
<entry>
<id>urn:uuid:285E9972-4FC6-49EA-8FAD-1086F7FC5354</id>

View file

@ -5,21 +5,22 @@
<title>Conan Server Manager Version Feed</title>
<subtitle>This is the Conan Server Manager beta version feed.</subtitle>
<link href="http://servermanagers.freeforums.net/" />
<updated>2021-11-21T00:00:00Z</updated>
<updated>2021-11-24T00:00:00Z</updated>
<entry>
<id>urn:uuid:285E9972-4FC6-49EA-8FAD-1086F7FC5354</id>
<title>1.1.52 (1.1.52.1)</title>
<summary>1.1.52.1</summary>
<id>urn:uuid:80B2DFDC-E9BE-4B56-A1FE-DD57E64647D1</id>
<title>1.1.53 (1.1.53.1)</title>
<summary>1.1.53.1</summary>
<link href="" />
<updated>2021-11-21T00:00:00Z</updated>
<updated>2021-11-24T00:00:00Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
<p>
<u style="font-size: .9em;">CHANGE</u>
<u style="font-size: .9em;">NEW</u>
<br/>
<ul>
<li>Server Status checks - a few code tweaks to the server status checks.</li>
<li>Global Settings - Added option to set the Main Window start mode - Normal, Maximized, Minimized.</li>
<li>Main Window - now sotres the Left and Top positions of the window, when in Normal mode. Will restore the window position when started. Defaults to 50,50.</li>
</ul>
</p>
</div>

View file

@ -7,7 +7,8 @@
xmlns:cc="clr-namespace:ServerManagerTool.Common.Converters;assembly=ServerManager.Common"
xmlns:gctl="clr-namespace:WPFSharp.Globalizer.Controls;assembly=WPFSharp.Globalizer"
mc:Ignorable="d"
d:DesignWidth="800">
d:DesignWidth="800"
x:Name="GlobalSettings">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
@ -19,6 +20,10 @@
<cc:MinutesToTimeValueConverter x:Key="MinutesToTimeValueConverter"/>
<SolidColorBrush x:Key="BeigeBorder" Color="#FFD8CCBC"/>
<LinearGradientBrush x:Key="BeigeGradient" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFECE1D4" Offset="1"/>
<GradientStop Color="#FFEAE8E6"/>
</LinearGradientBrush>
<Style x:Key="GroupBoxStyle" TargetType="GroupBox" BasedOn="{StaticResource {x:Type GroupBox}}">
<Setter Property="BorderBrush" Value="{StaticResource BeigeBorder}"/>
@ -81,8 +86,8 @@
</ContentControl>
</ResourceDictionary>
</UserControl.Resources>
<Grid Margin="3">
<Grid Margin="3" Background="{StaticResource BeigeGradient}">
<ScrollViewer VerticalScrollBarVisibility="Visible">
<Grid>
<Grid.RowDefinitions>
@ -112,6 +117,7 @@
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
@ -128,14 +134,17 @@
</DockPanel>
<CheckBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_RunAsAdministratorLabel}" IsChecked="{Binding Config.RunAsAdministratorPrompt, Mode=TwoWay}" HorizontalAlignment="Left"/>
<CheckBox Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_MinimizeToTrayLabel}" IsChecked="{Binding Config.MainWindow_MinimizeToTray, Mode=TwoWay}" HorizontalAlignment="Left"/>
<CheckBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_ManageFirewallLabel}" IsChecked="{Binding Config.ManageFirewallAutomatically, Mode=TwoWay}" HorizontalAlignment="Left"/>
<CheckBox Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_ManagePublicIPLabel}" IsChecked="{Binding CurrentConfig.ManagePublicIPAutomatically, Mode=TwoWay}" HorizontalAlignment="Left"/>
<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 Config.MainWindow_WindowState}" 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_DataDirectoryLabel}" VerticalAlignment="Center"/>
<TextBox Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" Margin="1" Text="{Binding Config.DataPath, Mode=TwoWay}" IsReadOnly="True" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" />
<Button Grid.Row="3" Grid.Column="3" Grid.ColumnSpan="2" Margin="5,1,0,1" VerticalAlignment="Center" HorizontalAlignment="Left" Content="{DynamicResource DataDirectoryButtonContent}" Click="SetDataDir_Click"/>
<CheckBox Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_ManageFirewallLabel}" IsChecked="{Binding Config.ManageFirewallAutomatically, Mode=TwoWay}" HorizontalAlignment="Left"/>
<CheckBox Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="2" Margin="5" Content="{DynamicResource GlobalSettings_ManagePublicIPLabel}" IsChecked="{Binding Config.ManagePublicIPAutomatically, Mode=TwoWay}" HorizontalAlignment="Left"/>
<Label Grid.Row="4" Grid.Column="0" Margin="1" Content="{DynamicResource GlobalSettings_DataDirectoryLabel}" VerticalAlignment="Center"/>
<TextBox Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" Margin="1" Text="{Binding Config.DataPath, Mode=TwoWay}" IsReadOnly="True" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" />
<Button Grid.Row="4" Grid.Column="3" Grid.ColumnSpan="2" Margin="5,1,0,1" VerticalAlignment="Center" HorizontalAlignment="Left" Content="{DynamicResource DataDirectoryButtonContent}" Click="SetDataDir_Click"/>
<Label Grid.Row="5" Grid.Column="0" Margin="1" Content="{DynamicResource GlobalSettings_BackupDirectoryLabel}" VerticalAlignment="Center"/>
<TextBox Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="2" Margin="1" Text="{Binding Config.BackupPath, Mode=TwoWay}" IsReadOnly="True" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" />

View file

@ -4,6 +4,7 @@ using ServerManagerTool.Common;
using ServerManagerTool.Common.Lib;
using ServerManagerTool.Common.Utils;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
@ -11,6 +12,7 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Xml;
using WPFSharp.Globalizer;
@ -26,6 +28,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 GlobalSettingsControl()
{
@ -35,6 +38,12 @@ namespace ServerManagerTool
this.IsAdministrator = SecurityUtils.IsAdministrator();
this.Version = GetDeployedVersion();
this.WindowStates = new List<WindowState>();
foreach (var windowState in Enum.GetValues(typeof(WindowState)))
{
this.WindowStates.Add((WindowState)windowState);
}
InitializeComponent();
WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
@ -65,6 +74,12 @@ namespace ServerManagerTool
set { SetValue(IsAdministratorProperty, value); }
}
public List<WindowState> WindowStates
{
get { return (List<WindowState>)GetValue(WindowStatesProperty); }
set { SetValue(WindowStatesProperty, value); }
}
public string Version
{
get;
@ -287,6 +302,18 @@ namespace ServerManagerTool
}
}
private void ComboBox_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
var comboBox = sender as ComboBox;
if (comboBox == null)
return;
if (comboBox.IsDropDownOpen)
return;
e.Handled = true;
}
private void LanguageSelectionComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Config.CultureName = AvailableLanguages.Instance.SelectedLanguage;

View file

@ -10,8 +10,8 @@
xmlns:clib="clr-namespace:ServerManagerTool.Common.Lib;assembly=ServerManager.Common"
xmlns:tsk="clr-namespace:Microsoft.Win32.TaskScheduler;assembly=Microsoft.Win32.TaskScheduler"
xmlns:tb="http://www.hardcodet.net/taskbar"
MinWidth="900" MinHeight="600" Width="1100" Height="900" Left="50" Top="50"
Loaded="Window_Loaded" SizeChanged="Window_SizeChanged" StateChanged="Window_StateChanged"
MinWidth="900" MinHeight="600" Width="1100" Height="900" Left="50" Top="50" WindowState="Normal"
Loaded="Window_Loaded" SizeChanged="Window_SizeChanged" StateChanged="Window_StateChanged" LocationChanged="Window_LocationChanged"
Name="Main" Icon="../Art/favicon.ico" Title="{DynamicResource MainWindow_Title}">
<Window.Resources>
<ResourceDictionary>

View file

@ -152,8 +152,11 @@ namespace ServerManagerTool
}
}
this.Left = Config.Default.MainWindow_Left;
this.Top = Config.Default.MainWindow_Top;
this.Height = Config.Default.MainWindow_Height;
this.Width = Config.Default.MainWindow_Width;
this.WindowState = Config.Default.MainWindow_WindowState;
// hook into the language change event
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent += ResourceDictionaryChangedEvent;
@ -197,6 +200,15 @@ namespace ServerManagerTool
this.Activate();
}
private void Window_LocationChanged(object sender, EventArgs e)
{
if (this.WindowState == WindowState.Normal)
{
Config.Default.MainWindow_Left = Math.Max(0D, this.Left);
Config.Default.MainWindow_Top = Math.Max(0D, this.Top);
}
}
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (this.WindowState != WindowState.Minimized)