📄 notifywindowimage.cs
字号:
namespace Imps.Client.Pc.BizControls.NotifyWindows
{
using System;
using System.Drawing;
using System.Runtime.CompilerServices;
public class NotifyWindowImage : INotifyWindowElement, IDisposable
{
private bool clickable;
private System.Drawing.Image image;
private bool isMouseOver;
private System.Drawing.Rectangle realRectangle;
private 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 NotifyWindowImage(System.Drawing.Rectangle rectangle, System.Drawing.Image image)
{
this.rectangle = rectangle;
this.image = image;
}
protected void CalculateRectangles()
{
if (this.image != null)
{
int width = this.Image.Width;
int height = this.Image.Height;
if (width > this.Rectangle.Width)
{
width = this.Rectangle.Width;
}
if (height > this.Rectangle.Height)
{
height = this.Rectangle.Height;
}
this.RealRectangle = new System.Drawing.Rectangle(this.Rectangle.X, this.Rectangle.Y, width, height);
}
}
public void Dispose()
{
}
public void Draw(Graphics g)
{
if (this.image != null)
{
this.CalculateRectangles();
g.DrawImage(this.Image, this.Rectangle);
}
}
public void OnClick(NotifyWindowEventArgs e)
{
if (this.Click != null)
{
this.Click(this, e);
}
}
public void OnMouseDown(NotifyWindowEventArgs e)
{
this.IsMouseOver = true;
if (this.MouseDown != null)
{
this.MouseDown(this, e);
}
}
public void OnMouseOut(NotifyWindowEventArgs e)
{
this.IsMouseOver = false;
if (this.MouseOut != null)
{
this.MouseOut(this, e);
}
}
public void OnMouseOver(NotifyWindowEventArgs e)
{
this.IsMouseOver = true;
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.rectangle = rectangle;
this.image = image;
}
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;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -