mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
* Remove NStack and replace ustring to string.
* Add unit test and improving some code.
* Adjust code and fix all unit tests errors.
* Add XML Document and move the Rune folder into the Text folder.
* Improve unit tests with byte array on DecodeRune and DecodeLastRune.
* Fix unit test.
* 😂Code review
* Reduce unit tests code.
* Change StringExtensions.Make to StringExtensions.ToString and added some more unit tests.
* Fix merge errors.
* Remove GetTextWidth and calls replaced with StringExtensions.GetColumns.
* Hack to use UseSystemConsole passed in the command line arguments.
* Revert "Hack to use UseSystemConsole passed in the command line arguments."
This reverts commit b74d11c786.
* Remove Application.UseSystemConsole from the config file.
* Fix errors related by removing UseSystemConsole from the config file.
* Fixes #2633. DecodeEscSeq throw an exception if cki is null.
* Fix an exception if SelectedItem is -1.
* Set SelectedItem to 0 and remove unnecessary ToString.
* Using a unique ToString method for Rune and other for byte.
* Fix a bug where a wider rune is added with only a width of 1.
* Force the SelectedGlyph is the one that was typed after jumpList is executed.
* Added more InlineData to RuneTests.
* Reducing significantly the code by using Theory attribute in the TextFormatterTests.
* Override PositionCursor to handle the CharMap cursor position.
* Fix merge errors.
* Minor tweaks to API docs
---------
Co-authored-by: Tig Kindel <tig@users.noreply.github.com>
106 lines
4.2 KiB
C#
106 lines
4.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Terminal.Gui;
|
|
|
|
namespace UICatalog.Scenarios {
|
|
[ScenarioMetadata (Name: "WizardAsView", Description: "Shows using the Wizard class in an non-modal way")]
|
|
[ScenarioCategory ("Wizards")]
|
|
public class WizardAsView : Scenario {
|
|
|
|
public override void Init ()
|
|
{
|
|
Application.Init ();
|
|
|
|
var menu = new MenuBar (new MenuBarItem [] {
|
|
new MenuBarItem ("_File", new MenuItem [] {
|
|
new MenuItem ("_Restart Configuration...", "", () => MessageBox.Query ("Wizaard", "Are you sure you want to reset the Wizard and start over?", "Ok", "Cancel")),
|
|
new MenuItem ("Re_boot Server...", "", () => MessageBox.Query ("Wizaard", "Are you sure you want to reboot the server start over?", "Ok", "Cancel")),
|
|
new MenuItem ("_Shutdown Server...", "", () => MessageBox.Query ("Wizaard", "Are you sure you want to cancel setup and shutdown?", "Ok", "Cancel")),
|
|
})
|
|
});
|
|
Application.Top.Add (menu);
|
|
|
|
// No need for a Title because the border is disabled
|
|
var wizard = new Wizard () {
|
|
X = 0,
|
|
Y = 0,
|
|
Width = Dim.Fill (),
|
|
Height = Dim.Fill (),
|
|
};
|
|
|
|
// Set Mdoal to false to cause the Wizard class to render without a frame and
|
|
// behave like an non-modal View (vs. a modal/pop-up Window).
|
|
wizard.Modal = false;
|
|
|
|
wizard.MovingBack += (s, args) => {
|
|
//args.Cancel = true;
|
|
//actionLabel.Text = "Moving Back";
|
|
};
|
|
|
|
wizard.MovingNext += (s, args) => {
|
|
//args.Cancel = true;
|
|
//actionLabel.Text = "Moving Next";
|
|
};
|
|
|
|
wizard.Finished += (s, args) => {
|
|
//args.Cancel = true;
|
|
MessageBox.Query ("Setup Wizard", "Finished", "Ok");
|
|
Application.RequestStop ();
|
|
};
|
|
|
|
wizard.Cancelled += (s, args) => {
|
|
var btn = MessageBox.Query ("Setup Wizard", "Are you sure you want to cancel?", "Yes", "No");
|
|
args.Cancel = btn == 1;
|
|
if (btn == 0) {
|
|
Application.RequestStop ();
|
|
}
|
|
};
|
|
|
|
// Add 1st step
|
|
var firstStep = new Wizard.WizardStep () { Title = "End User License Agreement" };
|
|
wizard.AddStep (firstStep);
|
|
firstStep.NextButtonText = "Accept!";
|
|
firstStep.HelpText = "This is the End User License Agreement.\n\n\n\n\n\nThis is a test of the emergency broadcast system. This is a test of the emergency broadcast system.\nThis is a test of the emergency broadcast system.\n\n\nThis is a test of the emergency broadcast system.\n\nThis is a test of the emergency broadcast system.\n\n\n\nThe end of the EULA.";
|
|
|
|
// Add 2nd step
|
|
var secondStep = new Wizard.WizardStep () { Title = "Second Step" };
|
|
wizard.AddStep (secondStep);
|
|
secondStep.HelpText = "This is the help text for the Second Step.\n\nPress the button to change the Title.\n\nIf First Name is empty the step will prevent moving to the next step.";
|
|
|
|
var buttonLbl = new Label () { Text = "Second Step Button: ", X = 0, Y = 0 };
|
|
var button = new Button () {
|
|
Text = "Press Me to Rename Step",
|
|
X = Pos.Right (buttonLbl),
|
|
Y = Pos.Top (buttonLbl)
|
|
};
|
|
button.Clicked += (s, e) => {
|
|
secondStep.Title = "2nd Step";
|
|
MessageBox.Query ("Wizard Scenario", "This Wizard Step's title was changed to '2nd Step'", "Ok");
|
|
};
|
|
secondStep.Add (buttonLbl, button);
|
|
var lbl = new Label () { Text = "First Name: ", X = Pos.Left (buttonLbl), Y = Pos.Bottom (buttonLbl) };
|
|
var firstNameField = new TextField () { Text = "Number", Width = 30, X = Pos.Right (lbl), Y = Pos.Top (lbl) };
|
|
secondStep.Add (lbl, firstNameField);
|
|
lbl = new Label () { Text = "Last Name: ", X = Pos.Left (buttonLbl), Y = Pos.Bottom (lbl) };
|
|
var lastNameField = new TextField () { Text = "Six", Width = 30, X = Pos.Right (lbl), Y = Pos.Top (lbl) };
|
|
secondStep.Add (lbl, lastNameField);
|
|
|
|
// Add last step
|
|
var lastStep = new Wizard.WizardStep () { Title = "The last step" };
|
|
wizard.AddStep (lastStep);
|
|
lastStep.HelpText = "The wizard is complete!\n\nPress the Finish button to continue.\n\nPressing Esc will cancel.";
|
|
|
|
Application.Top.Add (wizard);
|
|
Application.Run (Application.Top);
|
|
}
|
|
|
|
public override void Run ()
|
|
{
|
|
// Do nothing in the override because we call Application.Run above
|
|
// (just to make it clear how the Top is being run and not the Wizard).
|
|
}
|
|
}
|
|
}
|