fe1da03f66
Forward a direct LuminaryWindow launch through the bundle launcher so it starts desktop mode instead of showing a signed-out page. Refresh the guide screenshots and version the release as 0.5.0 Beta.
88 lines
2.8 KiB
C#
88 lines
2.8 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Luminary;
|
|
|
|
internal static class Program
|
|
{
|
|
[STAThread]
|
|
private static void Main(string[] args)
|
|
{
|
|
var url = "http://127.0.0.1:8787";
|
|
var urlProvided = false;
|
|
for (var i = 0; i < args.Length; i++)
|
|
{
|
|
var arg = args[i];
|
|
if (arg is "--url" or "-url")
|
|
{
|
|
if (i + 1 < args.Length) url = args[i + 1];
|
|
urlProvided = true;
|
|
break;
|
|
}
|
|
if (arg.StartsWith("--url=", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
url = arg[6..];
|
|
urlProvided = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
// This exe is the window the launcher opens. If someone double-clicks it
|
|
// directly there is no server in desktop mode, or port 8787 may belong
|
|
// to a full sign-in server. Start the real launcher and let it choose the
|
|
// port, set LUMINARY_LOCAL=1 and open this window with --url.
|
|
if (!urlProvided)
|
|
{
|
|
if (StartBundleLauncher()) return;
|
|
|
|
MessageBox.Show(
|
|
"LuminaryWindow.exe is only the app window.\n\n" +
|
|
"Start Luminary.exe (or Luminary.cmd) from the Luminary folder instead.",
|
|
"Luminary",
|
|
MessageBoxButtons.OK,
|
|
MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
|
|
Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);
|
|
Application.EnableVisualStyles();
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
Application.Run(new MainForm(url));
|
|
}
|
|
|
|
/// <summary>
|
|
/// A direct window launch forwards to the bundle launcher. That launcher
|
|
/// starts the local server with the correct desktop-mode environment and
|
|
/// then reopens this window with --url. Returns false when this file is not
|
|
/// inside a complete bundle.
|
|
/// </summary>
|
|
private static bool StartBundleLauncher()
|
|
{
|
|
// Environment.ProcessPath is the exe itself even in a single-file publish;
|
|
// AppContext.BaseDirectory is only a fallback.
|
|
var root = Path.GetDirectoryName(Environment.ProcessPath) ?? AppContext.BaseDirectory;
|
|
foreach (var name in new[] { "Luminary.exe", "Luminary.vbs", "Luminary.cmd" })
|
|
{
|
|
var launcher = Path.Combine(root, name);
|
|
if (!File.Exists(launcher)) continue;
|
|
|
|
try
|
|
{
|
|
Process.Start(new ProcessStartInfo(launcher)
|
|
{
|
|
WorkingDirectory = root,
|
|
UseShellExecute = true,
|
|
});
|
|
return true;
|
|
}
|
|
catch
|
|
{
|
|
// Try the next entry point before giving up.
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|