/*----------------------------------------------------------------
// Copyright (C) 2007 liu523@QQ.COM
// 版权所有。
// 开发者:liu523@QQ.COM团队
// 文件名:MoseEvent.cs
// 文件功能描述:涉及到屏幕管理的指令-鼠标控制指令。
//----------------------------------------------------------------*/
using System;
namespace RemoteControlLib.Codes
{
///
/// 鼠标事件类型
///
[Serializable]
public enum MouseEventType
{
MouseMove,
MouseLeftDown,
MouseLeftUp,
MouseRightDown,
MouseRightUp,
MouseClick,
MouseDoubleClick
}
///
/// 鼠标事件结构
///
[Serializable]
public class MouseEvent : BaseCode
{
private Byte[] type;
private Byte[] x;
private Byte[] y;
///
/// 创建鼠标事件的实例
///
/// 类型
/// 鼠标指针的X坐标
/// 鼠标指针的Y坐标
public MouseEvent(MouseEventType Type, int X, int Y)
{
this.type = BitConverter.GetBytes((int)Type);
this.x = BitConverter.GetBytes(X);
this.y = BitConverter.GetBytes(Y);
}
public MouseEvent(Byte[] Type, Byte[] X, Byte[] Y)
{
this.type = Type;
this.x = X;
this.y = Y;
}
public MouseEvent(Byte[] Content)
{
type = new byte[4];
x = new byte[4];
y = new byte[4];
for (int i = 0; i < Content.Length; i++)
{
if (i >= 0 && i < 4)
type[i] = Content[i];
if (i >= 4 && i < 8)
x[i - 4] = Content[i];
if (i >= 8 && i < 12)
y[i - 8] = Content[i];
}
}
///
/// 类型
///
public MouseEventType Type
{
get { return (MouseEventType)BitConverter.ToInt32(type, 0); }
}
///
/// 鼠标指针的X坐标
///
public int X
{
get { return BitConverter.ToInt32(x, 0); }
}
///
/// 鼠标指针的Y坐标
///
public int Y
{
get { return BitConverter.ToInt32(y, 0); }
}
public Byte[] ToBytes()
{
Byte[] Bytes = new Byte[12];
type.CopyTo(Bytes, 0);
x.CopyTo(Bytes, 4);
y.CopyTo(Bytes, 8);
return Bytes;
}
}
}