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:
maj00r
2026-11-01 16:06:16 +01:00
parent 6e45f5de59
commit 2ebff91316
9 changed files with 670 additions and 124 deletions

View File

@@ -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;