App.paml.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Linq;
  3. using Perspex;
  4. using Perspex.Controls;
  5. using Perspex.Diagnostics;
  6. using Perspex.Markup.Xaml;
  7. using Perspex.Themes.Default;
  8. namespace ControlCatalog
  9. {
  10. class App : Application
  11. {
  12. public App()
  13. {
  14. RegisterServices();
  15. InitializeSubsystems(GetPlatformId());
  16. Styles = new DefaultTheme();
  17. InitializeComponent();
  18. }
  19. public static void AttachDevTools(Window window)
  20. {
  21. #if DEBUG
  22. DevTools.Attach(window);
  23. #endif
  24. }
  25. static void Main(string[] args)
  26. {
  27. var app = new App();
  28. var window = new MainWindow();
  29. window.Show();
  30. app.Run(window);
  31. }
  32. private void InitializeComponent()
  33. {
  34. PerspexXamlLoader.Load(this);
  35. }
  36. private int GetPlatformId()
  37. {
  38. var args = Environment.GetCommandLineArgs();
  39. if (args.Contains("--gtk"))
  40. {
  41. return (int)PlatformID.Unix;
  42. }
  43. else
  44. {
  45. return (int)Environment.OSVersion.Platform;
  46. }
  47. }
  48. }
  49. }