App.xaml.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using AIPractice.LabellerServer.Managers;
  2. using System;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Threading;
  6. using System.Windows;
  7. namespace AIPractice.LabellerServer
  8. {
  9. /// <summary>
  10. /// Interaction logic for App.xaml
  11. /// </summary>
  12. public partial class App : Application
  13. {
  14. private LabellerServer _labellerServer;
  15. protected override void OnStartup(StartupEventArgs e)
  16. {
  17. if (e.Args.Contains("DelayStart"))
  18. {
  19. Thread.Sleep(3000);
  20. }
  21. if (Environment.Is64BitProcess)
  22. {
  23. File.Copy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "sqlite3.x64.dll"), Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "sqlite3.dll"), true);
  24. }
  25. else
  26. {
  27. File.Copy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "sqlite3.x86.dll"), Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "sqlite3.dll"), true);
  28. }
  29. ManagerContainer.RegisterManager<ILabelManager>(new LabelManager());
  30. ManagerContainer.RegisterManager<IDataManager>(new DataManager());
  31. _labellerServer = new LabellerServer();
  32. _labellerServer.Start();
  33. base.OnStartup(e);
  34. }
  35. protected override void OnExit(ExitEventArgs e)
  36. {
  37. _labellerServer.Stop();
  38. base.OnExit(e);
  39. }
  40. }
  41. }