Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
64 lines (54 loc) · 2.37 KB
/
Copy pathProgram.cs
File metadata and controls
64 lines (54 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.IO;
using Avalonia;
using Projektanker.Icons.Avalonia;
using Projektanker.Icons.Avalonia.FontAwesome;
namespace MissionPlanner;
sealed class Program {
[STAThread]
public static void Main(string[] args) {
if (args.Length == 3 && args[0] == "--mcp-stdio" && args[1] == "--port" && int.TryParse(args[2], out int mcpPort)) {
try { Environment.ExitCode = Services.Mcp.McpStdioBridge.RunAsync(mcpPort, Console.In, Console.Out).GetAwaiter().GetResult(); }
catch (Exception e) { Console.Error.WriteLine("Mission Planner MCP connection failed: " + e.GetType().Name); Environment.ExitCode = 1; }
return;
}
if (args.Length == 2 && args[0] == "--mcp-terminal-session") {
try { Environment.ExitCode = Services.Mcp.McpTerminalLaunch.RunHandoffAsync(args[1]).GetAwaiter().GetResult(); }
catch (Exception e) { Console.Error.WriteLine("Mission Planner agent launch failed: " + e.GetType().Name); Environment.ExitCode = 1; }
return;
}
Services.AppPaths.Initialize();
AppDomain.CurrentDomain.UnhandledException += (_, e) => LogCrash(e.ExceptionObject as Exception);
System.Threading.Tasks.TaskScheduler.UnobservedTaskException += (_, e) => {
LogCrash(e.Exception);
e.SetObserved();
};
IconProvider.Current.Register<FontAwesomeIconProvider>();
try {
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
} catch (Exception ex) {
LogCrash(ex);
throw;
}
}
private static void LogCrash(Exception? ex) {
if (ex == null) {
return;
}
try {
Directory.CreateDirectory(Path.GetDirectoryName(Services.AppPaths.CrashLogPath)!);
File.AppendAllText(Services.AppPaths.CrashLogPath, $"---- crash ----\n{ex}\n\n");
} catch {
}
}
public static AppBuilder BuildAvaloniaApp() =>
AppBuilder.Configure<App>()
.UsePlatformDetect()
// Embed popups in the top-level window instead of creating separate X11 override-redirect
// windows. Avalonia's X11 ManagedPopupPositioner mislocates ComboBox dropdowns under HiDPI
// + GNOME fractional scaling (e.g. the FlightData "Set Mode" list flipping over the HUD or
// jumping to the top-left corner). Overlay popups bypass that positioner entirely.
.With(new X11PlatformOptions { OverlayPopups = true })
.WithInterFont()
.LogToTrace();
}