wpf. , , , Foreground , .
Foreground , User32
[DllImport("user32.dll")]
private static extern bool GetWindowRect(HandleRef hWnd, [In, Out] ref RECT rect);
[DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow();
[StructLayout(LayoutKind.Sequential)]
private struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
System.Windows.Forms System.Drawing, Screen. , ForegroundWindow FullScreen.
public bool IsAnyWindowFullScreen()
{
RECT rect = new RECT();
GetWindowRect(new HandleRef(null, GetForegroundWindow()), ref rect);
return new System.Drawing.Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top).Contains(Screen.PrimaryScreen.Bounds);
}
if(!IsAnyWindowFullScreen())
{
window.Topmost = true;
}
window.Show();