|
|
|
|
@ -1,14 +1,13 @@
@@ -1,14 +1,13 @@
|
|
|
|
|
using ErsatzTV.Core; |
|
|
|
|
using System.Diagnostics; |
|
|
|
|
using Asmichi.ProcessManagement; |
|
|
|
|
using System.Reflection; |
|
|
|
|
using CliWrap; |
|
|
|
|
|
|
|
|
|
namespace ErsatzTV_Windows; |
|
|
|
|
|
|
|
|
|
public class TrayApplicationContext : ApplicationContext |
|
|
|
|
{ |
|
|
|
|
private readonly NotifyIcon _trayIcon; |
|
|
|
|
private readonly IChildProcess? _childProcess; |
|
|
|
|
private readonly CancellationTokenSource _tokenSource; |
|
|
|
|
|
|
|
|
|
public TrayApplicationContext() |
|
|
|
|
{ |
|
|
|
|
@ -19,6 +18,8 @@ public class TrayApplicationContext : ApplicationContext
@@ -19,6 +18,8 @@ public class TrayApplicationContext : ApplicationContext
|
|
|
|
|
Visible = true |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
_tokenSource = new CancellationTokenSource(); |
|
|
|
|
|
|
|
|
|
AddMenuItem("Launch Web UI", LaunchWebUI); |
|
|
|
|
AddMenuItem("Show Logs", ShowLogs); |
|
|
|
|
_trayIcon.ContextMenuStrip.Items.Add(new ToolStripSeparator()); |
|
|
|
|
@ -29,8 +30,11 @@ public class TrayApplicationContext : ApplicationContext
@@ -29,8 +30,11 @@ public class TrayApplicationContext : ApplicationContext
|
|
|
|
|
|
|
|
|
|
if (File.Exists(exe)) |
|
|
|
|
{ |
|
|
|
|
var si = new ChildProcessStartInfo(exe); |
|
|
|
|
_childProcess = ChildProcess.Start(si); |
|
|
|
|
|
|
|
|
|
Cli.Wrap(exe) |
|
|
|
|
.WithWorkingDirectory(folder) |
|
|
|
|
.WithValidation(CommandResultValidation.None) |
|
|
|
|
.ExecuteAsync(_tokenSource.Token); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -64,7 +68,7 @@ public class TrayApplicationContext : ApplicationContext
@@ -64,7 +68,7 @@ public class TrayApplicationContext : ApplicationContext
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool disposing) |
|
|
|
|
{ |
|
|
|
|
_childProcess?.Dispose(); |
|
|
|
|
_tokenSource?.Cancel(); |
|
|
|
|
base.Dispose(disposing); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|