|
@@ -17,11 +17,13 @@ public class Text : Scenario
|
|
|
private Label _labelMirroringTimeField;
|
|
|
private TimeField _timeField;
|
|
|
|
|
|
- public override void Setup ()
|
|
|
+ public override void Main ()
|
|
|
{
|
|
|
+ Application.Init ();
|
|
|
+ var win = new Window { Title = GetQuitKeyAndName () };
|
|
|
// TextField is a simple, single-line text input control
|
|
|
var label = new Label { Text = "_TextField:" };
|
|
|
- Win.Add (label);
|
|
|
+ win.Add (label);
|
|
|
|
|
|
var textField = new TextField
|
|
|
{
|
|
@@ -43,7 +45,7 @@ public class Text : Scenario
|
|
|
.ToList ();
|
|
|
}
|
|
|
|
|
|
- Win.Add (textField);
|
|
|
+ win.Add (textField);
|
|
|
|
|
|
var labelMirroringTextField = new Label
|
|
|
{
|
|
@@ -54,12 +56,12 @@ public class Text : Scenario
|
|
|
Height = 1,
|
|
|
Text = textField.Text
|
|
|
};
|
|
|
- Win.Add (labelMirroringTextField);
|
|
|
+ win.Add (labelMirroringTextField);
|
|
|
textField.TextChanged += (s, prev) => { labelMirroringTextField.Text = textField.Text; };
|
|
|
|
|
|
// TextView is a rich (as in functionality, not formatting) text editing control
|
|
|
label = new() { Text = "T_extView:", Y = Pos.Bottom (label) + 1 };
|
|
|
- Win.Add (label);
|
|
|
+ win.Add (label);
|
|
|
|
|
|
var textView = new TextView
|
|
|
{
|
|
@@ -80,7 +82,7 @@ public class Text : Scenario
|
|
|
.ToList ();
|
|
|
}
|
|
|
|
|
|
- Win.Add (textView);
|
|
|
+ win.Add (textView);
|
|
|
|
|
|
var labelMirroringTextView = new Label
|
|
|
{
|
|
@@ -90,7 +92,7 @@ public class Text : Scenario
|
|
|
Width = Dim.Fill (1) - 1,
|
|
|
Height = Dim.Height (textView) - 1
|
|
|
};
|
|
|
- Win.Add (labelMirroringTextView);
|
|
|
+ win.Add (labelMirroringTextView);
|
|
|
|
|
|
// Use ContentChanged to detect if the user has typed something in a TextView.
|
|
|
// The TextChanged property is only fired if the TextView.Text property is
|
|
@@ -107,7 +109,7 @@ public class Text : Scenario
|
|
|
{
|
|
|
X = Pos.Left (textView), Y = Pos.Bottom (textView), State = textView.Multiline ? CheckState.Checked : CheckState.UnChecked, Text = "_Multiline"
|
|
|
};
|
|
|
- Win.Add (chxMultiline);
|
|
|
+ win.Add (chxMultiline);
|
|
|
|
|
|
var chxWordWrap = new CheckBox
|
|
|
{
|
|
@@ -117,7 +119,7 @@ public class Text : Scenario
|
|
|
Text = "_Word Wrap"
|
|
|
};
|
|
|
chxWordWrap.Toggle += (s, e) => textView.WordWrap = e.NewValue == CheckState.Checked;
|
|
|
- Win.Add (chxWordWrap);
|
|
|
+ win.Add (chxWordWrap);
|
|
|
|
|
|
// TextView captures Tabs (so users can enter /t into text) by default;
|
|
|
// This means using Tab to navigate doesn't work by default. This shows
|
|
@@ -163,11 +165,11 @@ public class Text : Scenario
|
|
|
|
|
|
textView.AllowsTab = e.NewValue == CheckState.Checked;
|
|
|
};
|
|
|
- Win.Add (chxCaptureTabs);
|
|
|
+ win.Add (chxCaptureTabs);
|
|
|
|
|
|
// Hex editor
|
|
|
label = new() { Text = "_HexView:", Y = Pos.Bottom (chxMultiline) + 1 };
|
|
|
- Win.Add (label);
|
|
|
+ win.Add (label);
|
|
|
|
|
|
var hexEditor =
|
|
|
new HexView (
|
|
@@ -176,7 +178,7 @@ public class Text : Scenario
|
|
|
{
|
|
|
X = Pos.Right (label) + 1, Y = Pos.Bottom (chxMultiline) + 1, Width = Dim.Percent (50) - 1, Height = Dim.Percent (30)
|
|
|
};
|
|
|
- Win.Add (hexEditor);
|
|
|
+ win.Add (hexEditor);
|
|
|
|
|
|
var labelMirroringHexEditor = new Label
|
|
|
{
|
|
@@ -195,14 +197,14 @@ public class Text : Scenario
|
|
|
byte [] array = ((MemoryStream)hexEditor.Source).ToArray ();
|
|
|
labelMirroringHexEditor.Text = Encoding.UTF8.GetString (array, 0, array.Length);
|
|
|
};
|
|
|
- Win.Add (labelMirroringHexEditor);
|
|
|
+ win.Add (labelMirroringHexEditor);
|
|
|
|
|
|
// DateField
|
|
|
label = new() { Text = "_DateField:", Y = Pos.Bottom (hexEditor) + 1 };
|
|
|
- Win.Add (label);
|
|
|
+ win.Add (label);
|
|
|
|
|
|
var dateField = new DateField (DateTime.Now) { X = Pos.Right (label) + 1, Y = Pos.Bottom (hexEditor) + 1, Width = 20 };
|
|
|
- Win.Add (dateField);
|
|
|
+ win.Add (dateField);
|
|
|
|
|
|
var labelMirroringDateField = new Label
|
|
|
{
|
|
@@ -213,13 +215,13 @@ public class Text : Scenario
|
|
|
Height = Dim.Height (dateField),
|
|
|
Text = dateField.Text
|
|
|
};
|
|
|
- Win.Add (labelMirroringDateField);
|
|
|
+ win.Add (labelMirroringDateField);
|
|
|
|
|
|
dateField.TextChanged += (s, prev) => { labelMirroringDateField.Text = dateField.Text; };
|
|
|
|
|
|
// TimeField
|
|
|
label = new() { Text = "T_imeField:", Y = Pos.Top (dateField), X = Pos.Right (labelMirroringDateField) + 5 };
|
|
|
- Win.Add (label);
|
|
|
+ win.Add (label);
|
|
|
|
|
|
_timeField = new()
|
|
|
{
|
|
@@ -229,7 +231,7 @@ public class Text : Scenario
|
|
|
IsShortFormat = false,
|
|
|
Time = DateTime.Now.TimeOfDay
|
|
|
};
|
|
|
- Win.Add (_timeField);
|
|
|
+ win.Add (_timeField);
|
|
|
|
|
|
_labelMirroringTimeField = new()
|
|
|
{
|
|
@@ -240,7 +242,7 @@ public class Text : Scenario
|
|
|
Height = Dim.Height (_timeField),
|
|
|
Text = _timeField.Text
|
|
|
};
|
|
|
- Win.Add (_labelMirroringTimeField);
|
|
|
+ win.Add (_labelMirroringTimeField);
|
|
|
|
|
|
_timeField.TimeChanged += TimeChanged;
|
|
|
|
|
@@ -251,7 +253,7 @@ public class Text : Scenario
|
|
|
Y = Pos.Bottom (dateField) + 1,
|
|
|
Text = "_NetMaskedTextProvider [ 999 000 LLL >LLL |AAA aaa ]:"
|
|
|
};
|
|
|
- Win.Add (netProviderLabel);
|
|
|
+ win.Add (netProviderLabel);
|
|
|
|
|
|
var netProvider = new NetMaskedTextProvider ("999 000 LLL >LLL |AAA aaa");
|
|
|
|
|
@@ -259,7 +261,7 @@ public class Text : Scenario
|
|
|
{
|
|
|
X = Pos.Right (netProviderLabel) + 1, Y = Pos.Y (netProviderLabel), Provider = netProvider
|
|
|
};
|
|
|
- Win.Add (netProviderField);
|
|
|
+ win.Add (netProviderField);
|
|
|
|
|
|
var labelMirroringNetProviderField = new Label
|
|
|
{
|
|
@@ -270,7 +272,7 @@ public class Text : Scenario
|
|
|
Height = Dim.Height (netProviderField),
|
|
|
Text = netProviderField.Text
|
|
|
};
|
|
|
- Win.Add (labelMirroringNetProviderField);
|
|
|
+ win.Add (labelMirroringNetProviderField);
|
|
|
|
|
|
netProviderField.Provider.TextChanged += (s, prev) => { labelMirroringNetProviderField.Text = netProviderField.Text; };
|
|
|
|
|
@@ -281,7 +283,7 @@ public class Text : Scenario
|
|
|
Y = Pos.Bottom (netProviderLabel) + 1,
|
|
|
Text = "Text_RegexProvider [ ^([0-9]?[0-9]?[0-9]|1000)$ ]:"
|
|
|
};
|
|
|
- Win.Add (regexProvider);
|
|
|
+ win.Add (regexProvider);
|
|
|
|
|
|
var provider2 = new TextRegexProvider ("^([0-9]?[0-9]?[0-9]|1000)$") { ValidateOnInput = false };
|
|
|
|
|
@@ -293,7 +295,7 @@ public class Text : Scenario
|
|
|
TextAlignment = Alignment.Center,
|
|
|
Provider = provider2
|
|
|
};
|
|
|
- Win.Add (regexProviderField);
|
|
|
+ win.Add (regexProviderField);
|
|
|
|
|
|
var labelMirroringRegexProviderField = new Label
|
|
|
{
|
|
@@ -304,7 +306,7 @@ public class Text : Scenario
|
|
|
Height = Dim.Height (regexProviderField),
|
|
|
Text = regexProviderField.Text
|
|
|
};
|
|
|
- Win.Add (labelMirroringRegexProviderField);
|
|
|
+ win.Add (labelMirroringRegexProviderField);
|
|
|
|
|
|
regexProviderField.Provider.TextChanged += (s, prev) => { labelMirroringRegexProviderField.Text = regexProviderField.Text; };
|
|
|
|
|
@@ -428,8 +430,12 @@ public class Text : Scenario
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- Win.Add (labelAppendAutocomplete);
|
|
|
- Win.Add (appendAutocompleteTextField);
|
|
|
+ win.Add (labelAppendAutocomplete);
|
|
|
+ win.Add (appendAutocompleteTextField);
|
|
|
+
|
|
|
+ Application.Run (win);
|
|
|
+ win.Dispose ();
|
|
|
+ Application.Shutdown ();
|
|
|
}
|
|
|
|
|
|
private void TimeChanged (object sender, DateTimeEventArgs<TimeSpan> e) { _labelMirroringTimeField.Text = _timeField.Text; }
|