Program.cs 2.1 KB

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