Program.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.Skia;
  8. using Avalonia.ReactiveUI;
  9. namespace ControlCatalog.NetCore
  10. {
  11. static class Program
  12. {
  13. static int Main(string[] args)
  14. {
  15. Thread.CurrentThread.TrySetApartmentState(ApartmentState.STA);
  16. if (args.Contains("--wait-for-attach"))
  17. {
  18. Console.WriteLine("Attach debugger and use 'Set next statement'");
  19. while (true)
  20. {
  21. Thread.Sleep(100);
  22. if (Debugger.IsAttached)
  23. break;
  24. }
  25. }
  26. var builder = BuildAvaloniaApp();
  27. if (args.Contains("--fbdev"))
  28. {
  29. System.Threading.ThreadPool.QueueUserWorkItem(_ => ConsoleSilencer());
  30. return builder.StartLinuxFramebuffer(args);
  31. }
  32. else
  33. return builder.StartWithClassicDesktopLifetime(args);
  34. }
  35. /// <summary>
  36. /// This method is needed for IDE previewer infrastructure
  37. /// </summary>
  38. public static AppBuilder BuildAvaloniaApp()
  39. => AppBuilder.Configure<App>()
  40. .UsePlatformDetect()
  41. .With(new X11PlatformOptions {EnableMultiTouch = true})
  42. .With(new Win32PlatformOptions
  43. {
  44. EnableMultitouch = true,
  45. AllowEglInitialization = true
  46. })
  47. .UseSkia()
  48. .UseReactiveUI();
  49. static void ConsoleSilencer()
  50. {
  51. Console.CursorVisible = false;
  52. while (true)
  53. Console.ReadKey(true);
  54. }
  55. }
  56. }