using System;
using System.Drawing;
public static class DisplayFusionFunction
{
public static void Run(IntPtr windowHandle)
{
Rectangle MonRect = BFS.Monitor.GetMonitorBoundsByMouseCursor();
// Loop through the visible windows and move them to the monitor that has the mouse cursor, if they are not on any monitor
foreach (IntPtr handle in BFS.Window.GetVisibleWindowHandles())
{
Rectangle WinRect = BFS.Window.GetBounds(handle);
bool moveit = false;
uint monitorid = BFS.Monitor.GetMonitorIDByWindow(handle);
if(monitorid == 0) // Not on any monitor
{
moveit = true;
}
else
{
Rectangle IntersectSize = Rectangle.Intersect(WinRect, BFS.Monitor.GetMonitorBoundsByID(monitorid));
if (IntersectSize.Width < 3 || IntersectSize.Height < 3) // Has a monitor, but barely visible
{
moveit = true;
}
}
if(moveit)
{
BFS.DisplayFusion.RunFunctionWithWindowHandle("Move Window to Current Monitor", handle);
BFS.Window.MoveToCentreMonitor(handle);
BFS.Window.SetSize(handle, WinRect.Width, WinRect.Height);
}
}
}
}