{ "name": "Expand Up", "language": 0, "code": "using System;\r\nusing System.Drawing;\r\nusing System.Collections.Generic;\r\n\r\n// The 'windowHandle' parameter will contain the window handle for the:\r\n// - Active window when run by hotkey\r\n// - Trigger target when run by a Trigger rule\r\n// - TitleBar Button owner when run by a TitleBar Button\r\n// - Jump List owner when run from a Taskbar Jump List\r\n// - Currently focused window if none of these match\r\npublic static class DisplayFusionFunction\r\n{\r\n\tpublic static void Run(IntPtr windowHandle)\r\n\t{\r\n\t\t// Get the bounds of the current window\r\n\t\tRectangle windowBounds = BFS.Window.GetBounds(windowHandle);\r\n\t\t\r\n\t\t// Get the bounds of the current monitor\r\n\t\tRectangle bounds = BFS.Monitor.GetMonitorWorkAreaByWindow(windowHandle);\r\n\t\t\r\n\t\t// Bigger up\r\n\t\t// See if the window is smaller than the current monitor\r\n\t\tif(windowBounds.Y > bounds.Y)\r\n\t\t{\r\n BFS.Window.SetSizeAndLocation(windowHandle, windowBounds.X, bounds.Y, windowBounds.Width, Math.Abs(bounds.Y - windowBounds.Y) + windowBounds.Height);\r\n return;\r\n\t\t}\r\n\t\t\r\n\t\t// Find a monitor above and embiggen\r\n\t\t// Find the index of the current monitor\r\n\t\tint index = -1;\r\n\t\tfor(int i = 0; i < BFS.Monitor.GetMonitorCountEnabled(); i++)\r\n\t\t{\r\n if(!BFS.Monitor.GetMonitorWorkAreas()[i].Equals(bounds))\r\n continue;\r\n \r\n index = i;\r\n break;\r\n\t\t}\t\t\r\n\t\t\r\n\t\t// Couldn't find monitor, exit\r\n\t\tif(index == -1)\r\n return;\r\n \r\n // Expand window to the previous monitor\r\n while(true)\r\n {\r\n // Decrement index\r\n index--;\r\n \r\n // Check to see if there are any more monitors to expand to\r\n if(index < 0)\r\n break;\r\n \r\n // Check to see if we're already expanded to the edge of the previous monitor\r\n Rectangle previousWorkArea = BFS.Monitor.GetMonitorWorkAreas()[index];\r\n if(windowBounds.Y <= previousWorkArea.Y)\r\n continue;\r\n \r\n // If we got this far, just expand the window to the previous monitor\r\n BFS.Window.SetSizeAndLocation(windowHandle, windowBounds.X, previousWorkArea.Y, windowBounds.Width, Math.Abs(previousWorkArea.Y - windowBounds.Y) + windowBounds.Height);\r\n break;\r\n }\r\n\t}\r\n}", "description": "", "references": "System.Core.dll|System.Data.dll|System.dll|System.Drawing.dll|System.Management.dll|System.Web.dll|System.Windows.Forms.dll|System.Xml.dll" }