Search Results for

    Show / Hide Table of Contents

    Class Scenario

    Base class for each demo/scenario.

    To define a new scenario:

    1. Create a new .cs file in the Scenarios directory that derives from Scenario.
    2. Annotate the Scenario derived class with a Scenario.ScenarioMetadata attribute specifying the scenario's name and description.
    3. Add one or more Scenario.ScenarioCategory attributes to the class specifying which categories the scenario belongs to. If you don't specify a category the scenario will show up in "_All".
    4. Implement the Setup() override which will be called when a user selects the scenario to run.
    5. Optionally, implement the and/or Run() overrides to provide a custom implementation.

    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. /

    Inheritance
    System.Object
    Scenario
    AllViewsTester
    Animation
    ASCIICustomButtonTest
    AutoSizeAndDirectionText
    BackgroundWorkerCollection
    BasicColors
    Borders
    BordersComparisons
    BordersOnFrameView
    BordersOnToplevel
    BordersOnWindow
    Buttons
    CenteredWindowInsideMdiContainerWindow
    CenteredWindowInsideWindow
    CharacterMap
    ClassExplorer
    Clipping
    CollectionNavigatorTester
    ColorPickers
    ComboBoxIteration
    ComputedLayout
    ContextMenus
    CsvEditor
    Dialogs
    DynamicMenuBar
    DynamicStatusBar
    Editor
    GraphViewExample
    HexEditor
    InteractiveTree
    InvertColors
    Keys
    LabelsAsLabels
    LineDrawing
    LineViewExample
    ListsAndCombos
    ListViewWithSelection
    MessageBoxes
    Mouse
    MultiColouredTable
    MyScenario
    Notepad
    Progress
    ProgressBarStyles
    RuneWidthGreaterThanOne
    RunTExample
    Scrolling
    SendKeys
    SingleBackgroundWorker
    Snake
    SyntaxHighlighting
    TableEditor
    TabViewExample
    Text
    TextAlignments
    TextAlignmentsAndDirections
    TextFormatterDemo
    TextViewAutocompletePopup
    Threading
    TimeAndDate
    TreeUseCases
    TreeViewFileSystem
    UnicodeInMenu
    VkeyPacketSimulator
    WindowsAndFrameViews
    WizardAsView
    Wizards
    Implements
    System.IDisposable
    Examples

    The example below is provided in the Scenarios directory as a generic sample that can be copied and re-named:

    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")
                });
            }
        }
    }
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    Namespace: UICatalog
    Assembly: UICatalog.dll
    Syntax
    public class Scenario : IDisposable

    Properties

    | Improve this Doc View Source

    Win

    The Window for the Scenario. This should be set to Top in most cases.

    Declaration
    public Window Win { get; set; }
    Property Value
    Type Description
    Window

    Methods

    | Improve this Doc View Source

    Dispose()

    Declaration
    public void Dispose()
    | Improve this Doc View Source

    Dispose(Boolean)

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing
    | Improve this Doc View Source

    GetCategories()

    Helper function to get the list of categories a Scenario belongs to (defined in Scenario.ScenarioCategory)

    Declaration
    public List<string> GetCategories()
    Returns
    Type Description
    System.Collections.Generic.List<System.String>

    list of category names

    | Improve this Doc View Source

    GetDescription()

    Helper to get the Scenario Description (defined in Scenario.ScenarioMetadata)

    Declaration
    public string GetDescription()
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    GetName()

    Helper to get the Scenario Name (defined in Scenario.ScenarioMetadata)

    Declaration
    public string GetName()
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    GetScenarios()

    Returns a list of all Scenario instanaces defined in the project, sorted by Name. https://stackoverflow.com/questions/5411694/get-all-inherited-classes-of-an-abstract-class

    Declaration
    public static List<Scenario> GetScenarios()
    Returns
    Type Description
    System.Collections.Generic.List<Scenario>
    | Improve this Doc View Source

    Init(ColorScheme)

    Helper that provides the default Window implementation with a frame and label showing the name of the Scenario and logic to exit back to the Scenario picker UI. Override Init(ColorScheme) to provide any Toplevel behavior needed.

    Declaration
    public virtual void Init(ColorScheme colorScheme)
    Parameters
    Type Name Description
    ColorScheme colorScheme

    The colorscheme to use.

    | Improve this Doc View Source

    RequestStop()

    Stops the scenario. Override to change shutdown behavior for the Scenario.

    Declaration
    public virtual void RequestStop()
    | Improve this Doc View Source

    Run()

    Runs the Scenario. Override to start the Scenario using a Toplevel different than Top.

    Declaration
    public virtual void Run()
    | Improve this Doc View Source

    Setup()

    Override this to implement the Scenario setup logic (create controls, etc...).

    Declaration
    public virtual void Setup()
    | Improve this Doc View Source

    ToString()

    Gets the Scenario Name + Description with the Description padded based on the longest known Scenario name.

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String
    Overrides
    System.Object.ToString()

    Implements

    System.IDisposable
    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX