public void Enable() { p_Enabled = true; p_Cursor.SetArrow(Direction.ALL); }
private void updateMouse() { //pan active? if (p_Pan.Enabled) { return; } if ( //control hijacked? p_EventHijacker != null || //logic disabled? p_LogicDisabled || //game has focus? !p_Window.Focused || //arrow key? p_ArrowKeyDown != ArrowKey.NONE || //clickdrag active? p_ClickDrag.Enabled) { p_Cursor.SetArrow(Direction.NONE); return; } //get the cursor position relative to the window content Point mousePosition = PointToClient(Cursor.Position); //is the mouse at the side of the screen so we move the camera? int width = p_Window.Context.Width; int height = p_Window.Context.Height; int margin = 40; int x = mousePosition.X; int y = mousePosition.Y; int step = 10; int dX = 0, dY = 0; //if the cursor exceeds the bounds of the window at all, we ignore //the processing of moving the camera. if (x < 0 || y < 0 || x > width || y > height) { return; } if (x < margin) { dX = -step; } if (y < margin) { dY = -step; } if (x > width - margin) { dX = step; } if (y > height - margin) { dY = step; } if (dX == 0 && dY == 0) { p_Cursor.SetArrow(Direction.NONE); return; } //adjust cursor arrow direction according to change in camera Direction direction = Direction.NONE; if (dX < 0) { direction |= Direction.WEST; } if (dX > 0) { direction |= Direction.EAST; } if (dY < 0) { direction |= Direction.NORTH; } if (dY > 0) { direction |= Direction.SOUTH; } p_Cursor.SetArrow(direction); //move camera p_Camera.Move(dX, dY); }