Task Scheduler Changes

- added on Login option to Auto-Start server.
This commit is contained in:
Brett Hewitson 2022-08-08 00:39:22 +10:00
parent 795055f2f1
commit 19a6a80c56
7 changed files with 92 additions and 26 deletions

View file

@ -1237,8 +1237,12 @@
<sys:String x:Key="ServerSettings_AutomaticManagementLabel">Automatic Management</sys:String>
<sys:String x:Key="ServerSettings_NoAutoManagementButtonLabel">Why can't I use this?</sys:String>
<sys:String x:Key="ServerSettings_ServerManagerSettingsLabel">Server Manager Settings</sys:String>
<sys:String x:Key="ServerSettings_AutoStartLabel">Auto-Start server on boot</sys:String>
<sys:String x:Key="ServerSettings_AutoStartTooltip">Automatically start the server when the machine starts.</sys:String>
<sys:String x:Key="ServerSettings_AutoStartServerLabel">Auto-Start server</sys:String>
<sys:String x:Key="ServerSettings_AutoStartServerTooltip">Automatically start the server.</sys:String>
<sys:String x:Key="ServerSettings_AutoStartServerOnBootLabel">on Boot</sys:String>
<sys:String x:Key="ServerSettings_AutoStartServerOnBootTooltip">Start the server when the machine starts.</sys:String>
<sys:String x:Key="ServerSettings_AutoStartServerOnLoginLabel">on Login</sys:String>
<sys:String x:Key="ServerSettings_AutoStartServerOnLoginTooltip">Start the server when the user logs in.</sys:String>
<sys:String x:Key="ServerSettings_EnableAutoShutdownLabel">Shutdown server at</sys:String>
<sys:String x:Key="ServerSettings_EnableAutoShutdownTooltip">The hour and minute of the day to force a server shutdown.</sys:String>
<sys:String x:Key="ServerSettings_RestartAfterShutdownLabel">then restart</sys:String>

View file

@ -486,6 +486,14 @@ namespace ServerManagerTool.Lib
set { SetValue(EnableAutoStartProperty, value); }
}
public static readonly DependencyProperty AutoStartOnLoginProperty = DependencyProperty.Register(nameof(AutoStartOnLogin), typeof(bool), typeof(ServerProfile), new PropertyMetadata(false));
[DataMember]
public bool AutoStartOnLogin
{
get { return (bool)GetValue(AutoStartOnLoginProperty); }
set { SetValue(AutoStartOnLoginProperty, value); }
}
public static readonly DependencyProperty EnableAutoUpdateProperty = DependencyProperty.Register(nameof(EnableAutoUpdate), typeof(bool), typeof(ServerProfile), new PropertyMetadata(false));
[DataMember]
public bool EnableAutoUpdate
@ -1240,7 +1248,7 @@ namespace ServerManagerTool.Lib
var taskKey = GetProfileKey();
if(!TaskSchedulerUtils.ScheduleAutoStart(taskKey, null, this.EnableAutoStart, GetLauncherFile(), ProfileName, true, Config.Default.AutoStart_TaskPriority))
if (!TaskSchedulerUtils.ScheduleAutoStart(taskKey, null, this.EnableAutoStart, GetLauncherFile(), ProfileName, this.AutoStartOnLogin, Config.Default.AutoStart_TaskPriority))
{
return false;
}

View file

@ -981,7 +981,11 @@
</Style>
</Grid.Style>
<CheckBox Grid.Row="0" Margin="5,5,5,0" Content="{DynamicResource ServerSettings_AutoStartLabel}" IsChecked="{Binding EnableAutoStart}" VerticalAlignment="Center" ToolTip="{DynamicResource ServerSettings_AutoStartTooltip}" HorizontalAlignment="Left"/>
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="5,5,5,0">
<CheckBox Content="{DynamicResource ServerSettings_AutoStartServerLabel}" VerticalAlignment="Bottom" IsChecked="{Binding EnableAutoStart}" ToolTip="{DynamicResource ServerSettings_AutoStartServerTooltip}" HorizontalAlignment="Left"/>
<RadioButton GroupName="AutoStartServer" Margin="10,0,0,0" VerticalAlignment="Bottom" IsEnabled="{Binding EnableAutoStart}" IsChecked="{Binding AutoStartOnLogin, Converter={StaticResource InvertBooleanConverter}}" Content="{DynamicResource ServerSettings_AutoStartServerOnBootLabel}" ToolTip="{DynamicResource ServerSettings_AutoStartServerOnBootTooltip}"/>
<RadioButton GroupName="AutoStartServer" Margin="5,0,0,0" VerticalAlignment="Bottom" IsEnabled="{Binding EnableAutoStart}" IsChecked="{Binding AutoStartOnLogin}" Content="{DynamicResource ServerSettings_AutoStartServerOnLoginLabel}" ToolTip="{DynamicResource ServerSettings_AutoStartServerOnLoginTooltip}"/>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="5,5,5,0" >
<CheckBox Name="EnableAutoShutdown1Checkbox" IsChecked="{Binding EnableAutoShutdown1}" Content="{DynamicResource ServerSettings_EnableAutoShutdownLabel}" VerticalAlignment="Bottom" ToolTip="{DynamicResource ServerSettings_EnableAutoShutdownTooltip}"/>