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

📄 inputname.cs

📁 这个程序是基于c#平台的俄罗斯方框游戏。拿来共享。要求加分哦!
💻 CS
字号:


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace AnotherBlock
{
	/// <summary>
	/// Input Name dialog.
	/// </summary>
	public class InputName : System.Windows.Forms.Form
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		/// <summary>
		/// Text box with the name to be put in the current high score entry.
		/// </summary>
		private System.Windows.Forms.TextBox txtName;
		/// <summary>
		/// "Ok" button.
		/// </summary>
		private System.Windows.Forms.Button butOk;
		/// <summary>
		/// Label with the text "High Score!".
		/// </summary>
		private System.Windows.Forms.Label lblTextHighScore;
		/// <summary>
		/// Label with the text "Enter your name: ".
		/// </summary>
		private System.Windows.Forms.Label lblTextEnterName;

		/// <summary>
		/// Private attribute that holds the high score name.
		/// </summary>
		private string highScoreName = "";

		/// <summary>
		/// Class constructor that creates the Input Name dialog.
		/// </summary>
		public InputName()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
		}

		/// <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(InputName));
			this.lblTextHighScore = new System.Windows.Forms.Label();
			this.lblTextEnterName = new System.Windows.Forms.Label();
			this.txtName = new System.Windows.Forms.TextBox();
			this.butOk = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// lblTextHighScore
			// 
			this.lblTextHighScore.AccessibleDescription = resources.GetString("lblTextHighScore.AccessibleDescription");
			this.lblTextHighScore.AccessibleName = resources.GetString("lblTextHighScore.AccessibleName");
			this.lblTextHighScore.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("lblTextHighScore.Anchor")));
			this.lblTextHighScore.AutoSize = ((bool)(resources.GetObject("lblTextHighScore.AutoSize")));
			this.lblTextHighScore.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("lblTextHighScore.Dock")));
			this.lblTextHighScore.Enabled = ((bool)(resources.GetObject("lblTextHighScore.Enabled")));
			this.lblTextHighScore.Font = ((System.Drawing.Font)(resources.GetObject("lblTextHighScore.Font")));
			this.lblTextHighScore.Image = ((System.Drawing.Image)(resources.GetObject("lblTextHighScore.Image")));
			this.lblTextHighScore.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblTextHighScore.ImageAlign")));
			this.lblTextHighScore.ImageIndex = ((int)(resources.GetObject("lblTextHighScore.ImageIndex")));
			this.lblTextHighScore.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("lblTextHighScore.ImeMode")));
			this.lblTextHighScore.Location = ((System.Drawing.Point)(resources.GetObject("lblTextHighScore.Location")));
			this.lblTextHighScore.Name = "lblTextHighScore";
			this.lblTextHighScore.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("lblTextHighScore.RightToLeft")));
			this.lblTextHighScore.Size = ((System.Drawing.Size)(resources.GetObject("lblTextHighScore.Size")));
			this.lblTextHighScore.TabIndex = ((int)(resources.GetObject("lblTextHighScore.TabIndex")));
			this.lblTextHighScore.Text = resources.GetString("lblTextHighScore.Text");
			this.lblTextHighScore.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblTextHighScore.TextAlign")));
			this.lblTextHighScore.Visible = ((bool)(resources.GetObject("lblTextHighScore.Visible")));
			// 
			// lblTextEnterName
			// 
			this.lblTextEnterName.AccessibleDescription = resources.GetString("lblTextEnterName.AccessibleDescription");
			this.lblTextEnterName.AccessibleName = resources.GetString("lblTextEnterName.AccessibleName");
			this.lblTextEnterName.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("lblTextEnterName.Anchor")));
			this.lblTextEnterName.AutoSize = ((bool)(resources.GetObject("lblTextEnterName.AutoSize")));
			this.lblTextEnterName.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("lblTextEnterName.Dock")));
			this.lblTextEnterName.Enabled = ((bool)(resources.GetObject("lblTextEnterName.Enabled")));
			this.lblTextEnterName.Font = ((System.Drawing.Font)(resources.GetObject("lblTextEnterName.Font")));
			this.lblTextEnterName.Image = ((System.Drawing.Image)(resources.GetObject("lblTextEnterName.Image")));
			this.lblTextEnterName.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblTextEnterName.ImageAlign")));
			this.lblTextEnterName.ImageIndex = ((int)(resources.GetObject("lblTextEnterName.ImageIndex")));
			this.lblTextEnterName.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("lblTextEnterName.ImeMode")));
			this.lblTextEnterName.Location = ((System.Drawing.Point)(resources.GetObject("lblTextEnterName.Location")));
			this.lblTextEnterName.Name = "lblTextEnterName";
			this.lblTextEnterName.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("lblTextEnterName.RightToLeft")));
			this.lblTextEnterName.Size = ((System.Drawing.Size)(resources.GetObject("lblTextEnterName.Size")));
			this.lblTextEnterName.TabIndex = ((int)(resources.GetObject("lblTextEnterName.TabIndex")));
			this.lblTextEnterName.Text = resources.GetString("lblTextEnterName.Text");
			this.lblTextEnterName.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblTextEnterName.TextAlign")));
			this.lblTextEnterName.Visible = ((bool)(resources.GetObject("lblTextEnterName.Visible")));
			// 
			// txtName
			// 
			this.txtName.AccessibleDescription = resources.GetString("txtName.AccessibleDescription");
			this.txtName.AccessibleName = resources.GetString("txtName.AccessibleName");
			this.txtName.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("txtName.Anchor")));
			this.txtName.AutoSize = ((bool)(resources.GetObject("txtName.AutoSize")));
			this.txtName.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("txtName.BackgroundImage")));
			this.txtName.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("txtName.Dock")));
			this.txtName.Enabled = ((bool)(resources.GetObject("txtName.Enabled")));
			this.txtName.Font = ((System.Drawing.Font)(resources.GetObject("txtName.Font")));
			this.txtName.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("txtName.ImeMode")));
			this.txtName.Location = ((System.Drawing.Point)(resources.GetObject("txtName.Location")));
			this.txtName.MaxLength = ((int)(resources.GetObject("txtName.MaxLength")));
			this.txtName.Multiline = ((bool)(resources.GetObject("txtName.Multiline")));
			this.txtName.Name = "txtName";
			this.txtName.PasswordChar = ((char)(resources.GetObject("txtName.PasswordChar")));
			this.txtName.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("txtName.RightToLeft")));
			this.txtName.ScrollBars = ((System.Windows.Forms.ScrollBars)(resources.GetObject("txtName.ScrollBars")));
			this.txtName.Size = ((System.Drawing.Size)(resources.GetObject("txtName.Size")));
			this.txtName.TabIndex = ((int)(resources.GetObject("txtName.TabIndex")));
			this.txtName.Text = resources.GetString("txtName.Text");
			this.txtName.TextAlign = ((System.Windows.Forms.HorizontalAlignment)(resources.GetObject("txtName.TextAlign")));
			this.txtName.Visible = ((bool)(resources.GetObject("txtName.Visible")));
			this.txtName.WordWrap = ((bool)(resources.GetObject("txtName.WordWrap")));
			// 
			// butOk
			// 
			this.butOk.AccessibleDescription = resources.GetString("butOk.AccessibleDescription");
			this.butOk.AccessibleName = resources.GetString("butOk.AccessibleName");
			this.butOk.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("butOk.Anchor")));
			this.butOk.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("butOk.BackgroundImage")));
			this.butOk.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("butOk.Dock")));
			this.butOk.Enabled = ((bool)(resources.GetObject("butOk.Enabled")));
			this.butOk.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("butOk.FlatStyle")));
			this.butOk.Font = ((System.Drawing.Font)(resources.GetObject("butOk.Font")));
			this.butOk.Image = ((System.Drawing.Image)(resources.GetObject("butOk.Image")));
			this.butOk.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("butOk.ImageAlign")));
			this.butOk.ImageIndex = ((int)(resources.GetObject("butOk.ImageIndex")));
			this.butOk.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("butOk.ImeMode")));
			this.butOk.Location = ((System.Drawing.Point)(resources.GetObject("butOk.Location")));
			this.butOk.Name = "butOk";
			this.butOk.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("butOk.RightToLeft")));
			this.butOk.Size = ((System.Drawing.Size)(resources.GetObject("butOk.Size")));
			this.butOk.TabIndex = ((int)(resources.GetObject("butOk.TabIndex")));
			this.butOk.Text = resources.GetString("butOk.Text");
			this.butOk.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("butOk.TextAlign")));
			this.butOk.Visible = ((bool)(resources.GetObject("butOk.Visible")));
			this.butOk.Click += new System.EventHandler(this.butOk_Click);
			// 
			// InputName
			// 
			this.AcceptButton = this.butOk;
			this.AccessibleDescription = resources.GetString("$this.AccessibleDescription");
			this.AccessibleName = resources.GetString("$this.AccessibleName");
			this.AutoScaleBaseSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScaleBaseSize")));
			this.AutoScroll = ((bool)(resources.GetObject("$this.AutoScroll")));
			this.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMargin")));
			this.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMinSize")));
			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.ClientSize = ((System.Drawing.Size)(resources.GetObject("$this.ClientSize")));
			this.Controls.Add(this.butOk);
			this.Controls.Add(this.txtName);
			this.Controls.Add(this.lblTextEnterName);
			this.Controls.Add(this.lblTextHighScore);
			this.Enabled = ((bool)(resources.GetObject("$this.Enabled")));
			this.Font = ((System.Drawing.Font)(resources.GetObject("$this.Font")));
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("$this.ImeMode")));
			this.Location = ((System.Drawing.Point)(resources.GetObject("$this.Location")));
			this.MaximizeBox = false;
			this.MaximumSize = ((System.Drawing.Size)(resources.GetObject("$this.MaximumSize")));
			this.MinimumSize = ((System.Drawing.Size)(resources.GetObject("$this.MinimumSize")));
			this.Name = "InputName";
			this.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("$this.RightToLeft")));
			this.ShowInTaskbar = false;
			this.StartPosition = ((System.Windows.Forms.FormStartPosition)(resources.GetObject("$this.StartPosition")));
			this.Text = resources.GetString("$this.Text");
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// Readonly property that holds the high score name.
		/// </summary>
		public string HighScoreName
		{
			get
			{
				// Returns the value in the highScoreName attribute.
				return highScoreName;
			}
		}

		/// <summary>
		/// The click of the "Ok" button. Sets the highScoreName attribute and closes the Input Name dialog window.
		/// </summary>
		/// <param name="sender">The parent control who triggered the event.</param>
		/// <param name="e">Default event arguments.</param>
		private void butOk_Click(object sender, System.EventArgs e)
		{
			// Sets the highScoreName attribute to the value in the text field txtName.
			highScoreName = txtName.Text;
			// Closes this window.
			this.Close();
		}
	}
}

⌨️ 快捷键说明

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