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

📄 optionform.cs

📁 C#纸牌游戏,做的还是比较精致的.值得学习.
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace CardGame
{
	/// <summary>
	/// OptionForm 的摘要说明。
	/// </summary>
	public class OptionForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.GroupBox groupBox2;
		private System.Windows.Forms.Button btn_confirm;
		private System.Windows.Forms.Button btn_cancel;
		private System.Windows.Forms.RadioButton rbtn_one;
		private System.Windows.Forms.RadioButton rbtn_three;
		private System.Windows.Forms.CheckBox check_record;
		private System.Windows.Forms.CheckBox check_state;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public bool State=false;
		public bool Record=false;
		public bool Score=false;
		public bool Loop=false;
		private System.Windows.Forms.CheckBox check_score;
		private System.Windows.Forms.CheckBox check_loop;
		public bool ReStartGame=false;
		public OptionForm(bool state,bool record,bool score,bool loop)
		{
			State=state;
			Record=record;
			Score=score;
			Loop=loop;
			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(OptionForm));
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.rbtn_three = new System.Windows.Forms.RadioButton();
			this.rbtn_one = new System.Windows.Forms.RadioButton();
			this.groupBox2 = new System.Windows.Forms.GroupBox();
			this.check_score = new System.Windows.Forms.CheckBox();
			this.check_state = new System.Windows.Forms.CheckBox();
			this.check_record = new System.Windows.Forms.CheckBox();
			this.btn_confirm = new System.Windows.Forms.Button();
			this.btn_cancel = new System.Windows.Forms.Button();
			this.check_loop = new System.Windows.Forms.CheckBox();
			this.groupBox1.SuspendLayout();
			this.groupBox2.SuspendLayout();
			this.SuspendLayout();
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.check_loop);
			this.groupBox1.Controls.Add(this.rbtn_three);
			this.groupBox1.Controls.Add(this.rbtn_one);
			this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.groupBox1.Location = new System.Drawing.Point(8, 8);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(112, 88);
			this.groupBox1.TabIndex = 0;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "翻牌";
			// 
			// rbtn_three
			// 
			this.rbtn_three.Checked = true;
			this.rbtn_three.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.rbtn_three.Location = new System.Drawing.Point(16, 40);
			this.rbtn_three.Name = "rbtn_three";
			this.rbtn_three.Size = new System.Drawing.Size(72, 16);
			this.rbtn_three.TabIndex = 1;
			this.rbtn_three.TabStop = true;
			this.rbtn_three.Text = "翻三张";
			// 
			// rbtn_one
			// 
			this.rbtn_one.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.rbtn_one.Location = new System.Drawing.Point(16, 16);
			this.rbtn_one.Name = "rbtn_one";
			this.rbtn_one.Size = new System.Drawing.Size(88, 24);
			this.rbtn_one.TabIndex = 0;
			this.rbtn_one.Text = "翻一张";
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.Add(this.check_score);
			this.groupBox2.Controls.Add(this.check_state);
			this.groupBox2.Controls.Add(this.check_record);
			this.groupBox2.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.groupBox2.Location = new System.Drawing.Point(128, 8);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(120, 88);
			this.groupBox2.TabIndex = 1;
			this.groupBox2.TabStop = false;
			this.groupBox2.Text = "状态";
			// 
			// check_score
			// 
			this.check_score.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.check_score.Location = new System.Drawing.Point(16, 36);
			this.check_score.Name = "check_score";
			this.check_score.Size = new System.Drawing.Size(96, 24);
			this.check_score.TabIndex = 2;
			this.check_score.Text = "计分";
			// 
			// check_state
			// 
			this.check_state.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.check_state.Location = new System.Drawing.Point(16, 56);
			this.check_state.Name = "check_state";
			this.check_state.Size = new System.Drawing.Size(96, 24);
			this.check_state.TabIndex = 1;
			this.check_state.Text = "状态栏";
			// 
			// check_record
			// 
			this.check_record.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.check_record.Location = new System.Drawing.Point(16, 16);
			this.check_record.Name = "check_record";
			this.check_record.Size = new System.Drawing.Size(96, 24);
			this.check_record.TabIndex = 0;
			this.check_record.Text = "计时游戏";
			// 
			// btn_confirm
			// 
			this.btn_confirm.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
			this.btn_confirm.DialogResult = System.Windows.Forms.DialogResult.OK;
			this.btn_confirm.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.btn_confirm.Location = new System.Drawing.Point(56, 112);
			this.btn_confirm.Name = "btn_confirm";
			this.btn_confirm.Size = new System.Drawing.Size(64, 24);
			this.btn_confirm.TabIndex = 2;
			this.btn_confirm.Text = "确定";
			this.btn_confirm.Click += new System.EventHandler(this.btn_confirm_Click);
			// 
			// btn_cancel
			// 
			this.btn_cancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
			this.btn_cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btn_cancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.btn_cancel.Location = new System.Drawing.Point(128, 112);
			this.btn_cancel.Name = "btn_cancel";
			this.btn_cancel.Size = new System.Drawing.Size(64, 24);
			this.btn_cancel.TabIndex = 3;
			this.btn_cancel.Text = "取消";
			// 
			// check_loop
			// 
			this.check_loop.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.check_loop.Location = new System.Drawing.Point(16, 56);
			this.check_loop.Name = "check_loop";
			this.check_loop.Size = new System.Drawing.Size(80, 24);
			this.check_loop.TabIndex = 2;
			this.check_loop.Text = "重复翻牌";
			// 
			// OptionForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(258, 144);
			this.Controls.Add(this.btn_cancel);
			this.Controls.Add(this.btn_confirm);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.groupBox1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "OptionForm";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "选项";
			this.Load += new System.EventHandler(this.OptionForm_Load);
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void OptionForm_Load(object sender, System.EventArgs e)
		{
			if(GamePlace.ShowCount==GamePlace.OnceShowCount.One)
			{
				rbtn_one.Checked=true;
			}
			else
			{
				rbtn_three.Checked=true;
			}

			check_record.Checked=Record;
			check_state.Checked=State;
			check_score.Checked=Score;
			check_loop.Checked=Loop;
			
		}

		private void btn_confirm_Click(object sender, System.EventArgs e)
		{
			if(Score!=check_score.Checked)ReStartGame=true;
			Score=check_score.Checked;

			if(Record!=check_record.Checked)ReStartGame=true;
			Record=check_record.Checked;

			if(Loop!=check_loop.Checked)ReStartGame=true;
			Loop=check_loop.Checked;

			State=check_state.Checked;

			GamePlace.OnceShowCount showCount=rbtn_one.Checked?GamePlace.OnceShowCount.One:GamePlace.OnceShowCount.Three;
			if(GamePlace.ShowCount!=showCount)ReStartGame=true;
			GamePlace.ShowCount=showCount;
		}
	}
}

⌨️ 快捷键说明

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