⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exwin.cs

📁 Csharp编写的关于智能手机(smartphone)闹钟程序
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace MyClock
{
	/// <summary>
	/// ExWin 的摘要说明。
	/// </summary>
	public class ExWin : System.Windows.Forms.Form
	{
		private ClockLabel label1;
		private System.Windows.Forms.Button btnOK;
		private System.Windows.Forms.Button BtnCancel;
		private System.ComponentModel.IContainer components;

		private string OpName ;
		private System.Windows.Forms.Timer timer1;
		private int TimesUp = 15 ;

		public ExWin(string op)
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//

			OpName = op ;

			this.label1 .Text = "您的电脑将在"+TimesUp.ToString ()+"秒后"+OpName;
			this.timer1 .Start ();
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			this.label1 = new MyClock.ClockLabel();
			this.btnOK = new System.Windows.Forms.Button();
			this.BtnCancel = new System.Windows.Forms.Button();
			this.timer1 = new System.Windows.Forms.Timer(this.components);
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.BorderStyle = System.Windows.Forms.Border3DStyle.SunkenOuter;
			this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label1.GradientColorTwo = System.Drawing.Color.Orange;
			this.label1.Location = new System.Drawing.Point(8, 8);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(256, 88);
			this.label1.TabIndex = 0;
			this.label1.Text = "您的电脑将在10秒后关闭";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// btnOK
			// 
			this.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnOK.Location = new System.Drawing.Point(96, 104);
			this.btnOK.Name = "btnOK";
			this.btnOK.TabIndex = 1;
			this.btnOK.Text = "立即执行";
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// BtnCancel
			// 
			this.BtnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.BtnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.BtnCancel.Location = new System.Drawing.Point(190, 104);
			this.BtnCancel.Name = "BtnCancel";
			this.BtnCancel.TabIndex = 2;
			this.BtnCancel.Text = "取消操作";
			this.BtnCancel.Click += new System.EventHandler(this.BtnCancel_Click);
			// 
			// timer1
			// 
			this.timer1.Interval = 1000;
			this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
			// 
			// ExWin
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.CancelButton = this.BtnCancel;
			this.ClientSize = new System.Drawing.Size(272, 135);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.BtnCancel,
																		  this.btnOK,
																		  this.label1});
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "ExWin";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "定时操作 (按ESC键取消)";
			this.TopMost = true;
			this.Load += new System.EventHandler(this.ExWin_Load);
			this.ResumeLayout(false);

		}
		#endregion


		private void DoEx()
		{
			switch (OpName)
			{
				case "关机":
					Common.DoExitWin (Common.EWX_POWEROFF );
					//MessageBox.Show ("关机喽!!!");
					break;
				case "重启":
					Common.DoExitWin (Common.EWX_REBOOT );
					//MessageBox.Show ("重新启动!!!");
					break;
				default:
					break;

			}
		}

		private void timer1_Tick(object sender, System.EventArgs e)
		{
			TimesUp -= 1;
			this.label1 .Text = "您的电脑将在"+TimesUp.ToString ()+"秒后"+OpName;
			this.Focus ();
			if(TimesUp<=0)
			{
				this.timer1 .Dispose ();
				DoEx();
			}
			
		}

		private void btnOK_Click(object sender, System.EventArgs e)
		{
			this.timer1 .Dispose ();
			DoEx();
			this.Close ();
		}

		private void BtnCancel_Click(object sender, System.EventArgs e)
		{
			this.timer1 .Dispose ();
			this.Close ();
		}

		private void ExWin_Load(object sender, System.EventArgs e)
		{
			
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -