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

📄 bitmappatterneditor.cs

📁 OOP With Microsoft VB.NET And Csharp Step By Step
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace PatternMaker
{
	/// <summary>
	/// Summary description for BitmapPatternEditor.
	/// </summary>
	public class BitmapPatternEditor : PatternEditor
	{
		private System.Windows.Forms.PictureBox pictureBox1;
		private System.Windows.Forms.Button browse;
		private System.Windows.Forms.OpenFileDialog openFileDialog1;
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public BitmapPatternEditor()
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			// TODO: Add any initialization after the InitForm 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 Component 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.pictureBox1 = new System.Windows.Forms.PictureBox();
			this.browse = new System.Windows.Forms.Button();
			this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
			this.SuspendLayout();
			// 
			// pictureBox1
			// 
			this.pictureBox1.Location = new System.Drawing.Point(8, 8);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(61, 61);
			this.pictureBox1.TabIndex = 0;
			this.pictureBox1.TabStop = false;
			// 
			// browse
			// 
			this.browse.Location = new System.Drawing.Point(8, 112);
			this.browse.Name = "browse";
			this.browse.TabIndex = 1;
			this.browse.Text = "Browse";
			this.browse.Click += new System.EventHandler(this.browse_Click);
			// 
			// BitmapPatternEditor
			// 
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.browse,
																		  this.pictureBox1});
			this.Name = "BitmapPatternEditor";
			this.ResumeLayout(false);

		}
		#endregion

		private string m_bitmapFile;
		private BitmapPattern m_pattern = null;


		public BitmapPatternEditor(BitmapPattern pattern)
		{
			InitializeComponent();
			m_pattern = pattern;
			m_bitmapFile = pattern.BitmapFile;
			this.pictureBox1.Paint += new PaintEventHandler(this.Draw);
		}

		public void Draw(object sender,
			System.Windows.Forms.PaintEventArgs e)
		{
			e.Graphics.DrawImage(new
				System.Drawing.Bitmap(m_bitmapFile),0,0);
		}

		private void browse_Click(object sender, System.EventArgs e)
		{
			this.openFileDialog1.ShowDialog();
			if (this.openFileDialog1.FileName.Length !=0)
			{
				m_bitmapFile =this.openFileDialog1.FileName;
				this.pictureBox1.Refresh();
			}
		}

		public override void SavePattern()
		{
			m_pattern.BitmapFile = m_bitmapFile;
		}

	}

}

⌨️ 快捷键说明

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