AIA.Selection.KeyboardListener C# (CSharp) Method

KeyboardListener() public method

public KeyboardListener ( KeyboardState CurrentKeyboardState, KeyboardState LastKeyboardState, Microsoft.Xna.Framework.Input.MouseState CurrentMouseState, Microsoft.Xna.Framework.Input.MouseState LastMouseState ) : void
CurrentKeyboardState Microsoft.Xna.Framework.Input.KeyboardState
LastKeyboardState Microsoft.Xna.Framework.Input.KeyboardState
CurrentMouseState Microsoft.Xna.Framework.Input.MouseState
LastMouseState Microsoft.Xna.Framework.Input.MouseState
return void
        public void KeyboardListener(KeyboardState CurrentKeyboardState, KeyboardState LastKeyboardState, MouseState CurrentMouseState, MouseState LastMouseState)
        {
            //If left button just pressed then set start position of rectangle
            if (CurrentMouseState.LeftButton == ButtonState.Pressed && LastMouseState.LeftButton == ButtonState.Released)
            {
                UpdateStartingPoint(CurrentMouseState.X, CurrentMouseState.Y);

                //Clear previously selected when you left click
             //   ClearSelection();
            }

            //If the left mouse button is being held down then update the size of the rectangle.
            if (CurrentMouseState.LeftButton == ButtonState.Pressed && LastMouseState.LeftButton == ButtonState.Pressed)
            {
                UpdateSelectionBox((CurrentMouseState.X - SelectionBox.X), (CurrentMouseState.Y - SelectionBox.Y));

                //TODO: Add code so rectangle constantly updates to cope with left to right boxes and other combinations.
            }

            //Once the mouse is released
            //Convert rectangle to a positive rectangle
            if (CurrentMouseState.LeftButton == ButtonState.Released && LastMouseState.LeftButton == ButtonState.Pressed)
            {
                if (SelectionBox.Width < 0)
                {
                    UpdateStartingPoint((SelectionBox.X + SelectionBox.Width), SelectionBox.Y);
                    UpdateSelectionBox((SelectionBox.Width - (2 * SelectionBox.Width)), SelectionBox.Height);
                }

                if (SelectionBox.Height < 0)
                {
                    UpdateStartingPoint(SelectionBox.X, (SelectionBox.Y + SelectionBox.Height));
                    UpdateSelectionBox(SelectionBox.Width, (SelectionBox.Height - (2 * SelectionBox.Height)));
                }

                //Updates the list of selected buildings
                _BuildingManager.UpdateSelectionList(SelectionBox);

                SelectionBox = new Rectangle(0, 0, 0, 0);

            }
        }