How do I identify when there has been a rotation of the Windows tablet screen?
How do I identify when there has been a rotation of the Windows tablet screen?
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.