Ejemplo 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);
        }
Ejemplo 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;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="item">登録するアイテム</param>
        public MysetItem(GroupItem item)
        {
            icon    = item.icon.Clone(FormType.MysetList);
            ExePath = new StringBuilder(255);
            long hwnd = item.Handle;

            GHProcess.GetProcessPath(ref hwnd, out ExePath);

            icon.item_name.Clear();
            icon.item_name = new StringBuilder(System.IO.Path.GetFileNameWithoutExtension(ExePath.ToString()));

            icon.control.MouseClick += new MouseEventHandler(Item_Control_Click);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// グループ内ウィンドウをすべてアクティブか最小化にする
 /// </summary>
 /// <param name="show"></param>
 public void ShowOrHideWindows(bool show)
 {
     if (Items.Count > 0)
     {
         if (show)
         {
             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);
             }
         }
     }
 }
Ejemplo n.º 5
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);
                }
            }
        }
Ejemplo n.º 6
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;
            }
        }
Ejemplo n.º 7
0
 private static void OpenSelectItem()
 {
     if (GHManager.Launcher.FormVisible)
     {
         FormType n = GHManager.GetActiveForm();
         if (n == FormType.Launcher)
         {
             // ランチャー
             if (GHManager.Launcher.MysetIcon.control.Focused)
             {
                 if (GHManager.MysetList.FormVisible)
                 {
                     GHManager.MysetList.FixedActive = false;
                     GHManager.MysetList.MysetList_Hide();
                 }
                 else
                 {
                     if (MysetManager.Items.Count > 0)
                     {
                         GHManager.MysetList.FixedActive = true;
                         GHManager.MysetList.MysetList_Show();
                     }
                 }
             }
             else if (GroupManager.CheckRange(GHManager.Launcher.SelectIndex - 1))
             {
                 GroupManager.Items[GHManager.Launcher.SelectIndex - 1].SwitchShowOrHide();
             }
         }
         else if (n == FormType.ItemList)
         {
             // アイテムリスト
             int num;
             int select = GHManager.ItemList.SelectIndex;
             if (GHManager.ItemList.ParentGHForm == 0)
             {
                 num = GHManager.Launcher.SelectIndex - 1;
                 if (GroupManager.CheckRange(num))
                 {
                     if (GroupManager.Items[num].CheckRange(select))
                     {
                         GHProcess.SwitchShowOrHide((IntPtr)GroupManager.Items[num].Items[select].Handle);
                     }
                 }
             }
             else
             {
                 num = GHManager.MysetList.SelectIndex;
                 if (MysetManager.CheckRange(num))
                 {
                     if (MysetManager.Items[num].CheckRange(select))
                     {
                         MysetManager.Items[num].Items[select].Execute();
                     }
                 }
             }
         }
         else if (n == FormType.MysetList)
         {
             // マイセット
             int num = GHManager.MysetList.SelectIndex;
             if (MysetManager.CheckRange(num))
             {
                 MysetManager.Items[num].ExecuteItems();
             }
         }
     }
 }