Updated Unicode Scenario

This commit is contained in:
Tig
2024-06-16 22:33:29 -07:00
parent fc9474e2b7
commit ef9a7daa2a
2 changed files with 74 additions and 65 deletions

View File

@@ -36,29 +36,29 @@ public class TextViewAutocompletePopup : Scenario
{
Menus =
[
new MenuBarItem (
"_File",
new []
{
_miMultiline =
new MenuItem (
"_Multiline",
"",
() => Multiline ()
) { CheckType = MenuItemCheckStyle.Checked },
_miWrap = new MenuItem (
"_Word Wrap",
"",
() => WordWrap ()
) { CheckType = MenuItemCheckStyle.Checked },
new ("_Quit", "", () => Quit ())
}
)
new (
"_File",
new []
{
_miMultiline =
new (
"_Multiline",
"",
() => Multiline ()
) { CheckType = MenuItemCheckStyle.Checked },
_miWrap = new (
"_Word Wrap",
"",
() => WordWrap ()
) { CheckType = MenuItemCheckStyle.Checked },
new ("_Quit", "", () => Quit ())
}
)
]
};
appWindow.Add (menu);
_textViewTopLeft = new TextView
_textViewTopLeft = new()
{
Y = 1,
Width = width, Height = _height, Text = text
@@ -66,22 +66,22 @@ public class TextViewAutocompletePopup : Scenario
_textViewTopLeft.DrawContent += TextViewTopLeft_DrawContent;
appWindow.Add (_textViewTopLeft);
_textViewTopRight = new TextView
_textViewTopRight = new()
{
X = Pos.AnchorEnd (width), Y = 1,
X = Pos.AnchorEnd (width), Y = 1,
Width = width, Height = _height, Text = text
};
_textViewTopRight.DrawContent += TextViewTopRight_DrawContent;
appWindow.Add (_textViewTopRight);
_textViewBottomLeft = new TextView
_textViewBottomLeft = new()
{
Y = Pos.AnchorEnd (_height), Width = width, Height = _height, Text = text
};
_textViewBottomLeft.DrawContent += TextViewBottomLeft_DrawContent;
appWindow.Add (_textViewBottomLeft);
_textViewBottomRight = new TextView
_textViewBottomRight = new()
{
X = Pos.AnchorEnd (width),
Y = Pos.AnchorEnd (_height),
@@ -92,7 +92,7 @@ public class TextViewAutocompletePopup : Scenario
_textViewBottomRight.DrawContent += TextViewBottomRight_DrawContent;
appWindow.Add (_textViewBottomRight);
_textViewCentered = new TextView
_textViewCentered = new()
{
X = Pos.Center (),
Y = Pos.Center (),
@@ -111,13 +111,12 @@ public class TextViewAutocompletePopup : Scenario
{
new (
Application.QuitKey,
$"Quit",
"Quit",
() => Quit ()
),
_siMultiline = new Shortcut (Key.Empty, "", null),
_siWrap = new Shortcut (Key.Empty, "", null)
_siMultiline = new (Key.Empty, "", null),
_siWrap = new (Key.Empty, "", null)
}
);
appWindow.Add (statusBar);
@@ -154,15 +153,9 @@ public class TextViewAutocompletePopup : Scenario
.ToList ();
}
private void SetMultilineStatusText ()
{
_siMultiline.Title = $"Multiline: {_miMultiline.Checked}";
}
private void SetMultilineStatusText () { _siMultiline.Title = $"Multiline: {_miMultiline.Checked}"; }
private void SetWrapStatusText ()
{
_siWrap.Title = $"WordWrap: {_miWrap.Checked}";
}
private void SetWrapStatusText () { _siWrap.Title = $"WordWrap: {_miWrap.Checked}"; }
private void TextViewBottomLeft_DrawContent (object sender, DrawEventArgs e) { SetAllSuggestions (_textViewBottomLeft); }
private void TextViewBottomRight_DrawContent (object sender, DrawEventArgs e) { SetAllSuggestions (_textViewBottomRight); }
private void TextViewCentered_DrawContent (object sender, DrawEventArgs e) { SetAllSuggestions (_textViewCentered); }

View File

@@ -10,7 +10,7 @@ namespace UICatalog.Scenarios;
[ScenarioCategory ("Controls")]
public class UnicodeInMenu : Scenario
{
public override void Setup ()
public override void Main ()
{
var unicode =
"Τὴ γλῶσσα μοῦ ἔδωσαν ἑλληνικὴ\nτὸ σπίτι φτωχικὸ στὶς ἀμμουδιὲς τοῦ Ὁμήρου.\nΜονάχη ἔγνοια ἡ γλῶσσα μου στὶς ἀμμουδιὲς τοῦ Ὁμήρου.";
@@ -28,6 +28,15 @@ public class UnicodeInMenu : Scenario
CM.Glyphs.HorizontalEllipsis
}";
// Init
Application.Init ();
// Setup - Create a top-level application window and configure it.
Window appWindow = new ()
{
Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}",
};
var menu = new MenuBar
{
Menus =
@@ -60,26 +69,24 @@ public class UnicodeInMenu : Scenario
)
]
};
Top.Add (menu);
appWindow.Add (menu);
var statusBar = new StatusBar (
#if V2_STATUSBAR
new StatusItem []
new Shortcut []
{
new (
Application.QuitKey,
$"{Application.QuitKey} Выход",
$"Выход",
() => Application.RequestStop ()
),
new (KeyCode.Null, "~F2~ Создать", null),
new (KeyCode.Null, "~F3~ Со_хранить", null)
new (Key.F2, "Создать", null),
new (Key.F3, "Со_хранить", null)
}
#endif
);
Top.Add (statusBar);
appWindow.Add (statusBar);
var label = new Label { X = 0, Y = 1, Text = "Label:" };
Win.Add (label);
appWindow.Add (label);
var testlabel = new Label
{
@@ -89,10 +96,10 @@ public class UnicodeInMenu : Scenario
Width = Dim.Percent (50),
Text = gitString
};
Win.Add (testlabel);
appWindow.Add (testlabel);
label = new() { X = Pos.X (label), Y = Pos.Bottom (label) + 1, Text = "Label (CanFocus):" };
Win.Add (label);
appWindow.Add (label);
var sb = new StringBuilder ();
sb.Append ('e');
sb.Append ('\u0301');
@@ -108,14 +115,14 @@ public class UnicodeInMenu : Scenario
HotKeySpecifier = new ('&'),
Text = $"Should be [e with two accents, but isn't due to #2616]: [{sb}]"
};
Win.Add (testlabel);
appWindow.Add (testlabel);
label = new() { X = Pos.X (label), Y = Pos.Bottom (label) + 1, Text = "Button:" };
Win.Add (label);
appWindow.Add (label);
var button = new Button { X = 20, Y = Pos.Y (label), Text = "A123456789♥♦♣♠JQK" };
Win.Add (button);
appWindow.Add (button);
label = new() { X = Pos.X (label), Y = Pos.Bottom (label) + 1, Text = "CheckBox:" };
Win.Add (label);
appWindow.Add (label);
var checkBox = new CheckBox
{
@@ -137,27 +144,27 @@ public class UnicodeInMenu : Scenario
TextAlignment = Alignment.End,
Text = $"End - {gitString}"
};
Win.Add (checkBox, checkBoxRight);
appWindow.Add (checkBox, checkBoxRight);
label = new() { X = Pos.X (label), Y = Pos.Bottom (checkBoxRight) + 1, Text = "ComboBox:" };
Win.Add (label);
appWindow.Add (label);
var comboBox = new ComboBox { X = 20, Y = Pos.Y (label), Width = Dim.Percent (50) };
comboBox.SetSource (new ObservableCollection<string> { gitString, "Со_хранить" });
Win.Add (comboBox);
appWindow.Add (comboBox);
comboBox.Text = gitString;
label = new() { X = Pos.X (label), Y = Pos.Bottom (label) + 2, Text = "HexView:" };
Win.Add (label);
appWindow.Add (label);
var hexView = new HexView (new MemoryStream (Encoding.ASCII.GetBytes (gitString + " Со_хранить")))
{
X = 20, Y = Pos.Y (label), Width = Dim.Percent (60), Height = 5
};
Win.Add (hexView);
appWindow.Add (hexView);
label = new() { X = Pos.X (label), Y = Pos.Bottom (hexView) + 1, Text = "ListView:" };
Win.Add (label);
appWindow.Add (label);
var listView = new ListView
{
@@ -169,10 +176,10 @@ public class UnicodeInMenu : Scenario
["item #1", gitString, "Со_хранить", unicode]
)
};
Win.Add (listView);
appWindow.Add (listView);
label = new() { X = Pos.X (label), Y = Pos.Bottom (listView) + 1, Text = "RadioGroup:" };
Win.Add (label);
appWindow.Add (label);
var radioGroup = new RadioGroup
{
@@ -181,19 +188,19 @@ public class UnicodeInMenu : Scenario
Width = Dim.Percent (60),
RadioLabels = new [] { "item #1", gitString, "Со_хранить", "𝔽𝕆𝕆𝔹𝔸" }
};
Win.Add (radioGroup);
appWindow.Add (radioGroup);
label = new() { X = Pos.X (label), Y = Pos.Bottom (radioGroup) + 1, Text = "TextField:" };
Win.Add (label);
appWindow.Add (label);
var textField = new TextField
{
X = 20, Y = Pos.Y (label), Width = Dim.Percent (60), Text = gitString + " = Со_хранить"
};
Win.Add (textField);
appWindow.Add (textField);
label = new() { X = Pos.X (label), Y = Pos.Bottom (textField) + 1, Text = "TextView:" };
Win.Add (label);
appWindow.Add (label);
var textView = new TextView
{
@@ -203,6 +210,15 @@ public class UnicodeInMenu : Scenario
Height = 5,
Text = unicode
};
Win.Add (textView);
appWindow.Add (textView);
// Run - Start the application.
Application.Run (appWindow);
appWindow.Dispose ();
// Shutdown - Calling Application.Shutdown is required.
Application.Shutdown ();
}
}