private Point GetDragLocation(long dragPoint) { int x = (int)dragPoint; int y = (int)(dragPoint >> 32); Point screenPt = new Point(x, y); return(_target.PointToClient(screenPt)); }
private void ProcessMouseEvents(RawMouseEventArgs e) { if (!_initialInputModifiers.HasValue) { _initialInputModifiers = e.InputModifiers & MOUSE_INPUTMODIFIERS; } void CheckDraggingAccepted(InputModifiers changedMouseButton) { if (_initialInputModifiers.Value.HasFlag(changedMouseButton)) { var result = RaiseEventAndUpdateCursor(RawDragEventType.Drop, e.Root, e.Position, e.InputModifiers); UpdateCursor(null, DragDropEffects.None); _result.OnNext(result); } else { CancelDragging(); } e.Handled = true; } switch (e.Type) { case RawMouseEventType.LeftButtonDown: case RawMouseEventType.RightButtonDown: case RawMouseEventType.MiddleButtonDown: case RawMouseEventType.NonClientLeftButtonDown: CancelDragging(); e.Handled = true; return; case RawMouseEventType.LeaveWindow: RaiseEventAndUpdateCursor(RawDragEventType.DragLeave, e.Root, e.Position, e.InputModifiers); break; case RawMouseEventType.LeftButtonUp: CheckDraggingAccepted(InputModifiers.LeftMouseButton); break; case RawMouseEventType.MiddleButtonUp: CheckDraggingAccepted(InputModifiers.MiddleMouseButton); break; case RawMouseEventType.RightButtonUp: CheckDraggingAccepted(InputModifiers.RightMouseButton); break; case RawMouseEventType.Move: var mods = e.InputModifiers & MOUSE_INPUTMODIFIERS; if (_initialInputModifiers.Value != mods) { CancelDragging(); e.Handled = true; return; } if (e.Root != _lastRoot) { if (_lastRoot != null) { RaiseEventAndUpdateCursor(RawDragEventType.DragLeave, _lastRoot, _lastRoot.PointToClient(e.Root.PointToScreen(e.Position)), e.InputModifiers); } RaiseEventAndUpdateCursor(RawDragEventType.DragEnter, e.Root, e.Position, e.InputModifiers); } else { RaiseEventAndUpdateCursor(RawDragEventType.DragOver, e.Root, e.Position, e.InputModifiers); } break; } }