Initial Checkin

This commit is contained in:
Joe Tretter
2020-12-10 10:22:36 -06:00
commit 31a511a09c
5 changed files with 85 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
*.user
/SShot/bin
/SShot/obj
/.vs

25
SShot.sln Normal file
View File

@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30503.244
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SShot", "SShot\SShot.csproj", "{6D8C0C2D-6BD5-4FA0-9FEB-A23D62DEF5C9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6D8C0C2D-6BD5-4FA0-9FEB-A23D62DEF5C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D8C0C2D-6BD5-4FA0-9FEB-A23D62DEF5C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D8C0C2D-6BD5-4FA0-9FEB-A23D62DEF5C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D8C0C2D-6BD5-4FA0-9FEB-A23D62DEF5C9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3B34ACF9-C926-431A-B5AF-16FCDA92C2AB}
EndGlobalSection
EndGlobal

42
SShot/Program.cs Normal file
View File

@@ -0,0 +1,42 @@
using System.Drawing;
using System.Drawing.Imaging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SShot
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
string fileName = DateTime.Now.ToString("u").Replace("Z", ".png").Replace(":", "-");
string dirName = DateTime.Now.ToString("u").Substring(0, 10);
System.IO.Directory.CreateDirectory(dirName);
captureScreen(dirName + "\\" + fileName);
}
private static void captureScreen(String filename)
{
try
{
Rectangle captureRectangle = SystemInformation.VirtualScreen;
Bitmap captureBitmap = new Bitmap(captureRectangle.Width, captureRectangle.Height, PixelFormat.Format32bppArgb);
Graphics captureGraphics = Graphics.FromImage(captureBitmap);
captureGraphics.CopyFromScreen(captureRectangle.Left, captureRectangle.Top, 0, 0, captureRectangle.Size);
captureBitmap.Save(filename, ImageFormat.Png);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}

9
SShot/SShot.csproj Normal file
View File

@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
</Project>

5
SShot/triggerSS.cmd Normal file
View File

@@ -0,0 +1,5 @@
SET ProgDir="%~dp0"
set YearMonth="%date:~-4%-%date:~4,2%-%date:~7,2%"
md .\%YearMonth%
cd .\%YearMonth%
%ProgDir%\sshot.exe