mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
* Fixed #3905, #3918 * Tweaked Generic * Label code cleanup * Clean up. * Clean up. * Clean up2.
40 lines
1.2 KiB
C#
40 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 (),
|
|
};
|
|
|
|
var button = new Button { 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");
|
|
};
|
|
|
|
appWindow.Add (button);
|
|
|
|
// Run - Start the application.
|
|
Application.Run (appWindow);
|
|
appWindow.Dispose ();
|
|
|
|
// Shutdown - Calling Application.Shutdown is required.
|
|
Application.Shutdown ();
|
|
}
|
|
}
|