Пример #1
0
        /**
         * <summary>
         * 左は1ウィンドウ、右は複数ウィンドウ
         * </summary>
         */
        public override void CalcuratePosition(int windowCount, int monitorTop, int monitorBottom, int monitorLeft, int monitorRight)
        {
            if (windowCount == 0)
            {
                return;
            }

            // 定義すべきウィンドウ位置の最大数は、
            // 右側の複数ウィンドウ+1(左側)だが
            // 右側はウィンドウ数によって可変
            var countOfWindowOfRightColumn = this.maxCountOfWindowOfRightColumn;

            if (windowCount - 1 < countOfWindowOfRightColumn)
            {
                countOfWindowOfRightColumn = windowCount - 1;
            }

            // 左側列の定義
            var monitorWidth            = monitorRight - monitorLeft;
            var monitorHeight           = monitorBottom - monitorTop;
            var windowWidthOfLeftColumn = (int)Math.Floor(monitorWidth * this.percentOfLeftColumn);

            this.windowRects.Add(new WindowRect(
                                     /* top     = */ monitorTop,
                                     /* bottom  = */ monitorBottom,
                                     /* left    = */ monitorLeft,
                                     /* right   = */ monitorLeft + windowWidthOfLeftColumn
                                     ));

            if (countOfWindowOfRightColumn == 0)
            {
                // 右側列にウィンドウがなければここで計算終了
                return;
            }

            // 右側列の定義
            var windowWidthOfRightColumn  = monitorWidth - windowWidthOfLeftColumn;
            var windowHeightOfRightColumn = monitorHeight / countOfWindowOfRightColumn;
            var windowTop   = monitorTop;
            var windowLeft  = monitorLeft + windowWidthOfLeftColumn;
            var windowRight = windowLeft + windowWidthOfRightColumn;

            for (int i = 0; i < countOfWindowOfRightColumn; i++)
            {
                var windowBottom  = windowTop + windowHeightOfRightColumn;
                var newWindowRect = new WindowRect(
                    /* top     = */ windowTop,
                    /* bottom  = */ windowBottom,
                    /* left    = */ windowLeft,
                    /* right   = */ windowRight
                    );

                var newWindowRectString = newWindowRect.ToString();
                Logger.WriteLine($"WindowTilerDividerBugn.CalcuratePosition : {newWindowRectString}");

                this.windowRects.Add(newWindowRect);

                windowTop = windowBottom;
            }
        }
Пример #2
0
        /**
         * <summary>
         * 指定されたWindowInfoWithHandleをWindowRectの位置に移動する
         * ただしWindowInfoWithHandle.positionXXAdjustmentで位置を補正して隙間ができないようにする
         * </summary>
         */
        public void MoveWindow(WindowInfoWithHandle windowInfoWithHandle, WindowRect windowRect)
        {
            var hWnd             = windowInfoWithHandle.windowHandle;
            var windowRectString = windowRect.ToString();

            Logger.WriteLine($"WindowManager.MoveWindow : hWnd={hWnd} To {windowRectString}");


            // 最大化、最小化Windowの場合は元のウィンドウにする
            // if ( IsZoomed(hWnd) || IsIconic(hWnd))
            if (IsZoomed(hWnd))
            {
                ShowWindow(hWnd, /* SW_RESTORE = */ 9);
            }


            MoveWindow(hWnd,
                       windowRect.GetX() + windowInfoWithHandle.positionLeftAdjustment,
                       windowRect.GetY() + windowInfoWithHandle.positionTopAdjustment,
                       windowRect.GetWidth() + windowInfoWithHandle.positionWidthAdjustment,
                       windowRect.GetHeight() + windowInfoWithHandle.positionHeightAdjustment,
                       /* bRepaint = */ 1);
        }