Ejemplo n.º 1
0
        void detectPreviousRunning()
        {
            //ALL THE PROCESSES!
            foreach (Process p in Process.GetProcesses("."))
            {
                try
                {
                    if (p.MainWindowTitle.Length > 0)
                    {
                        //ALL THE TILES!
                        foreach (Tile t in Globals.MainDock.DockTiles)
                        {
                            //Check to see if a tile is already assigned to this process
                            if (Helpers.GetProcessName(p.MainWindowHandle).Equals(Helpers.GetProcessName(t.hwID)))
                            {
                                //Tile exists, add Handle to Tile's handle list
                                t.lst_hwID.Add(p.MainWindowHandle);
                            }
                            else
                            {
                                //New tile!
                                Tile nt = new Tile(p.ProcessName.ToString(), Globals.randomTileColor(),
                                    Helpers.GetProcessName(p.MainWindowHandle), false);
                                nt.s_AppPath = Helpers.GetProcessName(p.MainWindowHandle);
                                nt.lst_hwID.Add(p.MainWindowHandle); //Add handle to handle list
                                nt.animateRunning();

                                Globals.MainDock.addTile(nt);
                            }
                        }
                    }
                }
                catch
                {
                    //lolwut
                }
            }
        }
Ejemplo n.º 2
0
Archivo: Globals.cs Proyecto: Foda/Tide
        static void sh_WindowCreated(ShellHook sender, IntPtr hWnd)
        {
            bool b_ExistingProcess = false;
            Tile foundTile;

            if (Helpers.GetWindowText(hWnd) == "Add Tile" || Helpers.GetWindowText(hWnd) == "Window1")
                return;

            foreach (UserControl t2 in Globals.MainDock.DockTiles)
            {
                if (t2 is Tile)
                {
                    Tile t3 = (Tile)t2;
                    Console.WriteLine("Sender: " + Helpers.GetProcessName(hWnd) + "::" + t3.s_AppPath);
                    if (Helpers.GetProcessName(hWnd).Equals(t3.s_AppPath) == true)
                    {
                        Console.WriteLine("Found same process");
                        b_ExistingProcess = true;
                        foundTile = t3;
                        t3.lst_hwID.Add(hWnd);
                        t3.animateRunning();
                    }
                }
            }

            if (b_ExistingProcess != true)
            {
                Tile t = new Tile(Helpers.GetWindowText(hWnd), randomTileColor(), Helpers.GetProcessName(hWnd), false);
                t.hwID = hWnd;
                t.lst_hwID.Add(hWnd);
                t.animateRunning();
                Globals.MainDock.addTile(t);
            }
        }