Question: How can I know in a C#-Application, in which direction the screen of the mobile device is orientated? (i.e. horizontal or vertical).

Answer: 
you should add 2 Refrences to the project:
Microsoft.WindowsMobile
Microsoft.WindowsMobile.Status

then you can use this code for determine orientation:

```
int orientation=Microsoft.WindowsMobile.Status.SystemState.DisplayRotation;
if(orientation== 90 || orientation==-90 || orientation==270) //Landscape is 90 or -90 or 270
{
    //your code;
}
else
{
    //your code;
}

```
Just guessing but my first attempt would be:

```
var rect = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
// or var rect = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;

var ratio = rect.Width / rect.Height;

if (ratio == 1.0) // square screen.
if (ratio > 1.0) // landscape.
if (ratio < 1.0) // portrait.

```