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

📄 backimageform.cs

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

namespace CardGame
{
	/// <summary>
	/// BackImageForm 的摘要说明。
	/// </summary>
	public class BackImageForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button btn_confirm;
		private System.Windows.Forms.Button btn_cancel;
		private System.Windows.Forms.ImageList imageList;
		private CardGame.ImageBrowser imageBrowser1;
		private System.ComponentModel.IContainer components;

		public BackImageForm()
		{
			//
			// 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()
		{
			this.components = new System.ComponentModel.Container();
			this.btn_confirm = new System.Windows.Forms.Button();
			this.btn_cancel = new System.Windows.Forms.Button();
			this.imageList = new System.Windows.Forms.ImageList(this.components);
			this.imageBrowser1 = new CardGame.ImageBrowser();
			this.SuspendLayout();
			// 
			// 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(64, 136);
			this.btn_confirm.Name = "btn_confirm";
			this.btn_confirm.Size = new System.Drawing.Size(80, 24);
			this.btn_confirm.TabIndex = 1;
			this.btn_confirm.Text = "确定";
			// 
			// 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(152, 136);
			this.btn_cancel.Name = "btn_cancel";
			this.btn_cancel.Size = new System.Drawing.Size(80, 24);
			this.btn_cancel.TabIndex = 2;
			this.btn_cancel.Text = "取消";
			// 
			// imageList
			// 
			this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
			this.imageList.ImageSize = new System.Drawing.Size(35, 48);
			this.imageList.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// imageBrowser1
			// 
			this.imageBrowser1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.imageBrowser1.HSpace = 8;
			this.imageBrowser1.ImageList = this.imageList;
			this.imageBrowser1.Location = new System.Drawing.Point(16, 16);
			this.imageBrowser1.Name = "imageBrowser1";
			this.imageBrowser1.SelectedColor = System.Drawing.Color.Blue;
			this.imageBrowser1.Size = new System.Drawing.Size(272, 112);
			this.imageBrowser1.TabIndex = 3;
			this.imageBrowser1.VSpace = 8;
			this.imageBrowser1.ItemSelected += new System.EventHandler(this.imageBrowser1_ItemSelected);
			// 
			// BackImageForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(298, 168);
			this.Controls.Add(this.imageBrowser1);
			this.Controls.Add(this.btn_cancel);
			this.Controls.Add(this.btn_confirm);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "BackImageForm";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "选定纸牌背面图案";
			this.Load += new System.EventHandler(this.BackImageForm_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void BackImageForm_Load(object sender, System.EventArgs e)
		{
			int[] section=NormalCard.CardBackImageIndexSection;
			if(section!=null&&section.Length>0)
			{
				int imgIndex=GamePlace.NormalCardBackImageIndex;
				int index=-1;
				for(int i=0;i<section.Length;i++)
				{
					if(imgIndex==section[i])
					{
						index=i;
					}
					imageList.Images.Add(Cards.CardImages[section[i]]);
				}
				imageBrowser1.ShowImages=true;
				imageBrowser1.SelectedIndex=index;
			}
		}

		private void imageBrowser1_ItemSelected(object sender, System.EventArgs e)
		{
			GamePlace.NormalCardBackImageIndex=NormalCard.CardBackImageIndexSection[((ImageBrowser.ImageItem)sender).Index];
			MouseEventArgs mouseEvent=(MouseEventArgs)e;
			if(mouseEvent.Button==MouseButtons.Left&&mouseEvent.Clicks==2)
			{
				this.DialogResult=DialogResult.OK;
				this.Close();
			}
		}
	}
}

⌨️ 快捷键说明

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