TITLE: An infinite sum from Green function
QUESTION [5 upvotes]: When reading the Green function for differential equation, I faced this sum and feel hard to deduce its result directly:
$$\frac{2}{\pi^2} \sum_{n=1}^\infty \frac{\sin n\pi x \sin n\pi y}{n^2}$$
I knew the result:
When $x \leqslant y, \qquad (1-y)x$ ;
when $x >y, \qquad (1-x)y$
My question is how to obtain the result from the infinite sum ? 
Thank you for your time.
++++++++++++++++++++
Update
++++++++++++++++++++
Thank @njguliyev a lot.
I am exciting since this problem has a simple solution, if one know the series njguliyev gave.
In fact, I keep this problem for a long time, which comes from the book by Hilbert & Courant, they simply gave the final result without analysis. I had a solution, but I didn't satisfied with it, I will give the detail below, so anyone find anything improper, please tell me your idea. Not like njguliyev's solution,  my way is not so elegant.
Tow formulas is needed:
Poisson summation formula: 
$$\sum_{n=-\infty}^\infty \psi(2\pi n) = \frac{1}{2\pi} \sum_{\nu = \infty}^\infty \int_{-\infty}^\infty \psi(\tau) e^{-i\nu \tau} \mathrm{d}\tau
$$
The Fourier Transformation:
$$
\int_{-\infty}^{+\infty} \frac{1}{t^2} \sin^2(at) e^{-i\omega t} \mathrm{d} t = \begin{cases} \pi\left(|a| - \frac{|\omega|}{2}\right), &\mbox{if  } |\omega| \leq 2a \\
0, &\mbox{if   } |\omega| > 2a\end{cases}
$$
And $x,y \in [0,1]$, if $n=0$ in the original sum formula, I took the limit value, as the well-known result $\lim\limits_{x \rightarrow 0} \frac{\sin x}{x} = 1$:
$$
\frac{\sin n\pi x\ \sin n\pi y}{n^2}\bigg|_{n=0} = \pi^2 xy
$$
therefor:
$$
\begin{align*}
\frac{2}{\pi^2} \sum_{n=1}^\infty \frac{\sin n\pi x \sin n\pi y}{n^2} 
&= \sum_{n=-\infty}^\infty \frac{1}{\pi^2} \frac{\sin n\pi x \sin n\pi y}{n^2} - xy \\
&= 4\cdot \sum_{n=-\infty}^\infty\frac{1}{(2n\pi)^2}\bigg[ \sin^2(2n\pi \frac{x+y}{4}) - \sin^2(2n\pi \frac{x-y}{4})\bigg] - xy\\
 &= \frac{4}{2\pi}\sum_{\nu = -\infty}^\infty \pi \bigg(\frac{x+y}{4} - \frac{|\nu|}{2}\bigg) - \frac{4}{2\pi}\sum_{\nu=-\infty}^\infty \pi\bigg(\frac{|x-y|}{4} -\frac{|\nu|}{2}\bigg) - xy \\
&=\begin{cases} (1 - y)x \qquad & x\leq y \quad \text{note: } x,y \in [0,1]\\
(1-x)y \qquad & x >y
\end{cases}
\end{align*}
$$

REPLY [5 votes]: Hint: Use
$$\sin \alpha \sin \beta = \frac12\left( \cos (\alpha- \beta) - \cos(\alpha +\beta) \right)$$
and
$$\sum_{n=1}^{\infty} \frac{\cos nx}{n^2} = \frac{x^2}{4} - \frac{\pi x}{2} + \frac{\pi^2}{6}, \quad 0 \le x \le \pi,$$
which can be obtained from the Fourier series of $\frac{\pi-x}{2}$.