protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { ActiveCursor.Scale = new Vector2(1); ActiveCursor.ScaleTo(0.90f, 800, Easing.OutQuint); ((Cursor)ActiveCursor).AdditiveLayer.Alpha = 0; ((Cursor)ActiveCursor).AdditiveLayer.FadeInFromZero(800, Easing.OutQuint); if (args.Button == MouseButton.Left && cursorRotate) { dragRotationState = DragRotationState.DragStarted; positionMouseDown = state.Mouse.Position; } return(base.OnMouseDown(state, args)); }
protected override void OnMouseUp(MouseUpEvent e) { if (!e.HasAnyButtonPressed) { activeCursor.AdditiveLayer.FadeOutFromOne(500, Easing.OutQuint); activeCursor.ScaleTo(1, 500, Easing.OutElastic); if (dragRotationState != DragRotationState.NotDragging) { activeCursor.RotateTo(0, 600 * (1 + Math.Abs(activeCursor.Rotation / 720)), Easing.OutElasticHalf); dragRotationState = DragRotationState.NotDragging; } } base.OnMouseUp(e); }
protected override bool OnMouseUp(MouseUpEvent e) { if (!e.IsPressed(MouseButton.Left) && !e.IsPressed(MouseButton.Right)) { activeCursor.AdditiveLayer.FadeOutFromOne(500, Easing.OutQuint); activeCursor.ScaleTo(1, 500, Easing.OutElastic); } if (e.Button == MouseButton.Left) { if (dragRotationState == DragRotationState.Rotating) { activeCursor.RotateTo(0, 600 * (1 + Math.Abs(activeCursor.Rotation / 720)), Easing.OutElasticHalf); } dragRotationState = DragRotationState.NotDragging; } return(base.OnMouseUp(e)); }
protected override bool OnMouseDown(MouseDownEvent e) { // only trigger animation for main mouse buttons activeCursor.Scale = new Vector2(1); activeCursor.ScaleTo(0.90f, 800, Easing.OutQuint); activeCursor.AdditiveLayer.Alpha = 0; activeCursor.AdditiveLayer.FadeInFromZero(800, Easing.OutQuint); if (cursorRotate.Value && dragRotationState != DragRotationState.Rotating) { // if cursor is already rotating don't reset its rotate origin dragRotationState = DragRotationState.DragStarted; positionMouseDown = e.MousePosition; } return(base.OnMouseDown(e)); }
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) { if (!state.Mouse.HasMainButtonPressed) { ((Cursor)ActiveCursor).AdditiveLayer.FadeOut(500, Easing.OutQuint); ActiveCursor.ScaleTo(1, 500, Easing.OutElastic); } if (args.Button == MouseButton.Left) { if (dragRotationState == DragRotationState.Rotating) { ActiveCursor.RotateTo(0, 600 * (1 + Math.Abs(ActiveCursor.Rotation / 720)), Easing.OutElasticHalf); } dragRotationState = DragRotationState.NotDragging; } return(base.OnMouseUp(state, args)); }
protected override bool OnMouseDown(MouseDownEvent e) { // only trigger animation for main mouse buttons if (e.Button <= MouseButton.Right) { activeCursor.Scale = new Vector2(1); activeCursor.ScaleTo(0.90f, 800, Easing.OutQuint); activeCursor.AdditiveLayer.Alpha = 0; activeCursor.AdditiveLayer.FadeInFromZero(800, Easing.OutQuint); } if (e.Button == MouseButton.Left && cursorRotate) { dragRotationState = DragRotationState.DragStarted; positionMouseDown = e.MousePosition; } return(base.OnMouseDown(e)); }
protected override bool OnMouseMove(MouseMoveEvent e) { if (dragRotationState != DragRotationState.NotDragging) { var position = e.MousePosition; var distance = Vector2Extensions.Distance(position, positionMouseDown); // don't start rotating until we're moved a minimum distance away from the mouse down location, // else it can have an annoying effect. if (dragRotationState == DragRotationState.DragStarted && distance > 30) { dragRotationState = DragRotationState.Rotating; } // don't rotate when distance is zero to avoid NaN if (dragRotationState == DragRotationState.Rotating && distance > 0) { Vector2 offset = e.MousePosition - positionMouseDown; float degrees = (float)MathHelper.RadiansToDegrees(Math.Atan2(-offset.X, offset.Y)) + 24.3f; // Always rotate in the direction of least distance float diff = (degrees - activeCursor.Rotation) % 360; if (diff < -180) { diff += 360; } if (diff > 180) { diff -= 360; } degrees = activeCursor.Rotation + diff; activeCursor.RotateTo(degrees, 600, Easing.OutQuint); } } return(base.OnMouseMove(e)); }