Program.cs 1.6 KB

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