Program.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Diagnostics;
  3. using System.Linq;
  4. using System.Threading;
  5. using Avalonia;
  6. using Avalonia.Skia;
  7. using Avalonia.ReactiveUI;
  8. namespace ControlCatalog.NetCore
  9. {
  10. static class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. Thread.CurrentThread.TrySetApartmentState(ApartmentState.STA);
  15. if (args.Contains("--wait-for-attach"))
  16. {
  17. Console.WriteLine("Attach debugger and use 'Set next statement'");
  18. while (true)
  19. {
  20. Thread.Sleep(100);
  21. if (Debugger.IsAttached)
  22. break;
  23. }
  24. }
  25. if (args.Contains("--fbdev"))
  26. AppBuilder.Configure<App>().InitializeWithLinuxFramebuffer(tl =>
  27. {
  28. tl.Content = new MainView();
  29. System.Threading.ThreadPool.QueueUserWorkItem(_ => ConsoleSilencer());
  30. });
  31. else
  32. BuildAvaloniaApp().Start(AppMain, args);
  33. }
  34. static void AppMain(Application app, string[] args)
  35. {
  36. app.Run(new MainWindow());
  37. }
  38. /// <summary>
  39. /// This method is needed for IDE previewer infrastructure
  40. /// </summary>
  41. public static AppBuilder BuildAvaloniaApp()
  42. => AppBuilder.Configure<App>()
  43. .UsePlatformDetect()
  44. .UseSkia()
  45. .UseReactiveUI()
  46. .UseDataGrid();
  47. static void ConsoleSilencer()
  48. {
  49. Console.CursorVisible = false;
  50. while (true)
  51. Console.ReadKey(true);
  52. }
  53. }
  54. }