imagebutton.cs

来自「C#实现DHTML编辑器功能!」· CS 代码 · 共 68 行

CS
68
字号
// DINAMIC XML Editor
//
// Copyright (c) 2002-2003 Dusan Hlavaty
// mailto: duddo@atlas.cz
//
// This software is licensed under the terms of
// GNU General Public license
//
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
using System.ComponentModel;

namespace XML_editor.MyComponents
{
	/// <summary>
	/// Komponenta tlacidlo, ktora zobrazuje obrazok a nemoze dostat focus. Da
	/// sa iba stlacat.
	/// </summary>
	[ToolboxBitmap(typeof(Button))]
	[DefaultProperty("FlatStyle")]
	public class ImageButton : Button
	{
		// -------------------------------------------------------------------------
		/// <summary>
		/// Inicializuje instanciu triedy <see cref="ImageButton"/>
		/// </summary>
		public ImageButton()
		{
			InternalConstruct();
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Interna inicializacna metoda
		/// </summary>
		private void InternalConstruct()
		{
			// Should not be allowed to select this control
			SetStyle(ControlStyles.Selectable, false);

			ImageAlign = System.Drawing.ContentAlignment.MiddleCenter;
			FlatStyle = FlatStyle.Flat;

		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Nastavi defaultnu velkost komponente - tak ako je odporucane
		/// v dokumentacii .NET
		/// </summary>
		protected override Size DefaultSize 
		{
			//			.NET docs:
			//			In order to maintain better performance,
			//			you should not set the Size of a control
			//      in its constructor. The preferred method
			//			is to override the DefaultSize property.
			get 
			{
				return new Size(20, 20);
			}
		}

	} // public class ImageButton : ...
} // namespace XML_editor.MyComponents

⌨️ 快捷键说明

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