private async Task onRepeatedlyExecute(object sender, EventArgs args) { if (!_enabled.Enabled || !_visible.Visible) { return; } IRoom room = _state.Room; if (room == null) { return; } PointF position = _input.MousePosition; var obj = room.GetObjectAt(position.X, position.Y); bool mouseIn = obj == _entity; bool leftMouseDown = _input.LeftMouseButtonDown; bool rightMouseDown = _input.RightMouseButtonDown; bool fireMouseMove = mouseIn && (_mouseX != position.X || _mouseY != position.Y); bool fireMouseEnter = mouseIn && !IsMouseIn; bool fireMouseLeave = !mouseIn && IsMouseIn; _mouseX = position.X; _mouseY = position.Y; IsMouseIn = mouseIn; bool wasLeftMouseDown = _leftMouseDown; bool wasRightMouseDown = _rightMouseDown; _leftMouseDown = leftMouseDown; _rightMouseDown = rightMouseDown; await handleMouseButton(_leftMouseClickTimer, _leftMouseDoubleClickTimer, wasLeftMouseDown, leftMouseDown, MouseButton.Left); await handleMouseButton(_rightMouseClickTimer, _rightMouseDoubleClickTimer, wasRightMouseDown, rightMouseDown, MouseButton.Right); if (fireMouseEnter) { await MouseEnter.InvokeAsync(_entity, new MousePositionEventArgs (position.X, position.Y)); } else if (fireMouseLeave) { await MouseLeave.InvokeAsync(_entity, new MousePositionEventArgs (position.X, position.Y)); } if (fireMouseMove) { await MouseMove.InvokeAsync(_entity, new MousePositionEventArgs(position.X, position.Y)); } }
public async Task OnMouseEnter() { await MouseEnter.InvokeAsync(Element); }