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

📄 frmw.cs

📁 北大青鸟内部资料
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;

namespace Scroll
{
	/// <summary>
	/// This program demonstrates multithreading
	/// </summary>
	public class frmWish : System.Windows.Forms.Form
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmWish()
		{
			//
			// 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()
		{
			this.lblMessage = new System.Windows.Forms.Label();
			this.lblMsgEnglish = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// lblMessage
			// 
			this.lblMessage.BackColor = System.Drawing.SystemColors.Control;
			this.lblMessage.Font = new System.Drawing.Font("Monotype Corsiva", 18F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lblMessage.ForeColor = System.Drawing.Color.SandyBrown;
			this.lblMessage.Location = new System.Drawing.Point(36, 32);
			this.lblMessage.Name = "lblMessage";
			this.lblMessage.Size = new System.Drawing.Size(127, 29);
			this.lblMessage.TabIndex = 0;
			this.lblMessage.Text = "生日快乐";
			// 
			// lblMsgEnglish
			// 
			this.lblMsgEnglish.BackColor = System.Drawing.SystemColors.Control;
			this.lblMsgEnglish.Font = new System.Drawing.Font("Monotype Corsiva", 18F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lblMsgEnglish.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(0)), ((System.Byte)(0)));
			this.lblMsgEnglish.Location = new System.Drawing.Point(240, 178);
			this.lblMsgEnglish.Name = "lblMsgEnglish";
			this.lblMsgEnglish.Size = new System.Drawing.Size(212, 29);
			this.lblMsgEnglish.TabIndex = 1;
			this.lblMsgEnglish.Text = "Happy Birthday...";
			// 
			// frmWish
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.SystemColors.Control;
			this.ClientSize = new System.Drawing.Size(480, 263);
			this.Controls.Add(this.lblMsgEnglish);
			this.Controls.Add(this.lblMessage);
			this.Name = "frmWish";
			this.Text = "随机消息";
			this.Load += new System.EventHandler(this.ScrollForm_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private System.Windows.Forms.Label lblMsgEnglish;


		private System.Windows.Forms.Label lblMessage;
		
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new frmWish());
		}

		private void ScrollForm_Load(object sender, System.EventArgs e)
		{
			// Create a thread
			Thread draw = new Thread (new ThreadStart(Display));
			// Invoke thread
			draw.Start ();	
			// Create a thread
			Thread drawEnglish = new Thread (new ThreadStart(DisplayEnglish));
			// Invoke thread
			drawEnglish.Start ();	
			
		}

		public void Display()
		{
			for(int index = 1; index <= 100000; index++)
			{
				// Generate two random numbers and assign to Top and Left of Label
				// Random object
				Random objRandom = new Random();

				// Location Variables 
				int x = 0;
				int y = 0;

				x = objRandom.Next(200);
				y = objRandom.Next(200);
				lblMessage.Left = x;
				lblMessage.Top = y;
				Thread.Sleep (500);
			}
		}


		public void DisplayEnglish()
		{
			for(int index = 1; index <= 100000; index++)
			{
				// Generate two random numbers and assign to Top and Left of Label
				// Random object
				Random objRandom = new Random();

				// Location Variables 
				int x = 0;
				int y = 0;

				x = objRandom.Next(100)*2;
				y = objRandom.Next(100)*2;
				lblMsgEnglish.Left = x;
				lblMsgEnglish.Top = y;
				Thread.Sleep (100);
			}
		}

	}
}

⌨️ 快捷键说明

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