예제 #1
0
 private static void SortOutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
 {
     if (!String.IsNullOrEmpty(outLine.Data))
     {
         if (form1.richTextBox1.InvokeRequired)
         {
             form1.richTextBox1.Invoke(new MethodInvoker(delegate {
                 if (outLine.Data.Contains("All rights reserved."))
                 {
                     form1.richTextBox1.Text = "[" + DateTime.Now.ToString("h:mm:ss tt") + "] Ready";
                 }
                 else if (outLine.Data.Contains("We will now attempt to import: ") && !startImport)     //part two of installation
                 {
                     var enterThread = new Thread(
                         new ThreadStart(
                             () => {
                         Installer.StartImport(SW, form1.playsDirectory);
                         form1.Invoke(new MethodInvoker(delegate {
                             form1.richTextBox1.AppendText(Environment.NewLine + "=======================================");
                             form1.richTextBox1.AppendText(Environment.NewLine + "=======================================");
                             form1.richTextBox1.AppendText(Environment.NewLine + "=======================================");
                             form1.richTextBox1.AppendText(Environment.NewLine + "[" + DateTime.Now.ToString("h:mm:ss tt") + "] This next process will take awhile (with no sign of progress)... Please be patient.");
                             form1.richTextBox1.ScrollToCaret();
                         }));
                     }
                             ));
                     form1.richTextBox1.ScrollToCaret();
                     startImport = true;
                     enterThread.Start();
                 }
                 else
                 {
                     if (outLine.Data.Contains("npm install") || outLine.Data.Contains("electron-forge package") || outLine.Data.Contains("asar extract"))
                     {
                         form1.richTextBox1.AppendText(Environment.NewLine + "=======================================");
                         form1.richTextBox1.AppendText(Environment.NewLine + "=======================================");
                         form1.richTextBox1.AppendText(Environment.NewLine + "=======================================");
                         form1.richTextBox1.AppendText(Environment.NewLine + "[" + DateTime.Now.ToString("h:mm:ss tt") + "] This next process will take awhile (with no sign of progress)... Please be patient.");
                     }
                     if (outLine.Data.Contains("Thanks for using ") && outLine.Data.Contains("electron-forge"))
                     {
                         Installer.StartModify(SW, form1.playsDirectory, form1.VERSION);
                     }
                     if (outLine.Data.Contains("npm ERR!"))
                     {
                         form1.TopMost = true;
                         System.Windows.Forms.MessageBox.Show("An unhandled error has occurred during the install, It is possible that the installation has corrupted.\nTry restarting your computer and turn off anti-virus before installing.\n\nReport this issue by copying the logs and sending it to a developer.");
                         form1.TopMost = false;
                     }
                     if (outLine.Data.Contains("'nodejs-portable.exe' is not recognized"))
                     {
                         form1.TopMost = true;
                         System.Windows.Forms.MessageBox.Show("'nodejs-portable.exe' is missing from the working directory.");
                         form1.TopMost = false;
                     }
                     if (outLine.Data.Contains(">exit"))
                     {
                         form1.richTextBox1.AppendText(Environment.NewLine + "=======================================");
                         form1.richTextBox1.AppendText(Environment.NewLine + "=======================================");
                         form1.richTextBox1.AppendText(Environment.NewLine + "=======================================");
                         form1.richTextBox1.AppendText(Environment.NewLine + "[" + DateTime.Now.ToString("h:mm:ss tt") + "] Installation Complete!");
                         form1.Invoke(new MethodInvoker(delegate { form1.InstallComplete(); }));
                     }
                     form1.richTextBox1.AppendText(Environment.NewLine + "[" + DateTime.Now.ToString("h:mm:ss tt") + "] " + outLine.Data.ToString());
                     form1.richTextBox1.ScrollToCaret();
                 }
             }));
         }
     }
 }