/// <summary> /// Called when the mouse moves on the screen. /// </summary> private void OnMouseMove(object sender, MouseEventArgs e) { if (m_currentControl == null) { return; } if (m_isMouseInside) { Point moving = new Point(e.X - m_lastMousePoint.X, e.Y - m_lastMousePoint.Y); m_lastMousePoint = e.Location; m_stateMouseOrPointer.NotifyMouseLocation( new Vector2((float)e.X, (float)e.Y), new Vector2((float)moving.X, (float)moving.Y), Vector2Ex.FromSize2(m_renderLoop.ViewInformation.CurrentViewSize)); } }
private void OnRendererElement_MouseMove(object sender, MouseEventArgs e) { if (m_rendererElement == null) { return; } m_stateMouseOrPointer.NotifyInside(true); System.Windows.Point currentPosition = e.GetPosition(m_rendererElement); if (m_lastDragPointValid) { m_stateMouseOrPointer.NotifyMouseLocation( Vector2Ex.FromWpfPoint(currentPosition), Vector2Ex.FromWpfVector(currentPosition - m_lastDragPoint), Vector2Ex.FromWpfSize(m_rendererElement.RenderSize)); } m_lastDragPointValid = true; m_lastDragPoint = currentPosition; }
private void OnTargetPanel_PointerMoved(object sender, PointerRoutedEventArgs e) { if (m_painter == null) { return; } // Calculate move distance PointerPoint currentPoint = e.GetCurrentPoint(m_painter.TargetPanel); if (m_lastDragPoint == null) { m_lastDragPoint = currentPoint; } Vector2 moveDistance = new Vector2( (float)(currentPoint.Position.X - m_lastDragPoint.Position.X), (float)(currentPoint.Position.Y - m_lastDragPoint.Position.Y)); Vector2 currentLocation = new Vector2( (float)currentPoint.Position.X, (float)currentPoint.Position.Y); // Track mouse/pointer state PointerPointProperties pointProperties = currentPoint.Properties; if (pointProperties.IsPrimary) { m_stateMouseOrPointer.NotifyButtonStates( pointProperties.IsLeftButtonPressed, pointProperties.IsMiddleButtonPressed, pointProperties.IsRightButtonPressed, pointProperties.IsXButton1Pressed, pointProperties.IsXButton2Pressed); m_stateMouseOrPointer.NotifyMouseLocation( currentLocation, moveDistance, m_painter.ActualSize.ToVector2()); } // Store last drag point m_lastDragPoint = currentPoint; }