Skip to content

Commit

Permalink
New
Browse files Browse the repository at this point in the history
  • Loading branch information
BobVul committed Jun 22, 2012
0 parents commit 5dfabf2
Show file tree
Hide file tree
Showing 13 changed files with 3,045 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bin/
obj/
*.csproj.*.user
*.suo
20 changes: 20 additions & 0 deletions IdleShutdown.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdleShutdown", "IdleShutdown\IdleShutdown.csproj", "{DD337D3A-E6EF-450F-B370-68D2E42EA111}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DD337D3A-E6EF-450F-B370-68D2E42EA111}.Debug|x86.ActiveCfg = Debug|x86
{DD337D3A-E6EF-450F-B370-68D2E42EA111}.Debug|x86.Build.0 = Debug|x86
{DD337D3A-E6EF-450F-B370-68D2E42EA111}.Release|x86.ActiveCfg = Release|x86
{DD337D3A-E6EF-450F-B370-68D2E42EA111}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
1 change: 1 addition & 0 deletions IdleShutdown/Attributions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Notification icon [Mazenl77](http://mazenl77.deviantart.com/) is sourced from http://www.iconspedia.com/icon/shutdown-1626.html and used under the CC-BY licence
87 changes: 87 additions & 0 deletions IdleShutdown/IdleShutdown.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{DD337D3A-E6EF-450F-B370-68D2E42EA111}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>IdleShutdown</RootNamespace>
<AssemblyName>IdleShutdown</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</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|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
165 changes: 165 additions & 0 deletions IdleShutdown/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 84 additions & 0 deletions IdleShutdown/MainForm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace IdleShutdown
{
public partial class MainForm : Form
{
TimeSpan DefaultWaitTime = TimeSpan.FromMinutes(5);
TimeSpan waittime;
Stopwatch stopwatch = new Stopwatch();
bool postponed = false;

public MainForm()
{
InitializeComponent();

double minutes;
if (Environment.GetCommandLineArgs().Length > 1 && Double.TryParse(Environment.GetCommandLineArgs()[1], out minutes))
DefaultWaitTime = TimeSpan.FromMinutes(minutes);

StartShutdownTimer();
}

private void StartShutdownTimer()
{
postponed = false;
waittime = DefaultWaitTime;
progressBarTime.Maximum = (int)waittime.TotalSeconds;
stopwatch.Restart();
this.Show();
}

private void buttonAbort_Click(object sender, EventArgs e)
{
Application.Exit();
}

private void timerShutdown_Tick(object sender, EventArgs e)
{
TimeSpan timeleft = (waittime - stopwatch.Elapsed);
if (postponed)
{
if ((int)(waittime - stopwatch.Elapsed).TotalSeconds <= 0)
StartShutdownTimer();
}
else
{
progressBarTime.Value = progressBarTime.Maximum - ((int)timeleft.TotalSeconds <= 0 ? 0 : (int)timeleft.TotalSeconds);
labelShutdownTimer.Text = "Shutting down in ";
if (timeleft.Hours > 0)
labelShutdownTimer.Text += timeleft.Hours + " hours ";
if (timeleft.Minutes > 0)
labelShutdownTimer.Text += timeleft.Minutes + " minutes ";
if (timeleft.Seconds > 0)
labelShutdownTimer.Text += timeleft.Seconds + " seconds ";

if ((int)timeleft.TotalSeconds <= 0)
Process.Start("shutdown", "/s /t 0");
}
}

private void buttonPostpone_Click(object sender, EventArgs e)
{
notifyIcon.ShowBalloonTip(5000, "Idle Shutdown timer postponed for " + numericUpDownPostponeMinutes.Value + " minutes.", " ", ToolTipIcon.Info);
postponed = true;
waittime = TimeSpan.FromMinutes((double)numericUpDownPostponeMinutes.Value);
stopwatch.Restart();
this.Hide();
}

private void notifyIcon_Click(object sender, EventArgs e)
{
this.Show();
StartShutdownTimer();
}
}
}
Loading

0 comments on commit 5dfabf2

Please sign in to comment.