ProgressBar.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 GUILabel messageLabel;
  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.Initialize(title, message, percent);
  24. }
  25. private void Initialize(LocString title, LocString message, float percent)
  26. {
  27. Width = 350;
  28. Height = 75;
  29. Title = title;
  30. Percent = percent;
  31. messageLabel.SetContent(message);
  32. }
  33. public static void Hide()
  34. {
  35. if (instance != null)
  36. instance.Close();
  37. instance = null;
  38. }
  39. protected ProgressBar()
  40. :base(false)
  41. { }
  42. private void OnInitialize()
  43. {
  44. progressBar = new GUIProgressBar();
  45. messageLabel = new GUILabel("");
  46. GUILayoutY layoutY = GUI.AddLayoutY();
  47. layoutY.AddFlexibleSpace();
  48. GUILayoutX messageLayout = layoutY.AddLayoutX();
  49. messageLayout.AddFlexibleSpace();
  50. messageLayout.AddElement(messageLabel);
  51. messageLayout.AddFlexibleSpace();
  52. layoutY.AddSpace(10);
  53. GUILayoutX barLayout = layoutY.AddLayoutX();
  54. barLayout.AddSpace(30);
  55. barLayout.AddElement(progressBar);
  56. barLayout.AddSpace(30);
  57. layoutY.AddFlexibleSpace();
  58. }
  59. }
  60. }