Exemple #1
0
        public void Run()
        {
            try {
                //create config file for overviewer to use
                string configFile = CreateConfig();

                main.Dispatcher.Invoke(() => {
                    main.console.AppendMsg("Created config file in " + ovPath + "\\" + configFile);
                });

                //create overviewer process
                ovProcess = new Process {
                    StartInfo = new ProcessStartInfo()
                    {
                        WindowStyle            = ProcessWindowStyle.Hidden,
                        FileName               = "cmd.exe",
                        WorkingDirectory       = ovPath,
                        Arguments              = "/C overviewer.exe --config=" + configFile,
                        UseShellExecute        = false,
                        RedirectStandardOutput = true,
                        CreateNoWindow         = true
                    }
                };

                if (RENDER)
                {
                    main.Dispatcher.Invoke(() => {
                        main.console.AppendMsg("Starting Overviewer process using "
                                               + (profile.ThreadCount < 1 ? "all" : "" + profile.ThreadCount)
                                               + " threads");
                    });

                    ovProcess.Start();
                }


                // print output and update progress bar
                while (!ovProcess.StandardOutput.EndOfStream)
                {
                    string line = ovProcess.StandardOutput.ReadLine();

                    main.Dispatcher.Invoke(() => {
                        main.console.Append("\t" + line, ColorCode.OV);
                        //set progress
                        if (line.Contains("complete"))
                        {
                            if (int.TryParse(line.Split('.')[1].Substring(2).Split('%')[0],
                                             out int perc))
                            {
                                main.SetProgress(perc);
                            }

                            if (line.Contains("100% complete."))
                            {
                                main.FinishProgress();
                            }
                        }
                    });
                }
            } catch (Exception e) {
                Console.WriteLine(e.StackTrace);
                main.Dispatcher.Invoke(() => {
                    main.console.AppendError("Exception during Launch: " + e.Message);
                });
            } finally {
                if (running)
                {
                    Finish();
                }
            }
        }