ProgressBar.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using BansheeEngine;
  3. namespace BansheeEditor
  4. {
  5. public class ProgressBar : ModalWindow
  6. {
  7. private static ProgressBar instance;
  8. private GUIProgressBar progressBar;
  9. private LocString message;
  10. public float Percent
  11. {
  12. set { progressBar.Percent = value; }
  13. get { return progressBar.Percent; }
  14. }
  15. public static void Show(LocString title, float percent)
  16. {
  17. Show(title, "", percent);
  18. }
  19. public static void Show(LocString title, LocString message, float percent)
  20. {
  21. if (instance == null)
  22. instance = new ProgressBar();
  23. instance.Width = 250;
  24. instance.Height = 75;
  25. instance.Title = title;
  26. instance.Percent = percent;
  27. instance.message = message;
  28. }
  29. public static void Hide()
  30. {
  31. if (instance != null)
  32. instance.Close();
  33. instance = null;
  34. }
  35. protected ProgressBar()
  36. :base(false)
  37. { }
  38. private void OnInitialize()
  39. {
  40. progressBar = new GUIProgressBar();
  41. GUILayoutY layoutY = GUI.layout.AddLayoutY();
  42. layoutY.AddFlexibleSpace();
  43. GUILayoutX messageLayout = layoutY.AddLayoutX();
  44. messageLayout.AddFlexibleSpace();
  45. messageLayout.AddElement(new GUILabel(message));
  46. messageLayout.AddFlexibleSpace();
  47. layoutY.AddSpace(10);
  48. GUILayoutX barLayout = layoutY.AddLayoutX();
  49. barLayout.AddSpace(10);
  50. barLayout.AddElement(progressBar);
  51. barLayout.AddSpace(10);
  52. layoutY.AddFlexibleSpace();
  53. }
  54. }
  55. }