mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* touching publish.yml * Moved Examples into ./Examples * Moved Benchmarks into ./Tests * Moved Benchmarks into ./Tests * Moved UICatalog into ./Examples * Moved UICatalog into ./Examples 2 * Moved tests into ./Tests * Updated nuget
57 lines
1.7 KiB
C#
57 lines
1.7 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 Shortcut()
|
|
{
|
|
CanFocus = true,
|
|
Id = "button",
|
|
X = Pos.Center (),
|
|
Y = 1,
|
|
ShadowStyle = ShadowStyle.None,
|
|
Text = "HelpText",
|
|
Title = "Command",
|
|
Key = Key.F10,
|
|
HighlightStyle = HighlightStyle.None
|
|
};
|
|
button.ColorScheme = Colors.ColorSchemes ["Error"];
|
|
|
|
button.Padding!.Thickness = new (1);
|
|
button.Padding.ColorScheme = Colors.ColorSchemes ["Toplevel"];
|
|
button.Margin!.Thickness = new (1);
|
|
|
|
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 ();
|
|
}
|
|
}
|