ConfirmImportInProgressWindow.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2019 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. using bs;
  5. namespace bs.Editor
  6. {
  7. /** @addtogroup Windows
  8. * @{
  9. */
  10. /// <summary>
  11. /// A modal window that notifies the user that resource import is in the progress and allows him to wait until it
  12. /// finishes or to cancel import.
  13. /// </summary>
  14. public class ConfirmImportInProgressWindow : ModalWindow
  15. {
  16. private static ConfirmImportInProgressWindow instance;
  17. private GUIProgressBar progressBar;
  18. private GUILabel messageLabel;
  19. private GUIButton cancelImport;
  20. /// <summary>
  21. /// Shows the window.
  22. /// </summary>
  23. public static void Show()
  24. {
  25. if (instance == null)
  26. {
  27. instance = new ConfirmImportInProgressWindow();
  28. instance.BuildGUI();
  29. }
  30. }
  31. /// <summary>
  32. /// Hides the window.
  33. /// </summary>
  34. public static void Hide()
  35. {
  36. if (instance != null)
  37. instance.Close();
  38. instance = null;
  39. }
  40. /// <summary>
  41. /// Creates a window.
  42. /// </summary>
  43. protected ConfirmImportInProgressWindow()
  44. : base(false)
  45. {
  46. Width = 350;
  47. Height = 180;
  48. Title = "Import still in progress";
  49. }
  50. private void BuildGUI()
  51. {
  52. progressBar = new GUIProgressBar();
  53. messageLabel = new GUILabel("", EditorStyles.MultiLineLabelCentered, GUIOption.FixedHeight(60));
  54. cancelImport = new GUIButton(new LocEdString("Cancel import"));
  55. cancelImport.OnClick += () =>
  56. {
  57. ProjectLibrary.CancelImport();
  58. cancelImport.Disabled = true;
  59. };
  60. GUILayoutY layoutY = GUI.AddLayoutY();
  61. layoutY.AddFlexibleSpace();
  62. GUILayoutX messageLayout = layoutY.AddLayoutX();
  63. messageLayout.AddSpace(15);
  64. messageLayout.AddElement(messageLabel);
  65. messageLayout.AddSpace(15);
  66. layoutY.AddSpace(10);
  67. GUILayoutX barLayout = layoutY.AddLayoutX();
  68. barLayout.AddSpace(30);
  69. barLayout.AddElement(progressBar);
  70. barLayout.AddSpace(30);
  71. layoutY.AddSpace(20);
  72. GUILayoutX buttonLayout = layoutY.AddLayoutX();
  73. buttonLayout.AddFlexibleSpace();
  74. buttonLayout.AddElement(cancelImport);
  75. buttonLayout.AddFlexibleSpace();
  76. layoutY.AddFlexibleSpace();
  77. messageLabel.SetContent(new LocEdString("Resource import is still in progress. You can wait until it " +
  78. "finishes or cancel import. \n\nNote that even when cancelling you will need to wait for active import threads to finish."));
  79. }
  80. private void OnEditorUpdate()
  81. {
  82. progressBar.Percent = ProjectLibrary.ImportProgressPercent;
  83. }
  84. }
  85. /** @} */
  86. }