Find joint CDF given a joint PDF 
Let $X$ and $Y$ have a joint density function given by
  $$
f(x, y) =
\begin{cases}
1, & \text{for } 0\leq x\leq2,\;\max(0,\,x-1)\leq y\leq \min(1,\,x), \\
0, & \text{otherwise}.
\end{cases}
$$
  Determine the joint and marginal distribution functions.


I know that $F_{XY}(x, y) = \int_{-\infty}^x\int_{-\infty}^y f(u, v)\;dudv$. But I have no idea how to apply this fact.
The obvious case that I can find is that if  $x > 2$, then $F_{XY}(x, y) = 1$.
Some other bounds are e.g. $0<x<1$ and $0<y<x$, but how do I find the CDF for this case? I can find some of the bounds, but don't know how to use them for the integrals.
 A: Revised correction, based on conversation with Maxim!
Summary for all $(x,y)$. For $x\le 0$ or $y\le 0,\ F(x,y)=0$.
For $0\lt x\le 1,\ 0\le y\le 1$, two parts: 
1) $0\lt y\le x,\ F(x,y)=xy-\frac{y^2}{2}$, 
2) $x\lt y\le 1,\ F(x,y)=\frac{x^2}{2}$, 
For $1\lt x,\ 0\le y\le 1$, two parts: [part 2) vacuous for $x\gt 2$]
1) $0\le y\le x-1,\ F(x,y)=y$,
2) $x-1\lt y\le1,\ F(x,y)=xy-\frac{y^2}{2}-\frac{(x-1)^2}{2}$, 
For $1\lt y,\ F(x,y)=F(x,1)$.
A: Let 
$$f_{X, Y}(x, y) = [0 \leq x \leq 2 \land \max(0, x-1) \leq y \leq \min(1, x)],$$ where $[P]$ is $1$ if $P$ is true and $0$ otherwise. Consider the cases $0 \leq x \leq 1$ and $1 < x \leq 2$ separately to get rid of $\min$ and $\max$ and verify that
$$f_{X, Y}(x, y) = [0 \leq y \leq 1 \land y \leq x \leq y + 1].$$
Integrating out the variable $x$ gives $1$ if the horizontal line intersects the parallelogram and $0$ otherwise:
$$f_Y(y) = \int_{-\infty}^\infty f_{X, Y}(x, y) dx = [0 \leq y \leq 1],$$
from which the marginal cdf of $Y$ is
$$F_Y(y) = y \,[0 \leq y \leq 1] + [1 < y].$$
The marginal pdf of $X$ is symmetric wrt the line $x = 1$:
$$f_X(x) = x \,[0 \leq x \leq 1] + (2 - x) \,[1 < x \leq 2], \\
F_X(x) = \frac {x^2} 2 \,[0 \leq x \leq 1] +
 \left( 2 x - \frac {x^2} 2 - 1 \right) [1 < x \leq 2] +
 [2 < x].$$
To find $F_{X, Y}(x, y)$, first take $(x, y)$ inside the parallelogram:
$$G(x, y) =
\int_{-\infty}^x \int_{-\infty}^y f_{X, Y}(u, v) dv du = \\
\left( x y - \frac {y^2} 2 \right) \,[x \leq 1] +
 \left( x - \frac {(x - y)^2 + 1} 2 \right) [1 < x], \\
f_{X, Y}(x, y) = 1.$$
Note that this is different from $\int_{-\infty}^x \int_{-\infty}^y f_{X, Y}(u, v) du dv$.
For $(x, y)$ outside of the parallelogram, project the point onto the boundary:
$$F_{X, Y}(x, y) =
G(\min(x, y + 1, 2), \min(y, x, 1)) \,[0 \leq x \land 0 \leq y].$$
It can be verified that
$$F_X(x) = F_{X, Y}(x, \infty), \;F_Y(y) = F_{X, Y}(\infty, y).$$
