csharp/aiportal/tscamera/Agent/UltraRecord/Core/Share/RawEvent.cs

RawEvent.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace bfbd.UltraRecord.Core.New
{
	interface KeyboardEvent
	{
		DateTime Time { get; }
		RawEventType Evt { get; }
		Keys Key { get; }
		bool Shift { get; }
		bool Ctrl { get; }
		bool Alt { get; }
	}

	interface MouseEvent
	{
		DateTime Time { get; }
		RawEventType Evt { get; }
		short X { get; }
		short Y { get; }
	}

	partial clast RawInputEvent : KeyboardEvent, MouseEvent
	{
		private DateTime _time;
		private RawEventType _evt;
		private Int16 _reserved;
		private UInt32 _data;

		public DateTime Time { get { return _time; } }
		public RawEventType Evt { get { return _evt; } }

		public Keys Key { get { return ((Keys)_data & Keys.KeyCode); } }
		public bool Shift { get { return ((Keys)_data & Keys.Shift) == Keys.Shift; } }
		public bool Ctrl { get { return ((Keys)_data & Keys.Control) == Keys.Control; } }
		public bool Alt { get { return ((Keys)_data & Keys.Alt) == Keys.Alt; } }

		public short X { get { return (short)(_data & Int16.MaxValue); } }
		public short Y { get { return (short)(_data >> 16); } }
		
		KeyboardEvent KeyEvt { get { return (_evt & RawEventType.KeyEvent) > 0 ? this as KeyboardEvent : null; } }
		MouseEvent MouseEvt { get { return (_evt & RawEventType.MouseEvent) > 0 ? this as MouseEvent : null; } }
	}

	partial clast RawInputEvent
	{
		public RawInputEvent(KeyboardEventType kEvt, System.Windows.Forms.Keys key) : this(kEvt, key, DateTime.Now) { }
		public RawInputEvent(KeyboardEventType kEvt, System.Windows.Forms.Keys key, DateTime time)
		{
			this._time = time;
			this._evt = KEvts[kEvt];
			this._data = (uint)key;
		}

		public RawInputEvent(MouseEventType mEvt, short x, short y) : this(mEvt, x, y, DateTime.Now) { }
		public RawInputEvent(MouseEventType mEvt, short x, short y, DateTime time)
		{
			this._time = time;
			this._evt = MEvts[mEvt];
			this._data = (uint)((((int)y)