using System; using System.Drawing; using System.Collections.Generic; // 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 { //an enum for easy user selection private enum UserOptionsEnum { UpperLeft, LowerLeft, UpperMiddle, LowerMiddle, TopRight, TopMiddleRight , BottomMiddleRight, BottomRight, } public static void Run(IntPtr windowHandle) { //add the options to a dictionary with the key being the description of the option Dictionary options = new Dictionary(); options.Add("Upper Left (25% x 50%)", UserOptionsEnum.UpperLeft); options.Add("Lower Left (25% x 50%)", UserOptionsEnum.LowerLeft); options.Add("Upper Middle (50% x 50%)", UserOptionsEnum.UpperMiddle); options.Add("Lower Middle (50% x 50%)", UserOptionsEnum.LowerMiddle); options.Add("Top Right (25% x 25%)", UserOptionsEnum.TopRight); options.Add("Top-Middle Right (25% x 25%)", UserOptionsEnum.TopMiddleRight); options.Add("Bottom-Middle Right (25% x 25%)", UserOptionsEnum.BottomMiddleRight); options.Add("Bottom Right (25% x 25%)", UserOptionsEnum.BottomRight); //get the bounds of the monitor that the window is in Rectangle monitorBounds = BFS.Monitor.GetMonitorWorkAreaByWindow(windowHandle); //convert the dictionary keys into a string array and display a drop down to the user string selection = BFS.Dialog.GetUserInputList("Select a Window Position", new List(options.Keys).ToArray()); //if the string is empty, exit the script if(string.IsNullOrEmpty(selection)) return; //move the window depending on the user's selection switch(options[selection]) { case UserOptionsEnum.UpperLeft: BFS.Window.SetSizeAndLocation(windowHandle, monitorBounds.X, monitorBounds.Y, monitorBounds.Width / 4, monitorBounds.Height / 2); break; case UserOptionsEnum.LowerLeft: BFS.Window.SetSizeAndLocation(windowHandle, monitorBounds.X, monitorBounds.Y + monitorBounds.Height / 2, monitorBounds.Width / 4, monitorBounds.Height / 2); break; case UserOptionsEnum.UpperMiddle: BFS.Window.SetSizeAndLocation(windowHandle, monitorBounds.X + monitorBounds.Width / 4, monitorBounds.Y, monitorBounds.Width / 2, monitorBounds.Height / 2); break; case UserOptionsEnum.LowerMiddle: BFS.Window.SetSizeAndLocation(windowHandle, monitorBounds.X + monitorBounds.Width / 4, monitorBounds.Y + monitorBounds.Height / 2, monitorBounds.Width / 2, monitorBounds.Height / 2); break; case UserOptionsEnum.TopRight: BFS.Window.SetSizeAndLocation(windowHandle, monitorBounds.X + monitorBounds.Width - monitorBounds.Width / 4, monitorBounds.Y, monitorBounds.Width / 4, monitorBounds.Height / 4); break; case UserOptionsEnum.TopMiddleRight: BFS.Window.SetSizeAndLocation(windowHandle, monitorBounds.X + monitorBounds.Width - monitorBounds.Width / 4, (int)(monitorBounds.Y + monitorBounds.Height * 0.25m), monitorBounds.Width / 4, monitorBounds.Height / 4); break; case UserOptionsEnum.BottomMiddleRight: BFS.Window.SetSizeAndLocation(windowHandle, monitorBounds.X + monitorBounds.Width - monitorBounds.Width / 4, (int)(monitorBounds.Y + monitorBounds.Height * 0.50m), monitorBounds.Width / 4, monitorBounds.Height / 4); break; case UserOptionsEnum.BottomRight: BFS.Window.SetSizeAndLocation(windowHandle, monitorBounds.X + monitorBounds.Width - monitorBounds.Width / 4, (int)(monitorBounds.Y + monitorBounds.Height * 0.75m), monitorBounds.Width / 4, monitorBounds.Height / 4); break; } } }