Program.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Diagnostics;
  3. using System.Linq;
  4. using System.Threading;
  5. using Avalonia;
  6. using Avalonia.Controls;
  7. using Avalonia.LinuxFramebuffer.Output;
  8. using Avalonia.Skia;
  9. using Avalonia.ReactiveUI;
  10. namespace ControlCatalog.NetCore
  11. {
  12. static class Program
  13. {
  14. static int Main(string[] args)
  15. {
  16. Thread.CurrentThread.TrySetApartmentState(ApartmentState.STA);
  17. if (args.Contains("--wait-for-attach"))
  18. {
  19. Console.WriteLine("Attach debugger and use 'Set next statement'");
  20. while (true)
  21. {
  22. Thread.Sleep(100);
  23. if (Debugger.IsAttached)
  24. break;
  25. }
  26. }
  27. var builder = BuildAvaloniaApp();
  28. if (args.Contains("--fbdev"))
  29. {
  30. SilenceConsole();
  31. return builder.StartLinuxFbDev(args);
  32. }
  33. else if (args.Contains("--drm"))
  34. {
  35. SilenceConsole();
  36. return builder.StartLinuxDrm(args);
  37. }
  38. else
  39. return builder.StartWithClassicDesktopLifetime(args);
  40. }
  41. /// <summary>
  42. /// This method is needed for IDE previewer infrastructure
  43. /// </summary>
  44. public static AppBuilder BuildAvaloniaApp()
  45. => AppBuilder.Configure<App>()
  46. .UsePlatformDetect()
  47. .With(new X11PlatformOptions {EnableMultiTouch = true})
  48. .With(new Win32PlatformOptions
  49. {
  50. EnableMultitouch = true,
  51. AllowEglInitialization = true
  52. })
  53. .UseSkia()
  54. .UseReactiveUI();
  55. static void SilenceConsole()
  56. {
  57. new Thread(() =>
  58. {
  59. Console.CursorVisible = false;
  60. while (true)
  61. Console.ReadKey(true);
  62. }) {IsBackground = true}.Start();
  63. }
  64. }
  65. }