Click here to Skip to main content
15,893,588 members
Articles / Programming Languages / C#

Timer Computer Shutdown

Rate me:
Please Sign up or sign in to vote.
4.63/5 (16 votes)
2 Oct 2002 349.2K   13.4K   106  
This application provides functionality to Shutdown, Restart, Stand By, Hibernate or Log Off supported computers at a selected date and time.
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace TimerComputerShutdown
{
	/// <summary>
	/// Summary description for Error.
	/// </summary>
	public class Warning : System.Windows.Forms.Form
	{
		private System.Windows.Forms.PictureBox pictureBox;
		private System.Windows.Forms.Button buttonOK;
		private System.Windows.Forms.Panel panel;
		private System.Windows.Forms.Label labelWarning1;
		private System.Windows.Forms.Label labelWarning2;
		
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Warning()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Warning));
			this.pictureBox = new System.Windows.Forms.PictureBox();
			this.labelWarning1 = new System.Windows.Forms.Label();
			this.buttonOK = new System.Windows.Forms.Button();
			this.panel = new System.Windows.Forms.Panel();
			this.labelWarning2 = new System.Windows.Forms.Label();
			this.panel.SuspendLayout();
			this.SuspendLayout();
			// 
			// pictureBox
			// 
			this.pictureBox.Image = ((System.Drawing.Bitmap)(resources.GetObject("pictureBox.Image")));
			this.pictureBox.Location = new System.Drawing.Point(8, 8);
			this.pictureBox.Name = "pictureBox";
			this.pictureBox.Size = new System.Drawing.Size(32, 32);
			this.pictureBox.TabIndex = 0;
			this.pictureBox.TabStop = false;
			// 
			// labelWarning1
			// 
			this.labelWarning1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.labelWarning1.Location = new System.Drawing.Point(47, 16);
			this.labelWarning1.Name = "labelWarning1";
			this.labelWarning1.Size = new System.Drawing.Size(145, 16);
			this.labelWarning1.TabIndex = 1;
			this.labelWarning1.Text = "WARNING: Brute Shutdown";
			// 
			// buttonOK
			// 
			this.buttonOK.BackColor = System.Drawing.Color.GhostWhite;
			this.buttonOK.Cursor = System.Windows.Forms.Cursors.Hand;
			this.buttonOK.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.buttonOK.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.buttonOK.Location = new System.Drawing.Point(152, 104);
			this.buttonOK.Name = "buttonOK";
			this.buttonOK.Size = new System.Drawing.Size(56, 24);
			this.buttonOK.TabIndex = 10;
			this.buttonOK.Text = "&OK";
			this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
			// 
			// panel
			// 
			this.panel.BackColor = System.Drawing.Color.GhostWhite;
			this.panel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.panel.Controls.AddRange(new System.Windows.Forms.Control[] {
																				this.labelWarning2,
																				this.labelWarning1,
																				this.pictureBox});
			this.panel.Location = new System.Drawing.Point(8, 8);
			this.panel.Name = "panel";
			this.panel.Size = new System.Drawing.Size(200, 88);
			this.panel.TabIndex = 4;
			// 
			// labelWarning2
			// 
			this.labelWarning2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.labelWarning2.Location = new System.Drawing.Point(16, 48);
			this.labelWarning2.Name = "labelWarning2";
			this.labelWarning2.Size = new System.Drawing.Size(168, 24);
			this.labelWarning2.TabIndex = 2;
			this.labelWarning2.Text = "All processes will be terminated. All unsaved data will be lost.";
			// 
			// Warning
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.BackColor = System.Drawing.Color.GhostWhite;
			this.ClientSize = new System.Drawing.Size(218, 135);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.buttonOK,
																		  this.panel});
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "Warning";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "Timer Computer Shutdown";
			this.TopMost = true;
			this.panel.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void buttonOK_Click(object sender, System.EventArgs e)
		{
			this.DialogResult = System.Windows.Forms.DialogResult.OK;

			this.Close();
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions