Пример #1
0
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        /// <param name="input">The InputState instance that relays the state of input.</param>
        public override void HandleInput(InputState input)
        {
            //If the InputState is null, throw an exception.
            if (input == null) { throw new ArgumentNullException("input"); }

            //If the game should be paused, bring up the pause game screen.
            if (input.PauseGame) { ScreenManager.AddScreen(new PauseMenuScreen()); }
            //Otherwise let the System instance handle input as usual.
            else { /*_System.HandleInput(input);*/ }
        }
Пример #2
0
        /// <summary>
        /// Handle user input.
        /// </summary>
        /// <param name="input">The helper for reading input from the user.</param>
        public override void HandleInput(InputState input)
        {
            //The inherited method.
            base.HandleInput(input);

            //If the item is active.
            if (IsActive)
            {
                //If the item is visible.
                if (IsVisible)
                {
                    //If the item has focus.
                    if (HasFocus) { }
                }
            }
        }
Пример #3
0
 /// <summary>
 /// Handle user input.
 /// </summary>
 /// <param name="input">The helper for reading input from the user.</param>
 public void HandleInput(InputState input)
 {
 }
Пример #4
0
        /// <summary>
        /// Handle user input.
        /// </summary>
        /// <param name="input">The helper for reading input from the user.</param>
        public override void HandleInput(InputState input)
        {
            //The inherited method.
            base.HandleInput(input);

            //If the item is active.
            if (IsActive)
            {
                //If the item is visible.
                if (IsVisible)
                {
                    //Let the component handle user input.
                    _Field.HandleInput(input);
                }
            }
        }
Пример #5
0
 /// <summary>
 /// Allows the screen to handle user input. Unlike Update, this method
 /// is only called when the screen is active, and not when some other
 /// screen has taken the focus.
 /// </summary>
 public virtual void HandleInput(InputState input)
 {
 }
Пример #6
0
        /// <summary>
        /// Handle user input.
        /// </summary>
        /// <param name="input">The helper for reading input from the user.</param>
        public void HandleInput(InputState input)
        {
            //Let the GUI handle user input.
            _GUI.HandleInput(input);
            //Enable the DebugSystem to handle input.
            _DebugSystem.HandleInput(input);

            #region Camera
            //If the CTRL button is not held down.
            if (!input.IsKeyDown(Keys.LeftControl))
            {
                //Manage the camera movement.
                if (input.IsKeyDown(Keys.W)) { MoveCamera(new Vector2(0, -1)); }
                if (input.IsKeyDown(Keys.S)) { MoveCamera(new Vector2(0, 1)); }
                if (input.IsKeyDown(Keys.A)) { MoveCamera(new Vector2(-1, 0)); }
                if (input.IsKeyDown(Keys.D)) { MoveCamera(new Vector2(1, 0)); }

                //Let the user zoom in and out.
                if (input.IsKeyDown(Keys.Z)) { _Camera.Zoom(-.05f); }
                if (input.IsKeyDown(Keys.X)) { _Camera.Zoom(.05f); }
            }
            #endregion

            #region Editing
            //If the CTRL button is down.
            if (input.IsKeyDown(Keys.LeftControl))
            {
                //Manage the item movement.
                if (input.IsKeyDown(Keys.W)) { MoveItem(new Vector2(0, -5)); }
                if (input.IsKeyDown(Keys.S)) { MoveItem(new Vector2(0, 5)); }
                if (input.IsKeyDown(Keys.A)) { MoveItem(new Vector2(-5, 0)); }
                if (input.IsKeyDown(Keys.D)) { MoveItem(new Vector2(5, 0)); }

                //Let the user rotate the item.
                if (input.IsKeyDown(Keys.Q)) { RotateItem(-.01f); }
                if (input.IsKeyDown(Keys.E)) { RotateItem(.01f); }

                //Let the user scale the item.
                if (input.IsKeyDown(Keys.Z)) { ScaleItem(new Vector2(-.05f, -.05f)); }
                if (input.IsKeyDown(Keys.X)) { ScaleItem(new Vector2(.05f, .05f)); }

                //Let the user copy the item.
                if (input.IsNewKeyPress(Keys.V)) { CopyItem(Helper.GetMousePosition()); }
            }

            //If the GUI hasn't been clicked.
            if (!_IsGUIClicked)
            {
                //Select an item.
                if (input.IsNewLeftMouseClick()) { SelectItem(GetItemAtPosition(Helper.GetMousePosition())); }

                //If the user wants to seize and move an item with the mouse.
                if (input.IsNewLeftMousePress() && _SelectedItem != null)
                {
                    //Handle the item grapple.
                    GrappleItem();
                }
            }

            //If the user disengages the grapple function.
            if (input.IsNewLeftMouseReleased())
            {
                //If the grapple joint exists.
                if (_MouseGrappleJoint != null)
                {
                    //Remove the grapple joint from the world simulation.
                    _Level.World.RemoveJoint(_MouseGrappleJoint);
                    _MouseGrappleJoint = null;
                }

                //Reset the grapple point.
                _ItemGrapplePoint = Vector2.Zero;
            }
            #endregion

            //Quickie.
            if (input.IsKeyDown(Keys.N)) { SetUpTreeView(); }
            if (input.IsNewKeyPress(Keys.M)) { ToggleGUI(); }

            //Let the level handle user input.
            _Level.HandleInput(input);
        }
Пример #7
0
        /// <summary>
        /// Get a string containing the writable keyboard input from last update.
        /// </summary>
        /// <param name="input">The input state.</param>
        /// <param name="i">The player index.</param>
        /// <returns>A string of writable keys.</returns>
        private string GetTextInput(InputState input, int i)
        {
            //The list of keys to return.
            string text = "";
            //Make the pressed keys more accessible.
            Keys[] keys = input.CurrentKeyboardStates[i].GetPressedKeys();

            //Loop through the list of recently pressed keys and see if they are eligible for writing.
            for (int a = 0; a < keys.Length; a++)
            {
                //If the key has not been pressed for a while, continue.
                if (!_UsedKeys.ContainsKey(keys[a]))
                {
                    //Add the key to the list of recently pressed keys.
                    _UsedKeys.Add(keys[a], _TotalElapsedTime);

                    //If an alphabetical key has been pressed.
                    if ((keys[a] >= Keys.A) && (keys[a] <= Keys.Z))
                    {
                        //If uppercase.
                        //TODO: No support for Caps Lock.
                        if (input.IsKeyDown(Keys.LeftShift)) { text += keys[a].ToString().ToUpper(); }
                        else { text += keys[a].ToString().ToLower(); }
                    }
                    //If a numerical key has been pressed.
                    else if ((keys[a] >= Keys.D0 && keys[a] <= Keys.D9))
                    {
                        //If left shift is currently down.
                        if (input.IsKeyDown(Keys.LeftShift))
                        {
                            //Shifted numerical keys.
                            switch (keys[a])
                            {
                                case Keys.D1: { text += "!"; break; }
                                case Keys.D2: { text += "\""; break; }
                                case Keys.D3: { text += "#"; break; }
                                case Keys.D4: { text += "¤"; break; }
                                case Keys.D5: { text += "%"; break; }
                                case Keys.D6: { text += "&"; break; }
                                case Keys.D7: { text += "/"; break; }
                                case Keys.D8: { text += "("; break; }
                                case Keys.D9: { text += ")"; break; }
                                case Keys.D0: { text += "="; break; }
                                default: { break; }
                            }
                        }
                        //If right alt is currently down.
                        else if (input.IsKeyDown(Keys.RightAlt))
                        {
                            //Non-shifted numerical symbol keys.
                            switch (keys[a])
                            {
                                case Keys.D1: { text += ""; break; }
                                case Keys.D2: { text += "@"; break; }
                                case Keys.D3: { text += "£"; break; }
                                case Keys.D4: { text += "$"; break; }
                                case Keys.D5: { text += "€"; break; }
                                case Keys.D6: { text += ""; break; }
                                case Keys.D7: { text += "{"; break; }
                                case Keys.D8: { text += "["; break; }
                                case Keys.D9: { text += "]"; break; }
                                case Keys.D0: { text += "}"; break; }
                                default: { break; }
                            }
                        }
                        //Use the regular numerical keys.
                        else { text += keys[a].ToString().Replace("D", string.Empty); }
                    }
                    //If another symbol key has been pressed.
                    else
                    {
                        //Non-shifted symbol keys.
                        switch (keys[a])
                        {
                            case (Keys.OemComma): { text += ","; break; }
                            case (Keys.OemPeriod): { text += "."; break; }
                            case (Keys.OemBackslash): { text += @"\"; break; }
                            case (Keys.Multiply): { text += "*"; break; }
                            case (Keys.OemMinus): { text += "-"; break; }
                            case (Keys.OemPlus): { text += "+"; break; }
                            case (Keys.OemSemicolon): { text += ";"; break; }
                            case (Keys.OemQuotes): { text += "'"; break; }
                            case (Keys.Space): { text += " "; break; }
                            case (Keys.OemQuestion): { text += "?"; break; }
                            default: { break; }
                        }
                    }
                }
            }

            //Return the input in string format.
            return text;
        }
Пример #8
0
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            // Move to the previous menu entry?
            if (input.MenuUp)
            {
                selectedEntry--;

                if (selectedEntry < 0)
                    selectedEntry = menuEntries.Count - 1;
            }

            // Move to the next menu entry?
            if (input.MenuDown)
            {
                selectedEntry++;

                if (selectedEntry >= menuEntries.Count)
                    selectedEntry = 0;
            }

            // Accept or cancel the menu?
            if (input.MenuSelect)
            {
                OnSelectEntry(selectedEntry);
            }
            else if (input.MenuCancel)
            {
                OnCancel();
            }
        }
Пример #9
0
        /// <summary>
        /// Handle user input.
        /// </summary>
        /// <param name="input">The helper for reading input from the user.</param>
        public override void HandleInput(InputState input)
        {
            //The inherited method.
            base.HandleInput(input);

            //If the component is not active nor visible, stop here.
            if (!IsActive || !IsVisible) { return; }

            //If the component has focus.
            if (HasFocus)
            {
                //Delete text.
                if (input.IsKeyDown(Keys.Delete) && !_UsedKeys.ContainsKey(Keys.Delete)) { DeleteText(true); }
                else if (input.IsKeyDown(Keys.Back) && !_UsedKeys.ContainsKey(Keys.Back)) { DeleteText(false); }
                //Unfocus the textbox.
                else if (input.IsKeyDown(Keys.Enter) && !_UsedKeys.ContainsKey(Keys.Enter)) { FocusChangeInvoke(false); }

                //If the marker should be moved.
                if (input.IsKeyDown(Keys.Left) && !_UsedKeys.ContainsKey(Keys.Left)) { MoveMarkerLeft(); }
                if (input.IsKeyDown(Keys.Right) && !_UsedKeys.ContainsKey(Keys.Right)) { MoveMarkerRight(); }

                //If a key has been pressed, write to the textbox.
                if (input.IsAnyKeyPress()) { InsertText(input, 0, _MarkerIndex); }
            }
        }
Пример #10
0
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method, this will only be called when the gameplay screen is active.
        /// </summary>
        /// <param name="input">The InputState instance that relays the state of input.</param>
        public void HandleInput(InputState input)
        {
            //Enable the GUI to handle input as well.
            _GUI.HandleInput(input);

            //If the GUI hasn't been clicked.
            if (!_IsGUIClicked)
            {
                #region Mouse Clicks
                //If a left mouse click has occured, see what the user wants to be selected.
                if (input.IsNewLeftMouseClick())
                {
                    //If the click wasn't on any of the animation bars, select the closest bone to the mouse.
                    //if (!Helper.IsPointWithinBox(new Vector2(Mouse.GetState().X, Mouse.GetState().Y), _AnimationBars.Position, _AnimationBars.Width, _AnimationBars.Height))
                    {
                        //The bone index.
                        int index = -1;
                        //The shortest distance.
                        float shortest = -1;

                        //Loop through all bones in all skeletons and find the closest one.
                        foreach (Bone b in _Character.Skeleton.Bones)
                        {
                            //The average distance to the bone.
                            float distance = Vector2.Distance(new Vector2(Mouse.GetState().X, Mouse.GetState().Y), Vector2.Divide(Vector2.Add(b.TransformedPosition,
                                Helper.CalculateOrbitPosition(b.TransformedPosition, b.TransformedRotation, b.Length)), 2));

                            //Determine the shortest distance and the bone.
                            if (shortest == -1) { index = b.Index; shortest = distance; }
                            else if ((shortest != -1) && (distance < shortest))
                            {
                                //The selected index.
                                index = b.Index;
                                //The shortest distance so far.
                                shortest = distance;
                            }
                        }

                        //Pass along the new selected bone index.
                        _SelectedBoneIndex = index;
                    }
                }
                #endregion

                #region Keyboard Presses
                //If the user presses the TAB button, loop through all bones in the skeleton.
                if (input.IsNewKeyPress(Keys.Tab))
                {
                    //Increment the counter.
                    _SelectedBoneIndex++;
                    //Check the bounds of the selected bone index.
                    if (_SelectedBoneIndex >= _Character.Skeleton.Bones.Count) { _SelectedBoneIndex = 0; }
                }

                //If the user holds down CTRL.
                if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.LeftControl) || input.CurrentKeyboardStates[0].IsKeyDown(Keys.RightControl))
                {
                    //Add a new bone to the skeleton.
                    if (input.IsNewKeyPress(Keys.B)) { DisplayCreateBoneDialog(_SelectedBoneIndex); }
                    //If the user presses the K button, insert a new keyframe after the selected one.
                    if (input.IsNewKeyPress(Keys.K)) { AddKeyframe(GetAnimationBar().SelectedFrameNumber + 1); }
                    //If the user presses the DELETE button, delete the selected keyframe.
                    if (input.IsNewKeyPress(Keys.Delete)) { DeleteKeyframe(GetAnimationBar().SelectedFrameNumber); }
                }

                //If the animation has been paused.
                if (!IsAnyAnimationPlaying())
                {
                    //If the user holds down CTRL.
                    if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.LeftControl) || input.CurrentKeyboardStates[0].IsKeyDown(Keys.RightControl))
                    {
                        //Move the selected bone.
                        if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Right)) { MoveBone(_SelectedBoneIndex, new Vector2(1, 0)); }
                        else if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Left)) { MoveBone(_SelectedBoneIndex, new Vector2(-1, 0)); }
                        else if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Up)) { MoveBone(_SelectedBoneIndex, new Vector2(0, -1)); }
                        else if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Down)) { MoveBone(_SelectedBoneIndex, new Vector2(0, 1)); }
                    }
                    //Otherwise rotate the selected bone.
                    else
                    {
                        //If a bone is selected and the user presses an arrow button, rotate the bone.
                        if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Right))
                        {
                            //Rotate the bone and acknowledge that it has been modified.
                            _Character.Skeleton.Bones[_SelectedBoneIndex].Rotation += .1f;
                            _ModifiedBone[_SelectedBoneIndex] = true;
                        }
                        else if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Left))
                        {
                            //Rotate the bone and acknowledge that it has been modified.
                            _Character.Skeleton.Bones[_SelectedBoneIndex].Rotation -= .1f;
                            _ModifiedBone[_SelectedBoneIndex] = true;
                        }
                    }
                }
                #endregion
            }
        }
Пример #11
0
        /// <summary>
        /// Handle user input.
        /// </summary>
        /// <param name="input">The helper for reading input from the user.</param>
        public virtual void HandleInput(InputState input)
        {
            //If the component is not active nor visible, discontinue.
            if (!_IsActive || !_IsVisible) { return; }

            //If the left mouse button has been pressed.
            if (input.IsNewLeftMouseClick())
            {
                //If the user clicks somewhere on the item, fire the event.
                if (Helper.IsPointWithinBox(new Vector2(Mouse.GetState().X, Mouse.GetState().Y), Position, Width, Height))
                {
                    //Fire the event.
                    MouseClickInvoke(new Vector2(Mouse.GetState().X, Mouse.GetState().Y), MouseButton.Left);
                }
                //If not, see if it is appropriate to defocus the component.
                else { FocusChangeInvoke(false); }
            }

            //If the right mouse button has been pressed.
            if (input.IsNewRightMouseClick())
            {
                //If the user clicks somewhere on the item, fire the event.
                if (Helper.IsPointWithinBox(new Vector2(Mouse.GetState().X, Mouse.GetState().Y), Position, Width, Height))
                {
                    //Fire the event.
                    MouseClickInvoke(new Vector2(Mouse.GetState().X, Mouse.GetState().Y), MouseButton.Right);
                }
                //If not, see if it is appropriate to defocus the component.
                else { FocusChangeInvoke(false); }
            }

            //If the left mouse button is being held down.
            if (input.IsNewLeftMousePress())
            {
                //If the user clicks somewhere on the item, fire the event.
                if (Helper.IsPointWithinBox(new Vector2(Mouse.GetState().X, Mouse.GetState().Y), Position, Width, Height))
                {
                    //Fire the event.
                    MouseDownInvoke(Helper.GetMousePosition(), MouseButton.Left);
                }
            }

            //If the mouse is currently hovering over the component.
            if (Helper.IsPointWithinBox(Helper.GetMousePosition(), Position, Width, Height))
            {
                //If the mouse has just entered the component's surface, fire the event and enable the flag.
                if (!_IsMouseHovering) { MouseHoverInvoke(); }
            }
            //Else, disable the flag.
            else { _IsMouseHovering = false; }

            //Loop through all items and give them access to user input.
            _Items.ForEach(item => item.HandleInput(input));
        }
Пример #12
0
        /// <summary>
        /// Responds to user input, accepting or cancelling the message box.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            if (input.MenuSelect)
            {
                // Raise the accepted event, then exit the message box.
                if (Accepted != null)
                    Accepted(this, EventArgs.Empty);

                ExitScreen();
            }
            else if (input.MenuCancel)
            {
                // Raise the cancelled event, then exit the message box.
                if (Cancelled != null)
                    Cancelled(this, EventArgs.Empty);

                ExitScreen();
            }
        }
Пример #13
0
        /// <summary>
        /// Handle user input.
        /// </summary>
        /// <param name="input">The helper for reading input from the user.</param>
        public override void HandleInput(InputState input)
        {
            //The inherited method.
            base.HandleInput(input);

            //If the item is active.
            if (IsActive)
            {
                //If the item is visible.
                if (IsVisible)
                {
                    //Let the label handle user input.
                    _Checkbox.HandleInput(input);
                }
            }
        }
        /// <summary>
        /// Handle user input.
        /// </summary>
        /// <param name="input">The helper for reading input from the user.</param>
        public void HandleInput(InputState input)
        {
            //If the GUI is not active nor visible, discontinue.
            if (!_IsActive || !_IsVisible) { return; }

            //Decide which collection of items to use.
            if (_ForegroundItems.Count != 0) { _ForegroundItems.ForEach(item => item.HandleInput(input)); }
            else { _Items.ForEach(item => item.HandleInput(input)); }

            //If the right click list is enabled and the user has pressed the left mouse button.
            if (_HasRightClicked && input.IsNewLeftMouseClick())
            {
                //If the user clicks somewhere else than on the list, disable it.
                if (!Helper.IsPointWithinBox(new Vector2(Mouse.GetState().X, Mouse.GetState().Y), _RightClickList.Position, _RightClickList.Width, _RightClickList.Height))
                {
                    //Disable the list.
                    EnableOrDisableRightClickList(false, Vector2.Zero);
                }
            }

            //If the right mouse button has been pressed, enable or disable the right click list.
            if (input.IsNewRightMouseClick()) { EnableOrDisableRightClickList(true, new Vector2(Mouse.GetState().X, Mouse.GetState().Y)); }

            //Enable the right click list to handle user input, if the time is right.
            if (_HasRightClicked) { _RightClickList.HandleInput(input); }
        }
Пример #15
0
        /// <summary>
        /// Handle all input to the debug system.
        /// </summary>
        /// <param name="input">The input to consider.</param>
        public void HandleInput(InputState input)
        {
            if (input.IsNewKeyPress(Keys.F1)) { Debug(); }

            if (input.IsKeyDown(Keys.LeftShift))
            {
                if (input.IsNewKeyPress(Keys.Q)) { _World.Gravity = new Vector2(0, 0); }
                if (input.IsNewKeyPress(Keys.W)) { _World.Gravity = new Vector2(1, 0); }
                if (input.IsNewKeyPress(Keys.E)) { _World.Gravity = new Vector2(10, 0); }
                if (input.IsNewKeyPress(Keys.R)) { _World.Gravity = new Vector2(100, 0); }
                if (input.IsNewKeyPress(Keys.T)) { _World.Gravity = new Vector2(1000, 0); }
            }
            else
            {
                if (input.IsNewKeyPress(Keys.Q)) { _World.Gravity = new Vector2(0, -10); }
                if (input.IsNewKeyPress(Keys.W)) { _World.Gravity = new Vector2(0, -1); }
                if (input.IsNewKeyPress(Keys.E)) { _World.Gravity = new Vector2(0, 1); }
                if (input.IsNewKeyPress(Keys.R)) { _World.Gravity = new Vector2(0, 10); }
                if (input.IsNewKeyPress(Keys.T)) { _World.Gravity = new Vector2(0, 100); }
            }

            /*if (input.CurrentKeyboardStates[i].IsKeyDown(Keys.Z)) { System.UpdateSpeed = 0.1f; }
            if (input.CurrentKeyboardStates[i].IsKeyDown(Keys.X)) { System.UpdateSpeed = 0.01f; }
            if (input.CurrentKeyboardStates[i].IsKeyDown(Keys.C)) { System.UpdateSpeed = 0.001f; }
            if (input.CurrentKeyboardStates[i].IsKeyDown(Keys.V)) { System.UpdateSpeed = 0.0001f; }
            if (input.CurrentKeyboardStates[i].IsKeyDown(Keys.B)) { System.UpdateSpeed = 0.0f; }*/
        }
Пример #16
0
        /// <summary>
        /// Insert text into the textbox directly from an InputState buffer.
        /// </summary>
        /// <param name="input">The input state.</param>
        /// <param name="i">The specific input channel.</param>
        /// <param name="index">At which index to insert the text.</param>
        public void InsertText(InputState input, int i, int index)
        {
            //If the textbox is read only, stop here.
            if (_IsReadOnly) { return; }

            //Get the user input.
            string text = GetTextInput(input, i);

            //Control the string's legitimacy by running it through the validator.
            if (!text.Equals("") && Regex.IsMatch(text, _Validator))
            {
                //Insert the text at the correct position.
                _Text = _Text.Insert(index, text);

                //Finally, move the marker accordingly.
                if (_MarkerIndex >= index) { MoveMarker(text.Length); }
            }
        }
Пример #17
0
        /// <summary>
        /// Handle user input.
        /// </summary>
        /// <param name="input">The helper for reading input from the user.</param>
        public override void HandleInput(InputState input)
        {
            //The inherited method.
            base.HandleInput(input);

            //If the animation bar is active, write the input to the box.
            if (IsActive)
            {
                //If the animation bar is visible.
                if (IsVisible)
                {
                    //If the animation bar has focus.
                    if (HasFocus)
                    {
                        //If the left mouse button has been pressed.
                        if (input.IsNewLeftMouseClick())
                        {
                            //If the user clicks somewhere else, defocus the animation bar.
                            if (!Helper.IsPointWithinBox(new Vector2(Mouse.GetState().X, Mouse.GetState().Y), Position, Width, Height))
                            {
                                //Defocus this animation bar.
                                HasFocus = false;
                            }
                        }
                    }

                    //Let the play button handle input.
                    _PlayButton.HandleInput(input);
                }
            }
        }
Пример #18
0
        /// <summary>
        /// Handle user input.
        /// </summary>
        /// <param name="input">The helper for reading input from the user.</param>
        public override void HandleInput(InputState input)
        {
            //The inherited method.
            base.HandleInput(input);

            //If the scroller is active.
            if (IsActive)
            {
                //If the scroller is visible.
                if (IsVisible)
                {
                    //If the thumb button is currently held down but the mouse is pointing somewhere else.
                    if ((_IsThumbDown) && (!Helper.IsPointWithinBox(new Vector2(Mouse.GetState().X, Mouse.GetState().Y), _Thumb.Position, _Thumb.Width, _Thumb.Height)))
                    {
                        //If the left mouse button is still held down, pretend that the button is still held down.
                        if (input.IsNewLeftMousePress()) { OnThumbDown(this, new MouseClickEventArgs(new Vector2(Mouse.GetState().X, Mouse.GetState().Y), MouseButton.Left)); }
                        //Otherwise the thumb button isn't held down.
                        else { _IsThumbDown = false; }
                    }
                }
            }
        }