private void MouseListner_MouseDragStart(object sender, MonoGame.Extended.Input.InputListeners.MouseEventArgs e) { List <GuiContainer> windows = new List <GuiContainer>(); foreach (GuiContainer item in BoundHandler.GUIWindows) { //If the container contains the mouse position if (item.DrawingBounds.Contains(e.Position.X, e.Position.Y)) { //If the mouse position is within the drag zone if (item.DrawingBounds.Y - 40 < e.Position.Y) { //If the GUI is dragable if (item.IsMovable) { windows.Add(item); } } } } if (windows.Count > 0) { GuiContainer windowToMove = this.GetHighestPriority(windows); this.LastDragged = windowToMove; this.StillDraggingLast = true; } }
private void _uiLabel_MouseDrag(object sender, MonoGame.Extended.Input.InputListeners.MouseEventArgs e) { var pos = _uiLabel.ToScreen(e.Position.X, e.Position.Y); var diff = _labelMousePos - pos; _uiLabel.X -= (int)diff.X; _uiLabel.Y -= (int)diff.Y; _labelMousePos = pos; }
private void MouseListner_MouseDrag(object sender, MonoGame.Extended.Input.InputListeners.MouseEventArgs e) { if (this.StillDraggingLast) { int newX = this.LastDragged.DrawingBounds.X + (int)e.DistanceMoved.X; int newY = this.LastDragged.DrawingBounds.Y + (int)e.DistanceMoved.Y; Point position = new Point(newX, newY); Rectangle newPosition = new Rectangle(position, this.LastDragged.DrawingBounds.Size); this.LastDragged.DrawingBounds = newPosition; } }
private void MouseListner_MouseWheelMoved(object sender, MonoGame.Extended.Input.InputListeners.MouseEventArgs e) { float previous = e.PreviousState.ScrollWheelValue; float current = e.ScrollWheelValue; float change = (previous - current) / 1000; //Ensure that zoom is above the minimum. float aboveMin = Math.Max(ZoomHandler.MinZoom, RenderingPipe.Zoom - change); //Ensure that zoom is below the maximum. float belowMaxAndAboveMin = Math.Min(ZoomHandler.MaxZoom, aboveMin); RenderingPipe.Zoom = belowMaxAndAboveMin; MasterLog.DebugWriteLine("Zoom: " + RenderingPipe.Zoom.ToString()); }
private void MouseListner_MouseWheelMoved(object sender, MonoGame.Extended.Input.InputListeners.MouseEventArgs e) { float previous = e.PreviousState.ScrollWheelValue; float current = e.ScrollWheelValue; float change = (previous - current) / 1000; if (change > 0) { RenderInfo.Camera2D.HandleInput(Rendering.Map.CameraMovementState.ZoomIn); } if (change < 0) { RenderInfo.Camera2D.HandleInput(Rendering.Map.CameraMovementState.ZoomOut); } }
private void MouseListner_MouseDragEnd(object sender, MonoGame.Extended.Input.InputListeners.MouseEventArgs e) { this.StillDraggingLast = false; }
private void _uiLabel_MouseDragStart(object sender, MonoGame.Extended.Input.InputListeners.MouseEventArgs e) { _labelMousePos = _uiLabel.ToScreen(e.Position.X, e.Position.Y); }