Screen.FromControl
, Screen.FromPoint
и Screen.FromRectangle
должны помочь вам в этом. Например, в WinForms это будет:
class MyForm : Form
{
public Rectangle GetScreen()
{
return Screen.FromControl(this).Bounds;
}
}
Я не знаю эквивалентного вызова WPF. Поэтому вам нужно сделать что-то вроде этого метода расширения.
static class ExtensionsForWPF
{
public static System.Windows.Forms.Screen GetScreen(this Window window)
{
return System.Windows.Forms.Screen.FromHandle(new WindowInteropHelper(window).Handle);
}
}