Add FrmCover
This commit is contained in:
70
VAR.Toolbox/Code/Mouse.cs
Normal file
70
VAR.Toolbox/Code/Mouse.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace VAR.Toolbox.Code
|
||||
{
|
||||
public class Mouse
|
||||
{
|
||||
public static void Move(int dx, int dy)
|
||||
{
|
||||
User32.INPUT input = new User32.INPUT();
|
||||
input.Type = User32.INPUT_MOUSE;
|
||||
input.Data.Mouse.X = dx;
|
||||
input.Data.Mouse.Y = dy;
|
||||
input.Data.Mouse.Flags = User32.MOUSEEVENTF_MOVE;
|
||||
User32.INPUT[] inputs = new User32.INPUT[] { input };
|
||||
if (User32.SendInput(1, inputs, Marshal.SizeOf(typeof(User32.INPUT))) == 0)
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
public enum MouseButtons
|
||||
{
|
||||
Left,
|
||||
Middle,
|
||||
Right
|
||||
}
|
||||
|
||||
public static void SetButton(MouseButtons button, bool down)
|
||||
{
|
||||
User32.INPUT input = new User32.INPUT();
|
||||
input.Type = User32.INPUT_MOUSE;
|
||||
input.Data.Mouse.X = 0;
|
||||
input.Data.Mouse.Y = 0;
|
||||
if (button == MouseButtons.Left)
|
||||
{
|
||||
input.Data.Mouse.Flags = down ? User32.MOUSEEVENTF_LEFTDOWN : User32.MOUSEEVENTF_LEFTUP;
|
||||
}
|
||||
if (button == MouseButtons.Middle)
|
||||
{
|
||||
input.Data.Mouse.Flags = down ? User32.MOUSEEVENTF_MIDDLEDOWN : User32.MOUSEEVENTF_MIDDLEUP;
|
||||
}
|
||||
if (button == MouseButtons.Right)
|
||||
{
|
||||
input.Data.Mouse.Flags = down ? User32.MOUSEEVENTF_RIGHTDOWN : User32.MOUSEEVENTF_RIGHTUP;
|
||||
}
|
||||
User32.INPUT[] inputs = new User32.INPUT[] { input };
|
||||
if (User32.SendInput(1, inputs, Marshal.SizeOf(typeof(User32.INPUT))) == 0)
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
public static void Click(MouseButtons button)
|
||||
{
|
||||
SetButton(button, true);
|
||||
System.Threading.Thread.Sleep(500);
|
||||
SetButton(button, false);
|
||||
}
|
||||
|
||||
public static void GetPosition(out UInt32 x, out UInt32 y)
|
||||
{
|
||||
User32.POINT lpPoint;
|
||||
User32.GetCursorPos(out lpPoint);
|
||||
x = lpPoint.X;
|
||||
y = lpPoint.Y;
|
||||
}
|
||||
|
||||
public static void SetPosition(UInt32 x, UInt32 y)
|
||||
{
|
||||
User32.SetCursorPos(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
137
VAR.Toolbox/Code/User32.cs
Normal file
137
VAR.Toolbox/Code/User32.cs
Normal file
@@ -0,0 +1,137 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace VAR.Toolbox.Code
|
||||
{
|
||||
public class User32
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct INPUT
|
||||
{
|
||||
public uint Type;
|
||||
public MOUSEKEYBDHARDWAREINPUT Data;
|
||||
}
|
||||
|
||||
public const int INPUT_MOUSE = 0;
|
||||
public const int INPUT_KEYBOARD = 1;
|
||||
public const int INPUT_HARDWARE = 2;
|
||||
|
||||
/// <summary>
|
||||
/// http://social.msdn.microsoft.com/Forums/en/csharplanguage/thread/f0e82d6e-4999-4d22-b3d3-32b25f61fb2a
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct MOUSEKEYBDHARDWAREINPUT
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public HARDWAREINPUT Hardware;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public KEYBDINPUT Keyboard;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public MOUSEINPUT Mouse;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310(v=vs.85).aspx
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HARDWAREINPUT
|
||||
{
|
||||
public uint Msg;
|
||||
public ushort ParamL;
|
||||
public ushort ParamH;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310(v=vs.85).aspx
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct KEYBDINPUT
|
||||
{
|
||||
public ushort Vk;
|
||||
public ushort Scan;
|
||||
public uint Flags;
|
||||
public uint Time;
|
||||
public IntPtr ExtraInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/2abc6be8-c593-4686-93d2-89785232dacd
|
||||
/// https://msdn.microsoft.com/es-es/library/windows/desktop/ms646273%28v=vs.85%29.aspx
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct MOUSEINPUT
|
||||
{
|
||||
public int X;
|
||||
public int Y;
|
||||
public uint MouseData;
|
||||
public uint Flags;
|
||||
public uint Time;
|
||||
public IntPtr ExtraInfo;
|
||||
}
|
||||
|
||||
public const int MOUSEEVENTD_XBUTTON1 = 0x0001;
|
||||
public const int MOUSEEVENTD_XBUTTON2 = 0x0002;
|
||||
|
||||
public const uint MOUSEEVENTF_ABSOLUTE = 0x8000;
|
||||
public const uint MOUSEEVENTF_HWHEEL = 0x01000;
|
||||
public const uint MOUSEEVENTF_MOVE = 0x0001;
|
||||
public const uint MOUSEEVENTF_MOVE_NOCOALESCE = 0x2000;
|
||||
public const uint MOUSEEVENTF_LEFTDOWN = 0x0002;
|
||||
public const uint MOUSEEVENTF_LEFTUP = 0x0004;
|
||||
public const uint MOUSEEVENTF_RIGHTDOWN = 0x0008;
|
||||
public const uint MOUSEEVENTF_RIGHTUP = 0x0010;
|
||||
public const uint MOUSEEVENTF_MIDDLEDOWN = 0x0020;
|
||||
public const uint MOUSEEVENTF_MIDDLEUP = 0x0040;
|
||||
public const uint MOUSEEVENTF_VIRTUALDESK = 0x4000;
|
||||
public const uint MOUSEEVENTF_WHEEL = 0x0800;
|
||||
public const uint MOUSEEVENTF_XDOWN = 0x0080;
|
||||
public const uint MOUSEEVENTF_XUP = 0x0100;
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
public static extern int SendInput(int nInputs, INPUT[] pInputs, int cbSize);
|
||||
|
||||
// <summary>
|
||||
/// Struct representing a point.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct POINT
|
||||
{
|
||||
public UInt32 X;
|
||||
public UInt32 Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the cursor's position, in screen coordinates.
|
||||
/// </summary>
|
||||
/// <see>See MSDN documentation for further information.</see>
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool GetCursorPos(out POINT lpPoint);
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
public static extern Boolean SetCursorPos(UInt32 X, UInt32 Y);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct LASTINPUTINFO
|
||||
{
|
||||
public static readonly int SizeOf = Marshal.SizeOf(typeof(LASTINPUTINFO));
|
||||
|
||||
[MarshalAs(UnmanagedType.U4)]
|
||||
public UInt32 cbSize;
|
||||
|
||||
[MarshalAs(UnmanagedType.U4)]
|
||||
public UInt32 dwTime;
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern short GetAsyncKeyState(int vKey);
|
||||
|
||||
public const int VK_MBUTTON = 0x04;
|
||||
public const int VK_LBUTTON = 0x01;
|
||||
public const int VK_RBUTTON = 0x02;
|
||||
}
|
||||
}
|
||||
26
VAR.Toolbox/Code/Win32API.cs
Normal file
26
VAR.Toolbox/Code/Win32API.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
79
VAR.Toolbox/UI/FrmCover.cs
Normal file
79
VAR.Toolbox/UI/FrmCover.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using VAR.Toolbox.Code;
|
||||
|
||||
namespace VAR.Toolbox.UI
|
||||
{
|
||||
internal class FrmCover : Form
|
||||
{
|
||||
#region Declarations
|
||||
|
||||
private Random rnd = new Random();
|
||||
private Timer _timer = new Timer();
|
||||
|
||||
private UInt32 _mouseX = 0;
|
||||
private UInt32 _mouseY = 0;
|
||||
|
||||
#endregion Declarations
|
||||
|
||||
#region Form life cycle
|
||||
|
||||
public FrmCover()
|
||||
{
|
||||
Mouse.GetPosition(out _mouseX, out _mouseY);
|
||||
|
||||
TopMost = true;
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
BackColor = Color.Black;
|
||||
|
||||
Load += FrmCover_Load;
|
||||
Click += FrmCover_Click;
|
||||
|
||||
_timer.Interval = 1000;
|
||||
_timer.Enabled = true;
|
||||
_timer.Tick += timer_Tick;
|
||||
}
|
||||
|
||||
private void FrmCover_Load(object sender, EventArgs e)
|
||||
{
|
||||
Rectangle r = new Rectangle();
|
||||
foreach (Screen s in Screen.AllScreens)
|
||||
{
|
||||
r = Rectangle.Union(r, s.Bounds);
|
||||
}
|
||||
Top = r.Top;
|
||||
Left = r.Left;
|
||||
Width = r.Width;
|
||||
Height = r.Height;
|
||||
Cursor.Hide();
|
||||
_timer.Start();
|
||||
}
|
||||
|
||||
#endregion Form life cycle
|
||||
|
||||
#region UI events
|
||||
|
||||
private void FrmCover_Click(object sender, EventArgs e)
|
||||
{
|
||||
Cursor.Show();
|
||||
_timer.Stop();
|
||||
_timer.Enabled = false;
|
||||
Mouse.SetPosition(_mouseX, _mouseY);
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
private void timer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
Mouse.Move(
|
||||
(rnd.Next() % 11) - 5,
|
||||
(rnd.Next() % 11) - 5);
|
||||
|
||||
_timer.Stop();
|
||||
_timer.Start();
|
||||
}
|
||||
|
||||
#endregion UI events
|
||||
}
|
||||
}
|
||||
38
VAR.Toolbox/UI/FrmToolbox.Designer.cs
generated
38
VAR.Toolbox/UI/FrmToolbox.Designer.cs
generated
@@ -31,13 +31,17 @@
|
||||
this.btnBase64 = new System.Windows.Forms.Button();
|
||||
this.btnProxyCmd = new System.Windows.Forms.Button();
|
||||
this.btnWebcam = new System.Windows.Forms.Button();
|
||||
this.pnlCover1 = new VAR.Toolbox.UI.PnlCover();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnBase64
|
||||
//
|
||||
this.btnBase64.Location = new System.Drawing.Point(12, 12);
|
||||
this.btnBase64.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnBase64.Location = new System.Drawing.Point(18, 18);
|
||||
this.btnBase64.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.btnBase64.Name = "btnBase64";
|
||||
this.btnBase64.Size = new System.Drawing.Size(209, 34);
|
||||
this.btnBase64.Size = new System.Drawing.Size(293, 52);
|
||||
this.btnBase64.TabIndex = 0;
|
||||
this.btnBase64.Text = "Base64";
|
||||
this.btnBase64.UseVisualStyleBackColor = true;
|
||||
@@ -45,9 +49,12 @@
|
||||
//
|
||||
// btnProxyCmd
|
||||
//
|
||||
this.btnProxyCmd.Location = new System.Drawing.Point(12, 52);
|
||||
this.btnProxyCmd.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnProxyCmd.Location = new System.Drawing.Point(18, 80);
|
||||
this.btnProxyCmd.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.btnProxyCmd.Name = "btnProxyCmd";
|
||||
this.btnProxyCmd.Size = new System.Drawing.Size(209, 36);
|
||||
this.btnProxyCmd.Size = new System.Drawing.Size(293, 55);
|
||||
this.btnProxyCmd.TabIndex = 1;
|
||||
this.btnProxyCmd.Text = "ProxyCmd";
|
||||
this.btnProxyCmd.UseVisualStyleBackColor = true;
|
||||
@@ -55,23 +62,37 @@
|
||||
//
|
||||
// btnWebcam
|
||||
//
|
||||
this.btnWebcam.Location = new System.Drawing.Point(12, 94);
|
||||
this.btnWebcam.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnWebcam.Location = new System.Drawing.Point(18, 145);
|
||||
this.btnWebcam.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.btnWebcam.Name = "btnWebcam";
|
||||
this.btnWebcam.Size = new System.Drawing.Size(209, 36);
|
||||
this.btnWebcam.Size = new System.Drawing.Size(293, 55);
|
||||
this.btnWebcam.TabIndex = 2;
|
||||
this.btnWebcam.Text = "Webcam";
|
||||
this.btnWebcam.UseVisualStyleBackColor = true;
|
||||
this.btnWebcam.Click += new System.EventHandler(this.btnWebcam_Click);
|
||||
//
|
||||
// pnlCover1
|
||||
//
|
||||
this.pnlCover1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.pnlCover1.Location = new System.Drawing.Point(12, 246);
|
||||
this.pnlCover1.Name = "pnlCover1";
|
||||
this.pnlCover1.Size = new System.Drawing.Size(300, 126);
|
||||
this.pnlCover1.TabIndex = 3;
|
||||
//
|
||||
// FrmToolbox
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(233, 391);
|
||||
this.ClientSize = new System.Drawing.Size(324, 384);
|
||||
this.Controls.Add(this.pnlCover1);
|
||||
this.Controls.Add(this.btnWebcam);
|
||||
this.Controls.Add(this.btnProxyCmd);
|
||||
this.Controls.Add(this.btnBase64);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
|
||||
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "FrmToolbox";
|
||||
this.Text = "Toolbox";
|
||||
@@ -86,6 +107,7 @@
|
||||
private System.Windows.Forms.Button btnBase64;
|
||||
private System.Windows.Forms.Button btnProxyCmd;
|
||||
private System.Windows.Forms.Button btnWebcam;
|
||||
private PnlCover pnlCover1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,5 +79,6 @@ namespace VAR.Toolbox.UI
|
||||
}
|
||||
|
||||
#endregion Window handling
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
143
VAR.Toolbox/UI/PnlCover.Designer.cs
generated
Normal file
143
VAR.Toolbox/UI/PnlCover.Designer.cs
generated
Normal file
@@ -0,0 +1,143 @@
|
||||
namespace VAR.Toolbox.UI
|
||||
{
|
||||
partial class PnlCover
|
||||
{
|
||||
/// <summary>
|
||||
/// Variable del diseñador necesaria.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Limpiar los recursos que se estén usando.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true si los recursos administrados se deben desechar; false en caso contrario.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Código generado por el Diseñador de componentes
|
||||
|
||||
/// <summary>
|
||||
/// Método necesario para admitir el Diseñador. No se puede modificar
|
||||
/// el contenido de este método con el editor de código.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.grpCover = new System.Windows.Forms.GroupBox();
|
||||
this.btnCover = new System.Windows.Forms.Button();
|
||||
this.numInactive = new System.Windows.Forms.NumericUpDown();
|
||||
this.lblInactive = new System.Windows.Forms.Label();
|
||||
this.chkAutoCover = new System.Windows.Forms.CheckBox();
|
||||
this.timTicker = new System.Windows.Forms.Timer(this.components);
|
||||
this.grpCover.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numInactive)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// grpCover
|
||||
//
|
||||
this.grpCover.Controls.Add(this.btnCover);
|
||||
this.grpCover.Controls.Add(this.numInactive);
|
||||
this.grpCover.Controls.Add(this.lblInactive);
|
||||
this.grpCover.Controls.Add(this.chkAutoCover);
|
||||
this.grpCover.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.grpCover.Location = new System.Drawing.Point(0, 0);
|
||||
this.grpCover.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.grpCover.Name = "grpCover";
|
||||
this.grpCover.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.grpCover.Size = new System.Drawing.Size(262, 160);
|
||||
this.grpCover.TabIndex = 14;
|
||||
this.grpCover.TabStop = false;
|
||||
this.grpCover.Text = "Cover";
|
||||
//
|
||||
// btnCover
|
||||
//
|
||||
this.btnCover.Location = new System.Drawing.Point(8, 83);
|
||||
this.btnCover.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.btnCover.Name = "btnCover";
|
||||
this.btnCover.Size = new System.Drawing.Size(181, 35);
|
||||
this.btnCover.TabIndex = 7;
|
||||
this.btnCover.Text = "Cover";
|
||||
this.btnCover.UseVisualStyleBackColor = true;
|
||||
this.btnCover.Click += new System.EventHandler(this.btnCover_Click);
|
||||
//
|
||||
// numInactive
|
||||
//
|
||||
this.numInactive.Location = new System.Drawing.Point(131, 27);
|
||||
this.numInactive.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.numInactive.Maximum = new decimal(new int[] {
|
||||
300,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numInactive.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numInactive.Name = "numInactive";
|
||||
this.numInactive.Size = new System.Drawing.Size(58, 26);
|
||||
this.numInactive.TabIndex = 10;
|
||||
this.numInactive.Value = new decimal(new int[] {
|
||||
180,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// lblInactive
|
||||
//
|
||||
this.lblInactive.AutoSize = true;
|
||||
this.lblInactive.Location = new System.Drawing.Point(8, 58);
|
||||
this.lblInactive.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.lblInactive.Name = "lblInactive";
|
||||
this.lblInactive.Size = new System.Drawing.Size(79, 20);
|
||||
this.lblInactive.TabIndex = 8;
|
||||
this.lblInactive.Text = "lblInactive";
|
||||
//
|
||||
// chkAutoCover
|
||||
//
|
||||
this.chkAutoCover.AutoSize = true;
|
||||
this.chkAutoCover.Checked = true;
|
||||
this.chkAutoCover.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.chkAutoCover.Location = new System.Drawing.Point(8, 29);
|
||||
this.chkAutoCover.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.chkAutoCover.Name = "chkAutoCover";
|
||||
this.chkAutoCover.Size = new System.Drawing.Size(110, 24);
|
||||
this.chkAutoCover.TabIndex = 9;
|
||||
this.chkAutoCover.Text = "AutoCover";
|
||||
this.chkAutoCover.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// timTicker
|
||||
//
|
||||
this.timTicker.Enabled = true;
|
||||
this.timTicker.Tick += new System.EventHandler(this.timTicker_Tick);
|
||||
//
|
||||
// PnlCover
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.grpCover);
|
||||
this.Name = "PnlCover";
|
||||
this.Size = new System.Drawing.Size(262, 160);
|
||||
this.grpCover.ResumeLayout(false);
|
||||
this.grpCover.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numInactive)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox grpCover;
|
||||
private System.Windows.Forms.Button btnCover;
|
||||
private System.Windows.Forms.NumericUpDown numInactive;
|
||||
private System.Windows.Forms.Label lblInactive;
|
||||
private System.Windows.Forms.CheckBox chkAutoCover;
|
||||
private System.Windows.Forms.Timer timTicker;
|
||||
}
|
||||
}
|
||||
64
VAR.Toolbox/UI/PnlCover.cs
Normal file
64
VAR.Toolbox/UI/PnlCover.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using VAR.Toolbox.Code;
|
||||
|
||||
namespace VAR.Toolbox.UI
|
||||
{
|
||||
public partial class PnlCover : UserControl
|
||||
{
|
||||
public PnlCover()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void timTicker_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (DesignMode) { return; }
|
||||
bool userInactive = false;
|
||||
uint inactiveTime = Win32API.GetLastInputTime();
|
||||
|
||||
lblInactive.Text = String.Format("Inactive by {0} seconds", inactiveTime);
|
||||
|
||||
if (chkAutoCover.Checked)
|
||||
{
|
||||
if (!userInactive && inactiveTime > numInactive.Value)
|
||||
{
|
||||
userInactive = true;
|
||||
CoverScreen();
|
||||
}
|
||||
if (inactiveTime < 1)
|
||||
{
|
||||
userInactive = false;
|
||||
}
|
||||
}
|
||||
timTicker.Stop();
|
||||
timTicker.Start();
|
||||
}
|
||||
|
||||
private void btnCover_Click(object sender, EventArgs e)
|
||||
{
|
||||
CoverScreen();
|
||||
}
|
||||
|
||||
private FrmCover _frmCover = null;
|
||||
|
||||
private void CoverScreen()
|
||||
{
|
||||
if (DesignMode) { return; }
|
||||
if(_frmCover != null)
|
||||
{
|
||||
_frmCover.Show();
|
||||
return;
|
||||
}
|
||||
_frmCover = new FrmCover();
|
||||
_frmCover.FormClosing += (sender, e) => { _frmCover = null; };
|
||||
_frmCover.Show();
|
||||
|
||||
Form frmParent = Parent as Form;
|
||||
if (frmParent != null)
|
||||
{
|
||||
frmParent.WindowState = FormWindowState.Minimized;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
123
VAR.Toolbox/UI/PnlCover.resx
Normal file
123
VAR.Toolbox/UI/PnlCover.resx
Normal file
@@ -0,0 +1,123 @@
|
||||
<?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>
|
||||
<metadata name="timTicker.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -80,7 +80,10 @@
|
||||
<Compile Include="Code\DirectShow\Tools.cs" />
|
||||
<Compile Include="Code\DirectShow\Uuids.cs" />
|
||||
<Compile Include="Code\DirectShow\Win32.cs" />
|
||||
<Compile Include="Code\Mouse.cs" />
|
||||
<Compile Include="Code\User32.cs" />
|
||||
<Compile Include="Code\Webcam.cs" />
|
||||
<Compile Include="Code\Win32API.cs" />
|
||||
<Compile Include="Controls\CtrImageViewer.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
@@ -90,6 +93,9 @@
|
||||
<Compile Include="UI\FrmBase64.Designer.cs">
|
||||
<DependentUpon>FrmBase64.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UI\FrmCover.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\FrmProxyCmd.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@@ -115,6 +121,12 @@
|
||||
<Compile Include="UI\FrmWebcam.Designer.cs">
|
||||
<DependentUpon>FrmWebcam.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UI\PnlCover.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\PnlCover.Designer.cs">
|
||||
<DependentUpon>PnlCover.cs</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="UI\FrmBase64.resx">
|
||||
@@ -129,6 +141,9 @@
|
||||
<EmbeddedResource Include="UI\FrmWebcam.resx">
|
||||
<DependentUpon>FrmWebcam.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="UI\PnlCover.resx">
|
||||
<DependentUpon>PnlCover.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
|
||||
Reference in New Issue
Block a user