mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-19 06:55:59 +01:00
Start the scenery editor from its own button and note launches
With no scenery selected the button starts a new one in the editor. Each launch notes the scenery, the timetable number and the vehicles for the tapes. Tools work on the selected scenery, and an emptied consist stays listed.
This commit is contained in:
@@ -18,7 +18,8 @@ public sealed class SystemProcessLauncher : IProcessLauncher
|
||||
}
|
||||
|
||||
public IProcessHandle? Start(string executablePath, IReadOnlyList<string> arguments, string? workingDirectory,
|
||||
bool captureErrors, out string? error)
|
||||
IReadOnlyDictionary<string, string> environment, bool captureErrors,
|
||||
out string? error)
|
||||
{
|
||||
var info = new ProcessStartInfo
|
||||
{
|
||||
@@ -29,6 +30,8 @@ public sealed class SystemProcessLauncher : IProcessLauncher
|
||||
};
|
||||
foreach (string argument in arguments)
|
||||
info.ArgumentList.Add(argument);
|
||||
foreach (var (name, value) in environment)
|
||||
info.Environment[name] = value;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -87,6 +90,22 @@ public sealed class SystemProcessLauncher : IProcessLauncher
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsRunning(string processName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var found = Process.GetProcessesByName(processName);
|
||||
foreach (var process in found)
|
||||
process.Dispose();
|
||||
return found.Length > 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.Log($"lookup {processName}", ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class ProcessHandle : IProcessHandle
|
||||
{
|
||||
private const int KeptErrorLines = 20;
|
||||
|
||||
Reference in New Issue
Block a user