📄 notifywindowimagebutton.cs
字号:
namespace Imps.Client.Pc.BizControls.NotifyWindows
{
using System;
using System.Drawing;
using System.Runtime.CompilerServices;
public class NotifyWindowImageButton : INotifyWindowElement, IDisposable
{
private ButtonStatus buttonStatus;
protected bool clickable = true;
protected System.Drawing.Image image;
protected bool isMouseOver;
protected System.Drawing.Rectangle realRectangle;
protected System.Drawing.Rectangle rectangle;
public event NotifyWindowEventHandler Click;
public event NotifyWindowEventHandler MouseDown;
public event NotifyWindowEventHandler MouseOut;
public event NotifyWindowEventHandler MouseOver;
public event NotifyWindowEventHandler MouseUp;
public NotifyWindowImageButton(System.Drawing.Image image, System.Drawing.Rectangle rectangle)
{
this.image = image;
this.rectangle = rectangle;
}
public void Dispose()
{
}
public void Draw(Graphics g)
{
this.RealRectangle = this.Rectangle;
if (this.Image != null)
{
System.Drawing.Rectangle srcRect;
System.Drawing.Rectangle destRect = this.Rectangle;
switch (this.Status)
{
case ButtonStatus.Hover:
srcRect = new System.Drawing.Rectangle(new Point(destRect.Width, 0), destRect.Size);
break;
case ButtonStatus.Down:
srcRect = new System.Drawing.Rectangle(new Point(destRect.Width * 2, 0), destRect.Size);
break;
default:
srcRect = new System.Drawing.Rectangle(new Point(0, 0), destRect.Size);
break;
}
g.DrawImage(this.Image, destRect, srcRect, GraphicsUnit.Pixel);
}
}
public void OnClick(NotifyWindowEventArgs e)
{
if (this.Click != null)
{
this.Click(this, e);
}
}
public void OnMouseDown(NotifyWindowEventArgs e)
{
this.IsMouseOver = true;
this.Status = ButtonStatus.Down;
if (this.MouseDown != null)
{
this.MouseDown(this, e);
}
}
public void OnMouseOut(NotifyWindowEventArgs e)
{
this.IsMouseOver = false;
this.Status = ButtonStatus.Normal;
if (this.MouseOut != null)
{
this.MouseOut(this, e);
}
}
public void OnMouseOver(NotifyWindowEventArgs e)
{
this.IsMouseOver = true;
this.Status = ButtonStatus.Hover;
if (this.MouseOver != null)
{
this.MouseOver(this, e);
}
}
public void OnMouseUp(NotifyWindowEventArgs e)
{
this.IsMouseOver = false;
if (this.MouseUp != null)
{
this.MouseUp(this, e);
}
}
public void UpdateStyle(System.Drawing.Rectangle rectangle, System.Drawing.Image image)
{
this.image = image;
this.rectangle = rectangle;
}
public bool Clickable
{
get
{
return this.clickable;
}
set
{
this.clickable = value;
}
}
public System.Drawing.Image Image
{
get
{
return this.image;
}
set
{
this.image = value;
}
}
public bool IsMouseOver
{
get
{
return this.isMouseOver;
}
set
{
this.isMouseOver = value;
}
}
public System.Drawing.Rectangle RealRectangle
{
get
{
return this.realRectangle;
}
set
{
this.realRectangle = value;
}
}
public System.Drawing.Rectangle Rectangle
{
get
{
return this.rectangle;
}
set
{
this.rectangle = value;
}
}
public ButtonStatus Status
{
get
{
return this.buttonStatus;
}
set
{
this.buttonStatus = value;
}
}
public enum ButtonStatus
{
Normal,
Hover,
Down,
Disabled
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -