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

📄 mainform.cs

📁 摇奖机,很好玩,大家可以拿去测试一下,希望能喜欢
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime; 
using System.Threading; 

namespace TransBall
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class MainForm : System.Windows.Forms.Form
	{
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		/// 
		private Point mouseOffset;
		private bool isMouseDown = false;
		private bool IfThreadStart;
		Thread T1;
		Thread T2;
		Thread T3;
		Thread T4;
		Thread T5;
		Thread T6;

		private delegate void CALL(Control Tr);

		private System.Windows.Forms.PictureBox btnExit;
		private System.Windows.Forms.PictureBox btnStart;
		private System.Windows.Forms.Label L1;
		private System.Windows.Forms.Label L2;
		private System.Windows.Forms.Label L3;
		private System.Windows.Forms.Label L4;
		private System.Windows.Forms.Label L5;
		private System.Windows.Forms.Label L6;
		private System.Windows.Forms.Label lblLast;
		private System.ComponentModel.Container components = null;

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

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

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

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));
			this.L1 = new System.Windows.Forms.Label();
			this.L2 = new System.Windows.Forms.Label();
			this.L3 = new System.Windows.Forms.Label();
			this.L4 = new System.Windows.Forms.Label();
			this.L5 = new System.Windows.Forms.Label();
			this.L6 = new System.Windows.Forms.Label();
			this.btnExit = new System.Windows.Forms.PictureBox();
			this.btnStart = new System.Windows.Forms.PictureBox();
			this.lblLast = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// L1
			// 
			this.L1.BackColor = System.Drawing.Color.Yellow;
			this.L1.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.L1.Location = new System.Drawing.Point(114, 175);
			this.L1.Name = "L1";
			this.L1.Size = new System.Drawing.Size(21, 18);
			this.L1.TabIndex = 0;
			this.L1.Text = "1";
			// 
			// L2
			// 
			this.L2.BackColor = System.Drawing.Color.Yellow;
			this.L2.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.L2.Location = new System.Drawing.Point(181, 173);
			this.L2.Name = "L2";
			this.L2.Size = new System.Drawing.Size(21, 18);
			this.L2.TabIndex = 1;
			this.L2.Text = "2";
			// 
			// L3
			// 
			this.L3.BackColor = System.Drawing.Color.Yellow;
			this.L3.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.L3.Location = new System.Drawing.Point(249, 172);
			this.L3.Name = "L3";
			this.L3.Size = new System.Drawing.Size(21, 18);
			this.L3.TabIndex = 2;
			this.L3.Text = "3";
			// 
			// L4
			// 
			this.L4.BackColor = System.Drawing.Color.Yellow;
			this.L4.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.L4.Location = new System.Drawing.Point(315, 171);
			this.L4.Name = "L4";
			this.L4.Size = new System.Drawing.Size(21, 18);
			this.L4.TabIndex = 4;
			this.L4.Text = "4";
			// 
			// L5
			// 
			this.L5.BackColor = System.Drawing.Color.Yellow;
			this.L5.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.L5.Location = new System.Drawing.Point(382, 171);
			this.L5.Name = "L5";
			this.L5.Size = new System.Drawing.Size(21, 18);
			this.L5.TabIndex = 5;
			this.L5.Text = "5";
			// 
			// L6
			// 
			this.L6.BackColor = System.Drawing.Color.Yellow;
			this.L6.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.L6.Location = new System.Drawing.Point(450, 170);
			this.L6.Name = "L6";
			this.L6.Size = new System.Drawing.Size(21, 18);
			this.L6.TabIndex = 6;
			this.L6.Text = "6";
			// 
			// btnExit
			// 
			this.btnExit.BackColor = System.Drawing.Color.White;
			this.btnExit.Image = ((System.Drawing.Image)(resources.GetObject("btnExit.Image")));
			this.btnExit.Location = new System.Drawing.Point(75, 11);
			this.btnExit.Name = "btnExit";
			this.btnExit.Size = new System.Drawing.Size(17, 19);
			this.btnExit.TabIndex = 7;
			this.btnExit.TabStop = false;
			this.btnExit.Click += new System.EventHandler(this.btnExit_Click_1);
			// 
			// btnStart
			// 
			this.btnStart.BackColor = System.Drawing.Color.White;
			this.btnStart.Image = ((System.Drawing.Image)(resources.GetObject("btnStart.Image")));
			this.btnStart.Location = new System.Drawing.Point(7, 80);
			this.btnStart.Name = "btnStart";
			this.btnStart.Size = new System.Drawing.Size(20, 17);
			this.btnStart.TabIndex = 8;
			this.btnStart.TabStop = false;
			this.btnStart.Click += new System.EventHandler(this.pictureBox1_Click);
			// 
			// lblLast
			// 
			this.lblLast.BackColor = System.Drawing.Color.Yellow;
			this.lblLast.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lblLast.Location = new System.Drawing.Point(341, 18);
			this.lblLast.Name = "lblLast";
			this.lblLast.Size = new System.Drawing.Size(145, 18);
			this.lblLast.TabIndex = 9;
			this.lblLast.Text = "中奖号码:123456";
			this.lblLast.Visible = false;
			// 
			// MainForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.ClientSize = new System.Drawing.Size(496, 219);
			this.Controls.Add(this.lblLast);
			this.Controls.Add(this.btnStart);
			this.Controls.Add(this.btnExit);
			this.Controls.Add(this.L6);
			this.Controls.Add(this.L5);
			this.Controls.Add(this.L4);
			this.Controls.Add(this.L3);
			this.Controls.Add(this.L2);
			this.Controls.Add(this.L1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
			this.Name = "MainForm";
			this.TransparencyKey = System.Drawing.Color.Yellow;
			this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.MainForm_MouseDown);
			this.Load += new System.EventHandler(this.MainForm_Load);
			this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.MainForm_MouseUp);
			this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.MainForm_MouseMove);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new MainForm());
		}

		private void MainForm_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			if (e.Button == MouseButtons.Left) 
			{
				mouseOffset = new Point(-e.X, -e.Y);
				isMouseDown = true;
			}

		}

		private void MainForm_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			if (isMouseDown) 
			{
				Point mousePos = Control.MousePosition;
				mousePos.Offset(mouseOffset.X, mouseOffset.Y);
				this.Location = mousePos;
			}
		}

		private void MainForm_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			if (e.Button == MouseButtons.Left) 
			{
				isMouseDown = false;
			}
		}

		private void btnExit_Click_1(object sender, System.EventArgs e)
		{
			this.Close();
			Application.Exit(); 
		}

		private void pictureBox1_Click(object sender, System.EventArgs e)
		{
			if (IfThreadStart==false)
			{
				lblLast.Visible=false;
				InThread A1 = new InThread();
				A1.SetNumber(L1,1000);
				T1 = new Thread(new ThreadStart(A1.RunInThread));
				T1.Start(); 

				InThread A2 = new InThread();
				A2.SetNumber(L2,1111);
				T2 = new Thread(new ThreadStart(A2.RunInThread));
				T2.Start(); 
		
				InThread A3 = new InThread();
				A3.SetNumber(L3,2222);
				T3 = new Thread(new ThreadStart(A3.RunInThread));
				T3.Start(); 

				InThread A4 = new InThread();
				A4.SetNumber(L4,3333);
				T4 = new Thread(new ThreadStart(A4.RunInThread));
				T4.Start(); 

				InThread A5 = new InThread();
				A5.SetNumber(L5,4444);
				T5 = new Thread(new ThreadStart(A5.RunInThread));
				T5.Start(); 

				InThread A6 = new InThread();
				A6.SetNumber(L6,5555);
				T6 = new Thread(new ThreadStart(A6.RunInThread));
				T6.Start(); 

				IfThreadStart=true;
			}
			else
			{
				T1.Abort(); 
				T2.Abort(); 
				T3.Abort(); 
				T4.Abort(); 
				T5.Abort(); 
				T6.Abort(); 
				IfThreadStart=false;
				lblLast.Text ="中奖号码:"+L1.Text +L2.Text+L3.Text+L4.Text+L5.Text +L6.Text;    
				lblLast.Visible=true; 
			}
		}

		private void MainForm_Load(object sender, System.EventArgs e)
		{
			IfThreadStart = false;
		}
	}
}

⌨️ 快捷键说明

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