Progress.cs 971 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using Terminal.Gui;
  3. namespace UICatalog {
  4. //
  5. // This would be a great scenario to show of threading (Issue #471)
  6. //
  7. [ScenarioMetadata (Name: "Progress", Description: "Shows off ProgressBar.")]
  8. [ScenarioCategory ("Controls")]
  9. class Progress : Scenario {
  10. private ProgressBar _progressBar;
  11. public override void Setup ()
  12. {
  13. Win.Add (new Button ("Start") {
  14. X = Pos.Center () - 20,
  15. Y = Pos.Center () - 5,
  16. Clicked = () => Start ()
  17. }); ;
  18. Win.Add (new Button ("Stop") {
  19. X = Pos.Center () + 10,
  20. Y = Pos.Center () - 5,
  21. Clicked = () => Stop()
  22. });
  23. _progressBar = new ProgressBar () {
  24. X = Pos.Center (),
  25. // BUGBUG: If you remove the +1 below the control is drawn at top?!?!
  26. Y = Pos.Center ()+1,
  27. Width = 30,
  28. Fraction = 0.25F,
  29. };
  30. Win.Add (_progressBar);
  31. }
  32. private void Start ()
  33. {
  34. _progressBar.Fraction = 0F;
  35. }
  36. private void Stop ()
  37. {
  38. _progressBar.Fraction = 1F;
  39. }
  40. }
  41. }