Imported Version 1.0.0.0

This commit is contained in:
2019-03-05 21:01:17 +00:00
commit 9bb6d80782
28 changed files with 5079 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2027
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimedShutdown", "TimedShutdown\TimedShutdown.csproj", "{C1158C45-7666-4586-A6DA-CCC1EE95D457}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C1158C45-7666-4586-A6DA-CCC1EE95D457}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C1158C45-7666-4586-A6DA-CCC1EE95D457}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C1158C45-7666-4586-A6DA-CCC1EE95D457}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C1158C45-7666-4586-A6DA-CCC1EE95D457}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7E8B84F7-7D30-4B6A-9B9D-D9ED6C001280}
EndGlobalSection
EndGlobal
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
+14
View File
@@ -0,0 +1,14 @@
<Application x:Class="TimedShutdown.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TimedShutdown">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<local:Bootstrapper x:Key="Bootstrapper" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
+17
View File
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace TimedShutdown
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
+19
View File
@@ -0,0 +1,19 @@
using System.Windows;
using Caliburn.Micro;
using TimedShutdown.ViewModels;
namespace TimedShutdown
{
public class Bootstrapper : BootstrapperBase
{
public Bootstrapper()
{
Initialize();
}
protected override void OnStartup(object sender, StartupEventArgs e)
{
DisplayRootViewFor<ShellRootViewModel>();
}
}
}
+55
View File
@@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Timed Shutdown")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Fil Sapia")]
[assembly: AssemblyProduct("Timed Shutdown")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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")]
+73
View File
@@ -0,0 +1,73 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TimedShutdown.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// 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.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimedShutdown.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap ShutdownIcon {
get {
object obj = ResourceManager.GetObject("ShutdownIcon", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}
+124
View File
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="ShutdownIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ShutdownIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
+30
View File
@@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
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
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

+75
View File
@@ -0,0 +1,75 @@
using System;
using System.Diagnostics;
namespace TimedShutdown
{
public class ShutdownManager
{
public enum Operation
{
Shutdown,
Reboot
}
/// <summary>
/// Shuts down or reboots machine based on parameters.
/// </summary>
/// <param name="shutdownoperation"></param>
/// <param name="shutdownSeconds"></param>
/// <param name="forceShutdownState"></param>
public void ExecuteOperation(Operation shutdownoperation, int shutdownSeconds, bool forceShutdownState)
{
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" +
$" {shutdownSeconds}" +
$" {ForceShutdown(forceShutdownState)}";
info.WindowStyle = ProcessWindowStyle.Hidden;
info.CreateNoWindow = true;
proc.StartInfo = info;
proc.Start();
}
public void AbortOperation()
{
ProcessStartInfo info = new ProcessStartInfo();
Process proc = new Process();
info.FileName = "cmd.exe";
info.Arguments = $"/c shutdown -a";
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
proc.StartInfo = info;
proc.Start();
}
#region Functions
private string ShutdownOperation(Operation arg)
{
switch (arg)
{
case Operation.Shutdown:
return "-s";
case Operation.Reboot:
return "-r";
default:
return String.Empty;
}
}
private string ForceShutdown(bool arg)
{
return "-f";
}
#endregion
}
}
+122
View File
@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C1158C45-7666-4586-A6DA-CCC1EE95D457}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>TimedShutdown</RootNamespace>
<AssemblyName>TimedShutdown</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>ShutdownIcon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Caliburn.Micro, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.Core.3.2.0\lib\net45\Caliburn.Micro.dll</HintPath>
</Reference>
<Reference Include="Caliburn.Micro.Platform, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.dll</HintPath>
</Reference>
<Reference Include="Caliburn.Micro.Platform.Core, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="ShutdownManager.cs" />
<Compile Include="ViewModels\ShellRootViewModel.cs" />
<Compile Include="Views\ShellRootView.xaml.cs">
<DependentUpon>ShellRootView.xaml</DependentUpon>
</Compile>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Bootstrapper.cs" />
<Page Include="Views\ShellRootView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\ShutdownIcon.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="ShutdownIcon.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -0,0 +1,134 @@
using System;
using System.Windows.Media.Imaging;
using Caliburn.Micro;
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
#region Values
private int _hours;
public int Hours
{
get { return _hours; }
set
{
if (value < 0)
{
value = 0;
}
else if (value > 23)
{
value = 23;
}
_hours = value;
NotifyOfPropertyChange(() => Hours);
NotifyOfPropertyChange(() => ShutdownTime);
NotifyOfPropertyChange(() => ShutdownTimeSpan);
}
}
private int _minutes;
public int Minutes
{
get { return _minutes; }
set
{
if (value < 0)
{
value = 0;
}
else if (value > 59)
{
value = 59;
}
_minutes = value;
NotifyOfPropertyChange(() => Minutes);
NotifyOfPropertyChange(() => ShutdownTime);
NotifyOfPropertyChange(() => ShutdownTimeSpan);
}
}
public int ShutdownTime => Minutes * 60 + Hours * 60 * 60;
public TimeSpan ShutdownTimeSpan => TimeSpan.FromSeconds(ShutdownTime);
public bool ShutdownOptionsForce { get; set; }
#endregion
#region Buttons
public bool CanShutdown { get; set; } = true;
public void Shutdown()
{
shutdownManager.ExecuteOperation(ShutdownManager.Operation.Shutdown, ShutdownTime, false);
CanAbortShutdown = true;
CanReboot = false;
CanShutdown = false;
NotifyOfPropertyChange(() => CanAbortShutdown);
NotifyOfPropertyChange(() => CanReboot);
NotifyOfPropertyChange(() => CanShutdown);
}
public bool CanReboot { get; set; } = true;
public void Reboot()
{
shutdownManager.ExecuteOperation(ShutdownManager.Operation.Reboot, ShutdownTime, false);
CanAbortShutdown = true;
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;
CanReboot = true;
CanShutdown = true;
NotifyOfPropertyChange(() => CanAbortShutdown);
NotifyOfPropertyChange(() => CanReboot);
NotifyOfPropertyChange(() => CanShutdown);
}
#endregion
}
}
+78
View File
@@ -0,0 +1,78 @@
<Window x:Class="TimedShutdown.Views.ShellRootView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
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"
ResizeMode="NoResize">
<StackPanel>
<Grid x:Name="ShutdownIcon" Margin="15">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<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"/>
<!-- Row 1: Hours -->
<Label x:Name="LabelHoursLabel" 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" />
<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" />
<!-- Row 4: Shutdown Time -->
<Label x:Name="LabelShutdownTime" 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 -->
<Separator/>
<Grid Margin="15">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Button x:Name="Shutdown" Content="{Binding LabelShutdown}" 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"
Padding="5" Margin="2.5,5,0,0"/>
<Button x:Name="AbortShutdown" Content="{Binding LabelAbortShutdown}" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
Padding="5" Margin="0,5,0,0"/>
</Grid>
</StackPanel>
</Window>
+27
View File
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace TimedShutdown.Views
{
/// <summary>
/// Interaction logic for ShellRootView.xaml
/// </summary>
public partial class ShellRootView : Window
{
public ShellRootView()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,268 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>Caliburn.Micro.Platform.Core</name>
</assembly>
<members>
<member name="T:Caliburn.Micro.AssemblySource">
<summary>
A source of assemblies that are inspectable by the framework.
</summary>
</member>
<member name="F:Caliburn.Micro.AssemblySource.Instance">
<summary>
The singleton instance of the AssemblySource used by the framework.
</summary>
</member>
<member name="F:Caliburn.Micro.AssemblySource.FindTypeByNames">
<summary>
Finds a type which matches one of the elements in the sequence of names.
</summary>
</member>
<member name="T:Caliburn.Micro.AssemblySourceCache">
<summary>
A caching subsystem for <see cref="T:Caliburn.Micro.AssemblySource"/>.
</summary>
</member>
<member name="F:Caliburn.Micro.AssemblySourceCache.ExtractTypes">
<summary>
Extracts the types from the spezified assembly for storing in the cache.
</summary>
</member>
<member name="M:Caliburn.Micro.AssemblySourceCache.Install">
<summary>
Installs the caching subsystem.
</summary>
</member>
<member name="T:Caliburn.Micro.ExtensionMethods">
<summary>
Generic extension methods used by the framework.
</summary>
</member>
<member name="M:Caliburn.Micro.ExtensionMethods.GetAssemblyName(System.Reflection.Assembly)">
<summary>
Get's the name of the assembly.
</summary>
<param name="assembly">The assembly.</param>
<returns>The assembly's name.</returns>
</member>
<member name="M:Caliburn.Micro.ExtensionMethods.GetAttributes``1(System.Reflection.MemberInfo,System.Boolean)">
<summary>
Gets all the attributes of a particular type.
</summary>
<typeparam name="T">The type of attributes to get.</typeparam>
<param name="member">The member to inspect for attributes.</param>
<param name="inherit">Whether or not to search for inherited attributes.</param>
<returns>The list of attributes found.</returns>
</member>
<member name="M:Caliburn.Micro.ExtensionMethods.GetExportedTypes(System.Reflection.Assembly)">
<summary>
Gets a collection of the public types defined in this assembly that are visible outside the assembly.
</summary>
<param name="assembly">The assembly.</param>
<returns>A collection of the public types defined in this assembly that are visible outside the assembly.</returns>
<exception cref="T:System.ArgumentNullException"></exception>
</member>
<member name="M:Caliburn.Micro.ExtensionMethods.IsAssignableFrom(System.Type,System.Type)">
<summary>
Returns a value that indicates whether the specified type can be assigned to the current type.
</summary>
<param name="target">The target type</param>
<param name="type">The type to check.</param>
<returns>true if the specified type can be assigned to this type; otherwise, false.</returns>
</member>
<member name="M:Caliburn.Micro.ExtensionMethods.GetValueOrDefault``2(System.Collections.Generic.IDictionary{``0,``1},``0)">
<summary>
Gets the value for a key. If the key does not exist, return default(TValue);
</summary>
<typeparam name="TKey">The type of the keys in the dictionary.</typeparam>
<typeparam name="TValue">The type of the values in the dictionary.</typeparam>
<param name="dictionary">The dictionary to call this method on.</param>
<param name="key">The key to look up.</param>
<returns>The key value. default(TValue) if this key is not in the dictionary.</returns>
</member>
<member name="T:Caliburn.Micro.NameTransformer">
<summary>
Class for managing the list of rules for doing name transformation.
</summary>
</member>
<member name="P:Caliburn.Micro.NameTransformer.UseEagerRuleSelection">
<summary>
Flag to indicate if transformations from all matched rules are returned. Otherwise, transformations from only the first matched rule are returned.
</summary>
</member>
<member name="M:Caliburn.Micro.NameTransformer.AddRule(System.String,System.String,System.String)">
<summary>
Adds a transform using a single replacement value and a global filter pattern.
</summary>
<param name = "replacePattern">Regular expression pattern for replacing text</param>
<param name = "replaceValue">The replacement value.</param>
<param name = "globalFilterPattern">Regular expression pattern for global filtering</param>
</member>
<member name="M:Caliburn.Micro.NameTransformer.AddRule(System.String,System.Collections.Generic.IEnumerable{System.String},System.String)">
<summary>
Adds a transform using a list of replacement values and a global filter pattern.
</summary>
<param name = "replacePattern">Regular expression pattern for replacing text</param>
<param name = "replaceValueList">The list of replacement values</param>
<param name = "globalFilterPattern">Regular expression pattern for global filtering</param>
</member>
<member name="M:Caliburn.Micro.NameTransformer.Transform(System.String)">
<summary>
Gets the list of transformations for a given name.
</summary>
<param name = "source">The name to transform into the resolved name list</param>
<returns>The transformed names.</returns>
</member>
<member name="M:Caliburn.Micro.NameTransformer.Transform(System.String,System.Func{System.String,System.String})">
<summary>
Gets the list of transformations for a given name.
</summary>
<param name = "source">The name to transform into the resolved name list</param>
<param name = "getReplaceString">A function to do a transform on each item in the ReplaceValueList prior to applying the regular expression transform</param>
<returns>The transformed names.</returns>
</member>
<member name="T:Caliburn.Micro.NameTransformer.Rule">
<summary>
A rule that describes a name transform.
</summary>
</member>
<member name="F:Caliburn.Micro.NameTransformer.Rule.GlobalFilterPattern">
<summary>
Regular expression pattern for global filtering
</summary>
</member>
<member name="F:Caliburn.Micro.NameTransformer.Rule.ReplacePattern">
<summary>
Regular expression pattern for replacing text
</summary>
</member>
<member name="F:Caliburn.Micro.NameTransformer.Rule.ReplacementValues">
<summary>
The list of replacement values
</summary>
</member>
<member name="P:Caliburn.Micro.NameTransformer.Rule.GlobalFilterPatternRegex">
<summary>
Regular expression for global filtering
</summary>
</member>
<member name="P:Caliburn.Micro.NameTransformer.Rule.ReplacePatternRegex">
<summary>
Regular expression for replacing text
</summary>
</member>
<member name="T:Caliburn.Micro.RegExHelper">
<summary>
Helper class for encoding strings to regular expression patterns
</summary>
</member>
<member name="F:Caliburn.Micro.RegExHelper.NameRegEx">
<summary>
Regular expression pattern for valid name
</summary>
</member>
<member name="F:Caliburn.Micro.RegExHelper.SubNamespaceRegEx">
<summary>
Regular expression pattern for subnamespace (including dot)
</summary>
</member>
<member name="F:Caliburn.Micro.RegExHelper.NamespaceRegEx">
<summary>
Regular expression pattern for namespace or namespace fragment
</summary>
</member>
<member name="M:Caliburn.Micro.RegExHelper.GetCaptureGroup(System.String,System.String)">
<summary>
Creates a named capture group with the specified regular expression
</summary>
<param name="groupName">Name of capture group to create</param>
<param name="regEx">Regular expression pattern to capture</param>
<returns>Regular expression capture group with the specified group name</returns>
</member>
<member name="M:Caliburn.Micro.RegExHelper.NamespaceToRegEx(System.String)">
<summary>
Converts a namespace (including wildcards) to a regular expression string
</summary>
<param name="srcNamespace">Source namespace to convert to regular expression</param>
<returns>Namespace converted to a regular expression</returns>
</member>
<member name="M:Caliburn.Micro.RegExHelper.GetNameCaptureGroup(System.String)">
<summary>
Creates a capture group for a valid name regular expression pattern
</summary>
<param name="groupName">Name of capture group to create</param>
<returns>Regular expression capture group with the specified group name</returns>
</member>
<member name="M:Caliburn.Micro.RegExHelper.GetNamespaceCaptureGroup(System.String)">
<summary>
Creates a capture group for a namespace regular expression pattern
</summary>
<param name="groupName">Name of capture group to create</param>
<returns>Regular expression capture group with the specified group name</returns>
</member>
<member name="T:Caliburn.Micro.StringSplitter">
<summary>
Helper class when splitting strings
</summary>
</member>
<member name="M:Caliburn.Micro.StringSplitter.Split(System.String,System.Char)">
<summary>
Splits a string with a chosen separator.
If a substring is contained in [...] it will not be splitted.
</summary>
<param name="message">The message to split</param>
<param name="separator">The separator to use when splitting</param>
<returns></returns>
</member>
<member name="M:Caliburn.Micro.StringSplitter.SplitParameters(System.String)">
<summary>
Splits a string with , as separator.
Does not split within {},[],()
</summary>
<param name="parameters">The string to split</param>
<returns></returns>
</member>
<member name="T:Caliburn.Micro.TypeMappingConfiguration">
<summary>
Class to specify settings for configuring type mappings by the ViewLocator or ViewModelLocator
</summary>
</member>
<member name="F:Caliburn.Micro.TypeMappingConfiguration.DefaultSubNamespaceForViews">
<summary>
The default subnamespace for Views. Used for creating default subnamespace mappings. Defaults to "Views".
</summary>
</member>
<member name="F:Caliburn.Micro.TypeMappingConfiguration.DefaultSubNamespaceForViewModels">
<summary>
The default subnamespace for ViewModels. Used for creating default subnamespace mappings. Defaults to "ViewModels".
</summary>
</member>
<member name="F:Caliburn.Micro.TypeMappingConfiguration.UseNameSuffixesInMappings">
<summary>
Flag to indicate whether or not the name of the Type should be transformed when adding a type mapping. Defaults to true.
</summary>
</member>
<member name="F:Caliburn.Micro.TypeMappingConfiguration.NameFormat">
<summary>
The format string used to compose the name of a type from base name and name suffix
</summary>
</member>
<member name="F:Caliburn.Micro.TypeMappingConfiguration.IncludeViewSuffixInViewModelNames">
<summary>
Flag to indicate if ViewModel names should include View suffixes (i.e. CustomerPageViewModel vs. CustomerViewModel)
</summary>
</member>
<member name="F:Caliburn.Micro.TypeMappingConfiguration.ViewSuffixList">
<summary>
List of View suffixes for which default type mappings should be created. Applies only when UseNameSuffixesInMappings = true.
Default values are "View", "Page"
</summary>
</member>
<member name="F:Caliburn.Micro.TypeMappingConfiguration.ViewModelSuffix">
<summary>
The name suffix for ViewModels. Applies only when UseNameSuffixesInMappings = true. The default is "ViewModel".
</summary>
</member>
</members>
</doc>
File diff suppressed because it is too large Load Diff
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
Binary file not shown.
+5
View File
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Caliburn.Micro" version="3.2.0" targetFramework="net461" />
<package id="Caliburn.Micro.Core" version="3.2.0" targetFramework="net461" />
</packages>