Esempio n. 1
0
        private int VerticalTile()
        {
            int tileCnt = 0;
            int column  = (int)(Math.Ceiling((decimal)((Items.Count - 1) / 7.0f)) + 1);

            int[] row = new int[column];
            int   cnt = Items.Count;
            int   col = column;

            for (int i = 0; i < row.Length; ++i)
            {
                row[i] = (int)(Math.Floor((decimal)(cnt / col)));
                cnt   -= row[i];
                --col;
            }

            int    n = 0;
            int    width, height;
            IntPtr Handle;

            WinAPI.DSIZE scale = GHManager.Scale;

            Rectangle workRect = GHManager.WorkingArea;

            workRect = new Rectangle(
                (int)(workRect.Left / scale.cx),
                (int)(workRect.Top / scale.cy),
                (int)(workRect.Width / scale.cx),
                (int)(workRect.Height / scale.cy)
                );

            height = (workRect.Height / column);
            for (int i = 0; i < column; ++i)
            {
                width = (workRect.Width / row[i]);
                for (int j = 0; j < row[i]; ++j)
                {
                    Handle = (IntPtr)Items[n].Handle;
                    if (GHProcess.IsMinimize(Handle))
                    {
                        GHProcess.Normalize(Handle);
                    }
                    WinAPI.GetWindowRect(Handle, out WinAPI.RECT rect1);
                    DwmAPI.GetWindowRect(Handle, out Rectangle rect2);
                    int dif = rect2.Left - rect1.left;

                    Items[n].PrevRect = new Rectangle(rect1.left, rect1.top, rect1.right - rect1.left, rect1.bottom - rect1.top);
                    WinAPI.SetWindowPos(Handle, new IntPtr(-1), width * j - dif + workRect.Left, height * i + workRect.Top, width + dif * 2, height + dif, WinAPI.SWP_SHOWWINDOW);
                    WinAPI.SetWindowPos(Handle, new IntPtr(-2), 0, 0, 0, 0, WinAPI.SWP_NOMOVE | WinAPI.SWP_NOSIZE | WinAPI.SWP_SHOWWINDOW);
                    ++n;
                    tileCnt++;
                }
            }

            return(tileCnt);
        }
Esempio n. 2
0
 private void MenuItem_AutoTilePrev_Click(object sender, EventArgs e)
 {
     foreach (var item in Items)
     {
         if (GHProcess.IsMinimize((IntPtr)item.Handle))
         {
             GHProcess.Normalize((IntPtr)item.Handle);
         }
         WinAPI.SetWindowPos((IntPtr)item.Handle, new IntPtr(-1), item.PrevRect.Left, item.PrevRect.Top, item.PrevRect.Width, item.PrevRect.Height, WinAPI.SWP_SHOWWINDOW);
         WinAPI.SetWindowPos((IntPtr)item.Handle, new IntPtr(-2), 0, 0, 0, 0, WinAPI.SWP_NOMOVE | WinAPI.SWP_NOSIZE | WinAPI.SWP_SHOWWINDOW);
     }
     IsTiledWindows = false;
 }
Esempio n. 3
0
        /// <summary>
        /// 全てのアイテムのウィンドウの表示・非表示を切り替え
        /// </summary>
        public void SwitchShowOrHide()
        {
            if (Items.Count <= 0)
            {
                return;
            }

            IntPtr hwnd = (IntPtr)Items[0].Handle;

            if (GHProcess.IsMinimize(hwnd))
            {
                for (int i = 0; i < Items.Count; ++i)
                {
                    GHProcess.Normalize((IntPtr)Items[i].Handle);
                }
            }
            else
            {
                for (int i = 0; i < Items.Count; ++i)
                {
                    GHProcess.Minimize((IntPtr)Items[i].Handle);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// メニューの ウィンドウを並べる をクリックした時のイベント
        /// </summary>
        private void MenuItem_AutoTile2_Click(object sender, EventArgs e)
        {
            int tileCnt = 0;

            if (Items.Count == 1)
            {
                if (GHProcess.IsMinimize((IntPtr)Items.First().Handle))
                {
                    return;
                }
                DwmAPI.GetWindowRect((IntPtr)Items[0].Handle, out Rectangle rect);
                Items[0].PrevRect = rect;
                GHProcess.Maximize((IntPtr)Items[0].Handle);
                tileCnt++;
            }
            else
            {
                tileCnt = VerticalTile();
            }
            if (tileCnt > 0)
            {
                IsTiledWindows = true;
            }
        }