Ejemplo n.º 1
0
        private void LoadTiles()
        {
            //load text file from "\Users\{username}\LaunchPad\Apps.text"
            //i also place LaunchPad.exe, and its icons, in \Users\{username}\LaunchPad (not required though)
            //Apps.text is a single-text-line-per-entry, pipe-separated file, of the format:
            //  Title|IconPath|ExecutablePath|ExecutableArguments|WorkingDirectory
            //Arguments and WorkingDir are optional, other values are required.
            string launchPadDir = Environment.GetEnvironmentVariable("USERPROFILE") + "\\LaunchPad\\";

            string[] tileData = File.ReadAllLines(launchPadDir + "Apps.text");
            for (var i = 0; i < tileData.Length; i++)
            {
                string curr = tileData[i].Trim();
                if (curr.Length > 0)
                {
                    string[] components = curr.Split(new char[] { '|' });
                    if (components.Length > 2)
                    {
                        TileApp newApp = new TileApp();
                        newApp.Title      = components[0];
                        newApp.Icon       = Image.FromFile(launchPadDir + components[1]);
                        newApp.Executable = components[2];
                        if (components.Length > 3)
                        {
                            newApp.Arguments = components[3];
                        }
                        if (components.Length > 4)
                        {
                            newApp.WorkingDir = components[4];
                        }
                        tileApps.Add(newApp);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void frmMain_MouseClick(object sender, MouseEventArgs e)
        {
            Hide();

            //blank areas...
            int tileXOff = (e.X - offsetX) % tilePadSize; if (tileXOff > tileSize)
            {
                return;
            }
            int tileYOff = (e.Y - offsetY) % tilePadSize; if (tileYOff > (tileSize + 16))

            {
                return;
            }

            if ((e.X < offsetX) || (e.X > (Width - offsetX)))
            {
                return;
            }
            if ((e.Y < offsetY) || (e.Y > (Height - offsetY)))
            {
                return;
            }

            int tileX = ((e.X - offsetX) - tileXOff) / tilePadSize;
            int tileY = ((e.Y - offsetY) - tileYOff) / tilePadSize;
            int index = (tileY * nTilesX) + tileX;

            if ((index < 0) || (index >= tileApps.Count))
            {
                return;                                    //who knows how this would happen...
            }
            //launch selected tile
            TileApp ta = tileApps[index];

            System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
            psi.FileName         = ta.Executable;
            psi.Arguments        = ta.Arguments;
            psi.WorkingDirectory = ta.WorkingDir;
            System.Diagnostics.Process.Start(psi);
        }