C# Clamp object to window?
<p>In Monogame (c#), I can't figure out how to keep an object (in this case a burger) to stay inside the game window's borders so it doesn't go off the game window when the cursor does. Or in other words, "clamp" an object to the game window.</p>

<pre><code>    public class Burger
{
    #region Fields

    // graphic and drawing info
    Texture2D sprite;
    Rectangle drawRectangle;

    // burger stats
    int health = 100;

    // shooting support
    bool canShoot = true;
    int elapsedCooldownMilliseconds = 0;

    // sound effect
    SoundEffect shootSound;

    #endregion

    #region Constructors

    /// &lt;summary&gt;
    ///  Constructs a burger
    /// &lt;/summary&gt;
    /// &lt;param name="contentManager"&gt;the content manager for loading content&lt;/param&gt;
    /// &lt;param name="spriteName"&gt;the sprite name&lt;/param&gt;
    /// &lt;param name="x"&gt;the x location of the center of the burger&lt;/param&gt;
    /// &lt;param name="y"&gt;the y location of the center of the burger&lt;/param&gt;
    /// &lt;param name="shootSound"&gt;the sound the burger plays when shooting&lt;/param&gt;
    public Burger(ContentManager contentManager, string spriteName, int x, int y,
        SoundEffect shootSound)
    {
        LoadContent(contentManager, spriteName, x, y);
        this.shootSound = shootSound;
    }

    #endregion

    #region Properties

    /// &lt;summary&gt;
    /// Gets the collision rectangle for the burger
    /// &lt;/summary&gt;
    public Rectangle CollisionRectangle
    {
        get { return drawRectangle; }
    }

    #endregion

    #region Public methods

    /// &lt;summary&gt;
    /// Updates the burger's location based on mouse. Also fires 
    /// french fries as appropriate
    /// &lt;/summary&gt;
    /// &lt;param name="gameTime"&gt;game time&lt;/param&gt;
    /// &lt;param name="mouse"&gt;the current state of the mouse&lt;/param&gt;
    public void Update(GameTime gameTime, MouseState mouse)
    {
        // burger should only respond to input if it still has health

        // move burger using mouse
        if (health &gt; 0)
        {
            drawRectangle.X = mouse.X;
            drawRectangle.Y = mouse.Y;

        }

        // clamp burger in window

        [THIS IS WHERE THE CODE SHOULD GO]

        // update shooting allowed
        // timer concept (for animations) introduced in Chapter 7

        // shoot if appropriate

    }

    /// &lt;summary&gt;
    /// Draws the burger
    /// &lt;/summary&gt;
    /// &lt;param name="spriteBatch"&gt;the sprite batch to use&lt;/param&gt;
    public void Draw(SpriteBatch spriteBatch)
    {
        spriteBatch.Draw(sprite, drawRectangle, Color.CornflowerBlue);
    }

    #endregion

    #region Private methods

    /// &lt;summary&gt;
    /// Loads the content for the burger
    /// &lt;/summary&gt;
    /// &lt;param name="contentManager"&gt;the content manager to use&lt;/param&gt;
    /// &lt;param name="spriteName"&gt;the name of the sprite for the burger&lt;/param&gt;
    /// &lt;param name="x"&gt;the x location of the center of the burger&lt;/param&gt;
    /// &lt;param name="y"&gt;the y location of the center of the burger&lt;/param&gt;
    private void LoadContent(ContentManager contentManager, string spriteName,
        int x, int y)
    {
        // load content and set remainder of draw rectangle
        sprite = contentManager.Load&lt;Texture2D&gt;(spriteName);
        drawRectangle = new Rectangle(x - sprite.Width / 2,
            y - sprite.Height / 2, sprite.Width,
            sprite.Height);
    }

    #endregion
}
</code></pre>

<p>Any ideas how I could go about this? I've tried using mouse.Getstate and trying to lock the mouse cursor to the window but that didn't seem to work.</p>