private int BoundedX(int xPosition) { if (xPosition < this.Bounds.X) { return this.Bounds.X; } else { int maxX = this.Bounds.X + this.Bounds.Width - this.MarkerWidth; if (xPosition > maxX) { return maxX; } } return xPosition; }