반응형
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace DzERD.CustomControls.Common
{
public class ImageButtonER : Button
{
Image _click;
Image _nomal;
Image _hover;
Image _disable;
public Image Click1
{
get { return _click; }
set { _click = value; }
}
public Image Hover
{
get { return _hover; }
set { _hover = value; }
}
public Image Nomal
{
get { return _nomal; }
set { _nomal = value; }
}
public Image Disable
{
get { return _disable; }
set { _disable = value; }
}
public ImageButtonER()
{
this.BackColor = Color.Transparent;
this.BackgroundImageLayout = ImageLayout.Stretch;
this.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
if (this.Nomal != null)
{
this.BackgroundImage = Nomal;
}
this.FlatAppearance.BorderColor = Color.FromArgb(0, 255, 255, 255);
}
protected override bool ShowFocusCues
{
get
{
return false;
}
}
protected override void OnGotFocus(EventArgs e)
{
base.OnGotFocus(e);
this.BackgroundImage = Hover;
}
protected override void OnLostFocus(EventArgs e)
{
base.OnLostFocus(e);
this.BackgroundImage = Nomal;
}
protected override void InitLayout()
{
base.InitLayout();
if(this.Nomal != null)
{
this.BackgroundImage = Nomal;
}
}
protected override void OnMouseHover(EventArgs e)
{
this.BackgroundImage = _hover;
this.Refresh();
}
protected override void OnMouseEnter(EventArgs e)
{
this.BackgroundImage = _hover;
this.Refresh();
}
protected override void OnMouseUp(MouseEventArgs mevent)
{
this.BackgroundImage = _hover;
this.Refresh();
base.OnMouseUp(mevent);
}
protected override void OnMouseDown(MouseEventArgs mevent)
{
this.BackgroundImage = _click;
this.Refresh();
base.OnMouseDown(mevent);
}
protected override void OnMouseLeave(EventArgs e)
{
this.BackgroundImage = _nomal;
this.Refresh();
}
protected override void OnEnabledChanged(EventArgs e)
{
if (this.Enabled)
{
this.BackgroundImage = _nomal;
}
else
{
this.BackgroundImage = _disable;
}
base.OnEnabledChanged(e);
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
base.OnPaintBackground(pevent);
}
}
}
'Programing > C# ' 카테고리의 다른 글
레지스트리 파일 아이콘 변경후 리부팅 없이 적용 (0) | 2014.06.11 |
---|---|
showWindow 에서 TopMost로 폼창 띄우기 (0) | 2014.04.21 |
런타임시에 PropertyGrid 속성 감추기, 보여주기 (0) | 2014.04.03 |
한글입력 구분 (0) | 2014.03.26 |
Graphics Text Rotate 글자 회전 (0) | 2013.12.18 |