using System;
using System.Drawing;
// 20190720 ckx
// Shrink restored when nearly maximum size (trigger on window restored).
// Use with trigger:
// 1) On window restored
// 2) Window title <blank>
// 3) Add this script to run
public static class DisplayFusionFunction
{
public static void Run(IntPtr ha)
{
// set the scale amount
// (greater than 1.0 increases window size, less than 1.0 decreases window size)
float scaleAmount = 0.7f;
// set the minimum size for the window (relative to the monitor's size)
float minimumRelativeSize = 0.2f;
/* === DO NOT MODIFY BELOW THIS LINE === */
if(BFS.Window.IsMaximized(ha))
return;
Rectangle wbr = BFS.Window.GetBounds(ha);
Rectangle mbr = BFS.Monitor.GetMonitorBoundsByWindow(ha);
int dxd = Math.Abs( wbr.Width - mbr.Width );
int dyd = Math.Abs( wbr.Height - mbr.Height );
// ShoCoo(wbr,mbr,dxd,dyd);
if ( dxd > (int)(wbr.Width * minimumRelativeSize) )
return;
if (dyd > (int)(wbr.Height * minimumRelativeSize))
return;
int fxd = (int)(wbr.Width * scaleAmount);
int fyd = (int)(wbr.Height * scaleAmount);
int fxp = (int)(mbr.X + (wbr.Width - fxd) / 2) ;
int fyp = (int)(mbr.Y + (wbr.Height - fyd) / 2) ;
BFS.Window.SetSizeAndLocation(ha, fxp, fyp, fxd, fyd );
}
}