diff --git a/UICatalog/Program.cs b/UICatalog/Program.cs index f81df07df..17315ac5f 100644 --- a/UICatalog/Program.cs +++ b/UICatalog/Program.cs @@ -62,7 +62,7 @@ namespace UICatalog { new MenuBarItem ("_File", new MenuItem [] { new MenuItem ("_Quit", "", () => Application.RequestStop() ) }), - new MenuBarItem ("_About...", "About this app", () => MessageBox.Query (0, 6, "About UI Catalog", "UI Catalog is a comprehensive sample library for Terminal.Gui", "Ok")), + new MenuBarItem ("_About...", "About this app", () => MessageBox.Query (0, 10, "About UI Catalog", "UI Catalog is a comprehensive sample library for Terminal.Gui", "Ok")), }); _leftPane = new Window ("Categories") { diff --git a/UICatalog/README.md b/UICatalog/README.md index 6f6b019f8..49eebf94c 100644 --- a/UICatalog/README.md +++ b/UICatalog/README.md @@ -119,4 +119,4 @@ For complete control, the `Init` and `Run` overrides can be implemented. The `ba - Use the `Bug Rero` Category for `Scnarios` that reproduce bugs. - Include the Github Issue # in the Description. - Once the bug has been fixed in `master` submit another PR to remove the `Scenario` (or modify it to provide a good regression test). -- Tag bugs or suggestions for `UI Catalog` in the main `Terminal.Gui` Github Issues with "UICatalog: ". \ No newline at end of file +- Tag bugs or suggestions for `UI Catalog` as [`Terminal.Gui` Github Issues](https://github.com/migueldeicaza/gui.cs/issues) with "UICatalog: ". \ No newline at end of file diff --git a/UICatalog/Scenario.cs b/UICatalog/Scenario.cs index e491a4c8e..b43821a4e 100644 --- a/UICatalog/Scenario.cs +++ b/UICatalog/Scenario.cs @@ -17,7 +17,9 @@ namespace UICatalog { /// The Main program uses reflection to find all sceanarios and adds them to the /// ListViews. Press ENTER to run the selected sceanrio. Press CTRL-Q to exit it. /// - public class Scenario { + public class Scenario : IDisposable { + private bool _disposedValue; + /// /// The Top level for the Scenario. This should be set to `Application.Top` in most cases. /// @@ -177,5 +179,25 @@ namespace UICatalog { } return objects; } + + protected virtual void Dispose (bool disposing) + { + if (!_disposedValue) { + if (disposing) { + // TODO: dispose managed state (managed objects) + } + + // TODO: free unmanaged resources (unmanaged objects) and override finalizer + // TODO: set large fields to null + _disposedValue = true; + } + } + + public void Dispose () + { + // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method + Dispose (disposing: true); + GC.SuppressFinalize (this); + } } } diff --git a/UICatalog/Scenarios/Progress.cs b/UICatalog/Scenarios/Progress.cs index 082d0590a..55ceeef16 100644 --- a/UICatalog/Scenarios/Progress.cs +++ b/UICatalog/Scenarios/Progress.cs @@ -1,4 +1,5 @@ using System; +using System.Threading; using Terminal.Gui; namespace UICatalog { @@ -11,6 +12,8 @@ namespace UICatalog { private ProgressBar _activityProgressBar; private ProgressBar _pulseProgressBar; + private Timer _timer; + public override void Setup () { Win.Add (new Button ("Start") { @@ -50,24 +53,40 @@ namespace UICatalog { Win.Add (_pulseProgressBar); } + protected override void Dispose (bool disposing) + { + _timer?.Dispose (); + _timer = null; + base.Dispose (disposing); + } + private void Pulse () { - if (_activityProgressBar.Fraction + 0.1F >= 1) { + if (_activityProgressBar.Fraction + 0.01F >= 1) { _activityProgressBar.Fraction = 0F; } else { - _activityProgressBar.Fraction += 0.1F; + _activityProgressBar.Fraction += 0.01F; } _pulseProgressBar.Pulse (); + } private void Start () { + _timer?.Dispose (); + _timer = null; + _activityProgressBar.Fraction = 0F; _pulseProgressBar.Fraction = 0F; + + _timer = new Timer ((o) => Application.MainLoop.Invoke (() => Pulse ()), null, 0, 250); } private void Stop () { + _timer?.Dispose (); + _timer = null; + _activityProgressBar.Fraction = 1F; _pulseProgressBar.Fraction = 1F; } diff --git a/UICatalog/screenshot.png b/UICatalog/screenshot.png index 093c770e3..c81878bf2 100644 Binary files a/UICatalog/screenshot.png and b/UICatalog/screenshot.png differ