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.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. .With(new X11PlatformOptions {EnableMultiTouch = true})
  45. .With(new Win32PlatformOptions {EnableMultitouch = true})
  46. .UseSkia()
  47. .UseReactiveUI();
  48. static void ConsoleSilencer()
  49. {
  50. Console.CursorVisible = false;
  51. while (true)
  52. Console.ReadKey(true);
  53. }
  54. }
  55. }