mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
* shortcut tests * Generic demos * Optimize Margin to not defer draw if there's no shadow
54 lines
1.4 KiB
C#
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 ();
|
|
}
|
|
}
|