From c04fdfb770268159ccd6666152b60b7c6963e0ce Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 10 Aug 2014 22:44:46 +0100 Subject: [PATCH] form rename, and imported stuff from testing project --- USB Lockdown/lockScreen.Designer.cs | 57 +++++++++++++++++++++++++++++ USB Lockdown/lockScreen.cs | 49 +++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 USB Lockdown/lockScreen.Designer.cs create mode 100644 USB Lockdown/lockScreen.cs diff --git a/USB Lockdown/lockScreen.Designer.cs b/USB Lockdown/lockScreen.Designer.cs new file mode 100644 index 0000000..d64c71d --- /dev/null +++ b/USB Lockdown/lockScreen.Designer.cs @@ -0,0 +1,57 @@ +namespace USB_Lockdown +{ + partial class lockScreen + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.foregroundTimer = new System.Windows.Forms.Timer(this.components); + this.SuspendLayout(); + // + // foregroundTimer + // + this.foregroundTimer.Interval = 50; + this.foregroundTimer.Tick += new System.EventHandler(this.keepForeground); + // + // lockScreen + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(284, 261); + this.Name = "lockScreen"; + this.Text = "Form1"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.onClosing); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Timer foregroundTimer; + } +} + diff --git a/USB Lockdown/lockScreen.cs b/USB Lockdown/lockScreen.cs new file mode 100644 index 0000000..542bad2 --- /dev/null +++ b/USB Lockdown/lockScreen.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Runtime.InteropServices; + +namespace USB_Lockdown +{ + public partial class lockScreen : Form + { + [DllImport("user32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + static extern bool SetForegroundWindow(IntPtr hWnd); + + public lockScreen() + { + InitializeComponent(); + KeyboardLock.enable(); + setupWindow(); + + } + + + + private void setupWindow() + { + this.StartPosition = FormStartPosition.CenterScreen; + this.Height = SystemInformation.VirtualScreen.Height; + this.Width = SystemInformation.VirtualScreen.Width; + this.WindowState = FormWindowState.Maximized; + this.BackColor = Color.Black; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + SetForegroundWindow(this.Handle); + this.ShowInTaskbar = false; + } + + private void onClosing(object sender, FormClosingEventArgs e) + { + if (e.CloseReason == CloseReason.UserClosing) { e.Cancel = true; } //disables alt+F4 + } + + private void keepForeground(object sender, EventArgs e) { SetForegroundWindow(this.Handle); } + } +}