{ "name": "Expand Right", "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 to the right\r\n\t\t// See if the window is smaller than the current monitor\r\n\t\tif(windowBounds.X + windowBounds.Width < bounds.X + bounds.Width)\r\n\t\t{\r\n BFS.Window.SetSizeAndLocation(windowHandle, windowBounds.X, windowBounds.Y, bounds.X + bounds.Width - windowBounds.X, windowBounds.Height);\r\n return;\r\n\t\t}\r\n\t\t\r\n\t\t// Find a monitor to the right 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 next monitor\r\n while(true)\r\n {\r\n // Increment index\r\n index++;\r\n \r\n // Check to see if there are any more monitors to expand to\r\n if(index >= BFS.Monitor.GetMonitorCountEnabled())\r\n break;\r\n \r\n // Check to see if we're already expanded to the edge of the next monitor\r\n Rectangle nextWorkArea = BFS.Monitor.GetMonitorWorkAreas()[index];\r\n if(windowBounds.X + windowBounds.Width >= nextWorkArea.X + nextWorkArea.Width)\r\n continue;\r\n \r\n // If we got this far, just expand the window to the next monitor\r\n BFS.Window.SetSizeAndLocation(windowHandle, windowBounds.X, windowBounds.Y, nextWorkArea.X + nextWorkArea.Width - windowBounds.X, 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" }