public void ViewDragListener_MovesView() { Action <EventBase> listener = a => {}; eventManMock.Setup(m => m.AddListener <ViewDragEvent>(It.IsNotNull <Action <EventBase> >())) .Callback <Action <EventBase> >(a => listener = a); windowMock.SetupGet(m => m.Size).Returns(new Vector2u(1, 1)); renderManager.Initialize(); renderManager.PostInitialize(); var @event = new ViewDragEvent { Delta = new Vector2(.5f, .5f) }; var expected = renderManager.View.Size * .5f; // expect view to move by 50% of size listener(@event); Assert.AreEqual(expected, renderManager.View.Center); eventManMock.VerifyAll(); windowMock.VerifyAll(); }
private void HandleMouseMoved(object sender, MouseMoveEventArgs args) { if (!m_buttonStates[ViewDragButton]) { return; } var position = new Vector2i(args.X, args.Y); var deltaPosition = m_mousePos - position; var @event = new ViewDragEvent { Delta = new Vector2 { X = (float)deltaPosition.X / m_window.Size.X, Y = (float)deltaPosition.Y / m_window.Size.Y } }; m_eventManager.QueueEvent(@event); // update the position m_mousePos = position; }