internal void Update(DeviceStatus data) { Position = data.Location.ToPoint(); if (data.ButtonState == DeviceState.Move) State = ContactState.Moved; else if (data.ButtonState == DeviceState.Up) State = ContactState.Removed; }
public MouseContact(DeviceStatus state) : base(idCounter, ContactState.New, state.Location.ToPoint(), width, height) { Handle = state.Handle; Interlocked.Increment(ref idCounter); Orientation = 0; }
void UpdateMouse(MouseData mouseData, DeviceStatus state) { Point location = state.Location; location.X += (int)(mouseData.X * mouseSpeed); location.Y += (int)(mouseData.Y * mouseSpeed); if (location.X <= 0) location.X = 0; if (location.Y <= 0) location.Y = 0; if (location.X >= virtualScreen.Width) location.X = virtualScreen.Width; if (location.Y >= virtualScreen.Height) location.Y = virtualScreen.Height; state.Location = location; switch (mouseData.ButtonState) { case MouseButtonState.LeftDown: state.ButtonState = DeviceState.Down; break; case MouseButtonState.LeftUp: state.ButtonState = DeviceState.Up; break; case MouseButtonState.None: state.ButtonState = DeviceState.Move; break; } }
void UpdatePen(DeviceData deviceData, DeviceStatus state) { int count; int size; IntPtr ptr = deviceData.GetDataPtr(out size, out count); PEN_DATA pen_DATA = (PEN_DATA)Marshal.PtrToStructure(ptr, typeof(PEN_DATA)); int x = pen_DATA.X * virtualScreen.Width / PEN_X_MAX; int y = pen_DATA.Y * virtualScreen.Height / PEN_Y_MAX; state.Location = new Point(x, y); if((pen_DATA.Status & PenStatus.PenTipDown) == PenStatus.PenTipDown && state.ButtonState == DeviceState.None) state.ButtonState = DeviceState.Down; else if ((pen_DATA.Status & PenStatus.PenTipDown) == PenStatus.PenTipDown && (state.ButtonState == DeviceState.Down || state.ButtonState == DeviceState.Move)) state.ButtonState = DeviceState.Move; else if ((pen_DATA.Status & PenStatus.InRange) == PenStatus.InRange && (state.ButtonState == DeviceState.Move || state.ButtonState == DeviceState.Down)) state.ButtonState = DeviceState.Up; else state.ButtonState = DeviceState.None; }