Esempio n. 1
0
 /// <summary>
 ///     Restore (Un-Minimize/Maximize) the Window
 /// </summary>
 /// <param name="interopWindow">InteropWindow</param>
 /// <returns>IInteropWindow for fluent calls</returns>
 public static IInteropWindow Restore(this IInteropWindow interopWindow)
 {
     User32Api.ShowWindow(interopWindow.Handle, ShowWindowCommands.Restore);
     interopWindow.IsMinimized = false;
     interopWindow.IsMaximized = false;
     return(interopWindow);
 }
Esempio n. 2
0
        public override void Execute(PlacementAction action, IJobContext context)
        {
            var display = context.Display;

            if (action.Placement.DisplayIndex is int displayIndex)
            {
                if (_displayService.Displays.ContainsKey(displayIndex))
                {
                    display = _displayService.Displays[displayIndex];
                }
                else
                {
                    return;
                }
            }

            if (action.Placement.Bounds == null)
            {
                var bounds = display.WorkingArea;
                User32Api.SetWindowPos(context.Window.Handle, IntPtr.Zero, bounds.X, bounds.Y, bounds.Width, bounds.Height, WindowPos.SWP_SHOWWINDOW);
                User32Api.ShowWindow(context.Window.Handle, ShowWindowCommands.ShowMaximized);
            }
            else
            {
                var bounds = display.WorkingArea.CropByPercentage(action.Placement.Bounds) + context.Window.Border;
                User32Api.SetWindowPos(context.Window.Handle, IntPtr.Zero, bounds.X, bounds.Y, bounds.Width, bounds.Height, WindowPos.SWP_SHOWWINDOW);
            }
        }
Esempio n. 3
0
 /// <summary>
 ///     Minimize the Window
 /// </summary>
 /// <param name="interopWindow">InteropWindow</param>
 /// <returns>IInteropWindow for fluent calls</returns>
 public static IInteropWindow Minimize(this IInteropWindow interopWindow)
 {
     User32Api.ShowWindow(interopWindow.Handle, ShowWindowCommands.Minimize);
     interopWindow.IsMinimized = true;
     return(interopWindow);
 }
 /// <summary>
 ///     Maximize the window
 /// </summary>
 /// <param name="interopWindow">InteropWindow</param>
 public static void Maximize(this IInteropWindow interopWindow)
 {
     User32Api.ShowWindow(interopWindow.Handle, ShowWindowCommands.Maximize);
     interopWindow.IsMaximized = true;
     interopWindow.IsMinimized = false;
 }