Code cleanup.

This commit is contained in:
2018-11-03 15:37:49 +01:00
parent 24b49af7f6
commit 0a99ba746e
59 changed files with 513 additions and 528 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using VAR.Toolbox.Code.Windows;
namespace VAR.Toolbox.Code
{

View File

@@ -2,7 +2,7 @@
namespace VAR.Toolbox.Code
{
internal class ProxyCmdExecutorWMIC : IProxyCmdExecutor
public class ProxyCmdExecutorWMIC : IProxyCmdExecutor
{
private string _configWMIC;

View File

@@ -1,6 +1,7 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using VAR.Toolbox.Code.Windows;
namespace VAR.Toolbox.Code
{

View File

@@ -1,9 +1,8 @@
using System;
using System.Text;
using System.Text;
namespace VAR.Toolbox.Code
{
class TextCoderHexToAscii : ITextCoder
public class TextCoderHexToAscii : ITextCoder
{
public const string Name = "HexToAscii";

View File

@@ -1,9 +1,8 @@
using System;
using System.Text;
using System.Text;
namespace VAR.Toolbox.Code
{
class TextCoderHexToUtf8 : ITextCoder
public class TextCoderHexToUtf8 : ITextCoder
{
public const string Name = "HexToUtf8";

View File

@@ -5,6 +5,7 @@ using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using VAR.Toolbox.Code.DirectShow;
using VAR.Toolbox.Code.Windows;
namespace VAR.Toolbox.Code
{

View File

@@ -1,26 +0,0 @@
using System;
using System.Runtime.InteropServices;
namespace VAR.Toolbox.Code
{
public class Win32API
{
[DllImport("PowrProf.dll")]
public static extern Boolean SetSuspendState(Boolean Hibernate, Boolean ForceCritical, Boolean DisableWakeEvent);
public static uint GetLastInputTime()
{
uint idleTime = 0;
User32.LASTINPUTINFO lastInputInfo = new User32.LASTINPUTINFO();
lastInputInfo.cbSize = (uint)Marshal.SizeOf(lastInputInfo);
lastInputInfo.dwTime = 0;
uint envTicks = (uint)Environment.TickCount;
if (User32.GetLastInputInfo(ref lastInputInfo))
{
uint lastInputTick = lastInputInfo.dwTime;
idleTime = envTicks - lastInputTick;
}
return ((idleTime > 0) ? (idleTime / 1000) : 0);
}
}
}

View File

@@ -1,9 +1,9 @@
using System;
using System.Runtime.InteropServices;
namespace VAR.Toolbox.Code
namespace VAR.Toolbox.Code.Windows
{
public class GDI32
public static class GDI32
{
public const int SRCCOPY = 0x00CC0020; // BitBlt dwRop parameter

View File

@@ -1,9 +1,9 @@
using System;
using System.Runtime.InteropServices;
namespace VAR.Toolbox.Code
namespace VAR.Toolbox.Code.Windows
{
public class User32
public static class User32
{
[StructLayout(LayoutKind.Sequential)]
public struct INPUT

View File

@@ -1,14 +1,10 @@
namespace VAR.Toolbox.Code.DirectShow
{
using System;
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
/// <summary>
/// Some Win32 API used internally.
/// </summary>
///
internal static class Win32
namespace VAR.Toolbox.Code.Windows
{
public static class Win32
{
/// <summary>
/// Supplies a pointer to an implementation of <b>IBindCtx</b> (a bind context object).
@@ -90,5 +86,23 @@ namespace VAR.Toolbox.Code.DirectShow
int lcid,
int dwReserved,
IntPtr lpvReserved);
[DllImport("PowrProf.dll")]
public static extern Boolean SetSuspendState(Boolean Hibernate, Boolean ForceCritical, Boolean DisableWakeEvent);
public static uint GetLastInputTime()
{
uint idleTime = 0;
User32.LASTINPUTINFO lastInputInfo = new User32.LASTINPUTINFO();
lastInputInfo.cbSize = (uint)Marshal.SizeOf(lastInputInfo);
lastInputInfo.dwTime = 0;
uint envTicks = (uint)Environment.TickCount;
if (User32.GetLastInputInfo(ref lastInputInfo))
{
uint lastInputTick = lastInputInfo.dwTime;
idleTime = envTicks - lastInputTick;
}
return ((idleTime > 0) ? (idleTime / 1000) : 0);
}
}
}

View File

@@ -8,7 +8,7 @@ namespace VAR.Toolbox.Controls
{
#region Declarations
Image _imageShow = null;
private Image _imageShow = null;
// Image projection
private double offsetX = 0;

View File

@@ -5,13 +5,13 @@ using VAR.Toolbox.UI;
namespace VAR.Toolbox
{
static class Program
public static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
private static void Main()
{
Application.ThreadException += Application_ThreadException;

View File

@@ -5,7 +5,7 @@ using VAR.Toolbox.Code;
namespace VAR.Toolbox.UI
{
internal class FrmCover : Form
public class FrmCover : Form
{
#region Declarations

View File

@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using VAR.Toolbox.Code;
using VAR.Toolbox.Code.Windows;
namespace VAR.Toolbox.UI
{

View File

@@ -20,14 +20,15 @@ namespace VAR.Toolbox
cboWebcams_LoadData();
}
void webcam_NewFrame(object sender, Bitmap frame)
private void webcam_NewFrame(object sender, Bitmap frame)
{
picWebcam.ImageShow = frame;
}
private void FrmWebcam_FormClosed(object sender, FormClosedEventArgs e)
{
if(webcam!=null){
if (webcam != null)
{
webcam.Stop();
}
}

View File

@@ -1,6 +1,6 @@
using System;
using System.Windows.Forms;
using VAR.Toolbox.Code;
using VAR.Toolbox.Code.Windows;
namespace VAR.Toolbox.UI
{
@@ -15,7 +15,7 @@ namespace VAR.Toolbox.UI
{
if (DesignMode) { return; }
bool userInactive = false;
uint inactiveTime = Win32API.GetLastInputTime();
uint inactiveTime = Win32.GetLastInputTime();
lblInactive.Text = String.Format("Inactive by {0} seconds", inactiveTime);

View File

@@ -1,6 +1,6 @@
using System;
using System.Windows.Forms;
using VAR.Toolbox.Code;
using VAR.Toolbox.Code.Windows;
namespace VAR.Toolbox.UI
{
@@ -139,7 +139,7 @@ namespace VAR.Toolbox.UI
private void SuspendSystem()
{
Win32API.SetSuspendState(false, true, false);
Win32.SetSuspendState(false, true, false);
}
}

View File

@@ -42,13 +42,9 @@
<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.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
@@ -86,8 +82,7 @@
<Compile Include="Code\DirectShow\Structures.cs" />
<Compile Include="Code\DirectShow\Tools.cs" />
<Compile Include="Code\DirectShow\Uuids.cs" />
<Compile Include="Code\DirectShow\Win32.cs" />
<Compile Include="Code\GDI32.cs" />
<Compile Include="Code\Windows\GDI32.cs" />
<Compile Include="Code\ITextCoder.cs" />
<Compile Include="Code\IOutputHandler.cs" />
<Compile Include="Code\IProxyCmdExecutor.cs" />
@@ -100,9 +95,9 @@
<Compile Include="Code\TextCoderFactory.cs" />
<Compile Include="Code\TextCoderHexToAscii.cs" />
<Compile Include="Code\TextCoderHexToUtf8.cs" />
<Compile Include="Code\User32.cs" />
<Compile Include="Code\Windows\User32.cs" />
<Compile Include="Code\Webcam.cs" />
<Compile Include="Code\Win32API.cs" />
<Compile Include="Code\Windows\Win32.cs" />
<Compile Include="Controls\CtrImageViewer.cs">
<SubType>Component</SubType>
</Compile>