From da778f05ac30a681eeb71735dd21fc86eaef4a23 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Fri, 7 Oct 2022 00:16:07 +0800 Subject: [PATCH] Update --- extra/exe-builder/Program.cs | 42 ++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/extra/exe-builder/Program.cs b/extra/exe-builder/Program.cs index 5516a1ff0..840bc873c 100644 --- a/extra/exe-builder/Program.cs +++ b/extra/exe-builder/Program.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Drawing; using System.Linq; using System.Reflection; @@ -23,6 +24,7 @@ namespace UptimeKuma { public class UptimeKumaApplicationContext : ApplicationContext { private NotifyIcon trayIcon; + private Process process; public UptimeKumaApplicationContext() { @@ -31,19 +33,41 @@ namespace UptimeKuma { trayIcon.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); trayIcon.ContextMenu = new ContextMenu(new MenuItem[] { + new MenuItem("Open", Open), new MenuItem("Check for Update", CheckForUpdate), new MenuItem("About", About), new MenuItem("Exit", Exit), }); trayIcon.Visible = true; + + var startInfo = new ProcessStartInfo(); + startInfo.FileName = "node/node.exe"; + startInfo.Arguments = "server/server.js"; + startInfo.RedirectStandardOutput = true; + startInfo.RedirectStandardError = true; + startInfo.UseShellExecute = false; + startInfo.CreateNoWindow = true; + startInfo.WorkingDirectory = "core"; + + process = new Process(); + process.StartInfo = startInfo; + process.EnableRaisingEvents = true; + try { + process.Start(); + Open(null, null); + } catch (Exception e) { + MessageBox.Show("Startup failed: " + e.Message, "Uptime Kuma Error"); + throw; + } } - void Exit(object sender, EventArgs e) - { - // Hide tray icon, otherwise it will remain shown until user mouses over it - trayIcon.Visible = false; - Application.Exit(); + void Open(object sender, EventArgs e) { + Process.Start("http://localhost:3001"); + } + + void CheckForUpdate(object sender, EventArgs e) { + } void About(object sender, EventArgs e) @@ -51,8 +75,12 @@ namespace UptimeKuma { MessageBox.Show("Uptime Kuma v1.0.0" + Environment.NewLine + "© 2022 Louis Lam", "Info"); } - void CheckForUpdate(object sneder, EventArgs e) { - + void Exit(object sender, EventArgs e) + { + // Hide tray icon, otherwise it will remain shown until user mouses over it + trayIcon.Visible = false; + process.Close(); + Application.Exit(); } } }