mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
46 lines
1.2 KiB
C#
46 lines
1.2 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 (),
|
|
BorderStyle = LineStyle.None
|
|
};
|
|
|
|
var button = new Button ()
|
|
{
|
|
X = Pos.Center (),
|
|
Y = 1,
|
|
Title = "_Button",
|
|
};
|
|
|
|
button.Accepting += (s, e) =>
|
|
{
|
|
// When Accepting is handled, set e.Handled to true to prevent further processing.
|
|
e.Handled = true;
|
|
MessageBox.ErrorQuery ("Error", "You pressed the button!", "_Ok");
|
|
};
|
|
|
|
appWindow.Add (button);
|
|
|
|
// Run - Start the application.
|
|
Application.Run (appWindow);
|
|
appWindow.Dispose ();
|
|
|
|
// Shutdown - Calling Application.Shutdown is required.
|
|
Application.Shutdown ();
|
|
}
|
|
}
|