mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 08:50:25 +01:00
more unit tests and refactoring
This commit is contained in:
committed by
Tig Kindel
parent
1bc2c79938
commit
ab503d1de1
@@ -2399,7 +2399,7 @@ namespace Terminal.Gui {
|
||||
}
|
||||
}
|
||||
|
||||
bool oldEnabled = true;
|
||||
bool oldEnabled;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Enabled {
|
||||
|
||||
@@ -276,9 +276,7 @@ namespace Terminal.Gui {
|
||||
foreach (var step in steps) {
|
||||
step.Y = 0;
|
||||
}
|
||||
if (steps.Count > 0) {
|
||||
CurrentStep = steps.First.Value;
|
||||
}
|
||||
CurrentStep = GetNextStep (); // gets the first step if CurrentStep == null
|
||||
}
|
||||
|
||||
private void NextfinishBtn_Clicked ()
|
||||
@@ -440,7 +438,7 @@ namespace Terminal.Gui {
|
||||
}
|
||||
set {
|
||||
wizardTitle = value;
|
||||
base.Title = $"{wizardTitle}{(steps.Count > 0 ? " - " + currentStep.Title : string.Empty)}";
|
||||
base.Title = $"{wizardTitle}{(steps.Count > 0 && currentStep != null ? " - " + currentStep.Title : string.Empty)}";
|
||||
}
|
||||
}
|
||||
private ustring wizardTitle = ustring.Empty;
|
||||
|
||||
@@ -150,8 +150,7 @@ namespace UICatalog.Scenarios {
|
||||
// Add 2nd step
|
||||
var secondStep = new Wizard.WizardStep ("Second Step");
|
||||
wizard.AddStep (secondStep);
|
||||
secondStep.HelpText = "This is the help text for the Second Step.\n\nPress the button to see a message box.\n\nEnter name too.";
|
||||
|
||||
secondStep.HelpText = "This is the help text for the Second Step.\n\nPress the button to see a message box.\n\nEnter First Name too.";
|
||||
|
||||
View viewForControls = secondStep.Controls;
|
||||
ustring frameMsg = "Added to WizardStep.Controls";
|
||||
@@ -191,15 +190,15 @@ namespace UICatalog.Scenarios {
|
||||
};
|
||||
frame.Add (new TextField ("This is a TextField inside of the frame."));
|
||||
viewForControls.Add (frame);
|
||||
wizard.StepChanging += (args) => {
|
||||
if (args.OldStep == secondStep && firstNameField.Text.IsEmpty ) {
|
||||
args.Cancel = true;
|
||||
var btn = MessageBox.ErrorQuery ("Second Step", "You must enter a First Name to continue", "Ok");
|
||||
}
|
||||
};
|
||||
|
||||
// Add 3rd (optional) step
|
||||
var thirdStep = new Wizard.WizardStep ("Third Step (Optional)");
|
||||
|
||||
thirdStep.Enabled = thirdStepEnabledCeckBox.Checked;
|
||||
thirdStepEnabledCeckBox.Toggled += (args) => {
|
||||
thirdStep.Enabled = thirdStepEnabledCeckBox.Checked;
|
||||
};
|
||||
|
||||
wizard.AddStep (thirdStep);
|
||||
thirdStep.HelpText = "This is step is optional (WizardStep.Enabled = false). Enable it with the checkbox in Step 2.";
|
||||
var step3Label = new Label () {
|
||||
@@ -217,7 +216,11 @@ namespace UICatalog.Scenarios {
|
||||
Fraction = 0.42F
|
||||
};
|
||||
thirdStep.Controls.Add (progLbl, progressBar);
|
||||
|
||||
thirdStep.Enabled = thirdStepEnabledCeckBox.Checked;
|
||||
thirdStepEnabledCeckBox.Toggled += (args) => {
|
||||
thirdStep.Enabled = thirdStepEnabledCeckBox.Checked;
|
||||
};
|
||||
|
||||
// Add 4th step
|
||||
var fourthStep = new Wizard.WizardStep ("Step Four");
|
||||
wizard.AddStep (fourthStep);
|
||||
@@ -232,22 +235,9 @@ namespace UICatalog.Scenarios {
|
||||
AllowsTab = false
|
||||
};
|
||||
fourthStep.Controls.Add (someText);
|
||||
//fourthStep.NextButtonText = "4";
|
||||
fourthStep.NextButtonText = "Go To Last Step";
|
||||
var scrollBar = new ScrollBarView (someText, true);
|
||||
|
||||
//wizard.StepChanging += (args) => {
|
||||
// if (args.NewStep == fourthStep) {
|
||||
// var btn = MessageBox.ErrorQuery ("Wizards", "Move to Step Four?", "Yes", "No");
|
||||
// args.Cancel = btn == 1;
|
||||
// }
|
||||
//};
|
||||
|
||||
//wizard.StepChanged += (args) => {
|
||||
// if (args.NewStep == fourthStep) {
|
||||
// var btn = MessageBox.ErrorQuery ("Wizards", "Yay. Moved to Step Four", "Ok");
|
||||
// }
|
||||
//};
|
||||
|
||||
scrollBar.ChangedPosition += () => {
|
||||
someText.TopRow = scrollBar.Position;
|
||||
if (someText.TopRow != scrollBar.Position) {
|
||||
|
||||
Reference in New Issue
Block a user