예제 #1
0
        private void LaunchHyper(IEnumerable <ListViewItem> distroItems)
        {
            string hyperConfigFile     = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Hyper", ".hyper.js");
            string tempHyperConfigFile = hyperConfigFile + ".tmp";

            if (File.Exists(hyperConfigFile))
            {
                if (distroItems == null || distroItems.Count() < 1)
                {
                    return;
                }

                foreach (DistroProperties eachItem in distroItems.Select(x => x.Tag as DistroProperties))
                {
                    string distroExecutable = Path.Combine(
                        SharedRoutines.GetWslShimDirectoryPath(),
                        eachItem.DistroName + "_simple.exe")
                                              .Replace("\\", "\\\\");

                    StreamReader input  = new StreamReader(hyperConfigFile);
                    StreamWriter output = new StreamWriter(tempHyperConfigFile);
                    string       line;
                    while (null != (line = input.ReadLine()))
                    {
                        if (line.StartsWith("    shell: "))
                        {
                            output.WriteLine("    shell: '" + distroExecutable + "',");
                        }
                        else
                        {
                            output.WriteLine(line);
                        }
                    }
                    input.Close();
                    output.Close();
                    File.Delete(hyperConfigFile);
                    File.Move(tempHyperConfigFile, hyperConfigFile);

                    ProcessStartInfo startInfo;

                    startInfo = new ProcessStartInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "hyper", "Hyper.exe"));

                    var proc = Process.Start(startInfo);
                }
            }

            if (!File.Exists(hyperConfigFile))
            {
                MessageBox.Show(this, "Hyper installation not found!\n" +
                                "Hyper can be installed from: https://hyper.is",
                                "Error: Hyper not Installed",
                                MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
예제 #2
0
        private void ShimGenerator_DoWork(object sender, DoWorkEventArgs e)
        {
            var targetDir = SharedRoutines.GetWslShimDirectoryPath();

            EnsureDirectoryCreate(targetDir, false);

            var arg = e.Argument as BackgroundWorkerArgument <DistroProperties[]>;

            if (arg?.Argument == null)
            {
                return;
            }

            // Shim exe file may not have icon due to missing icon cache
            var result = new Dictionary <string, CompilerResults>();

            e.Result = new BackgroundWorkerResult <Dictionary <string, CompilerResults> >(arg.HasTriggeredByUser, result);

            foreach (var eachItem in arg.Argument)
            {
                var fileName   = eachItem.DistroName;
                var eachResult = WslShimGenerator.CreateWslShim(
                    eachItem.DistroName, false, targetDir, fileName);

                if (eachResult.Errors.HasErrors)
                {
                    result.Add(fileName, eachResult);
                }

                fileName   = eachItem.DistroName + "_simple";
                eachResult = WslShimGenerator.CreateWslShim(
                    eachItem.DistroName, true, targetDir, fileName);

                if (eachResult.Errors.HasErrors)
                {
                    result.Add(fileName, eachResult);
                }
            }
        }