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; } }
private bool ProcessRawMouseEvent(RawMouseEventArgs input) { MouseEventArgs e = null; switch (input.Type) { case RawMouseEventType.Move: e = new MouseEventArgs(this, input.Timestamp); e.RoutedEvent = UIElement.MouseMoveEvent; break; case RawMouseEventType.LeftButtonDown: e = new MouseButtonEventArgs(this, input.Timestamp); e.RoutedEvent = UIElement.MouseLeftButtonDownEvent; break; case RawMouseEventType.LeftButtonUp: e = new MouseButtonEventArgs(this, input.Timestamp); e.RoutedEvent = UIElement.MouseLeftButtonUpEvent; break; } if (e != null) { InputManager.Current.ProcessInput(e); return true; } else { return false; } }