using System;
using System.Drawing;
// The 'windowHandle' parameter will contain the window handle for the:
// - Active window when run by hotkey
// - Window Location target when run by a Window Location rule
// - TitleBar Button owner when run by a TitleBar Button
// - Jump List owner when run from a Taskbar Jump List
// - Currently focused window if none of these match
public static class DisplayFusionFunction
{
public static void Run(IntPtr windowHandle)
{
//set your two sizes here in percentages (i.e. 0.5f is 50% of the monitor)
float smallSize = 0.7f;
float largeSize = 0.9f;
//get the bounds of the current window
Rectangle windowBounds = BFS.Window.GetBounds(windowHandle);
//get the bounds of the current monitor
Rectangle monitorBounds = BFS.Monitor.GetMonitorWorkAreaByWindow(windowHandle);
//if the window is close in size to the smallSize variable, size the window to the largeSize variable
//otherwise, size the window to the smallSize variable
if(IsWithin(windowBounds.Width, (int)(monitorBounds.Width * smallSize), 10))
BFS.Window.SetSize(windowHandle, (int)(monitorBounds.Width * largeSize), (int)(monitorBounds.Height * largeSize));
else
BFS.Window.SetSize(windowHandle, (int)(monitorBounds.Width * smallSize), (int)(monitorBounds.Height * smallSize));
}
//this function returns true if a value is close to another value
private static bool IsWithin(int value, int target, int threshold)
{
return (value == target) || ((value >= target - threshold) && (value <= target + threshold));
}
}