Files
Terminal.Gui/UICatalog/Scenarios/Generic.cs
Tig ce7fc04100 Fixes #3984 - Margin w/out shadow should not force draw (#3985)
* shortcut tests

* Generic demos

* Optimize Margin to not defer draw if there's no shadow
2025-03-13 18:16:53 +01:00

54 lines
1.4 KiB
C#

#nullable enable
using Terminal.Gui;
namespace UICatalog.Scenarios;
[ScenarioMetadata ("Generic", "Generic sample - A template for creating new Scenarios")]
[ScenarioCategory ("Controls")]
public sealed class Generic : Scenario
{
public override void Main ()
{
// Init
Application.Init ();
// Setup - Create a top-level application window and configure it.
Window appWindow = new ()
{
Title = GetQuitKeyAndName (),
};
FrameView frame = new ()
{
Height = Dim.Fill (),
Width = Dim.Fill (),
Title = "Frame"
};
appWindow.Add (frame);
var button = new Shortcut ()
{
Id = "button",
X = Pos.Center (),
Y = 1,
Text = "_Press me!"
};
button.Accepting += (s, e) =>
{
// Anytime Accepting is handled, make sure to set e.Cancel to false.
e.Cancel = true;
MessageBox.ErrorQuery ("Error", "You pressed the button!", "_Ok");
};
frame.Add (button);
// Run - Start the application.
Application.Run (appWindow);
appWindow.Dispose ();
// Shutdown - Calling Application.Shutdown is required.
Application.Shutdown ();
}
}