Files
Terminal.Gui/docs/api/UICatalog/UICatalog.Scenario.html
2020-05-23 19:39:15 -06:00

470 lines
20 KiB
HTML

<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Class Scenario
</title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Class Scenario
">
<meta name="generator" content="docfx 2.53.1.0">
<link rel="shortcut icon" href="../../favicon.ico">
<link rel="stylesheet" href="../../styles/docfx.vendor.css">
<link rel="stylesheet" href="../../styles/docfx.css">
<link rel="stylesheet" href="../../styles/main.css">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<meta property="docfx:navrel" content="">
<meta property="docfx:tocrel" content="toc.html">
<meta property="docfx:rel" content="../../">
</head> <body data-spy="scroll" data-target="#affix" data-offset="120">
<div id="wrapper">
<header>
<nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../../index.html">
<img id="logo" class="svg" src="../../images/logo48.png" alt="">
</a>
</div>
<div class="collapse navbar-collapse" id="navbar">
<form class="navbar-form navbar-right" role="search" id="search">
<div class="form-group">
<input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
</div>
</form>
</div>
</div>
</nav>
<div class="subnav navbar navbar-default">
<div class="container hide-when-search" id="breadcrumb">
<ul class="breadcrumb">
<li></li>
</ul>
</div>
</div>
</header>
<div class="container body-content">
<div id="search-results">
<div class="search-list"></div>
<div class="sr-items">
<p><i class="glyphicon glyphicon-refresh index-loading"></i></p>
</div>
<ul id="pagination"></ul>
</div>
</div>
<div role="main" class="container body-content hide-when-search">
<div class="sidenav hide-when-search">
<a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
<div class="sidetoggle collapse" id="sidetoggle">
<div id="sidetoc"></div>
</div>
</div>
<div class="article row grid-right">
<div class="col-md-10">
<article class="content wrap" id="_content" data-uid="UICatalog.Scenario">
<h1 id="UICatalog_Scenario" data-uid="UICatalog.Scenario" class="text-break">Class Scenario
</h1>
<div class="markdown level0 summary"><p>Base class for each demo/scenario.</p>
<p>
To define a new scenario:
<ol><li>Create a new <code>.cs</code> file in the <cs>Scenarios</cs> directory that derives from <a class="xref" href="UICatalog.Scenario.html">Scenario</a>.</li><li>Annotate the <a class="xref" href="UICatalog.Scenario.html">Scenario</a> derived class with a <see cref="!:Scenario.ScenarioMetaData"></see> attribute specifying the scenario&apos;s name and description.</li><li>Add one or more <a class="xref" href="UICatalog.Scenario.ScenarioCategory.html">Scenario.ScenarioCategory</a> attributes to the class specifying which categories the sceanrio belongs to. If you don&apos;t specify a category the sceanrio will show up in &quot;All&quot;.</li><li>Implement the <a class="xref" href="UICatalog.Scenario.html#UICatalog_Scenario_Setup">Setup()</a> override which will be called when a user selects the scenario to run.</li><li>Optionally, implement the <a class="xref" href="UICatalog.Scenario.html#UICatalog_Scenario_Init_Terminal_Gui_Toplevel_">Init(Toplevel)</a> and/or <a class="xref" href="UICatalog.Scenario.html#UICatalog_Scenario_Run">Run()</a> overrides to provide a custom implementation.</li></ol>
</p>
<p>
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. /
</p>
</div>
<div class="markdown level0 conceptual"></div>
<div class="inheritance">
<h5>Inheritance</h5>
<div class="level0"><span class="xref">System.Object</span></div>
<div class="level1"><span class="xref">Scenario</span></div>
</div>
<div classs="implements">
<h5>Implements</h5>
<div><span class="xref">System.IDisposable</span></div>
</div>
<div class="inheritedMembers">
<h5>Inherited Members</h5>
<div>
<span class="xref">System.Object.Equals(System.Object)</span>
</div>
<div>
<span class="xref">System.Object.Equals(System.Object, System.Object)</span>
</div>
<div>
<span class="xref">System.Object.GetHashCode()</span>
</div>
<div>
<span class="xref">System.Object.GetType()</span>
</div>
<div>
<span class="xref">System.Object.MemberwiseClone()</span>
</div>
<div>
<span class="xref">System.Object.ReferenceEquals(System.Object, System.Object)</span>
</div>
</div>
<h6><strong>Namespace</strong>: <a class="xref" href="UICatalog.html">UICatalog</a></h6>
<h6><strong>Assembly</strong>: UICatalog.dll</h6>
<h5 id="UICatalog_Scenario_syntax">Syntax</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public class Scenario : IDisposable</code></pre>
</div>
<h5 id="UICatalog_Scenario_examples"><strong>Examples</strong></h5>
<p>The example below is provided in the <code>Scenarios</code> directory as a generic sample that can be copied and re-named:</p>
<pre><code>using Terminal.Gui;
namespace UICatalog {
[ScenarioMetadata (Name: &quot;Generic&quot;, Description: &quot;Generic sample - A template for creating new Scenarios&quot;)]
[ScenarioCategory (&quot;Controls&quot;)]
class MyScenario : Scenario {
public override void Setup ()
{
// Put your scenario code here, e.g.
Win.Add (new Button (&quot;Press me!&quot;) {
X = Pos.Center (),
Y = Pos.Center (),
Clicked = () => MessageBox.Query (20, 7, &quot;Hi&quot;, &quot;Neat?&quot;, &quot;Yes&quot;, &quot;No&quot;)
});
}
}
}</code></pre>
<h3 id="properties">Properties
</h3>
<a id="UICatalog_Scenario_Top_" data-uid="UICatalog.Scenario.Top*"></a>
<h4 id="UICatalog_Scenario_Top" data-uid="UICatalog.Scenario.Top">Top</h4>
<div class="markdown level1 summary"><p>The Top level for the <a class="xref" href="UICatalog.Scenario.html">Scenario</a>. This should be set to <a class="xref" href="../Terminal.Gui/Terminal.Gui.Application.html#Terminal_Gui_Application_Top">Top</a> in most cases.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public Toplevel Top { get; set; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="../Terminal.Gui/Terminal.Gui.Toplevel.html">Toplevel</a></td>
<td></td>
</tr>
</tbody>
</table>
<a id="UICatalog_Scenario_Win_" data-uid="UICatalog.Scenario.Win*"></a>
<h4 id="UICatalog_Scenario_Win" data-uid="UICatalog.Scenario.Win">Win</h4>
<div class="markdown level1 summary"><p>The Window for the <a class="xref" href="UICatalog.Scenario.html">Scenario</a>. This should be set within the <a class="xref" href="../Terminal.Gui/Terminal.Gui.Application.html#Terminal_Gui_Application_Top">Top</a> in most cases.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public Window Win { get; set; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="../Terminal.Gui/Terminal.Gui.Window.html">Window</a></td>
<td></td>
</tr>
</tbody>
</table>
<h3 id="methods">Methods
</h3>
<a id="UICatalog_Scenario_Dispose_" data-uid="UICatalog.Scenario.Dispose*"></a>
<h4 id="UICatalog_Scenario_Dispose" data-uid="UICatalog.Scenario.Dispose">Dispose()</h4>
<div class="markdown level1 summary"></div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public void Dispose()</code></pre>
</div>
<a id="UICatalog_Scenario_Dispose_" data-uid="UICatalog.Scenario.Dispose*"></a>
<h4 id="UICatalog_Scenario_Dispose_System_Boolean_" data-uid="UICatalog.Scenario.Dispose(System.Boolean)">Dispose(Boolean)</h4>
<div class="markdown level1 summary"></div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">protected virtual void Dispose(bool disposing)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Boolean</span></td>
<td><span class="parametername">disposing</span></td>
<td></td>
</tr>
</tbody>
</table>
<a id="UICatalog_Scenario_GetCategories_" data-uid="UICatalog.Scenario.GetCategories*"></a>
<h4 id="UICatalog_Scenario_GetCategories" data-uid="UICatalog.Scenario.GetCategories">GetCategories()</h4>
<div class="markdown level1 summary"><p>Helper function to get the list of categories a <a class="xref" href="UICatalog.Scenario.html">Scenario</a> belongs to (defined in <a class="xref" href="UICatalog.Scenario.ScenarioCategory.html">Scenario.ScenarioCategory</a>)</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public List&lt;string&gt; GetCategories()</code></pre>
</div>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Collections.Generic.List</span>&lt;<span class="xref">System.String</span>&gt;</td>
<td><p>list of catagory names</p>
</td>
</tr>
</tbody>
</table>
<a id="UICatalog_Scenario_GetDescription_" data-uid="UICatalog.Scenario.GetDescription*"></a>
<h4 id="UICatalog_Scenario_GetDescription" data-uid="UICatalog.Scenario.GetDescription">GetDescription()</h4>
<div class="markdown level1 summary"><p>Helper to get the <a class="xref" href="UICatalog.Scenario.html">Scenario</a> Description (defined in <a class="xref" href="UICatalog.Scenario.ScenarioMetadata.html">Scenario.ScenarioMetadata</a>)</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public string GetDescription()</code></pre>
</div>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.String</span></td>
<td></td>
</tr>
</tbody>
</table>
<a id="UICatalog_Scenario_GetName_" data-uid="UICatalog.Scenario.GetName*"></a>
<h4 id="UICatalog_Scenario_GetName" data-uid="UICatalog.Scenario.GetName">GetName()</h4>
<div class="markdown level1 summary"><p>Helper to get the <a class="xref" href="UICatalog.Scenario.html">Scenario</a> Name (defined in <a class="xref" href="UICatalog.Scenario.ScenarioMetadata.html">Scenario.ScenarioMetadata</a>)</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public string GetName()</code></pre>
</div>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.String</span></td>
<td></td>
</tr>
</tbody>
</table>
<a id="UICatalog_Scenario_Init_" data-uid="UICatalog.Scenario.Init*"></a>
<h4 id="UICatalog_Scenario_Init_Terminal_Gui_Toplevel_" data-uid="UICatalog.Scenario.Init(Terminal.Gui.Toplevel)">Init(Toplevel)</h4>
<div class="markdown level1 summary"><p>Helper that provides the default <a class="xref" href="../Terminal.Gui/Terminal.Gui.Window.html">Window</a> implementation with a frame and
label showing the name of the <a class="xref" href="UICatalog.Scenario.html">Scenario</a> and logic to exit back to
the Scenario picker UI.
Override <a class="xref" href="UICatalog.Scenario.html#UICatalog_Scenario_Init_Terminal_Gui_Toplevel_">Init(Toplevel)</a> to provide any <a class="xref" href="../Terminal.Gui/Terminal.Gui.Toplevel.html">Toplevel</a> behavior needed.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public virtual void Init(Toplevel top)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="../Terminal.Gui/Terminal.Gui.Toplevel.html">Toplevel</a></td>
<td><span class="parametername">top</span></td>
<td></td>
</tr>
</tbody>
</table>
<h5 id="UICatalog_Scenario_Init_Terminal_Gui_Toplevel__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>
Thg base implementation calls <a class="xref" href="../Terminal.Gui/Terminal.Gui.Application.html#Terminal_Gui_Application_Init">Init()</a>, sets <a class="xref" href="UICatalog.Scenario.html#UICatalog_Scenario_Top">Top</a> to the passed in <a class="xref" href="../Terminal.Gui/Terminal.Gui.Toplevel.html">Toplevel</a>, creates a <a class="xref" href="../Terminal.Gui/Terminal.Gui.Window.html">Window</a> for <a class="xref" href="UICatalog.Scenario.html#UICatalog_Scenario_Win">Win</a> and adds it to <a class="xref" href="UICatalog.Scenario.html#UICatalog_Scenario_Top">Top</a>.
</p>
<p>
Overrides that do not call the base.<a class="xref" href="UICatalog.Scenario.html#UICatalog_Scenario_Run">Run()</a>, must call <a class="xref" href="../Terminal.Gui/Terminal.Gui.Application.html#Terminal_Gui_Application_Init">Init()</a> before creating any views or calling other Terminal.Gui APIs.
</p>
</div>
<a id="UICatalog_Scenario_RequestStop_" data-uid="UICatalog.Scenario.RequestStop*"></a>
<h4 id="UICatalog_Scenario_RequestStop" data-uid="UICatalog.Scenario.RequestStop">RequestStop()</h4>
<div class="markdown level1 summary"><p>Stops the scenario. Override to change shutdown behavior for the <a class="xref" href="UICatalog.Scenario.html">Scenario</a>.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public virtual void RequestStop()</code></pre>
</div>
<a id="UICatalog_Scenario_Run_" data-uid="UICatalog.Scenario.Run*"></a>
<h4 id="UICatalog_Scenario_Run" data-uid="UICatalog.Scenario.Run">Run()</h4>
<div class="markdown level1 summary"><p>Runs the <a class="xref" href="UICatalog.Scenario.html">Scenario</a>. Override to start the <a class="xref" href="UICatalog.Scenario.html">Scenario</a> using a <a class="xref" href="../Terminal.Gui/Terminal.Gui.Toplevel.html">Toplevel</a> different than <code>Top</code>.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public virtual void Run()</code></pre>
</div>
<h5 id="UICatalog_Scenario_Run_remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>Overrides that do not call the base.<a class="xref" href="UICatalog.Scenario.html#UICatalog_Scenario_Run">Run()</a>, must call <a class="xref" href="../Terminal.Gui/Terminal.Gui.Application.html#Terminal_Gui_Application_Shutdown">Shutdown()</a> before returning.</p>
</div>
<a id="UICatalog_Scenario_Setup_" data-uid="UICatalog.Scenario.Setup*"></a>
<h4 id="UICatalog_Scenario_Setup" data-uid="UICatalog.Scenario.Setup">Setup()</h4>
<div class="markdown level1 summary"><p>Override this to implement the <a class="xref" href="UICatalog.Scenario.html">Scenario</a> setup logic (create controls, etc...). </p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public virtual void Setup()</code></pre>
</div>
<h5 id="UICatalog_Scenario_Setup_remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This is typically the best place to put scenario logic code.</p>
</div>
<a id="UICatalog_Scenario_ToString_" data-uid="UICatalog.Scenario.ToString*"></a>
<h4 id="UICatalog_Scenario_ToString" data-uid="UICatalog.Scenario.ToString">ToString()</h4>
<div class="markdown level1 summary"></div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public override string ToString()</code></pre>
</div>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.String</span></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="overrides">Overrides</h5>
<div><span class="xref">System.Object.ToString()</span></div>
<h3 id="implements">Implements</h3>
<div>
<span class="xref">System.IDisposable</span>
</div>
</article>
</div>
<div class="hidden-sm col-md-2" role="complementary">
<div class="sideaffix">
<div class="contribution">
<ul class="nav">
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
</nav>
</div>
</div>
</div>
</div>
<footer>
<div class="grad-bottom"></div>
<div class="footer">
<div class="container">
<span class="pull-right">
<a href="#top">Back to top</a>
</span>
<span>Generated by <strong>DocFX</strong></span>
</div>
</div>
</footer>
</div>
<script type="text/javascript" src="../../styles/docfx.vendor.js"></script>
<script type="text/javascript" src="../../styles/docfx.js"></script>
<script type="text/javascript" src="../../styles/main.js"></script>
</body>
</html>