Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 62de4ecc42 | |||
| 10f0cc0bb1 | |||
| d434adada9 | |||
| fe66efba31 | |||
| 2cae359adf | |||
| 1b208c0afa | |||
| 16ba287d62 | |||
| 7192a2d3e8 |
+1
-1
@@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27130.2027
|
||||
VisualStudioVersion = 15.0.27004.2005
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimedShutdown", "TimedShutdown\TimedShutdown.csproj", "{C1158C45-7666-4586-A6DA-CCC1EE95D457}"
|
||||
EndProject
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
</configuration>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace TimedShutdown
|
||||
{
|
||||
public class Messaging
|
||||
{
|
||||
public enum Message
|
||||
{
|
||||
RemoteShutdown
|
||||
}
|
||||
|
||||
public void Show(Message message, string info)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case Message.RemoteShutdown:
|
||||
MessageBox.Show(
|
||||
$"The following remote machine has been sent a shutdown/reboot signal:\n\n{info}",
|
||||
"Timed Shutdown",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Information);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Threading;
|
||||
|
||||
namespace TimedShutdown
|
||||
{
|
||||
public class PingWidget
|
||||
{
|
||||
private string RemoteAddress { get; set; }
|
||||
public bool WidgetHasInitialized { get; private set; } = false;
|
||||
|
||||
BackgroundWorker contPingBackgroundWorker = new BackgroundWorker();
|
||||
|
||||
public void InitatePingRequest(string _remoteAddress)
|
||||
{
|
||||
RemoteAddress = _remoteAddress;
|
||||
|
||||
contPingBackgroundWorker.WorkerSupportsCancellation = true;
|
||||
contPingBackgroundWorker.DoWork += ContPingBackgroundWorkerDoWork;
|
||||
|
||||
if (contPingBackgroundWorker.IsBusy == false)
|
||||
{
|
||||
contPingBackgroundWorker.RunWorkerAsync();
|
||||
}
|
||||
|
||||
WidgetHasInitialized = true;
|
||||
}
|
||||
|
||||
public void StopCurrentPingRequest()
|
||||
{
|
||||
contPingBackgroundWorker.CancelAsync();
|
||||
Debug.WriteLine("Stopped ping request");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Will continuously ping the input IP address every 5 seconds,
|
||||
/// will stop if a cancellation request is made.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ContPingBackgroundWorkerDoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
|
||||
while (contPingBackgroundWorker.CancellationPending == false)
|
||||
{
|
||||
Ping pingSender = new Ping();
|
||||
IPAddress address = IPAddressConverter(RemoteAddress);
|
||||
PingReply reply = pingSender.Send(address);
|
||||
|
||||
if (reply.Status == IPStatus.Success)
|
||||
{
|
||||
Debug.WriteLine("Ping Success!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine(reply.Status);
|
||||
}
|
||||
|
||||
Thread.Sleep(3000);
|
||||
}
|
||||
}
|
||||
|
||||
private IPAddress IPAddressConverter (string remoteAddress)
|
||||
{
|
||||
IPAddress ip;
|
||||
if (IPAddress.TryParse(remoteAddress, out ip))
|
||||
return ip;
|
||||
else
|
||||
{
|
||||
IPHostEntry iphost = Dns.GetHostEntry(remoteAddress);
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,5 +51,5 @@ using System.Windows;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyVersion("1.1.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.1.0.0")]
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ namespace TimedShutdown.Properties {
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class Resources {
|
||||
|
||||
+9
-13
@@ -8,21 +8,17 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace TimedShutdown.Properties
|
||||
{
|
||||
|
||||
|
||||
namespace TimedShutdown.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.2.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace TimedShutdown
|
||||
{
|
||||
public class ShutdownManager
|
||||
{
|
||||
private readonly Func<bool, string> _funcForceShutdown = ForceShutdown;
|
||||
private readonly Func<Operation, string> _funcShutdownOperation = ShutdownOperation;
|
||||
private readonly Func<string, string> _funcRemoteShutdown = RemoteShutdown;
|
||||
|
||||
public enum Operation
|
||||
{
|
||||
Shutdown,
|
||||
@@ -17,18 +23,16 @@ namespace TimedShutdown
|
||||
/// <param name="shutdownoperation"></param>
|
||||
/// <param name="shutdownSeconds"></param>
|
||||
/// <param name="forceShutdownState"></param>
|
||||
public void ExecuteOperation(Operation shutdownoperation, int shutdownSeconds, bool forceShutdownState)
|
||||
public void ExecuteOperation(Operation shutdownoperation, int shutdownSeconds, bool forceShutdownState, string remoteShutdown)
|
||||
{
|
||||
Func<bool,string> forceShutdown = ForceShutdown;
|
||||
Func<Operation, string> shutdownOperation = ShutdownOperation;
|
||||
|
||||
ProcessStartInfo info = new ProcessStartInfo();
|
||||
Process proc = new Process();
|
||||
|
||||
info.FileName = "cmd.exe";
|
||||
info.Arguments = $"/c shutdown {ShutdownOperation(shutdownoperation)} -t" +
|
||||
info.Arguments = $"/c shutdown {_funcShutdownOperation(shutdownoperation)} -t" +
|
||||
$" {shutdownSeconds}" +
|
||||
$" {ForceShutdown(forceShutdownState)}";
|
||||
$" {_funcForceShutdown(forceShutdownState)}" +
|
||||
$" {_funcRemoteShutdown(remoteShutdown)}";
|
||||
info.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
info.CreateNoWindow = true;
|
||||
|
||||
@@ -36,22 +40,23 @@ namespace TimedShutdown
|
||||
proc.Start();
|
||||
}
|
||||
|
||||
public void AbortOperation()
|
||||
public void AbortOperation(string remoteShutdown)
|
||||
{
|
||||
ProcessStartInfo info = new ProcessStartInfo();
|
||||
Process proc = new Process();
|
||||
|
||||
info.FileName = "cmd.exe";
|
||||
info.Arguments = $"/c shutdown -a";
|
||||
info.Arguments = $"/c shutdown -a {_funcRemoteShutdown(remoteShutdown)}";
|
||||
info.CreateNoWindow = true;
|
||||
info.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
|
||||
proc.StartInfo = info;
|
||||
proc.Start();
|
||||
}
|
||||
|
||||
#region Functions
|
||||
|
||||
private string ShutdownOperation(Operation arg)
|
||||
private static string ShutdownOperation(Operation arg)
|
||||
{
|
||||
switch (arg)
|
||||
{
|
||||
@@ -64,11 +69,24 @@ namespace TimedShutdown
|
||||
}
|
||||
}
|
||||
|
||||
private string ForceShutdown(bool arg)
|
||||
private static string ForceShutdown(bool arg)
|
||||
{
|
||||
return "-f";
|
||||
}
|
||||
|
||||
private static string RemoteShutdown(string arg)
|
||||
{
|
||||
if (string.IsNullOrEmpty(arg)) return string.Empty;
|
||||
|
||||
if (IPAddress.TryParse(arg, out IPAddress address) == false) { throw new FormatException(); }
|
||||
|
||||
if (arg.StartsWith(@"\\"))
|
||||
{
|
||||
return $"-m {arg}";
|
||||
}
|
||||
return $@"-m \\{arg}";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
@@ -8,11 +8,12 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>TimedShutdown</RootNamespace>
|
||||
<AssemblyName>TimedShutdown</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -70,6 +71,8 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Messaging.cs" />
|
||||
<Compile Include="PingWidget.cs" />
|
||||
<Compile Include="ShutdownManager.cs" />
|
||||
<Compile Include="ViewModels\ShellRootViewModel.cs" />
|
||||
<Compile Include="Views\ShellRootView.xaml.cs">
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Caliburn.Micro;
|
||||
|
||||
@@ -6,29 +8,8 @@ namespace TimedShutdown.ViewModels
|
||||
{
|
||||
public class ShellRootViewModel : Screen
|
||||
{
|
||||
readonly ShutdownManager shutdownManager = new ShutdownManager();
|
||||
|
||||
#region Labels
|
||||
|
||||
public string LabelWindowTitle { get; } = "Timed Shutdown";
|
||||
|
||||
public string LabelHoursLabel { get; } = "Hours:";
|
||||
|
||||
public string LabelMinutesLabel { get; } = "Minutes:";
|
||||
|
||||
public string LabelShutdownOptions { get; } = "Options:";
|
||||
|
||||
public string LabelShutdownOptionsForce { get; } = "Force Operation";
|
||||
|
||||
public string LabelShutdownTime { get; set; } = "Shutdown Time:";
|
||||
|
||||
public string LabelShutdown { get; } = "Shutdown";
|
||||
|
||||
public string LabelReboot { get; } = "Reboot";
|
||||
|
||||
public string LabelAbortShutdown { get; } = "Abort Shutdown";
|
||||
|
||||
#endregion
|
||||
private readonly ShutdownManager _shutdownManager = new ShutdownManager();
|
||||
private readonly PingWidget pingWidget = new PingWidget();
|
||||
|
||||
#region Values
|
||||
|
||||
@@ -82,19 +63,79 @@ namespace TimedShutdown.ViewModels
|
||||
|
||||
public bool ShutdownOptionsForce { get; set; }
|
||||
|
||||
private string _IPRemoteShutdown;
|
||||
public string IPRemoteShutdown
|
||||
{
|
||||
get { return _IPRemoteShutdown; }
|
||||
set
|
||||
{
|
||||
if (IPAddress.TryParse(value, out IPAddress address) == false) { value = string.Empty; } // Temporary validation.
|
||||
_IPRemoteShutdown = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _pingRemoteHost;
|
||||
public bool PingRemoteHost
|
||||
{
|
||||
get { return _pingRemoteHost; }
|
||||
set
|
||||
{
|
||||
_pingRemoteHost = value;
|
||||
|
||||
if (value == true)
|
||||
{
|
||||
|
||||
pingWidget.InitatePingRequest(IPRemoteShutdown);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pingWidget.WidgetHasInitialized == true)
|
||||
{
|
||||
pingWidget.StopCurrentPingRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string PingRemoteHostStatus { get; set; }
|
||||
|
||||
#region Remote Expander
|
||||
|
||||
public int WindowHeight { get; set; } = 335; // Default 335
|
||||
|
||||
private bool _remoteExpander;
|
||||
public bool RemoteExpander
|
||||
{
|
||||
get { return _remoteExpander; }
|
||||
set
|
||||
{
|
||||
WindowHeight = value ? 460 : 335;
|
||||
NotifyOfPropertyChange(() => WindowHeight);
|
||||
|
||||
_remoteExpander = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Buttons
|
||||
#endregion
|
||||
|
||||
#region Controls
|
||||
|
||||
public bool CanShutdown { get; set; } = true;
|
||||
public void Shutdown()
|
||||
{
|
||||
shutdownManager.ExecuteOperation(ShutdownManager.Operation.Shutdown, ShutdownTime, false);
|
||||
CanAbortShutdown = true;
|
||||
_shutdownManager.ExecuteOperation(
|
||||
ShutdownManager.Operation.Shutdown,
|
||||
ShutdownTime,
|
||||
ShutdownOptionsForce,
|
||||
IPRemoteShutdown);
|
||||
|
||||
ProcessRemoteShutdownAlert();
|
||||
|
||||
CanReboot = false;
|
||||
CanShutdown = false;
|
||||
|
||||
NotifyOfPropertyChange(() => CanAbortShutdown);
|
||||
NotifyOfPropertyChange(() => CanReboot);
|
||||
NotifyOfPropertyChange(() => CanShutdown);
|
||||
}
|
||||
@@ -102,31 +143,96 @@ namespace TimedShutdown.ViewModels
|
||||
public bool CanReboot { get; set; } = true;
|
||||
public void Reboot()
|
||||
{
|
||||
shutdownManager.ExecuteOperation(ShutdownManager.Operation.Reboot, ShutdownTime, false);
|
||||
CanAbortShutdown = true;
|
||||
_shutdownManager.ExecuteOperation(
|
||||
ShutdownManager.Operation.Reboot,
|
||||
ShutdownTime,
|
||||
ShutdownOptionsForce,
|
||||
IPRemoteShutdown);
|
||||
|
||||
ProcessRemoteShutdownAlert();
|
||||
|
||||
CanReboot = false;
|
||||
CanShutdown = false;
|
||||
|
||||
NotifyOfPropertyChange(() => CanAbortShutdown);
|
||||
NotifyOfPropertyChange(() => CanReboot);
|
||||
NotifyOfPropertyChange(() => CanShutdown);
|
||||
}
|
||||
|
||||
public bool CanAbortShutdown { get; set; } = true;
|
||||
public void AbortShutdown()
|
||||
{
|
||||
// Reset values to defaults.
|
||||
Minutes = 0;
|
||||
Hours = 0;
|
||||
|
||||
shutdownManager.AbortOperation();
|
||||
CanAbortShutdown = false;
|
||||
_shutdownManager.AbortOperation(IPRemoteShutdown);
|
||||
CanReboot = true;
|
||||
CanShutdown = true;
|
||||
|
||||
NotifyOfPropertyChange(() => CanAbortShutdown);
|
||||
NotifyOfPropertyChange(() => CanReboot);
|
||||
NotifyOfPropertyChange(() => CanShutdown);
|
||||
NotifyOfPropertyChange(() => IPRemoteShutdown);
|
||||
}
|
||||
|
||||
private bool _contextRemoteShutdown;
|
||||
public bool ContextRemoteShutdown
|
||||
{
|
||||
get { return _contextRemoteShutdown; }
|
||||
set
|
||||
{
|
||||
_contextRemoteShutdown = value;
|
||||
|
||||
if (value == true)
|
||||
{
|
||||
IPRemoteShutdownEnabled = true;
|
||||
PingRemoteHostEnabled = true;
|
||||
|
||||
NotifyOfPropertyChange(() => IPRemoteShutdownEnabled);
|
||||
NotifyOfPropertyChange(() => PingRemoteHostEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _contextLocalShutdown = true;
|
||||
public bool ContextLocalShutdown
|
||||
{
|
||||
get { return _contextLocalShutdown; }
|
||||
set
|
||||
{
|
||||
|
||||
_contextLocalShutdown = value;
|
||||
|
||||
if (value == true)
|
||||
{
|
||||
IPRemoteShutdownEnabled = false;
|
||||
PingRemoteHostEnabled = false;
|
||||
IPRemoteShutdown = string.Empty;
|
||||
|
||||
NotifyOfPropertyChange(() => IPRemoteShutdown);
|
||||
NotifyOfPropertyChange(() => IPRemoteShutdownEnabled);
|
||||
NotifyOfPropertyChange(() => PingRemoteHostEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IPRemoteShutdownEnabled { get; set; }
|
||||
|
||||
public bool PingRemoteHostEnabled { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Alerts
|
||||
|
||||
private void ProcessRemoteShutdownAlert()
|
||||
{
|
||||
// Show remote shutdown alert upon checking for a non-loopback
|
||||
// address.
|
||||
if (!string.IsNullOrEmpty(IPRemoteShutdown)
|
||||
&& IPRemoteShutdown != "localhost"
|
||||
&& IPRemoteShutdown != "127.0.0.1")
|
||||
{
|
||||
Messaging alert = new Messaging();
|
||||
alert.Show(Messaging.Message.RemoteShutdown, IPRemoteShutdown);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Title="{Binding LabelWindowTitle}" Height="300" Width="400" WindowStartupLocation="CenterScreen"
|
||||
Title="Timed Shutdown" Height="{Binding WindowHeight, Mode=TwoWay}" Width="400" WindowStartupLocation="CenterScreen"
|
||||
ResizeMode="NoResize">
|
||||
<StackPanel>
|
||||
<Grid x:Name="ShutdownIcon" Margin="15">
|
||||
@@ -21,36 +21,37 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Icon -->
|
||||
<Image Source="/TimedShutdown;component/Resources/ShutdownIcon.png" Grid.Column="0" Grid.Row="0"
|
||||
Margin="0,0,5,0" Grid.RowSpan="3" RenderOptions.BitmapScalingMode="Fant"/>
|
||||
Margin="0,0,5,0" Grid.RowSpan="5" RenderOptions.BitmapScalingMode="Fant"/>
|
||||
|
||||
<!-- Row 1: Hours -->
|
||||
<Label x:Name="LabelHoursLabel" Grid.Row="0" Grid.Column="1" />
|
||||
<Label Content="Hours:" Grid.Row="0" Grid.Column="1" />
|
||||
<Slider Value="{Binding Hours, Mode=TwoWay}" Grid.Row="0" Grid.Column="2"
|
||||
Margin="10,0,10,0" Maximum="23" TickPlacement="BottomRight"/>
|
||||
<TextBox Text="{Binding Hours, Mode=TwoWay}" Grid.Row="0" Grid.Column="3"
|
||||
Margin="0,2.5" Padding="5" />
|
||||
|
||||
<!-- Row 2: Minutes -->
|
||||
<Label x:Name="LabelMinutesLabel" Grid.Row="1" Grid.Column="1" />
|
||||
<Label Content="Minutes:" Grid.Row="1" Grid.Column="1" />
|
||||
<Slider Value="{Binding Minutes, Mode=TwoWay}" Grid.Row="1" Grid.Column="2"
|
||||
Margin="10,0,10,0" Maximum="59" TickPlacement="BottomRight"/>
|
||||
<TextBox Text="{Binding Minutes, Mode=TwoWay}" Grid.Row="1" Grid.Column="3"
|
||||
Margin="0,2.5" Padding="5"/>
|
||||
|
||||
<!-- Row 3: Options -->
|
||||
<Label x:Name="LabelShutdownOptions" Grid.Row="2" Grid.Column="1" />
|
||||
<CheckBox x:Name="ShutdownOptionsForce" Content="{Binding LabelShutdownOptionsForce}" Grid.Row="2" Grid.Column="2"
|
||||
Margin="10,6,0,0" />
|
||||
<Label Content="Options:" Grid.Row="2" Grid.Column="1" />
|
||||
<CheckBox x:Name="ShutdownOptionsForce" Content="Force Operation" Grid.Row="2" Grid.Column="2"
|
||||
Margin="10,6,0,0" ToolTip="Forces a system shutdown/restart by ignoring programs preventing a shutdown."/>
|
||||
|
||||
<!-- Row 4: Shutdown Time -->
|
||||
<Label x:Name="LabelShutdownTime" Grid.Row="4" Grid.Column="1" Margin="0,5,0,0"/>
|
||||
<Label Content="Shutdown Time:" Grid.Row="4" Grid.Column="1" Margin="0,5,0,0"/>
|
||||
<TextBox Text="{Binding ShutdownTimeSpan, Mode=OneWay}" Grid.Row="4" Grid.Column="2"
|
||||
Grid.ColumnSpan="2" Padding="5" Margin="10,5,0,0" IsEnabled="False"/>
|
||||
|
||||
|
||||
</Grid>
|
||||
|
||||
<!-- Row 5: Shutdown/Reboot -->
|
||||
@@ -64,15 +65,61 @@
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Button x:Name="Shutdown" Content="{Binding LabelShutdown}" Grid.Row="0" Grid.Column="0"
|
||||
<Button x:Name="Shutdown" Content="Shutdown" Grid.Row="0" Grid.Column="0"
|
||||
Padding="5" Margin="0,5,2.5,0"/>
|
||||
<Button x:Name="Reboot" Content="{Binding LabelReboot}" Grid.Row="0" Grid.Column="1"
|
||||
<Button x:Name="Reboot" Content="Reboot" Grid.Row="0" Grid.Column="1"
|
||||
Padding="5" Margin="2.5,5,0,0"/>
|
||||
<Button x:Name="AbortShutdown" Content="{Binding LabelAbortShutdown}" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
|
||||
<Button x:Name="AbortShutdown" Content="Abort Shutdown" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
|
||||
Padding="5" Margin="0,5,0,0"/>
|
||||
|
||||
<!-- Remote Shutdown Options -->
|
||||
</Grid>
|
||||
<Separator/>
|
||||
<Expander IsExpanded="{Binding RemoteExpander}" x:Name="remoteExpander" Header="Remote Shutdown Options" Height="172" Padding="5">
|
||||
|
||||
<Grid>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Row 6: Shutdown Type -->
|
||||
<Label Content="Shutdown Type:" Grid.Row="0" Grid.Column="0" />
|
||||
<RadioButton IsChecked="{Binding ContextLocalShutdown}" Content="Local" Grid.Row="0" Grid.Column="1"
|
||||
Margin="10,5,0,0"/>
|
||||
<RadioButton IsChecked="{Binding ContextRemoteShutdown}" Content="Remote" Grid.Row="0" Grid.Column="2"
|
||||
Margin="10,5,0,0"/>
|
||||
|
||||
<!-- Row 7: Hostname/IP -->
|
||||
<Label Content="Hostname/IP Address:" Grid.Row="1" Grid.Column="0" Margin="0,5,0,0"/>
|
||||
<TextBox Text="{Binding IPRemoteShutdown, Mode=TwoWay}" Grid.Row="1" Grid.Column="1"
|
||||
IsEnabled="{Binding IPRemoteShutdownEnabled, Mode=TwoWay}"
|
||||
Padding="5" Margin="10,5,5,0" Grid.ColumnSpan="2"
|
||||
ToolTip="Enter the machine name or IP address to remotely shutdown. NOTE: This will only work on machines part of the same Windows Domain."/>
|
||||
|
||||
<!-- Row 8: Ping remote host -->
|
||||
<Label Content="Options:" Grid.Row="2" Grid.Column="0"/>
|
||||
<CheckBox IsChecked="{Binding PingRemoteHost, Mode=OneWayToSource}" Content="Ping remote host"
|
||||
IsEnabled="{Binding PingRemoteHostEnabled, Mode=TwoWay}"
|
||||
Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" Margin="10,5,0,0"/>
|
||||
|
||||
<!-- Row 9: Ping status -->
|
||||
<Label Content="Status:" Grid.Row="3" Grid.Column="0"/>
|
||||
<Label Content="{Binding PingRemoteHostStatus}" Grid.Row="3" Grid.Column="1"/>
|
||||
</Grid>
|
||||
</Expander>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user