updated docs further, added UICatalog API, clean up

This commit is contained in:
Charlie Kindel
2020-05-23 19:39:15 -06:00
parent b2fc685622
commit 78cd1bbd1e
97 changed files with 13953 additions and 2720 deletions

View File

@@ -6,35 +6,62 @@ using Terminal.Gui;
namespace UICatalog {
/// <summary>
/// Base class for each demo/scenario. To define a new <see cref="Scenario"/> simply
///
/// 1) declare a class derived from <see cref="Scenario"/>,
/// 2) Set Name and Description as appropriate using [<see cref="ScenarioMetadata"/>] attribute
/// 3) Set one or more categories with the [<see cref="ScenarioCatagory"/>] attribute
/// 4) Implement Setup.
/// 5) Optionally, implement <see cref="Init"/> and/or <see cref="Run"/>.
///
/// This program uses reflection to find all scenarios and adds them to the
/// ListViews. Press ENTER to run the selected <see cref="Scenario"/>. Press CTRL-Q to exit it.
/// <para>Base class for each demo/scenario.</para>
/// <para>
/// To define a new scenario:
/// <list type="number">
/// <item><description>Create a new <c>.cs</c> file in the <cs>Scenarios</cs> directory that derives from <see cref="Scenario"/>.</description></item>
/// <item><description>Annotate the <see cref="Scenario"/> derived class with a <see cref="Scenario.ScenarioMetaData"/> attribute specifying the scenario's name and description.</description></item>
/// <item><description>Add one or more <see cref="Scenario.ScenarioCategory"/> attributes to the class specifying which categories the sceanrio belongs to. If you don't specify a category the sceanrio will show up in "All".</description></item>
/// <item><description>Implement the <see cref="Setup"/> override which will be called when a user selects the scenario to run.</description></item>
/// <item><description>Optionally, implement the <see cref="Init(Toplevel)"/> and/or <see cref="Run"/> overrides to provide a custom implementation.</description></item>
/// </list>
/// </para>
/// <para>
/// The UI Catalog program uses reflection to find all scenarios and adds them to the
/// ListViews. Press ENTER to run the selected scenario. Press CTRL-Q to exit it. /
/// </para>
/// </summary>
/// <example>
/// The example below is provided in the `Scenarios` directory as a generic sample that can be copied and re-named:
/// <code>
/// using Terminal.Gui;
///
/// namespace UICatalog {
/// [ScenarioMetadata (Name: "Generic", Description: "Generic sample - A template for creating new Scenarios")]
/// [ScenarioCategory ("Controls")]
/// class MyScenario : Scenario {
/// public override void Setup ()
/// {
/// // Put your scenario code here, e.g.
/// Win.Add (new Button ("Press me!") {
/// X = Pos.Center (),
/// Y = Pos.Center (),
/// Clicked = () => MessageBox.Query (20, 7, "Hi", "Neat?", "Yes", "No")
/// });
/// }
/// }
/// }
/// </code>
/// </example>
public class Scenario : IDisposable {
private bool _disposedValue;
/// <summary>
/// The <see cref="Toplevel"/> for the <see cref="Scenario"/>. This should be set to <see cref="Application.Top"/> in most cases.
/// The Top level for the <see cref="Scenario"/>. This should be set to <see cref="Terminal.Gui.Application.Top"/> in most cases.
/// </summary>
public Toplevel Top { get; set; }
/// <summary>
/// The <see cref="Window"/> for the <see cref="Scenario"/>. This should be set within <see cref="Application.Top"/>` in most cases.
/// The Window for the <see cref="Scenario"/>. This should be set within the <see cref="Terminal.Gui.Application.Top"/> in most cases.
/// </summary>
public Window Win { get; set; }
/// <summary>
/// Helper that provides the default <see cref="Window"/> implementation with a frame and
/// Helper that provides the default <see cref="Terminal.Gui.Window"/> implementation with a frame and
/// label showing the name of the <see cref="Scenario"/> and logic to exit back to
/// the <see cref="Scenario"/> picker UI.
/// Override Init to provide any `Toplevel` behavior needed.
/// the Scenario picker UI.
/// Override <see cref="Init(Toplevel)"/> to provide any <see cref="Terminal.Gui.Toplevel"/> behavior needed.
/// </summary>
/// <param name="top"></param>
/// <remarks>