Program.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using ComputerSalesApp.Services;
  2. using ComputerSalesApp.UI;
  3. namespace ComputerSalesApp;
  4. internal static class Program
  5. {
  6. [STAThread]
  7. private static void Main()
  8. {
  9. Application.SetHighDpiMode(HighDpiMode.SystemAware);
  10. Application.EnableVisualStyles();
  11. Application.SetCompatibleTextRenderingDefault(false);
  12. try
  13. {
  14. bool restart;
  15. do
  16. {
  17. restart = false;
  18. using var loginForm = new LoginForm();
  19. if (loginForm.ShowDialog() != DialogResult.OK || loginForm.Session == null)
  20. {
  21. break;
  22. }
  23. using var mainForm = new MainForm(loginForm.Session);
  24. Application.Run(mainForm);
  25. restart = mainForm.LogoutRequested;
  26. }
  27. while (restart);
  28. }
  29. catch (Exception ex)
  30. {
  31. ErrorHandler.Show("Критическая ошибка", "Приложение не смогло продолжить работу.", ex);
  32. }
  33. }
  34. }