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

📄 dragsource.cs

📁 gamecode 很不错的小游戏源代码
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace MapEditor
{
	/// <summary>
	/// DragSource 的摘要说明。
	/// </summary>
	public class DragSource : System.Windows.Forms.PictureBox
	{
		/// <summary> 
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		/// <summary>
		/// 当前的控件
		/// </summary>
		public static DragSource thisControl = null;
		/// <summary>
		/// 当前控件图片的ID
		/// </summary>
		private int imageIndex;
		/// <summary>
		/// 当前图片的保存文件ID
		/// </summary>
		private int fileIndex;

		/// <summary>
		/// 构造函数,初始化成员变量
		/// </summary>
		public DragSource()
		{
			// 该调用是 Windows.Forms 窗体设计器所必需的。
			InitializeComponent();

			// TODO: 在 InitializeComponent 调用后添加任何初始化
			this.imageIndex = 5;
			this.fileIndex = 0;
		}

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

		#region 组件设计器生成的代码
		/// <summary> 
		/// 设计器支持所需的方法 - 不要使用代码编辑器 
		/// 修改此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			// 
			// DragSource
			// 
			this.Name = "DragSource";
			this.Size = new System.Drawing.Size(104, 96);
			this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.DragSource_MouseDown);

		}
		#endregion

		public int ImageIndex
		{
			get
			{
				return this.imageIndex;
			}
			set
			{
				this.imageIndex = value;
			}
		}

		public int FileIndex
		{
			get
			{
				return this.fileIndex;
			}
			set
			{
				this.fileIndex = value;
			}
		}

		/// <summary>
		/// DragSource上的鼠标按下事件,显示当前的控件
		/// </summary>
		/// <param name="sender">事件的发出者(此处为DragSource的实例)</param>
		/// <param name="e"></param>
		private void DragSource_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			if(e.Button == MouseButtons.Left)
			{
				DragSource.thisControl.BorderStyle = BorderStyle.None;
				DragSource.thisControl = this;
				this.BorderStyle = BorderStyle.Fixed3D;
			}
		}
	}
}

⌨️ 快捷键说明

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