using System;
using System.Windows.Forms;
namespace Microsoft.Windows.Forms
{
partial class UIControl
{
private static readonly object EVENT_PARENT_CHANGED = new object();
///
/// 父控件改变事件
///
public event EventHandler ParentChanged
{
add
{
base.Events.AddHandler(EVENT_PARENT_CHANGED, value);
}
remove
{
base.Events.RemoveHandler(EVENT_PARENT_CHANGED, value);
}
}
///
/// 触发父控件改变事件
///
/// 数据
protected virtual void OnParentChanged(EventArgs e)
{
EventHandler handler = base.Events[EVENT_PARENT_CHANGED] as EventHandler;
if (handler != null)
handler(this, e);
}
private static readonly object EVENT_ENTER = new object();
///
/// 鼠标进入事件
///
public event EventHandler Enter
{
add
{
base.Events.AddHandler(EVENT_ENTER, value);
}
remove
{
base.Events.RemoveHandler(EVENT_ENTER, value);
}
}
///
/// 触发鼠标进入事件
///
///
protected virtual void OnEnter(EventArgs e)
{
EventHandler handler = base.Events[EVENT_ENTER] as EventHandler;
if (handler != null)
handler(this, e);
}
private static readonly object EVENT_LEAVE = new object();
///
/// 鼠标离开事件
///
public event EventHandler Leave
{
add
{
base.Events.AddHandler(EVENT_LEAVE, value);
}
remove
{
base.Events.RemoveHandler(EVENT_LEAVE, value);
}
}
///
/// 触发鼠标离开事件
///
/// 数据
protected virtual void OnLeave(EventArgs e)
{
EventHandler handler = base.Events[EVENT_LEAVE] as EventHandler;
if (handler != null)
handler(this, e);
}
private static readonly object EVENT_LOCATION_CHANGED = new object();
///
/// 坐标改变事件
///
public event EventHandler LocationChanged
{
add
{
base.Events.AddHandler(EVENT_LOCATION_CHANGED, value);
}
remove
{
base.Events.RemoveHandler(EVENT_LOCATION_CHANGED, value);
}
}
///
/// 触发坐标改变事件
///
/// 数据
protected virtual void OnLocationChanged(EventArgs e)
{
EventHandler handler = base.Events[EVENT_LOCATION_CHANGED] as EventHandler;
if (handler != null)
handler(this, e);
}
private static readonly object EVENT_SIZE_CHANGED = new object();
///
/// 大小改变事件
///
public event EventHandler SizeChanged
{
add
{
base.Events.AddHandler(EVENT_SIZE_CHANGED, value);
}
remove
{
base.Events.RemoveHandler(EVENT_SIZE_CHANGED, value);
}
}
///
/// 触发大小改变事件
///
/// 数据
protected virtual void OnSizeChanged(EventArgs e)
{
EventHandler handler = base.Events[EVENT_SIZE_CHANGED] as EventHandler;
if (handler != null)
handler(this, e);
}
private static readonly object EVENT_MOUSE_DOWN = new object();
///
/// 鼠标按下事件
///
public event MouseEventHandler MouseDown
{
add
{
base.Events.AddHandler(EVENT_MOUSE_DOWN, value);
}
remove
{
base.Events.RemoveHandler(EVENT_MOUSE_DOWN, value);
}
}
///
/// 触发鼠标按下事件
///
/// 数据
protected virtual void OnMouseDown(MouseEventArgs e)
{
MouseEventHandler handler = base.Events[EVENT_MOUSE_DOWN] as MouseEventHandler;
if (handler != null)
handler(this, e);
}
private static readonly object EVENT_MOUSE_UP = new object();
///
/// 鼠标弹起事件
///
public event MouseEventHandler MouseUp
{
add
{
base.Events.AddHandler(EVENT_MOUSE_UP, value);
}
remove
{
base.Events.RemoveHandler(EVENT_MOUSE_UP, value);
}
}
///
/// 触发鼠标弹起事件
///
/// 数据
protected virtual void OnMouseUp(MouseEventArgs e)
{
MouseEventHandler handler = base.Events[EVENT_MOUSE_UP] as MouseEventHandler;
if (handler != null)
handler(this, e);
}
private static readonly object EVENT_MOUSE_MOVE = new object();
///
/// 鼠标移动事件
///
public event MouseEventHandler MouseMove
{
add
{
base.Events.AddHandler(EVENT_MOUSE_MOVE, value);
}
remove
{
base.Events.RemoveHandler(EVENT_MOUSE_MOVE, value);
}
}
///
/// 触发鼠标移动事件
///
/// 数据
protected virtual void OnMouseMove(MouseEventArgs e)
{
MouseEventHandler handler = base.Events[EVENT_MOUSE_MOVE] as MouseEventHandler;
if (handler != null)
handler(this, e);
}
private static readonly object EVENT_CLICK = new object();
///
/// 单击事件
///
public event EventHandler Click
{
add
{
base.Events.AddHandler(EVENT_CLICK, value);
}
remove
{
base.Events.RemoveHandler(EVENT_CLICK, value);
}
}
///
/// 触发单击事件
///
/// 数据
protected virtual void OnClick(EventArgs e)
{
EventHandler handler = base.Events[EVENT_CLICK] as EventHandler;
if (handler != null)
handler(this, e);
}
private static readonly object EVENT_DOUBLE_CLICK = new object();
///
/// 双击事件
///
public event EventHandler DoubleClick
{
add
{
base.Events.AddHandler(EVENT_DOUBLE_CLICK, value);
}
remove
{
base.Events.RemoveHandler(EVENT_DOUBLE_CLICK, value);
}
}
///
/// 触发双击事件
///
/// 数据
protected virtual void OnDoubleClick(EventArgs e)
{
EventHandler handler = base.Events[EVENT_DOUBLE_CLICK] as EventHandler;
if (handler != null)
handler(this, e);
}
private static readonly object EVENT_PAINT = new object();
///
/// 渲染事件
///
public event PaintEventHandler Paint
{
add
{
base.Events.AddHandler(EVENT_PAINT, value);
}
remove
{
base.Events.RemoveHandler(EVENT_PAINT, value);
}
}
///
/// 触发渲染事件
///
/// 要引发的事件
/// 数据
protected void RaisePaintEvent(object key, PaintEventArgs e)
{
PaintEventHandler handler = base.Events[EVENT_PAINT] as PaintEventHandler;
if (handler != null)
handler(this, e);
}
}
}