Detect when there is a Windows tablet screen rotation

1

How do I identify when there has been a rotation of the Windows tablet screen?

    
asked by anonymous 13.02.2017 / 17:04

1 answer

5

According to documentation here:

using System.Windows.Forms;
//. . .
//Set event handler
private void Form1_Load(object sender, System.EventArgs e)
{
    int theScreenRectHeight = Screen.PrimaryScreen.Bounds.Height;
    int theScreenRectWidth = Screen.PrimaryScreen.Bounds.Width;
    //Compare height and width of screen and act accordingly.
    if (theScreenRectHeight > theScreenRectWidth)
    {
        // Run the application in portrait, as in:
    MessageBox.Text = "Run in portrait.";
    }
    else
    {
        // Run the application in landscape, as in:
        MessageBox.Text = "Run in landscape.";
    }
}

This method detects whether it is in landscape or portrait.

    
13.02.2017 / 17:09