diff --git a/Terminal.Gui/View/ViewText.cs b/Terminal.Gui/View/ViewText.cs index 1ac70bb55..63ad748c7 100644 --- a/Terminal.Gui/View/ViewText.cs +++ b/Terminal.Gui/View/ViewText.cs @@ -209,46 +209,4 @@ public partial class View SetTextFormatterSize (); SetNeedsDisplay (); } - - - #region AutoSize - - [ObsoleteAttribute ("Use Dim.Auto instead.", false)] - public virtual bool AutoSize - { - get => _height is Dim.DimAuto && _width is Dim.DimAuto; - set - { - TextFormatter.AutoSize = value; - - // BUGBUG: This is all a hack until AutoSize is removed - if (value) - { - UpdateTextFormatterText (); - - if (IsInitialized) - { - Height = Dim.Auto (Dim.DimAutoStyle.Text); - Width = Dim.Auto (Dim.DimAutoStyle.Text); - } - else - { - _height = Dim.Auto (Dim.DimAutoStyle.Text); - _width = Dim.Auto (Dim.DimAutoStyle.Text); - OnResizeNeeded (); - } - } - else - { - _height = ContentSize.GetValueOrDefault ().Height; - _width = ContentSize.GetValueOrDefault ().Width; - - // Force ContentSize to be reset to Viewport - _contentSize = null; - OnResizeNeeded (); - } - } - } - - #endregion AutoSize } diff --git a/UICatalog/Scenarios/Adornments.cs b/UICatalog/Scenarios/Adornments.cs index 5f155b8ee..8467ab784 100644 --- a/UICatalog/Scenarios/Adornments.cs +++ b/UICatalog/Scenarios/Adornments.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.Linq; using Terminal.Gui; @@ -21,7 +20,7 @@ public class Adornments : Scenario Window app = new () { - Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}", + Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}" }; var editor = new AdornmentsEditor (); @@ -31,9 +30,9 @@ public class Adornments : Scenario { Title = "The _Window", Arrangement = ViewArrangement.Movable, - X = Pos.Right(editor), + X = Pos.Right (editor), Width = Dim.Percent (60), - Height = Dim.Percent (80), + Height = Dim.Percent (80) }; app.Add (window); @@ -74,7 +73,7 @@ public class Adornments : Scenario { Y = Pos.AnchorEnd (), Width = 40, - Height = Dim.Percent(20), + Height = Dim.Percent (20), Text = "Label\nY=AnchorEnd(),Height=Dim.Percent(10)", ColorScheme = Colors.ColorSchemes ["Error"] }; @@ -88,10 +87,9 @@ public class Adornments : Scenario window.Padding.Data = "Padding"; window.Padding.Thickness = new (3); - var longLabel = new Label () + var longLabel = new Label { - X = 40, Y = 5, Title = "This is long text (in a label) that should clip.", - + X = 40, Y = 5, Title = "This is long text (in a label) that should clip." }; longLabel.TextFormatter.WordWrap = true; window.Add (tf1, color, button, label, btnButtonInWindow, labelAnchorEnd, longLabel); @@ -99,19 +97,20 @@ public class Adornments : Scenario editor.Initialized += (s, e) => { editor.ViewToEdit = window; }; window.Initialized += (s, e) => - { - var labelInPadding = new Label () { X = 1, Y = 0, Title = "_Text:" }; - window.Padding.Add (labelInPadding); + { + var labelInPadding = new Label { X = 1, Y = 0, Title = "_Text:" }; + window.Padding.Add (labelInPadding); - var textFieldInPadding = new TextField () { X = Pos.Right (labelInPadding) + 1, Y = Pos.Top (labelInPadding), Width = 15, Text = "some text" }; - textFieldInPadding.Accept += (s, e) => MessageBox.Query (20, 7, "TextField", textFieldInPadding.Text, "Ok"); - window.Padding.Add (textFieldInPadding); + var textFieldInPadding = new TextField + { X = Pos.Right (labelInPadding) + 1, Y = Pos.Top (labelInPadding), Width = 15, Text = "some text" }; + textFieldInPadding.Accept += (s, e) => MessageBox.Query (20, 7, "TextField", textFieldInPadding.Text, "Ok"); + window.Padding.Add (textFieldInPadding); - var btnButtonInPadding = new Button { X = Pos.Center (), Y = 0, Text = "_Button in Padding" }; - btnButtonInPadding.Accept += (s, e) => MessageBox.Query (20, 7, "Hi", "Button in Padding Pressed!", "Ok"); - btnButtonInPadding.BorderStyle = LineStyle.Dashed; - btnButtonInPadding.Border.Thickness = new (1, 1, 1, 1); - window.Padding.Add (btnButtonInPadding); + var btnButtonInPadding = new Button { X = Pos.Center (), Y = 0, Text = "_Button in Padding" }; + btnButtonInPadding.Accept += (s, e) => MessageBox.Query (20, 7, "Hi", "Button in Padding Pressed!", "Ok"); + btnButtonInPadding.BorderStyle = LineStyle.Dashed; + btnButtonInPadding.Border.Thickness = new (1, 1, 1, 1); + window.Padding.Add (btnButtonInPadding); #if SUBVIEW_BASED_BORDER btnButtonInPadding.Border.CloseButton.Visible = true; @@ -125,7 +124,7 @@ public class Adornments : Scenario view.Accept += (s, e) => MessageBox.Query (20, 7, "Hi", "Window Close Button Pressed!", "Ok"); #endif - }; + }; app.Closed += (s, e) => View.Diagnostics = _diagnosticFlags; @@ -136,7 +135,7 @@ public class Adornments : Scenario } /// - /// Provides a composable UI for editing the settings of an Adornment. + /// Provides a composable UI for editing the settings of an Adornment. /// public class AdornmentEditor : View { @@ -171,6 +170,7 @@ public class Adornments : Scenario BorderStyle = LineStyle.Double; Initialized += AdornmentEditor_Initialized; } + public Attribute Color { get => new (_foregroundColorPicker.SelectedColor, _backgroundColorPicker.SelectedColor); @@ -337,7 +337,7 @@ public class Adornments : Scenario } /// - /// Provides an editor UI for the Margin, Border, and Padding of a View. + /// Provides an editor UI for the Margin, Border, and Padding of a View. /// public class AdornmentsEditor : View { @@ -470,19 +470,19 @@ public class Adornments : Scenario _paddingEditor.AttributeChanged += Editor_AttributeChanged; Add (_paddingEditor); - _diagCheckBox = new CheckBox { Text = "_Diagnostics", Y = Pos.Bottom (_paddingEditor) }; - _diagCheckBox.Checked = View.Diagnostics != ViewDiagnosticFlags.Off; + _diagCheckBox = new() { Text = "_Diagnostics", Y = Pos.Bottom (_paddingEditor) }; + _diagCheckBox.Checked = Diagnostics != ViewDiagnosticFlags.Off; _diagCheckBox.Toggled += (s, e) => { if (e.NewValue == true) { - View.Diagnostics = + Diagnostics = ViewDiagnosticFlags.Padding | ViewDiagnosticFlags.Ruler; } else { - View.Diagnostics = ViewDiagnosticFlags.Off; + Diagnostics = ViewDiagnosticFlags.Off; } }; diff --git a/UICatalog/Scenarios/Dialogs.cs b/UICatalog/Scenarios/Dialogs.cs index 869d71226..cdc05fe10 100644 --- a/UICatalog/Scenarios/Dialogs.cs +++ b/UICatalog/Scenarios/Dialogs.cs @@ -42,7 +42,7 @@ public class Dialogs : Scenario }; frame.Add (widthEdit); - label = new Label + label = new() { X = 0, Y = Pos.Bottom (label), @@ -76,9 +76,8 @@ public class Dialogs : Scenario } ); - label = new Label + label = new() { - AutoSize = false, X = 0, Y = Pos.Bottom (label), Width = Dim.Width (numButtonsLabel), @@ -121,9 +120,8 @@ public class Dialogs : Scenario }; frame.Add (glyphsNotWords); - label = new Label + label = new() { - AutoSize = false, X = 0, Y = Pos.Bottom (glyphsNotWords), Width = Dim.Width (numButtonsLabel), @@ -132,6 +130,7 @@ public class Dialogs : Scenario Text = "Button St_yle:" }; frame.Add (label); + var styleRadioGroup = new RadioGroup { X = Pos.Right (label) + 1, @@ -158,7 +157,7 @@ public class Dialogs : Scenario Win.Add (frame); - label = new Label + label = new() { X = Pos.Center (), Y = Pos.Bottom (frame) + 4, TextAlignment = TextAlignment.Right, Text = "Button Pressed:" }; @@ -180,19 +179,19 @@ public class Dialogs : Scenario }; showDialogButton.Accept += (s, e) => - { - Dialog dlg = CreateDemoDialog ( - widthEdit, - heightEdit, - titleEdit, - numButtonsEdit, - glyphsNotWords, - styleRadioGroup, - buttonPressedLabel - ); - Application.Run (dlg); - dlg.Dispose (); - }; + { + Dialog dlg = CreateDemoDialog ( + widthEdit, + heightEdit, + titleEdit, + numButtonsEdit, + glyphsNotWords, + styleRadioGroup, + buttonPressedLabel + ); + Application.Run (dlg); + dlg.Dispose (); + }; Win.Add (showDialogButton); @@ -232,7 +231,7 @@ public class Dialogs : Scenario { buttonId = i; - button = new Button + button = new() { Text = NumberToWords.Convert (buttonId) + " " + char.ConvertFromUtf32 (buttonId + CODE_POINT), IsDefault = buttonId == 0 @@ -240,14 +239,14 @@ public class Dialogs : Scenario } else { - button = new Button { Text = NumberToWords.Convert (buttonId), IsDefault = buttonId == 0 }; + button = new() { Text = NumberToWords.Convert (buttonId), IsDefault = buttonId == 0 }; } button.Accept += (s, e) => - { - clicked = buttonId; - Application.RequestStop (); - }; + { + clicked = buttonId; + Application.RequestStop (); + }; buttons.Add (button); } @@ -261,7 +260,7 @@ public class Dialogs : Scenario // This tests dynamically adding buttons; ensuring the dialog resizes if needed and // the buttons are laid out correctly - dialog = new Dialog + dialog = new() { Title = titleEdit.Text, ButtonAlignment = (Dialog.ButtonAlignments)styleRadioGroup.SelectedItem, @@ -277,36 +276,36 @@ public class Dialogs : Scenario var add = new Button { X = Pos.Center (), Y = Pos.Center (), Text = "_Add a button" }; add.Accept += (s, e) => - { - int buttonId = buttons.Count; - Button button; + { + int buttonId = buttons.Count; + Button button; - if (glyphsNotWords.Checked == true) - { - button = new Button - { - Text = NumberToWords.Convert (buttonId) + " " + char.ConvertFromUtf32 (buttonId + CODE_POINT), - IsDefault = buttonId == 0 - }; - } - else - { - button = new Button { Text = NumberToWords.Convert (buttonId), IsDefault = buttonId == 0 }; - } + if (glyphsNotWords.Checked == true) + { + button = new() + { + Text = NumberToWords.Convert (buttonId) + " " + char.ConvertFromUtf32 (buttonId + CODE_POINT), + IsDefault = buttonId == 0 + }; + } + else + { + button = new() { Text = NumberToWords.Convert (buttonId), IsDefault = buttonId == 0 }; + } - button.Accept += (s, e) => - { - clicked = buttonId; - Application.RequestStop (); - }; - buttons.Add (button); - dialog.AddButton (button); + button.Accept += (s, e) => + { + clicked = buttonId; + Application.RequestStop (); + }; + buttons.Add (button); + dialog.AddButton (button); - if (buttons.Count > 1) - { - button.TabIndex = buttons [buttons.Count - 2].TabIndex + 1; - } - }; + if (buttons.Count > 1) + { + button.TabIndex = buttons [buttons.Count - 2].TabIndex + 1; + } + }; dialog.Add (add); var addChar = new Button @@ -317,14 +316,14 @@ public class Dialogs : Scenario }; addChar.Accept += (s, e) => - { - foreach (Button button in buttons) - { - button.Text += char.ConvertFromUtf32 (CODE_POINT); - } + { + foreach (Button button in buttons) + { + button.Text += char.ConvertFromUtf32 (CODE_POINT); + } - dialog.LayoutSubviews (); - }; + dialog.LayoutSubviews (); + }; dialog.Closed += (s, e) => { buttonPressedLabel.Text = $"{clicked}"; }; dialog.Add (addChar); } diff --git a/UICatalog/Scenarios/DimAutoDemo.cs b/UICatalog/Scenarios/DimAutoDemo.cs index 4b8317d6d..c42cff51f 100644 --- a/UICatalog/Scenarios/DimAutoDemo.cs +++ b/UICatalog/Scenarios/DimAutoDemo.cs @@ -11,6 +11,7 @@ public class DimAutoDemo : Scenario public override void Main () { Application.Init (); + // Setup - Create a top-level application window and configure it. Window appWindow = new () { @@ -111,7 +112,7 @@ public class DimAutoDemo : Scenario { Text = "_Move down", X = Pos.Right (vlabel), - Y = Pos.Bottom (vlabel), + Y = Pos.Bottom (vlabel) }; movingButton.Accept += (s, e) => { movingButton.Y = movingButton.Frame.Y + 1; }; view.Add (movingButton); @@ -142,7 +143,6 @@ public class DimAutoDemo : Scenario // Shutdown - Calling Application.Shutdown is required. Application.Shutdown (); - } private void DlgButton_Clicked (object sender, EventArgs e) @@ -150,7 +150,8 @@ public class DimAutoDemo : Scenario var dlg = new Dialog { Title = "Test Dialog", - Width = Dim.Auto (min: Dim.Percent (10)), + Width = Auto (min: Percent (10)) + //Height = Dim.Auto (min: Dim.Percent (50)) }; @@ -166,7 +167,7 @@ public class DimAutoDemo : Scenario //{ // ValidatePosDim = true, // Text = "This is a label (AutoSize = false; Dim.Auto(3/20). Press Esc to close. Even more text.", - // AutoSize = false, + // // X = Pos.Center (), // Y = 0, // Height = Auto (min: 3), @@ -178,7 +179,7 @@ public class DimAutoDemo : Scenario { ValidatePosDim = true, Text = "TextField: X=1; Y=Pos.Bottom (label)+1, Width=Dim.Fill (0); Height=1", - TextFormatter = new TextFormatter { WordWrap = true }, + TextFormatter = new() { WordWrap = true }, X = 0, Y = 0, //Pos.Bottom (label) + 1, Width = Fill (10), @@ -194,6 +195,7 @@ public class DimAutoDemo : Scenario //btn.X = Pos.AnchorEnd () - (Pos.Right (btn) - Pos.Left (btn)); //dlg.Add (label); dlg.Add (text); + //dlg.Add (btn); Application.Run (dlg); dlg.Dispose (); diff --git a/UICatalog/Scenarios/DynamicMenuBar.cs b/UICatalog/Scenarios/DynamicMenuBar.cs index 650e854db..da0768f4f 100644 --- a/UICatalog/Scenarios/DynamicMenuBar.cs +++ b/UICatalog/Scenarios/DynamicMenuBar.cs @@ -107,31 +107,31 @@ public class DynamicMenuBar : Scenario var _lblTitle = new Label { Y = 1, Text = "Title:" }; Add (_lblTitle); - TextTitle = new TextField { X = Pos.Right (_lblTitle) + 2, Y = Pos.Top (_lblTitle), Width = Dim.Fill () }; + TextTitle = new() { X = Pos.Right (_lblTitle) + 2, Y = Pos.Top (_lblTitle), Width = Dim.Fill () }; Add (TextTitle); var _lblHelp = new Label { X = Pos.Left (_lblTitle), Y = Pos.Bottom (_lblTitle) + 1, Text = "Help:" }; Add (_lblHelp); - TextHelp = new TextField { X = Pos.Left (TextTitle), Y = Pos.Top (_lblHelp), Width = Dim.Fill () }; + TextHelp = new() { X = Pos.Left (TextTitle), Y = Pos.Top (_lblHelp), Width = Dim.Fill () }; Add (TextHelp); var _lblAction = new Label { X = Pos.Left (_lblTitle), Y = Pos.Bottom (_lblHelp) + 1, Text = "Action:" }; Add (_lblAction); - TextAction = new TextView + TextAction = new() { X = Pos.Left (TextTitle), Y = Pos.Top (_lblAction), Width = Dim.Fill (), Height = 5 }; Add (TextAction); - CkbIsTopLevel = new CheckBox + CkbIsTopLevel = new() { X = Pos.Left (_lblTitle), Y = Pos.Bottom (_lblAction) + 5, Text = "IsTopLevel" }; Add (CkbIsTopLevel); - CkbSubMenu = new CheckBox + CkbSubMenu = new() { X = Pos.Left (_lblTitle), Y = Pos.Bottom (CkbIsTopLevel), @@ -140,7 +140,7 @@ public class DynamicMenuBar : Scenario }; Add (CkbSubMenu); - CkbNullCheck = new CheckBox + CkbNullCheck = new() { X = Pos.Left (_lblTitle), Y = Pos.Bottom (CkbSubMenu), Text = "Allow null checked" }; @@ -148,7 +148,7 @@ public class DynamicMenuBar : Scenario var _rChkLabels = new [] { "NoCheck", "Checked", "Radio" }; - RbChkStyle = new RadioGroup + RbChkStyle = new() { X = Pos.Left (_lblTitle), Y = Pos.Bottom (CkbSubMenu) + 1, RadioLabels = _rChkLabels }; @@ -160,7 +160,7 @@ public class DynamicMenuBar : Scenario }; Add (_lblShortcut); - TextShortcut = new TextField + TextShortcut = new() { X = Pos.X (_lblShortcut), Y = Pos.Bottom (_lblShortcut), Width = Dim.Fill (), ReadOnly = true }; @@ -194,7 +194,7 @@ public class DynamicMenuBar : Scenario bool CheckShortcut (KeyCode k, bool pre) { - MenuItem m = _menuItem != null ? _menuItem : new MenuItem (); + MenuItem m = _menuItem != null ? _menuItem : new (); if (pre && !ShortcutHelper.PreShortcutValidation (k)) { @@ -422,24 +422,24 @@ public class DynamicMenuBar : Scenario var btnOk = new Button { IsDefault = true, Text = "Ok" }; btnOk.Accept += (s, e) => - { - if (string.IsNullOrEmpty (TextTitle.Text)) - { - MessageBox.ErrorQuery ("Invalid title", "Must enter a valid title!.", "Ok"); - } - else - { - valid = true; - Application.RequestStop (); - } - }; + { + if (string.IsNullOrEmpty (TextTitle.Text)) + { + MessageBox.ErrorQuery ("Invalid title", "Must enter a valid title!.", "Ok"); + } + else + { + valid = true; + Application.RequestStop (); + } + }; var btnCancel = new Button { Text = "Cancel" }; btnCancel.Accept += (s, e) => - { - TextTitle.Text = string.Empty; - Application.RequestStop (); - }; + { + TextTitle.Text = string.Empty; + Application.RequestStop (); + }; var dialog = new Dialog { Title = "Enter the menu details.", Buttons = [btnOk, btnCancel] }; Width = Dim.Fill (); @@ -452,7 +452,7 @@ public class DynamicMenuBar : Scenario if (valid) { - return new DynamicMenuItem + return new() { Title = TextTitle.Text, Help = TextHelp.Text, @@ -486,13 +486,13 @@ public class DynamicMenuBar : Scenario } else { - menuItem = new MenuItem ( - menuItem.Title, - menuItem.Help, - CreateAction (menuItem, new DynamicMenuItem ()), - null, - menuItem.Parent - ); + menuItem = new ( + menuItem.Title, + menuItem.Help, + CreateAction (menuItem, new ()), + null, + menuItem.Parent + ); if (idx > -1) { @@ -569,7 +569,7 @@ public class DynamicMenuBar : Scenario public DynamicMenuBarSample () { - DataContext = new DynamicMenuItemModel (); + DataContext = new (); var _frmDelimiter = new FrameView { @@ -626,7 +626,7 @@ public class DynamicMenuBar : Scenario TextAlignment = TextAlignment.Centered, X = Pos.Right (_btnPrevious) + 1, Y = Pos.Top (_btnPrevious), - AutoSize = false, + Width = Dim.Fill () - Dim.Function (() => _btnAdd.Frame.Width + 1), Height = 1 }; @@ -639,7 +639,7 @@ public class DynamicMenuBar : Scenario TextAlignment = TextAlignment.Centered, X = Pos.Right (_btnPrevious) + 1, Y = Pos.Top (_btnPrevious) + 1, - AutoSize = false, + Width = Dim.Fill () - Dim.Width (_btnAdd) - 1 }; _frmMenu.Add (_lblParent); @@ -650,7 +650,7 @@ public class DynamicMenuBar : Scenario }; _frmMenu.Add (_btnPreviowsParent); - _lstMenus = new ListView + _lstMenus = new() { ColorScheme = Colors.ColorSchemes ["Dialog"], X = Pos.Right (_btnPrevious) + 1, @@ -688,121 +688,121 @@ public class DynamicMenuBar : Scenario Add (_frmMenuDetails); _btnMenuBarUp.Accept += (s, e) => - { - int i = _currentSelectedMenuBar; + { + int i = _currentSelectedMenuBar; - MenuBarItem menuItem = _menuBar != null && _menuBar.Menus.Length > 0 - ? _menuBar.Menus [i] - : null; + MenuBarItem menuItem = _menuBar != null && _menuBar.Menus.Length > 0 + ? _menuBar.Menus [i] + : null; - if (menuItem != null) - { - MenuBarItem [] menus = _menuBar.Menus; + if (menuItem != null) + { + MenuBarItem [] menus = _menuBar.Menus; - if (i > 0) - { - menus [i] = menus [i - 1]; - menus [i - 1] = menuItem; - _currentSelectedMenuBar = i - 1; - _menuBar.SetNeedsDisplay (); - } - } - }; + if (i > 0) + { + menus [i] = menus [i - 1]; + menus [i - 1] = menuItem; + _currentSelectedMenuBar = i - 1; + _menuBar.SetNeedsDisplay (); + } + } + }; _btnMenuBarDown.Accept += (s, e) => - { - int i = _currentSelectedMenuBar; + { + int i = _currentSelectedMenuBar; - MenuBarItem menuItem = _menuBar != null && _menuBar.Menus.Length > 0 - ? _menuBar.Menus [i] - : null; + MenuBarItem menuItem = _menuBar != null && _menuBar.Menus.Length > 0 + ? _menuBar.Menus [i] + : null; - if (menuItem != null) - { - MenuBarItem [] menus = _menuBar.Menus; + if (menuItem != null) + { + MenuBarItem [] menus = _menuBar.Menus; - if (i < menus.Length - 1) - { - menus [i] = menus [i + 1]; - menus [i + 1] = menuItem; - _currentSelectedMenuBar = i + 1; - _menuBar.SetNeedsDisplay (); - } - } - }; + if (i < menus.Length - 1) + { + menus [i] = menus [i + 1]; + menus [i + 1] = menuItem; + _currentSelectedMenuBar = i + 1; + _menuBar.SetNeedsDisplay (); + } + } + }; _btnUp.Accept += (s, e) => - { - int i = _lstMenus.SelectedItem; - MenuItem menuItem = DataContext.Menus.Count > 0 ? DataContext.Menus [i].MenuItem : null; + { + int i = _lstMenus.SelectedItem; + MenuItem menuItem = DataContext.Menus.Count > 0 ? DataContext.Menus [i].MenuItem : null; - if (menuItem != null) - { - MenuItem [] childrens = ((MenuBarItem)_currentMenuBarItem).Children; + if (menuItem != null) + { + MenuItem [] childrens = ((MenuBarItem)_currentMenuBarItem).Children; - if (i > 0) - { - childrens [i] = childrens [i - 1]; - childrens [i - 1] = menuItem; - DataContext.Menus [i] = DataContext.Menus [i - 1]; + if (i > 0) + { + childrens [i] = childrens [i - 1]; + childrens [i - 1] = menuItem; + DataContext.Menus [i] = DataContext.Menus [i - 1]; - DataContext.Menus [i - 1] = - new DynamicMenuItemList { Title = menuItem.Title, MenuItem = menuItem }; - _lstMenus.SelectedItem = i - 1; - } - } - }; + DataContext.Menus [i - 1] = + new() { Title = menuItem.Title, MenuItem = menuItem }; + _lstMenus.SelectedItem = i - 1; + } + } + }; _btnDown.Accept += (s, e) => - { - int i = _lstMenus.SelectedItem; - MenuItem menuItem = DataContext.Menus.Count > 0 ? DataContext.Menus [i].MenuItem : null; + { + int i = _lstMenus.SelectedItem; + MenuItem menuItem = DataContext.Menus.Count > 0 ? DataContext.Menus [i].MenuItem : null; - if (menuItem != null) - { - MenuItem [] childrens = ((MenuBarItem)_currentMenuBarItem).Children; + if (menuItem != null) + { + MenuItem [] childrens = ((MenuBarItem)_currentMenuBarItem).Children; - if (i < childrens.Length - 1) - { - childrens [i] = childrens [i + 1]; - childrens [i + 1] = menuItem; - DataContext.Menus [i] = DataContext.Menus [i + 1]; + if (i < childrens.Length - 1) + { + childrens [i] = childrens [i + 1]; + childrens [i + 1] = menuItem; + DataContext.Menus [i] = DataContext.Menus [i + 1]; - DataContext.Menus [i + 1] = - new DynamicMenuItemList { Title = menuItem.Title, MenuItem = menuItem }; - _lstMenus.SelectedItem = i + 1; - } - } - }; + DataContext.Menus [i + 1] = + new() { Title = menuItem.Title, MenuItem = menuItem }; + _lstMenus.SelectedItem = i + 1; + } + } + }; _btnPreviowsParent.Accept += (s, e) => - { - if (_currentMenuBarItem != null && _currentMenuBarItem.Parent != null) - { - MenuItem mi = _currentMenuBarItem; - _currentMenuBarItem = _currentMenuBarItem.Parent as MenuBarItem; - SetListViewSource (_currentMenuBarItem, true); - int i = ((MenuBarItem)_currentMenuBarItem).GetChildrenIndex (mi); + { + if (_currentMenuBarItem != null && _currentMenuBarItem.Parent != null) + { + MenuItem mi = _currentMenuBarItem; + _currentMenuBarItem = _currentMenuBarItem.Parent as MenuBarItem; + SetListViewSource (_currentMenuBarItem, true); + int i = ((MenuBarItem)_currentMenuBarItem).GetChildrenIndex (mi); - if (i > -1) - { - _lstMenus.SelectedItem = i; - } + if (i > -1) + { + _lstMenus.SelectedItem = i; + } - if (_currentMenuBarItem.Parent != null) - { - DataContext.Parent = _currentMenuBarItem.Title; - } - else - { - DataContext.Parent = string.Empty; - } - } - else - { - DataContext.Parent = string.Empty; - } - }; + if (_currentMenuBarItem.Parent != null) + { + DataContext.Parent = _currentMenuBarItem.Title; + } + else + { + DataContext.Parent = string.Empty; + } + } + else + { + DataContext.Parent = string.Empty; + } + }; var _btnOk = new Button { X = Pos.Right (_frmMenu) + 20, Y = Pos.Bottom (_frmMenuDetails), Text = "Ok" }; Add (_btnOk); @@ -814,157 +814,157 @@ public class DynamicMenuBar : Scenario _lstMenus.SelectedItemChanged += (s, e) => { SetFrameDetails (); }; _btnOk.Accept += (s, e) => + { + if (string.IsNullOrEmpty (_frmMenuDetails.TextTitle.Text) && _currentEditMenuBarItem != null) + { + MessageBox.ErrorQuery ("Invalid title", "Must enter a valid title!.", "Ok"); + } + else if (_currentEditMenuBarItem != null) + { + var menuItem = new DynamicMenuItem + { + Title = _frmMenuDetails.TextTitle.Text, + Help = _frmMenuDetails.TextHelp.Text, + Action = _frmMenuDetails.TextAction.Text, + IsTopLevel = _frmMenuDetails.CkbIsTopLevel?.Checked ?? false, + HasSubMenu = _frmMenuDetails.CkbSubMenu?.Checked ?? false, + CheckStyle = _frmMenuDetails.RbChkStyle.SelectedItem == 0 + ? MenuItemCheckStyle.NoCheck + : _frmMenuDetails.RbChkStyle.SelectedItem == 1 + ? MenuItemCheckStyle.Checked + : MenuItemCheckStyle.Radio, + Shortcut = _frmMenuDetails.TextShortcut.Text + }; + UpdateMenuItem (_currentEditMenuBarItem, menuItem, _lstMenus.SelectedItem); + } + }; + + _btnAdd.Accept += (s, e) => { - if (string.IsNullOrEmpty (_frmMenuDetails.TextTitle.Text) && _currentEditMenuBarItem != null) + if (MenuBar == null) { - MessageBox.ErrorQuery ("Invalid title", "Must enter a valid title!.", "Ok"); + MessageBox.ErrorQuery ("Menu Bar Error", "Must add a MenuBar first!", "Ok"); + _btnAddMenuBar.SetFocus (); + + return; } - else if (_currentEditMenuBarItem != null) + + var frameDetails = new DynamicMenuBarDetails (null, _currentMenuBarItem != null); + DynamicMenuItem item = frameDetails.EnterMenuItem (); + + if (item == null) { - var menuItem = new DynamicMenuItem + return; + } + + if (!(_currentMenuBarItem is MenuBarItem)) + { + var parent = _currentMenuBarItem.Parent as MenuBarItem; + int idx = parent.GetChildrenIndex (_currentMenuBarItem); + + _currentMenuBarItem = new MenuBarItem ( + _currentMenuBarItem.Title, + new MenuItem [] { }, + _currentMenuBarItem.Parent + ); + _currentMenuBarItem.CheckType = item.CheckStyle; + parent.Children [idx] = _currentMenuBarItem; + } + else + { + MenuItem newMenu = CreateNewMenu (item, _currentMenuBarItem); + var menuBarItem = _currentMenuBarItem as MenuBarItem; + + if (menuBarItem == null) { - Title = _frmMenuDetails.TextTitle.Text, - Help = _frmMenuDetails.TextHelp.Text, - Action = _frmMenuDetails.TextAction.Text, - IsTopLevel = _frmMenuDetails.CkbIsTopLevel?.Checked ?? false, - HasSubMenu = _frmMenuDetails.CkbSubMenu?.Checked ?? false, - CheckStyle = _frmMenuDetails.RbChkStyle.SelectedItem == 0 - ? MenuItemCheckStyle.NoCheck - : _frmMenuDetails.RbChkStyle.SelectedItem == 1 - ? MenuItemCheckStyle.Checked - : MenuItemCheckStyle.Radio, - Shortcut = _frmMenuDetails.TextShortcut.Text - }; - UpdateMenuItem (_currentEditMenuBarItem, menuItem, _lstMenus.SelectedItem); + menuBarItem = new ( + _currentMenuBarItem.Title, + new [] { newMenu }, + _currentMenuBarItem.Parent + ); + } + else if (menuBarItem.Children == null) + { + menuBarItem.Children = new [] { newMenu }; + } + else + { + MenuItem [] childrens = menuBarItem.Children; + Array.Resize (ref childrens, childrens.Length + 1); + childrens [childrens.Length - 1] = newMenu; + menuBarItem.Children = childrens; + } + + DataContext.Menus.Add (new() { Title = newMenu.Title, MenuItem = newMenu }); + _lstMenus.MoveDown (); } }; - _btnAdd.Accept += (s, e) => - { - if (MenuBar == null) - { - MessageBox.ErrorQuery ("Menu Bar Error", "Must add a MenuBar first!", "Ok"); - _btnAddMenuBar.SetFocus (); - - return; - } - - var frameDetails = new DynamicMenuBarDetails (null, _currentMenuBarItem != null); - DynamicMenuItem item = frameDetails.EnterMenuItem (); - - if (item == null) - { - return; - } - - if (!(_currentMenuBarItem is MenuBarItem)) - { - var parent = _currentMenuBarItem.Parent as MenuBarItem; - int idx = parent.GetChildrenIndex (_currentMenuBarItem); - - _currentMenuBarItem = new MenuBarItem ( - _currentMenuBarItem.Title, - new MenuItem [] { }, - _currentMenuBarItem.Parent - ); - _currentMenuBarItem.CheckType = item.CheckStyle; - parent.Children [idx] = _currentMenuBarItem; - } - else - { - MenuItem newMenu = CreateNewMenu (item, _currentMenuBarItem); - var menuBarItem = _currentMenuBarItem as MenuBarItem; - - if (menuBarItem == null) - { - menuBarItem = new MenuBarItem ( - _currentMenuBarItem.Title, - new [] { newMenu }, - _currentMenuBarItem.Parent - ); - } - else if (menuBarItem.Children == null) - { - menuBarItem.Children = new [] { newMenu }; - } - else - { - MenuItem [] childrens = menuBarItem.Children; - Array.Resize (ref childrens, childrens.Length + 1); - childrens [childrens.Length - 1] = newMenu; - menuBarItem.Children = childrens; - } - - DataContext.Menus.Add (new DynamicMenuItemList { Title = newMenu.Title, MenuItem = newMenu }); - _lstMenus.MoveDown (); - } - }; - _btnRemove.Accept += (s, e) => - { - MenuItem menuItem = DataContext.Menus.Count > 0 - ? DataContext.Menus [_lstMenus.SelectedItem].MenuItem - : null; + { + MenuItem menuItem = DataContext.Menus.Count > 0 + ? DataContext.Menus [_lstMenus.SelectedItem].MenuItem + : null; - if (menuItem != null) - { - MenuItem [] childrens = ((MenuBarItem)_currentMenuBarItem).Children; - childrens [_lstMenus.SelectedItem] = null; - var i = 0; + if (menuItem != null) + { + MenuItem [] childrens = ((MenuBarItem)_currentMenuBarItem).Children; + childrens [_lstMenus.SelectedItem] = null; + var i = 0; - foreach (MenuItem c in childrens) - { - if (c != null) - { - childrens [i] = c; - i++; - } - } + foreach (MenuItem c in childrens) + { + if (c != null) + { + childrens [i] = c; + i++; + } + } - Array.Resize (ref childrens, childrens.Length - 1); + Array.Resize (ref childrens, childrens.Length - 1); - if (childrens.Length == 0) - { - if (_currentMenuBarItem.Parent == null) - { - ((MenuBarItem)_currentMenuBarItem).Children = null; + if (childrens.Length == 0) + { + if (_currentMenuBarItem.Parent == null) + { + ((MenuBarItem)_currentMenuBarItem).Children = null; - //_currentMenuBarItem.Action = _frmMenuDetails.CreateAction (_currentEditMenuBarItem, new DynamicMenuItem (_currentMenuBarItem.Title)); - } - else - { - _currentMenuBarItem = new MenuItem ( - _currentMenuBarItem.Title, - _currentMenuBarItem.Help, - _frmMenuDetails.CreateAction ( - _currentEditMenuBarItem, - new DynamicMenuItem - { - Title = _currentEditMenuBarItem - .Title - } - ), - null, - _currentMenuBarItem.Parent - ); - } - } - else - { - ((MenuBarItem)_currentMenuBarItem).Children = childrens; - } + //_currentMenuBarItem.Action = _frmMenuDetails.CreateAction (_currentEditMenuBarItem, new DynamicMenuItem (_currentMenuBarItem.Title)); + } + else + { + _currentMenuBarItem = new ( + _currentMenuBarItem.Title, + _currentMenuBarItem.Help, + _frmMenuDetails.CreateAction ( + _currentEditMenuBarItem, + new() + { + Title = _currentEditMenuBarItem + .Title + } + ), + null, + _currentMenuBarItem.Parent + ); + } + } + else + { + ((MenuBarItem)_currentMenuBarItem).Children = childrens; + } - DataContext.Menus.RemoveAt (_lstMenus.SelectedItem); + DataContext.Menus.RemoveAt (_lstMenus.SelectedItem); - if (_lstMenus.Source.Count > 0 && _lstMenus.SelectedItem > _lstMenus.Source.Count - 1) - { - _lstMenus.SelectedItem = _lstMenus.Source.Count - 1; - } + if (_lstMenus.Source.Count > 0 && _lstMenus.SelectedItem > _lstMenus.Source.Count - 1) + { + _lstMenus.SelectedItem = _lstMenus.Source.Count - 1; + } - _lstMenus.SetNeedsDisplay (); - SetFrameDetails (); - } - }; + _lstMenus.SetNeedsDisplay (); + SetFrameDetails (); + } + }; _lstMenus.OpenSelectedItem += (s, e) => { @@ -978,7 +978,7 @@ public class DynamicMenuBar : Scenario } DataContext.Parent = _currentMenuBarItem.Title; - DataContext.Menus = new List (); + DataContext.Menus = new (); SetListViewSource (_currentMenuBarItem, true); MenuItem menuBarItem = DataContext.Menus.Count > 0 ? DataContext.Menus [0].MenuItem : null; SetFrameDetails (menuBarItem); @@ -993,24 +993,24 @@ public class DynamicMenuBar : Scenario }; _btnNext.Accept += (s, e) => - { - if (_menuBar != null && _currentSelectedMenuBar + 1 < _menuBar.Menus.Length) - { - _currentSelectedMenuBar++; - } + { + if (_menuBar != null && _currentSelectedMenuBar + 1 < _menuBar.Menus.Length) + { + _currentSelectedMenuBar++; + } - SelectCurrentMenuBarItem (); - }; + SelectCurrentMenuBarItem (); + }; _btnPrevious.Accept += (s, e) => - { - if (_currentSelectedMenuBar - 1 > -1) - { - _currentSelectedMenuBar--; - } + { + if (_currentSelectedMenuBar - 1 > -1) + { + _currentSelectedMenuBar--; + } - SelectCurrentMenuBarItem (); - }; + SelectCurrentMenuBarItem (); + }; _lblMenuBar.Enter += (s, e) => { @@ -1022,89 +1022,89 @@ public class DynamicMenuBar : Scenario }; _btnAddMenuBar.Accept += (s, e) => - { - var frameDetails = new DynamicMenuBarDetails (null); - DynamicMenuItem item = frameDetails.EnterMenuItem (); + { + var frameDetails = new DynamicMenuBarDetails (null); + DynamicMenuItem item = frameDetails.EnterMenuItem (); - if (item == null) - { - return; - } + if (item == null) + { + return; + } - if (MenuBar == null) - { - _menuBar = new MenuBar (); - Add (_menuBar); - } + if (MenuBar == null) + { + _menuBar = new (); + Add (_menuBar); + } - var newMenu = CreateNewMenu (item) as MenuBarItem; + var newMenu = CreateNewMenu (item) as MenuBarItem; - MenuBarItem [] menus = _menuBar.Menus; - Array.Resize (ref menus, menus.Length + 1); - menus [^1] = newMenu; - _menuBar.Menus = menus; - _currentMenuBarItem = newMenu; - _currentMenuBarItem.CheckType = item.CheckStyle; - _currentSelectedMenuBar = menus.Length - 1; - _menuBar.Menus [_currentSelectedMenuBar] = newMenu; - _lblMenuBar.Text = newMenu.Title; - SetListViewSource (_currentMenuBarItem, true); - SetFrameDetails (_menuBar.Menus [_currentSelectedMenuBar]); - _menuBar.SetNeedsDisplay (); - }; + MenuBarItem [] menus = _menuBar.Menus; + Array.Resize (ref menus, menus.Length + 1); + menus [^1] = newMenu; + _menuBar.Menus = menus; + _currentMenuBarItem = newMenu; + _currentMenuBarItem.CheckType = item.CheckStyle; + _currentSelectedMenuBar = menus.Length - 1; + _menuBar.Menus [_currentSelectedMenuBar] = newMenu; + _lblMenuBar.Text = newMenu.Title; + SetListViewSource (_currentMenuBarItem, true); + SetFrameDetails (_menuBar.Menus [_currentSelectedMenuBar]); + _menuBar.SetNeedsDisplay (); + }; _btnRemoveMenuBar.Accept += (s, e) => - { - if (_menuBar == null || _menuBar.Menus.Length == 0) - { - return; - } + { + if (_menuBar == null || _menuBar.Menus.Length == 0) + { + return; + } - if (_menuBar != null && _menuBar.Menus.Length > 0) - { - _menuBar.Menus [_currentSelectedMenuBar] = null; - var i = 0; + if (_menuBar != null && _menuBar.Menus.Length > 0) + { + _menuBar.Menus [_currentSelectedMenuBar] = null; + var i = 0; - foreach (MenuBarItem m in _menuBar.Menus) - { - if (m != null) - { - _menuBar.Menus [i] = m; - i++; - } - } + foreach (MenuBarItem m in _menuBar.Menus) + { + if (m != null) + { + _menuBar.Menus [i] = m; + i++; + } + } - MenuBarItem [] menus = _menuBar.Menus; - Array.Resize (ref menus, menus.Length - 1); - _menuBar.Menus = menus; + MenuBarItem [] menus = _menuBar.Menus; + Array.Resize (ref menus, menus.Length - 1); + _menuBar.Menus = menus; - if (_currentSelectedMenuBar - 1 >= 0 && _menuBar.Menus.Length > 0) - { - _currentSelectedMenuBar--; - } + if (_currentSelectedMenuBar - 1 >= 0 && _menuBar.Menus.Length > 0) + { + _currentSelectedMenuBar--; + } - _currentMenuBarItem = _menuBar.Menus?.Length > 0 - ? _menuBar.Menus [_currentSelectedMenuBar] - : null; - } + _currentMenuBarItem = _menuBar.Menus?.Length > 0 + ? _menuBar.Menus [_currentSelectedMenuBar] + : null; + } - if (MenuBar != null && _currentMenuBarItem == null && _menuBar.Menus.Length == 0) - { - Remove (_menuBar); - _menuBar = null; - DataContext.Menus = new List (); - _currentMenuBarItem = null; - _currentSelectedMenuBar = -1; - _lblMenuBar.Text = string.Empty; - } - else - { - _lblMenuBar.Text = _menuBar.Menus [_currentSelectedMenuBar].Title; - } + if (MenuBar != null && _currentMenuBarItem == null && _menuBar.Menus.Length == 0) + { + Remove (_menuBar); + _menuBar = null; + DataContext.Menus = new (); + _currentMenuBarItem = null; + _currentSelectedMenuBar = -1; + _lblMenuBar.Text = string.Empty; + } + else + { + _lblMenuBar.Text = _menuBar.Menus [_currentSelectedMenuBar].Title; + } - SetListViewSource (_currentMenuBarItem, true); - SetFrameDetails (); - }; + SetListViewSource (_currentMenuBarItem, true); + SetFrameDetails (); + }; SetFrameDetails (); @@ -1153,14 +1153,14 @@ public class DynamicMenuBar : Scenario SetFrameDetails (menuBarItem); _currentMenuBarItem = menuBarItem; - DataContext.Menus = new List (); + DataContext.Menus = new (); SetListViewSource (_currentMenuBarItem, true); _lblParent.Text = string.Empty; } void SetListViewSource (MenuItem _currentMenuBarItem, bool fill = false) { - DataContext.Menus = new List (); + DataContext.Menus = new (); var menuBarItem = _currentMenuBarItem as MenuBarItem; if (menuBarItem != null && menuBarItem?.Children == null) @@ -1193,7 +1193,7 @@ public class DynamicMenuBar : Scenario } else if (parent != null) { - newMenu = new MenuItem (item.Title, item.Help, null, null, parent); + newMenu = new (item.Title, item.Help, null, null, parent); newMenu.CheckType = item.CheckStyle; newMenu.Action = _frmMenuDetails.CreateAction (newMenu, item); newMenu.Shortcut = ShortcutHelper.GetShortcutFromTag (item.Shortcut); @@ -1266,20 +1266,20 @@ public class DynamicMenuBar : Scenario { _frmMenuDetails.UpdateParent (ref _currentEditMenuBarItem); - _currentEditMenuBarItem = new MenuItem ( - menuItem.Title, - menuItem.Help, - _frmMenuDetails.CreateAction (_currentEditMenuBarItem, menuItem), - null, - _currentEditMenuBarItem.Parent - ); + _currentEditMenuBarItem = new ( + menuItem.Title, + menuItem.Help, + _frmMenuDetails.CreateAction (_currentEditMenuBarItem, menuItem), + null, + _currentEditMenuBarItem.Parent + ); } else { if (_currentEditMenuBarItem is MenuBarItem) { ((MenuBarItem)_currentEditMenuBarItem).Children = null; - DataContext.Menus = new List (); + DataContext.Menus = new (); } _currentEditMenuBarItem.Action = @@ -1298,7 +1298,7 @@ public class DynamicMenuBar : Scenario if (DataContext.Menus.Count == 0) { DataContext.Menus.Add ( - new DynamicMenuItemList + new() { Title = _currentEditMenuBarItem.Title, MenuItem = _currentEditMenuBarItem } @@ -1306,7 +1306,7 @@ public class DynamicMenuBar : Scenario } DataContext.Menus [index] = - new DynamicMenuItemList + new() { Title = _currentEditMenuBarItem.Title, MenuItem = _currentEditMenuBarItem }; @@ -1362,7 +1362,7 @@ public class DynamicMenuBar : Scenario PropertyChanged?.Invoke ( this, - new PropertyChangedEventArgs (GetPropertyName ()) + new (GetPropertyName ()) ); } } @@ -1381,7 +1381,7 @@ public class DynamicMenuBar : Scenario PropertyChanged?.Invoke ( this, - new PropertyChangedEventArgs (GetPropertyName ()) + new (GetPropertyName ()) ); } } @@ -1400,7 +1400,7 @@ public class DynamicMenuBar : Scenario PropertyChanged?.Invoke ( this, - new PropertyChangedEventArgs (GetPropertyName ()) + new (GetPropertyName ()) ); } } diff --git a/UICatalog/Scenarios/Editor.cs b/UICatalog/Scenarios/Editor.cs index 85bcba8b9..21e4b249a 100644 --- a/UICatalog/Scenarios/Editor.cs +++ b/UICatalog/Scenarios/Editor.cs @@ -44,7 +44,7 @@ public class Editor : Scenario Top = new (); - Win = new Window + Win = new() { Title = _fileName ?? "Untitled", X = 0, @@ -55,7 +55,7 @@ public class Editor : Scenario }; Top.Add (Win); - _textView = new TextView + _textView = new() { X = 0, Y = 0, @@ -75,168 +75,168 @@ public class Editor : Scenario { Menus = [ - new MenuBarItem ( - "_File", - new MenuItem [] - { - new ("_New", "", () => New ()), - new ("_Open", "", () => Open ()), - new ("_Save", "", () => Save ()), - new ("_Save As", "", () => SaveAs ()), - new ("_Close", "", () => CloseFile ()), - null, - new ("_Quit", "", () => Quit ()) - } - ), - new MenuBarItem ( - "_Edit", - new MenuItem [] - { - new ( - "_Copy", - "", - () => Copy (), - null, - null, - KeyCode.CtrlMask | KeyCode.C - ), - new ( - "C_ut", - "", - () => Cut (), - null, - null, - KeyCode.CtrlMask | KeyCode.W - ), - new ( - "_Paste", - "", - () => Paste (), - null, - null, - KeyCode.CtrlMask | KeyCode.Y - ), - null, - new ( - "_Find", - "", - () => Find (), - null, - null, - KeyCode.CtrlMask | KeyCode.S - ), - new ( - "Find _Next", - "", - () => FindNext (), - null, - null, - KeyCode.CtrlMask - | KeyCode.ShiftMask - | KeyCode.S - ), - new ( - "Find P_revious", - "", - () => FindPrevious (), - null, - null, - KeyCode.CtrlMask - | KeyCode.ShiftMask - | KeyCode.AltMask - | KeyCode.S - ), - new ( - "_Replace", - "", - () => Replace (), - null, - null, - KeyCode.CtrlMask | KeyCode.R - ), - new ( - "Replace Ne_xt", - "", - () => ReplaceNext (), - null, - null, - KeyCode.CtrlMask - | KeyCode.ShiftMask - | KeyCode.R - ), - new ( - "Replace Pre_vious", - "", - () => ReplacePrevious (), - null, - null, - KeyCode.CtrlMask - | KeyCode.ShiftMask - | KeyCode.AltMask - | KeyCode.R - ), - new ( - "Replace _All", - "", - () => ReplaceAll (), - null, - null, - KeyCode.CtrlMask - | KeyCode.ShiftMask - | KeyCode.AltMask - | KeyCode.A - ), - null, - new ( - "_Select All", - "", - () => SelectAll (), - null, - null, - KeyCode.CtrlMask | KeyCode.T - ) - } - ), - new MenuBarItem ("_ScrollBarView", CreateKeepChecked ()), - new MenuBarItem ("_Cursor", CreateCursorRadio ()), - new MenuBarItem ( - "Forma_t", - new [] - { - CreateWrapChecked (), - CreateAutocomplete (), - CreateAllowsTabChecked (), - CreateReadOnlyChecked () - } - ), - new MenuBarItem ( - "_Responder", - new [] { CreateCanFocusChecked (), CreateEnabledChecked (), CreateVisibleChecked () } - ), - new MenuBarItem ( - "Conte_xtMenu", - new [] - { - _miForceMinimumPosToZero = new MenuItem ( - "ForceMinimumPosTo_Zero", - "", - () => - { - _miForceMinimumPosToZero.Checked = - _forceMinimumPosToZero = - !_forceMinimumPosToZero; + new ( + "_File", + new MenuItem [] + { + new ("_New", "", () => New ()), + new ("_Open", "", () => Open ()), + new ("_Save", "", () => Save ()), + new ("_Save As", "", () => SaveAs ()), + new ("_Close", "", () => CloseFile ()), + null, + new ("_Quit", "", () => Quit ()) + } + ), + new ( + "_Edit", + new MenuItem [] + { + new ( + "_Copy", + "", + () => Copy (), + null, + null, + KeyCode.CtrlMask | KeyCode.C + ), + new ( + "C_ut", + "", + () => Cut (), + null, + null, + KeyCode.CtrlMask | KeyCode.W + ), + new ( + "_Paste", + "", + () => Paste (), + null, + null, + KeyCode.CtrlMask | KeyCode.Y + ), + null, + new ( + "_Find", + "", + () => Find (), + null, + null, + KeyCode.CtrlMask | KeyCode.S + ), + new ( + "Find _Next", + "", + () => FindNext (), + null, + null, + KeyCode.CtrlMask + | KeyCode.ShiftMask + | KeyCode.S + ), + new ( + "Find P_revious", + "", + () => FindPrevious (), + null, + null, + KeyCode.CtrlMask + | KeyCode.ShiftMask + | KeyCode.AltMask + | KeyCode.S + ), + new ( + "_Replace", + "", + () => Replace (), + null, + null, + KeyCode.CtrlMask | KeyCode.R + ), + new ( + "Replace Ne_xt", + "", + () => ReplaceNext (), + null, + null, + KeyCode.CtrlMask + | KeyCode.ShiftMask + | KeyCode.R + ), + new ( + "Replace Pre_vious", + "", + () => ReplacePrevious (), + null, + null, + KeyCode.CtrlMask + | KeyCode.ShiftMask + | KeyCode.AltMask + | KeyCode.R + ), + new ( + "Replace _All", + "", + () => ReplaceAll (), + null, + null, + KeyCode.CtrlMask + | KeyCode.ShiftMask + | KeyCode.AltMask + | KeyCode.A + ), + null, + new ( + "_Select All", + "", + () => SelectAll (), + null, + null, + KeyCode.CtrlMask | KeyCode.T + ) + } + ), + new ("_ScrollBarView", CreateKeepChecked ()), + new ("_Cursor", CreateCursorRadio ()), + new ( + "Forma_t", + new [] + { + CreateWrapChecked (), + CreateAutocomplete (), + CreateAllowsTabChecked (), + CreateReadOnlyChecked () + } + ), + new ( + "_Responder", + new [] { CreateCanFocusChecked (), CreateEnabledChecked (), CreateVisibleChecked () } + ), + new ( + "Conte_xtMenu", + new [] + { + _miForceMinimumPosToZero = new ( + "ForceMinimumPosTo_Zero", + "", + () => + { + _miForceMinimumPosToZero.Checked = + _forceMinimumPosToZero = + !_forceMinimumPosToZero; - _textView.ContextMenu.ForceMinimumPosToZero = - _forceMinimumPosToZero; - } - ) - { - CheckType = MenuItemCheckStyle.Checked, - Checked = _forceMinimumPosToZero - }, - new MenuBarItem ("_Languages", GetSupportedCultures ()) - } - ) + _textView.ContextMenu.ForceMinimumPosToZero = + _forceMinimumPosToZero; + } + ) + { + CheckType = MenuItemCheckStyle.Checked, + Checked = _forceMinimumPosToZero + }, + new MenuBarItem ("_Languages", GetSupportedCultures ()) + } + ) ] }; @@ -272,7 +272,7 @@ public class Editor : Scenario Top.Add (statusBar); - _scrollBar = new ScrollBarView (_textView, true); + _scrollBar = new (_textView, true); _scrollBar.ChangedPosition += (s, e) => { @@ -376,7 +376,7 @@ public class Editor : Scenario } }; - Top.Closed += (s, e) => Thread.CurrentThread.CurrentUICulture = new CultureInfo ("en-US"); + Top.Closed += (s, e) => Thread.CurrentThread.CurrentUICulture = new ("en-US"); } public override void Setup () { } @@ -584,7 +584,7 @@ public class Editor : Scenario List menuItems = new (); menuItems.Add ( - new MenuItem ("_Invisible", "", () => SetCursor (CursorVisibility.Invisible)) + new ("_Invisible", "", () => SetCursor (CursorVisibility.Invisible)) { CheckType = MenuItemCheckStyle.Radio, Checked = _textView.DesiredCursorVisibility @@ -593,7 +593,7 @@ public class Editor : Scenario ); menuItems.Add ( - new MenuItem ("_Box", "", () => SetCursor (CursorVisibility.Box)) + new ("_Box", "", () => SetCursor (CursorVisibility.Box)) { CheckType = MenuItemCheckStyle.Radio, Checked = _textView.DesiredCursorVisibility == CursorVisibility.Box @@ -601,19 +601,19 @@ public class Editor : Scenario ); menuItems.Add ( - new MenuItem ("_Underline", "", () => SetCursor (CursorVisibility.Underline)) + new ("_Underline", "", () => SetCursor (CursorVisibility.Underline)) { CheckType = MenuItemCheckStyle.Radio, Checked = _textView.DesiredCursorVisibility == CursorVisibility.Underline } ); - menuItems.Add (new MenuItem ("", "", () => { }, () => false)); - menuItems.Add (new MenuItem ("xTerm :", "", () => { }, () => false)); - menuItems.Add (new MenuItem ("", "", () => { }, () => false)); + menuItems.Add (new ("", "", () => { }, () => false)); + menuItems.Add (new ("xTerm :", "", () => { }, () => false)); + menuItems.Add (new ("", "", () => { }, () => false)); menuItems.Add ( - new MenuItem (" _Default", "", () => SetCursor (CursorVisibility.Default)) + new (" _Default", "", () => SetCursor (CursorVisibility.Default)) { CheckType = MenuItemCheckStyle.Radio, Checked = _textView.DesiredCursorVisibility @@ -622,7 +622,7 @@ public class Editor : Scenario ); menuItems.Add ( - new MenuItem (" _Vertical", "", () => SetCursor (CursorVisibility.Vertical)) + new (" _Vertical", "", () => SetCursor (CursorVisibility.Vertical)) { CheckType = MenuItemCheckStyle.Radio, Checked = _textView.DesiredCursorVisibility @@ -631,7 +631,7 @@ public class Editor : Scenario ); menuItems.Add ( - new MenuItem (" V_ertical Fix", "", () => SetCursor (CursorVisibility.VerticalFix)) + new (" V_ertical Fix", "", () => SetCursor (CursorVisibility.VerticalFix)) { CheckType = MenuItemCheckStyle.Radio, Checked = _textView.DesiredCursorVisibility == CursorVisibility.VerticalFix @@ -639,7 +639,7 @@ public class Editor : Scenario ); menuItems.Add ( - new MenuItem (" B_ox Fix", "", () => SetCursor (CursorVisibility.BoxFix)) + new (" B_ox Fix", "", () => SetCursor (CursorVisibility.BoxFix)) { CheckType = MenuItemCheckStyle.Radio, Checked = _textView.DesiredCursorVisibility @@ -648,7 +648,7 @@ public class Editor : Scenario ); menuItems.Add ( - new MenuItem (" U_nderline Fix", "", () => SetCursor (CursorVisibility.UnderlineFix)) + new (" U_nderline Fix", "", () => SetCursor (CursorVisibility.UnderlineFix)) { CheckType = MenuItemCheckStyle.Radio, Checked = _textView.DesiredCursorVisibility == CursorVisibility.UnderlineFix @@ -757,7 +757,7 @@ public class Editor : Scenario return; } - _winDialog = new Window + _winDialog = new() { Title = isFind ? "Find" : "Replace", X = Win.Viewport.Width / 2 - 30, @@ -765,11 +765,11 @@ public class Editor : Scenario ColorScheme = Colors.ColorSchemes ["TopLevel"] }; - _tabView = new TabView { X = 0, Y = 0, Width = Dim.Fill (), Height = Dim.Fill () }; + _tabView = new() { X = 0, Y = 0, Width = Dim.Fill (), Height = Dim.Fill () }; - _tabView.AddTab (new Tab { DisplayText = "Find", View = FindTab () }, isFind); + _tabView.AddTab (new() { DisplayText = "Find", View = FindTab () }, isFind); View replace = ReplaceTab (); - _tabView.AddTab (new Tab { DisplayText = "Replace", View = replace }, !isFind); + _tabView.AddTab (new() { DisplayText = "Replace", View = replace }, !isFind); _tabView.SelectedTabChanged += (s, e) => _tabView.SelectedTab.View.FocusFirst (); _winDialog.Add (_tabView); @@ -884,7 +884,7 @@ public class Editor : Scenario Y = 1, Width = lblWidth, TextAlignment = TextAlignment.Right, - AutoSize = false, + Text = "Find:" }; d.Add (label); @@ -906,7 +906,7 @@ public class Editor : Scenario Enabled = !string.IsNullOrEmpty (txtToFind.Text), TextAlignment = TextAlignment.Centered, IsDefault = true, - AutoSize = false, + Text = "Find _Next" }; btnFindNext.Accept += (s, e) => FindNext (); @@ -919,7 +919,7 @@ public class Editor : Scenario Width = 20, Enabled = !string.IsNullOrEmpty (txtToFind.Text), TextAlignment = TextAlignment.Centered, - AutoSize = false, + Text = "Find _Previous" }; btnFindPrevious.Accept += (s, e) => FindPrevious (); @@ -939,7 +939,7 @@ public class Editor : Scenario Y = Pos.Top (btnFindPrevious) + 2, Width = 20, TextAlignment = TextAlignment.Centered, - AutoSize = false, + Text = "Cancel" }; btnCancel.Accept += (s, e) => { DisposeWinDialog (); }; @@ -982,7 +982,7 @@ public class Editor : Scenario CreateAction (supportedCultures, culture); supportedCultures.Add (culture); index++; - culture = new MenuItem { CheckType = MenuItemCheckStyle.Checked }; + culture = new() { CheckType = MenuItemCheckStyle.Checked }; } culture.Title = $"_{c.Parent.EnglishName}"; @@ -998,7 +998,7 @@ public class Editor : Scenario { culture.Action += () => { - Thread.CurrentThread.CurrentUICulture = new CultureInfo (culture.Help); + Thread.CurrentThread.CurrentUICulture = new (culture.Help); culture.Checked = true; foreach (MenuItem item in supportedCultures) @@ -1063,6 +1063,7 @@ public class Editor : Scenario _fileName = d.FilePaths [0]; LoadFile (); } + d.Dispose (); } @@ -1135,7 +1136,7 @@ public class Editor : Scenario Y = 1, Width = lblWidth, TextAlignment = TextAlignment.Right, - AutoSize = false, + Text = "Find:" }; d.Add (label); @@ -1157,13 +1158,13 @@ public class Editor : Scenario Enabled = !string.IsNullOrEmpty (txtToFind.Text), TextAlignment = TextAlignment.Centered, IsDefault = true, - AutoSize = false, + Text = "Replace _Next" }; btnFindNext.Accept += (s, e) => ReplaceNext (); d.Add (btnFindNext); - label = new Label { X = Pos.Left (label), Y = Pos.Top (label) + 1, Text = "Replace:" }; + label = new() { X = Pos.Left (label), Y = Pos.Top (label) + 1, Text = "Replace:" }; d.Add (label); SetFindText (); @@ -1182,7 +1183,7 @@ public class Editor : Scenario Width = 20, Enabled = !string.IsNullOrEmpty (txtToFind.Text), TextAlignment = TextAlignment.Centered, - AutoSize = false, + Text = "Replace _Previous" }; btnFindPrevious.Accept += (s, e) => ReplacePrevious (); @@ -1195,7 +1196,7 @@ public class Editor : Scenario Width = 20, Enabled = !string.IsNullOrEmpty (txtToFind.Text), TextAlignment = TextAlignment.Centered, - AutoSize = false, + Text = "Replace _All" }; btnReplaceAll.Accept += (s, e) => ReplaceAll (); @@ -1216,7 +1217,7 @@ public class Editor : Scenario Y = Pos.Top (btnReplaceAll) + 1, Width = 20, TextAlignment = TextAlignment.Centered, - AutoSize = false, + Text = "Cancel" }; btnCancel.Accept += (s, e) => { DisposeWinDialog (); }; diff --git a/UICatalog/Scenarios/HotKeys.cs b/UICatalog/Scenarios/HotKeys.cs index 5b9507374..926d743ca 100644 --- a/UICatalog/Scenarios/HotKeys.cs +++ b/UICatalog/Scenarios/HotKeys.cs @@ -35,10 +35,10 @@ public class HotKeys : Scenario }; app.Add (view); - viewLabel = new() { Text = "Vi_ew:", X = 0, Y = Pos.Bottom (view) + 1 }; + viewLabel = new () { Text = "Vi_ew:", X = 0, Y = Pos.Bottom (view) + 1 }; app.Add (viewLabel); - view = new() + view = new () { Title = "View (n_ot focusable)", Text = "Text renders _Underscore", @@ -52,7 +52,6 @@ public class HotKeys : Scenario var labelWithFrameFocusable = new Label { - AutoSize = false, Title = "Label _with Frame (focusable)", CanFocus = true, X = Pos.Right (labelWithFrameLabel) + 1, Y = Pos.Top (labelWithFrameLabel), Width = 40, Height = 3, @@ -60,12 +59,11 @@ public class HotKeys : Scenario }; app.Add (labelWithFrameFocusable); - labelWithFrameLabel = new() { Text = "L_abel with Frame:", X = 0, Y = Pos.Bottom (labelWithFrameFocusable) + 1 }; + labelWithFrameLabel = new () { Text = "L_abel with Frame:", X = 0, Y = Pos.Bottom (labelWithFrameFocusable) + 1 }; app.Add (labelWithFrameLabel); var labelWithFrame = new Label { - AutoSize = false, Title = "Label with Frame (_not focusable)", X = Pos.Right (labelWithFrameLabel) + 1, Y = Pos.Top (labelWithFrameLabel), Width = 40, Height = 3, BorderStyle = LineStyle.Dashed @@ -77,7 +75,6 @@ public class HotKeys : Scenario var buttonWithFrameFocusable = new Button { - AutoSize = false, Title = "B_utton with Frame (focusable)", CanFocus = true, X = Pos.Right (buttonWithFrameLabel) + 1, Y = Pos.Top (buttonWithFrameLabel), Width = 40, Height = 3, @@ -85,12 +82,11 @@ public class HotKeys : Scenario }; app.Add (buttonWithFrameFocusable); - buttonWithFrameLabel = new() { Text = "Butt_on with Frame:", X = 0, Y = Pos.Bottom (buttonWithFrameFocusable) + 1 }; + buttonWithFrameLabel = new () { Text = "Butt_on with Frame:", X = 0, Y = Pos.Bottom (buttonWithFrameFocusable) + 1 }; app.Add (buttonWithFrameLabel); var buttonWithFrame = new Button { - AutoSize = false, Title = "Button with Frame (not focusab_le)", X = Pos.Right (buttonWithFrameLabel) + 1, Y = Pos.Top (buttonWithFrameLabel), Width = 40, Height = 3, CanFocus = false, @@ -103,7 +99,6 @@ public class HotKeys : Scenario var checkboxWithFrameFocusable = new CheckBox { - AutoSize = false, Title = "C_heckbox with Frame (focusable)", CanFocus = true, X = Pos.Right (checkboxWithFrameLabel) + 1, Y = Pos.Top (checkboxWithFrameLabel), Width = 40, Height = 3, @@ -111,12 +106,11 @@ public class HotKeys : Scenario }; app.Add (checkboxWithFrameFocusable); - checkboxWithFrameLabel = new() { Text = "Checkb_ox with Frame:", X = 0, Y = Pos.Bottom (checkboxWithFrameFocusable) + 1 }; + checkboxWithFrameLabel = new () { Text = "Checkb_ox with Frame:", X = 0, Y = Pos.Bottom (checkboxWithFrameFocusable) + 1 }; app.Add (checkboxWithFrameLabel); var checkboxWithFrame = new CheckBox { - AutoSize = false, Title = "Checkbox with Frame (not focusable)", X = Pos.Right (checkboxWithFrameLabel) + 1, Y = Pos.Top (checkboxWithFrameLabel), Width = 40, Height = 3, CanFocus = false, diff --git a/UICatalog/Scenarios/LineCanvasExperiment.cs b/UICatalog/Scenarios/LineCanvasExperiment.cs index d015cd23e..2d097b317 100644 --- a/UICatalog/Scenarios/LineCanvasExperiment.cs +++ b/UICatalog/Scenarios/LineCanvasExperiment.cs @@ -34,7 +34,6 @@ public class LineCanvasExperiment : Scenario var win1 = new Window { - AutoSize = false, Title = "win1", Text = "Win1 30%/50% Heavy", X = 20, diff --git a/UICatalog/Scenarios/ListColumns.cs b/UICatalog/Scenarios/ListColumns.cs index 0f92e1aad..ea093b769 100644 --- a/UICatalog/Scenarios/ListColumns.cs +++ b/UICatalog/Scenarios/ListColumns.cs @@ -13,7 +13,6 @@ namespace UICatalog.Scenarios; [ScenarioCategory ("Text and Formatting")] [ScenarioCategory ("Top Level Windows")] [ScenarioCategory ("Scrolling")] - public class ListColumns : Scenario { private ColorScheme _alternatingColorScheme; @@ -54,13 +53,13 @@ public class ListColumns : Scenario Win.Y = 1; // menu Win.Height = Dim.Fill (1); // status bar - _listColView = new TableView + _listColView = new() { X = 0, Y = 0, Width = Dim.Fill (), Height = Dim.Fill (1), - Style = new TableStyle + Style = new() { ShowHeaders = false, ShowHorizontalHeaderOverline = false, @@ -75,138 +74,138 @@ public class ListColumns : Scenario { Menus = [ - new MenuBarItem ( - "_File", - new MenuItem [] - { - new ( - "Open_BigListExample", + new ( + "_File", + new MenuItem [] + { + new ( + "Open_BigListExample", + "", + () => OpenSimpleList (true) + ), + new ( + "Open_SmListExample", + "", + () => OpenSimpleList (false) + ), + new ( + "_CloseExample", + "", + () => CloseExample () + ), + new ("_Quit", "", () => Quit ()) + } + ), + new ( + "_View", + new [] + { + _miTopline = + new ("_TopLine", "", () => ToggleTopline ()) + { + Checked = _listColView.Style + .ShowHorizontalHeaderOverline, + CheckType = MenuItemCheckStyle.Checked + }, + _miBottomline = new ( + "_BottomLine", + "", + () => ToggleBottomline () + ) + { + Checked = _listColView.Style + .ShowHorizontalBottomline, + CheckType = MenuItemCheckStyle + .Checked + }, + _miCellLines = new ( + "_CellLines", + "", + () => ToggleCellLines () + ) + { + Checked = _listColView.Style + .ShowVerticalCellLines, + CheckType = MenuItemCheckStyle + .Checked + }, + _miExpandLastColumn = new ( + "_ExpandLastColumn", + "", + () => ToggleExpandLastColumn () + ) + { + Checked = _listColView.Style.ExpandLastColumn, + CheckType = MenuItemCheckStyle.Checked + }, + _miAlwaysUseNormalColorForVerticalCellLines = + new ( + "_AlwaysUseNormalColorForVerticalCellLines", + "", + () => + ToggleAlwaysUseNormalColorForVerticalCellLines () + ) + { + Checked = _listColView.Style + .AlwaysUseNormalColorForVerticalCellLines, + CheckType = MenuItemCheckStyle.Checked + }, + _miSmoothScrolling = new ( + "_SmoothHorizontalScrolling", + "", + () => ToggleSmoothScrolling () + ) + { + Checked = _listColView.Style + .SmoothHorizontalScrolling, + CheckType = MenuItemCheckStyle.Checked + }, + _miAlternatingColors = new ( + "Alternating Colors", + "", + () => ToggleAlternatingColors () + ) { CheckType = MenuItemCheckStyle.Checked }, + _miCursor = new ( + "Invert Selected Cell First Character", "", - () => OpenSimpleList (true) - ), - new ( - "Open_SmListExample", - "", - () => OpenSimpleList (false) - ), - new ( - "_CloseExample", - "", - () => CloseExample () - ), - new ("_Quit", "", () => Quit ()) - } - ), - new MenuBarItem ( - "_View", - new [] - { - _miTopline = - new MenuItem ("_TopLine", "", () => ToggleTopline ()) - { - Checked = _listColView.Style - .ShowHorizontalHeaderOverline, - CheckType = MenuItemCheckStyle.Checked - }, - _miBottomline = new MenuItem ( - "_BottomLine", - "", - () => ToggleBottomline () - ) - { - Checked = _listColView.Style - .ShowHorizontalBottomline, - CheckType = MenuItemCheckStyle - .Checked - }, - _miCellLines = new MenuItem ( - "_CellLines", - "", - () => ToggleCellLines () - ) - { - Checked = _listColView.Style - .ShowVerticalCellLines, - CheckType = MenuItemCheckStyle - .Checked - }, - _miExpandLastColumn = new MenuItem ( - "_ExpandLastColumn", - "", - () => ToggleExpandLastColumn () - ) - { - Checked = _listColView.Style.ExpandLastColumn, - CheckType = MenuItemCheckStyle.Checked - }, - _miAlwaysUseNormalColorForVerticalCellLines = - new MenuItem ( - "_AlwaysUseNormalColorForVerticalCellLines", - "", - () => - ToggleAlwaysUseNormalColorForVerticalCellLines () - ) - { - Checked = _listColView.Style - .AlwaysUseNormalColorForVerticalCellLines, - CheckType = MenuItemCheckStyle.Checked - }, - _miSmoothScrolling = new MenuItem ( - "_SmoothHorizontalScrolling", - "", - () => ToggleSmoothScrolling () - ) - { - Checked = _listColView.Style - .SmoothHorizontalScrolling, - CheckType = MenuItemCheckStyle.Checked - }, - _miAlternatingColors = new MenuItem ( - "Alternating Colors", - "", - () => ToggleAlternatingColors () - ) { CheckType = MenuItemCheckStyle.Checked }, - _miCursor = new MenuItem ( - "Invert Selected Cell First Character", - "", - () => - ToggleInvertSelectedCellFirstCharacter () - ) - { - Checked = _listColView.Style - .InvertSelectedCellFirstCharacter, - CheckType = MenuItemCheckStyle.Checked - } - } - ), - new MenuBarItem ( - "_List", - new [] - { - //new MenuItem ("_Hide Headers", "", HideHeaders), - _miOrientVertical = new MenuItem ( - "_OrientVertical", - "", - () => ToggleVerticalOrientation () - ) - { - Checked = listColStyle.Orientation - == Orientation.Vertical, - CheckType = MenuItemCheckStyle.Checked - }, - _miScrollParallel = new MenuItem ( - "_ScrollParallel", - "", - () => ToggleScrollParallel () - ) - { - Checked = listColStyle.ScrollParallel, - CheckType = MenuItemCheckStyle.Checked - }, - new ("Set _Max Cell Width", "", SetListMaxWidth), - new ("Set Mi_n Cell Width", "", SetListMinWidth) - } - ) + () => + ToggleInvertSelectedCellFirstCharacter () + ) + { + Checked = _listColView.Style + .InvertSelectedCellFirstCharacter, + CheckType = MenuItemCheckStyle.Checked + } + } + ), + new ( + "_List", + new [] + { + //new MenuItem ("_Hide Headers", "", HideHeaders), + _miOrientVertical = new ( + "_OrientVertical", + "", + () => ToggleVerticalOrientation () + ) + { + Checked = listColStyle.Orientation + == Orientation.Vertical, + CheckType = MenuItemCheckStyle.Checked + }, + _miScrollParallel = new ( + "_ScrollParallel", + "", + () => ToggleScrollParallel () + ) + { + Checked = listColStyle.ScrollParallel, + CheckType = MenuItemCheckStyle.Checked + }, + new ("Set _Max Cell Width", "", SetListMaxWidth), + new ("Set Mi_n Cell Width", "", SetListMinWidth) + } + ) ] }; @@ -246,7 +245,7 @@ public class ListColumns : Scenario X = 0, Y = Pos.Bottom (_listColView), Text = "0,0", - AutoSize = false, + Width = Dim.Fill (), TextAlignment = TextAlignment.Right }; @@ -258,12 +257,12 @@ public class ListColumns : Scenario SetupScrollBar (); - _alternatingColorScheme = new ColorScheme + _alternatingColorScheme = new() { Disabled = Win.ColorScheme.Disabled, HotFocus = Win.ColorScheme.HotFocus, Focus = Win.ColorScheme.Focus, - Normal = new Attribute (Color.White, Color.BrightBlue) + Normal = new (Color.White, Color.BrightBlue) }; // if user clicks the mouse in TableView @@ -282,10 +281,10 @@ public class ListColumns : Scenario var ok = new Button { Text = "Ok", IsDefault = true }; ok.Accept += (s, e) => - { - accepted = true; - Application.RequestStop (); - }; + { + accepted = true; + Application.RequestStop (); + }; var cancel = new Button { Text = "Cancel" }; cancel.Accept += (s, e) => { Application.RequestStop (); }; var d = new Dialog { Title = prompt, Buttons = [ok, cancel] }; diff --git a/UICatalog/Scenarios/ListsAndCombos.cs b/UICatalog/Scenarios/ListsAndCombos.cs index 149d5152b..479e89fbb 100644 --- a/UICatalog/Scenarios/ListsAndCombos.cs +++ b/UICatalog/Scenarios/ListsAndCombos.cs @@ -36,7 +36,7 @@ public class ListsAndCombos : Scenario { ColorScheme = Colors.ColorSchemes ["TopLevel"], X = 0, - AutoSize = false, + Width = Dim.Percent (40), Text = "Listview" }; @@ -92,7 +92,7 @@ public class ListsAndCombos : Scenario { ColorScheme = Colors.ColorSchemes ["TopLevel"], X = Pos.Right (lbListView) + 1, - AutoSize = false, + Width = Dim.Percent (40), Text = "ComboBox" }; diff --git a/UICatalog/Scenarios/Localization.cs b/UICatalog/Scenarios/Localization.cs index 6669639ae..d679f5cc2 100644 --- a/UICatalog/Scenarios/Localization.cs +++ b/UICatalog/Scenarios/Localization.cs @@ -79,18 +79,18 @@ public class Localization : Scenario { Menus = [ - new MenuBarItem ( - "_File", - new MenuItem [] - { - new MenuBarItem ( - "_Language", - languageMenus - ), - null, - new ("_Quit", "", Quit) - } - ) + new ( + "_File", + new MenuItem [] + { + new MenuBarItem ( + "_Language", + languageMenus + ), + null, + new ("_Quit", "", Quit) + } + ) ] }; Top.Add (menu); @@ -99,13 +99,13 @@ public class Localization : Scenario { X = 2, Y = 1, - AutoSize = false, + Width = Dim.Fill (2), Text = "Please select a language." }; Win.Add (selectLanguageLabel); - _languageComboBox = new ComboBox + _languageComboBox = new() { X = 2, Y = Pos.Bottom (selectLanguageLabel) + 1, @@ -123,7 +123,7 @@ public class Localization : Scenario { X = 2, Y = Pos.Top (_languageComboBox) + 3, - AutoSize = false, + Width = Dim.Fill (2), Height = 1, Text = @@ -137,7 +137,7 @@ public class Localization : Scenario }; Win.Add (textField); - _allowAnyCheckBox = new CheckBox + _allowAnyCheckBox = new() { X = Pos.Right (textField) + 1, Y = Pos.Bottom (textAndFileDialogLabel) + 1, @@ -164,7 +164,7 @@ public class Localization : Scenario { X = 2, Y = Pos.Bottom (textField) + 1, - AutoSize = false, + Width = Dim.Fill (2), Text = "Click the button to open a wizard." }; @@ -206,9 +206,9 @@ public class Localization : Scenario public void ShowWizard () { var wizard = new Wizard { Height = 8, Width = 36, Title = "The wizard" }; - wizard.AddStep (new WizardStep { HelpText = "Wizard first step" }); - wizard.AddStep (new WizardStep { HelpText = "Wizard step 2", NextButtonText = ">>> (_N)" }); - wizard.AddStep (new WizardStep { HelpText = "Wizard last step" }); + wizard.AddStep (new() { HelpText = "Wizard first step" }); + wizard.AddStep (new() { HelpText = "Wizard step 2", NextButtonText = ">>> (_N)" }); + wizard.AddStep (new() { HelpText = "Wizard last step" }); Application.Run (wizard); wizard.Dispose (); } diff --git a/UICatalog/Scenarios/MessageBoxes.cs b/UICatalog/Scenarios/MessageBoxes.cs index 06c3533a1..df5a54050 100644 --- a/UICatalog/Scenarios/MessageBoxes.cs +++ b/UICatalog/Scenarios/MessageBoxes.cs @@ -27,11 +27,11 @@ public class MessageBoxes : Scenario }; frame.Add (widthEdit); - label = new Label + label = new() { X = 0, Y = Pos.Bottom (label), - AutoSize = false, + Width = Dim.Width (label), Height = 1, TextAlignment = TextAlignment.Right, @@ -62,11 +62,11 @@ public class MessageBoxes : Scenario } ); - label = new Label + label = new() { X = 0, Y = Pos.Bottom (label), - AutoSize = false, + Width = Dim.Width (label), Height = 1, TextAlignment = TextAlignment.Right, @@ -84,11 +84,11 @@ public class MessageBoxes : Scenario }; frame.Add (titleEdit); - label = new Label + label = new() { X = 0, Y = Pos.Bottom (label), - AutoSize = false, + Width = Dim.Width (label), Height = 1, TextAlignment = TextAlignment.Right, @@ -106,11 +106,11 @@ public class MessageBoxes : Scenario }; frame.Add (messageEdit); - label = new Label + label = new() { X = 0, Y = Pos.Bottom (messageEdit), - AutoSize = false, + Width = Dim.Width (label), Height = 1, TextAlignment = TextAlignment.Right, @@ -128,11 +128,11 @@ public class MessageBoxes : Scenario }; frame.Add (numButtonsEdit); - label = new Label + label = new() { X = 0, Y = Pos.Bottom (label), - AutoSize = false, + Width = Dim.Width (label), Height = 1, TextAlignment = TextAlignment.Right, @@ -150,11 +150,11 @@ public class MessageBoxes : Scenario }; frame.Add (defaultButtonEdit); - label = new Label + label = new() { X = 0, Y = Pos.Bottom (label), - AutoSize = false, + Width = Dim.Width (label), Height = 1, TextAlignment = TextAlignment.Right, @@ -193,7 +193,7 @@ public class MessageBoxes : Scenario Top.LayoutComplete += Top_LayoutComplete; - label = new Label + label = new() { X = Pos.Center (), Y = Pos.Bottom (frame) + 2, TextAlignment = TextAlignment.Right, Text = "Button Pressed:" }; @@ -216,58 +216,58 @@ public class MessageBoxes : Scenario }; showMessageBoxButton.Accept += (s, e) => - { - try - { - int width = int.Parse (widthEdit.Text); - int height = int.Parse (heightEdit.Text); - int numButtons = int.Parse (numButtonsEdit.Text); - int defaultButton = int.Parse (defaultButtonEdit.Text); + { + try + { + int width = int.Parse (widthEdit.Text); + int height = int.Parse (heightEdit.Text); + int numButtons = int.Parse (numButtonsEdit.Text); + int defaultButton = int.Parse (defaultButtonEdit.Text); - List btns = new (); + List btns = new (); - for (var i = 0; i < numButtons; i++) - { - //btns.Add(btnText[i % 10]); - btns.Add (NumberToWords.Convert (i)); - } + for (var i = 0; i < numButtons; i++) + { + //btns.Add(btnText[i % 10]); + btns.Add (NumberToWords.Convert (i)); + } - if (styleRadioGroup.SelectedItem == 0) - { - buttonPressedLabel.Text = - $"{ - MessageBox.Query ( - width, - height, - titleEdit.Text, - messageEdit.Text, - defaultButton, - (bool)ckbWrapMessage.Checked, - btns.ToArray () - ) - }"; - } - else - { - buttonPressedLabel.Text = - $"{ - MessageBox.ErrorQuery ( - width, - height, - titleEdit.Text, - messageEdit.Text, - defaultButton, - (bool)ckbWrapMessage.Checked, - btns.ToArray () - ) - }"; - } - } - catch (FormatException) - { - buttonPressedLabel.Text = "Invalid Options"; - } - }; + if (styleRadioGroup.SelectedItem == 0) + { + buttonPressedLabel.Text = + $"{ + MessageBox.Query ( + width, + height, + titleEdit.Text, + messageEdit.Text, + defaultButton, + (bool)ckbWrapMessage.Checked, + btns.ToArray () + ) + }"; + } + else + { + buttonPressedLabel.Text = + $"{ + MessageBox.ErrorQuery ( + width, + height, + titleEdit.Text, + messageEdit.Text, + defaultButton, + (bool)ckbWrapMessage.Checked, + btns.ToArray () + ) + }"; + } + } + catch (FormatException) + { + buttonPressedLabel.Text = "Invalid Options"; + } + }; Win.Add (showMessageBoxButton); Win.Add (buttonPressedLabel); diff --git a/UICatalog/Scenarios/Mouse.cs b/UICatalog/Scenarios/Mouse.cs index c6c5734f5..0e55dbd8f 100644 --- a/UICatalog/Scenarios/Mouse.cs +++ b/UICatalog/Scenarios/Mouse.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.CommandLine; using System.Linq; using Terminal.Gui; @@ -13,48 +12,50 @@ public class Mouse : Scenario public override void Main () { Application.Init (); + Window win = new () { - Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}", + Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}" }; - - var filterSlider = new Slider () + Slider filterSlider = new() { Title = "_Filter", X = 0, Y = 0, - AutoSize = true, BorderStyle = LineStyle.Single, Type = SliderType.Multiple, - Orientation = Orientation.Vertical, + Orientation = Orientation.Vertical }; + filterSlider.Options = Enum.GetValues (typeof (MouseFlags)) .Cast () - .Where (value => !value.ToString ().Contains ("None") && - !value.ToString().Contains("All")) - .Select (value => new SliderOption - { - Legend = value.ToString (), - Data = value, - }) + .Where (value => !value.ToString ().Contains ("None") && !value.ToString ().Contains ("All")) + .Select ( + value => new SliderOption + { + Legend = value.ToString (), + Data = value + }) .ToList (); - for (int i = 0; i < filterSlider.Options.Count; i++) + + for (var i = 0; i < filterSlider.Options.Count; i++) { filterSlider.SetOption (i); } + win.Add (filterSlider); - var clearButton = new Button () + var clearButton = new Button { Title = "_Clear Logs", X = 1, - Y = Pos.Bottom (filterSlider) + 1, + Y = Pos.Bottom (filterSlider) + 1 }; win.Add (clearButton); Label ml; var count = 0; - ml = new Label { X = Pos.Right(filterSlider), Y = 0, Text = "Mouse: " }; + ml = new() { X = Pos.Right (filterSlider), Y = 0, Text = "Mouse: " }; win.Add (ml); @@ -62,36 +63,35 @@ public class Mouse : Scenario { X = Pos.Right (filterSlider), Y = Pos.Bottom (ml), - Title = "_Want Continuous Button Pressed", - }; - cbWantContinuousPresses.Toggled += (s, e) => - { - win.WantContinuousButtonPressed = !win.WantContinuousButtonPressed; + Title = "_Want Continuous Button Pressed" }; + cbWantContinuousPresses.Toggled += (s, e) => { win.WantContinuousButtonPressed = !win.WantContinuousButtonPressed; }; win.Add (cbWantContinuousPresses); + CheckBox cbHighlightOnPress = new () { X = Pos.Right (filterSlider), Y = Pos.Bottom (cbWantContinuousPresses), - Title = "_Highlight on Press", + Title = "_Highlight on Press" }; cbHighlightOnPress.Checked = win.HighlightStyle == (HighlightStyle.Pressed | HighlightStyle.PressedOutside); + cbHighlightOnPress.Toggled += (s, e) => - { - if (e.NewValue == true) - { - win.HighlightStyle = HighlightStyle.Pressed | HighlightStyle.PressedOutside; - } - else - { - win.HighlightStyle = HighlightStyle.None; - } - }; + { + if (e.NewValue == true) + { + win.HighlightStyle = HighlightStyle.Pressed | HighlightStyle.PressedOutside; + } + else + { + win.HighlightStyle = HighlightStyle.None; + } + }; win.Add (cbHighlightOnPress); - var demo = new MouseDemo () + var demo = new MouseDemo { X = Pos.Right (filterSlider), Y = Pos.Bottom (cbHighlightOnPress), @@ -100,18 +100,19 @@ public class Mouse : Scenario Text = "Enter/Leave Demo", TextAlignment = TextAlignment.Centered, VerticalTextAlignment = VerticalTextAlignment.Middle, - ColorScheme = Colors.ColorSchemes ["Dialog"], + ColorScheme = Colors.ColorSchemes ["Dialog"] }; win.Add (demo); - var label = new Label () + var label = new Label { Text = "_App Events:", X = Pos.Right (filterSlider), - Y = Pos.Bottom (demo), + Y = Pos.Bottom (demo) }; List appLogList = new (); + var appLog = new ListView { X = Pos.Left (label), @@ -125,8 +126,9 @@ public class Mouse : Scenario Application.MouseEvent += (sender, a) => { - var i = filterSlider.Options.FindIndex (o => o.Data == a.Flags); - if (filterSlider.GetSetOptions().Contains(i)) + int i = filterSlider.Options.FindIndex (o => o.Data == a.Flags); + + if (filterSlider.GetSetOptions ().Contains (i)) { ml.Text = $"MouseEvent: ({a.X},{a.Y}) - {a.Flags} {count}"; appLogList.Add ($"({a.X},{a.Y}) - {a.Flags} {count++}"); @@ -134,13 +136,14 @@ public class Mouse : Scenario } }; - label = new Label () + label = new() { Text = "_Window Events:", - X = Pos.Right (appLog)+1, - Y = Pos.Top (label), + X = Pos.Right (appLog) + 1, + Y = Pos.Top (label) }; List winLogList = new (); + var winLog = new ListView { X = Pos.Left (label), @@ -157,18 +160,20 @@ public class Mouse : Scenario appLogList.Clear (); appLog.SetSource (appLogList); winLogList.Clear (); - winLog.SetSource(winLogList); + winLog.SetSource (winLogList); }; win.MouseEvent += (sender, a) => { - var i = filterSlider.Options.FindIndex (o => o.Data == a.MouseEvent.Flags); + int i = filterSlider.Options.FindIndex (o => o.Data == a.MouseEvent.Flags); + if (filterSlider.GetSetOptions ().Contains (i)) { winLogList.Add ($"MouseEvent: ({a.MouseEvent.X},{a.MouseEvent.Y}) - {a.MouseEvent.Flags} {count++}"); winLog.MoveDown (); } }; + win.MouseClick += (sender, a) => { winLogList.Add ($"MouseClick: ({a.MouseEvent.X},{a.MouseEvent.Y}) - {a.MouseEvent.Flags} {count++}"); @@ -181,10 +186,12 @@ public class Mouse : Scenario public class MouseDemo : View { - private bool _button1PressedOnEnter = false; + private bool _button1PressedOnEnter; + public MouseDemo () { CanFocus = true; + MouseEvent += (s, e) => { if (e.MouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed)) @@ -194,21 +201,20 @@ public class Mouse : Scenario ColorScheme = Colors.ColorSchemes ["Toplevel"]; } } + if (e.MouseEvent.Flags.HasFlag (MouseFlags.Button1Released)) { ColorScheme = Colors.ColorSchemes ["Dialog"]; _button1PressedOnEnter = false; } }; + MouseLeave += (s, e) => { ColorScheme = Colors.ColorSchemes ["Dialog"]; _button1PressedOnEnter = false; }; - MouseEnter += (s, e) => - { - _button1PressedOnEnter = e.MouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed); - }; + MouseEnter += (s, e) => { _button1PressedOnEnter = e.MouseEvent.Flags.HasFlag (MouseFlags.Button1Pressed); }; } } } diff --git a/UICatalog/Scenarios/Scrolling.cs b/UICatalog/Scenarios/Scrolling.cs index ec17a1d16..48a36c720 100644 --- a/UICatalog/Scenarios/Scrolling.cs +++ b/UICatalog/Scenarios/Scrolling.cs @@ -16,14 +16,16 @@ public class Scrolling : Scenario Application.Init (); _diagnosticFlags = View.Diagnostics; View.Diagnostics = ViewDiagnosticFlags.Ruler; - var app = new Window () + + var app = new Window { Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}", + // Offset to stress clipping X = 3, Y = 3, Width = Dim.Fill (3), - Height = Dim.Fill (3), + Height = Dim.Fill (3) }; var label = new Label { X = 0, Y = 0 }; @@ -53,7 +55,7 @@ public class Scrolling : Scenario { X = 0, Y = 0, - AutoSize = false, + Width = Dim.Fill (), Height = 2, ColorScheme = Colors.ColorSchemes ["Error"] @@ -66,7 +68,7 @@ public class Scrolling : Scenario { X = 0, Y = 0, - AutoSize = false, + Width = 1, Height = Dim.Fill (), ColorScheme = Colors.ColorSchemes ["Error"] @@ -81,7 +83,7 @@ public class Scrolling : Scenario { X = 3, Y = 4, - AutoSize = false, + Width = Dim.Fill (3), Text = "A very long button. Should be wide enough to demo clipping!" }; @@ -95,7 +97,7 @@ public class Scrolling : Scenario Y = 5, Width = 50, ColorScheme = Colors.ColorSchemes ["Dialog"], - Text = "This is a test of...", + Text = "This is a test of..." } ); @@ -106,7 +108,7 @@ public class Scrolling : Scenario Y = 10, Width = 50, ColorScheme = Colors.ColorSchemes ["Dialog"], - Text = "... the emergency broadcast system.", + Text = "... the emergency broadcast system." } ); @@ -117,7 +119,7 @@ public class Scrolling : Scenario Y = 99, Width = 50, ColorScheme = Colors.ColorSchemes ["Dialog"], - Text = "Last line", + Text = "Last line" } ); @@ -214,7 +216,7 @@ public class Scrolling : Scenario { X = Pos.Right (scrollView) + 1, Y = Pos.AnchorEnd (1), - AutoSize = false, + Width = 50, Text = "Mouse: " }; diff --git a/UICatalog/Scenarios/TableEditor.cs b/UICatalog/Scenarios/TableEditor.cs index cebac284c..b73fa19d2 100644 --- a/UICatalog/Scenarios/TableEditor.cs +++ b/UICatalog/Scenarios/TableEditor.cs @@ -22,305 +22,305 @@ public class TableEditor : Scenario private readonly List Ranges = new () { - new UnicodeRange ( - 0x0000, - 0x001F, - "ASCII Control Characters" - ), - new UnicodeRange (0x0080, 0x009F, "C0 Control Characters"), - new UnicodeRange ( - 0x1100, - 0x11ff, - "Hangul Jamo" - ), // This is where wide chars tend to start - new UnicodeRange (0x20A0, 0x20CF, "Currency Symbols"), - new UnicodeRange (0x2100, 0x214F, "Letterlike Symbols"), - new UnicodeRange (0x2190, 0x21ff, "Arrows"), - new UnicodeRange (0x2200, 0x22ff, "Mathematical symbols"), - new UnicodeRange ( - 0x2300, - 0x23ff, - "Miscellaneous Technical" - ), - new UnicodeRange ( - 0x2500, - 0x25ff, - "Box Drawing & Geometric Shapes" - ), - new UnicodeRange (0x2600, 0x26ff, "Miscellaneous Symbols"), - new UnicodeRange (0x2700, 0x27ff, "Dingbats"), - new UnicodeRange (0x2800, 0x28ff, "Braille"), - new UnicodeRange ( - 0x2b00, - 0x2bff, - "Miscellaneous Symbols and Arrows" - ), - new UnicodeRange ( - 0xFB00, - 0xFb4f, - "Alphabetic Presentation Forms" - ), - new UnicodeRange ( - 0x12400, - 0x1240f, - "Cuneiform Numbers and Punctuation" - ), - new UnicodeRange ( - (uint)(CharMap.MaxCodePoint - 16), - (uint)CharMap.MaxCodePoint, - "End" - ), - new UnicodeRange (0x0020, 0x007F, "Basic Latin"), - new UnicodeRange (0x00A0, 0x00FF, "Latin-1 Supplement"), - new UnicodeRange (0x0100, 0x017F, "Latin Extended-A"), - new UnicodeRange (0x0180, 0x024F, "Latin Extended-B"), - new UnicodeRange (0x0250, 0x02AF, "IPA Extensions"), - new UnicodeRange ( - 0x02B0, - 0x02FF, - "Spacing Modifier Letters" - ), - new UnicodeRange ( - 0x0300, - 0x036F, - "Combining Diacritical Marks" - ), - new UnicodeRange (0x0370, 0x03FF, "Greek and Coptic"), - new UnicodeRange (0x0400, 0x04FF, "Cyrillic"), - new UnicodeRange (0x0500, 0x052F, "Cyrillic Supplementary"), - new UnicodeRange (0x0530, 0x058F, "Armenian"), - new UnicodeRange (0x0590, 0x05FF, "Hebrew"), - new UnicodeRange (0x0600, 0x06FF, "Arabic"), - new UnicodeRange (0x0700, 0x074F, "Syriac"), - new UnicodeRange (0x0780, 0x07BF, "Thaana"), - new UnicodeRange (0x0900, 0x097F, "Devanagari"), - new UnicodeRange (0x0980, 0x09FF, "Bengali"), - new UnicodeRange (0x0A00, 0x0A7F, "Gurmukhi"), - new UnicodeRange (0x0A80, 0x0AFF, "Gujarati"), - new UnicodeRange (0x0B00, 0x0B7F, "Oriya"), - new UnicodeRange (0x0B80, 0x0BFF, "Tamil"), - new UnicodeRange (0x0C00, 0x0C7F, "Telugu"), - new UnicodeRange (0x0C80, 0x0CFF, "Kannada"), - new UnicodeRange (0x0D00, 0x0D7F, "Malayalam"), - new UnicodeRange (0x0D80, 0x0DFF, "Sinhala"), - new UnicodeRange (0x0E00, 0x0E7F, "Thai"), - new UnicodeRange (0x0E80, 0x0EFF, "Lao"), - new UnicodeRange (0x0F00, 0x0FFF, "Tibetan"), - new UnicodeRange (0x1000, 0x109F, "Myanmar"), - new UnicodeRange (0x10A0, 0x10FF, "Georgian"), - new UnicodeRange (0x1100, 0x11FF, "Hangul Jamo"), - new UnicodeRange (0x1200, 0x137F, "Ethiopic"), - new UnicodeRange (0x13A0, 0x13FF, "Cherokee"), - new UnicodeRange ( - 0x1400, - 0x167F, - "Unified Canadian Aboriginal Syllabics" - ), - new UnicodeRange (0x1680, 0x169F, "Ogham"), - new UnicodeRange (0x16A0, 0x16FF, "Runic"), - new UnicodeRange (0x1700, 0x171F, "Tagalog"), - new UnicodeRange (0x1720, 0x173F, "Hanunoo"), - new UnicodeRange (0x1740, 0x175F, "Buhid"), - new UnicodeRange (0x1760, 0x177F, "Tagbanwa"), - new UnicodeRange (0x1780, 0x17FF, "Khmer"), - new UnicodeRange (0x1800, 0x18AF, "Mongolian"), - new UnicodeRange (0x1900, 0x194F, "Limbu"), - new UnicodeRange (0x1950, 0x197F, "Tai Le"), - new UnicodeRange (0x19E0, 0x19FF, "Khmer Symbols"), - new UnicodeRange (0x1D00, 0x1D7F, "Phonetic Extensions"), - new UnicodeRange ( - 0x1E00, - 0x1EFF, - "Latin Extended Additional" - ), - new UnicodeRange (0x1F00, 0x1FFF, "Greek Extended"), - new UnicodeRange (0x2000, 0x206F, "General Punctuation"), - new UnicodeRange ( - 0x2070, - 0x209F, - "Superscripts and Subscripts" - ), - new UnicodeRange (0x20A0, 0x20CF, "Currency Symbols"), - new UnicodeRange ( - 0x20D0, - 0x20FF, - "Combining Diacritical Marks for Symbols" - ), - new UnicodeRange (0x2100, 0x214F, "Letterlike Symbols"), - new UnicodeRange (0x2150, 0x218F, "Number Forms"), - new UnicodeRange (0x2190, 0x21FF, "Arrows"), - new UnicodeRange (0x2200, 0x22FF, "Mathematical Operators"), - new UnicodeRange ( - 0x2300, - 0x23FF, - "Miscellaneous Technical" - ), - new UnicodeRange (0x2400, 0x243F, "Control Pictures"), - new UnicodeRange ( - 0x2440, - 0x245F, - "Optical Character Recognition" - ), - new UnicodeRange (0x2460, 0x24FF, "Enclosed Alphanumerics"), - new UnicodeRange (0x2500, 0x257F, "Box Drawing"), - new UnicodeRange (0x2580, 0x259F, "Block Elements"), - new UnicodeRange (0x25A0, 0x25FF, "Geometric Shapes"), - new UnicodeRange (0x2600, 0x26FF, "Miscellaneous Symbols"), - new UnicodeRange (0x2700, 0x27BF, "Dingbats"), - new UnicodeRange ( - 0x27C0, - 0x27EF, - "Miscellaneous Mathematical Symbols-A" - ), - new UnicodeRange (0x27F0, 0x27FF, "Supplemental Arrows-A"), - new UnicodeRange (0x2800, 0x28FF, "Braille Patterns"), - new UnicodeRange (0x2900, 0x297F, "Supplemental Arrows-B"), - new UnicodeRange ( - 0x2980, - 0x29FF, - "Miscellaneous Mathematical Symbols-B" - ), - new UnicodeRange ( - 0x2A00, - 0x2AFF, - "Supplemental Mathematical Operators" - ), - new UnicodeRange ( - 0x2B00, - 0x2BFF, - "Miscellaneous Symbols and Arrows" - ), - new UnicodeRange ( - 0x2E80, - 0x2EFF, - "CJK Radicals Supplement" - ), - new UnicodeRange (0x2F00, 0x2FDF, "Kangxi Radicals"), - new UnicodeRange ( - 0x2FF0, - 0x2FFF, - "Ideographic Description Characters" - ), - new UnicodeRange ( - 0x3000, - 0x303F, - "CJK Symbols and Punctuation" - ), - new UnicodeRange (0x3040, 0x309F, "Hiragana"), - new UnicodeRange (0x30A0, 0x30FF, "Katakana"), - new UnicodeRange (0x3100, 0x312F, "Bopomofo"), - new UnicodeRange ( - 0x3130, - 0x318F, - "Hangul Compatibility Jamo" - ), - new UnicodeRange (0x3190, 0x319F, "Kanbun"), - new UnicodeRange (0x31A0, 0x31BF, "Bopomofo Extended"), - new UnicodeRange ( - 0x31F0, - 0x31FF, - "Katakana Phonetic Extensions" - ), - new UnicodeRange ( - 0x3200, - 0x32FF, - "Enclosed CJK Letters and Months" - ), - new UnicodeRange (0x3300, 0x33FF, "CJK Compatibility"), - new UnicodeRange ( - 0x3400, - 0x4DBF, - "CJK Unified Ideographs Extension A" - ), - new UnicodeRange ( - 0x4DC0, - 0x4DFF, - "Yijing Hexagram Symbols" - ), - new UnicodeRange (0x4E00, 0x9FFF, "CJK Unified Ideographs"), - new UnicodeRange (0xA000, 0xA48F, "Yi Syllables"), - new UnicodeRange (0xA490, 0xA4CF, "Yi Radicals"), - new UnicodeRange (0xAC00, 0xD7AF, "Hangul Syllables"), - new UnicodeRange (0xD800, 0xDB7F, "High Surrogates"), - new UnicodeRange ( - 0xDB80, - 0xDBFF, - "High Private Use Surrogates" - ), - new UnicodeRange (0xDC00, 0xDFFF, "Low Surrogates"), - new UnicodeRange (0xE000, 0xF8FF, "Private Use Area"), - new UnicodeRange ( - 0xF900, - 0xFAFF, - "CJK Compatibility Ideographs" - ), - new UnicodeRange ( - 0xFB00, - 0xFB4F, - "Alphabetic Presentation Forms" - ), - new UnicodeRange ( - 0xFB50, - 0xFDFF, - "Arabic Presentation Forms-A" - ), - new UnicodeRange (0xFE00, 0xFE0F, "Variation Selectors"), - new UnicodeRange (0xFE20, 0xFE2F, "Combining Half Marks"), - new UnicodeRange ( - 0xFE30, - 0xFE4F, - "CJK Compatibility Forms" - ), - new UnicodeRange (0xFE50, 0xFE6F, "Small Form Variants"), - new UnicodeRange ( - 0xFE70, - 0xFEFF, - "Arabic Presentation Forms-B" - ), - new UnicodeRange ( - 0xFF00, - 0xFFEF, - "Halfwidth and Fullwidth Forms" - ), - new UnicodeRange (0xFFF0, 0xFFFF, "Specials"), - new UnicodeRange (0x10000, 0x1007F, "Linear B Syllabary"), - new UnicodeRange (0x10080, 0x100FF, "Linear B Ideograms"), - new UnicodeRange (0x10100, 0x1013F, "Aegean Numbers"), - new UnicodeRange (0x10300, 0x1032F, "Old Italic"), - new UnicodeRange (0x10330, 0x1034F, "Gothic"), - new UnicodeRange (0x10380, 0x1039F, "Ugaritic"), - new UnicodeRange (0x10400, 0x1044F, "Deseret"), - new UnicodeRange (0x10450, 0x1047F, "Shavian"), - new UnicodeRange (0x10480, 0x104AF, "Osmanya"), - new UnicodeRange (0x10800, 0x1083F, "Cypriot Syllabary"), - new UnicodeRange ( - 0x1D000, - 0x1D0FF, - "Byzantine Musical Symbols" - ), - new UnicodeRange (0x1D100, 0x1D1FF, "Musical Symbols"), - new UnicodeRange ( - 0x1D300, - 0x1D35F, - "Tai Xuan Jing Symbols" - ), - new UnicodeRange ( - 0x1D400, - 0x1D7FF, - "Mathematical Alphanumeric Symbols" - ), - new UnicodeRange (0x1F600, 0x1F532, "Emojis Symbols"), - new UnicodeRange ( - 0x20000, - 0x2A6DF, - "CJK Unified Ideographs Extension B" - ), - new UnicodeRange ( - 0x2F800, - 0x2FA1F, - "CJK Compatibility Ideographs Supplement" - ), - new UnicodeRange (0xE0000, 0xE007F, "Tags") + new ( + 0x0000, + 0x001F, + "ASCII Control Characters" + ), + new (0x0080, 0x009F, "C0 Control Characters"), + new ( + 0x1100, + 0x11ff, + "Hangul Jamo" + ), // This is where wide chars tend to start + new (0x20A0, 0x20CF, "Currency Symbols"), + new (0x2100, 0x214F, "Letterlike Symbols"), + new (0x2190, 0x21ff, "Arrows"), + new (0x2200, 0x22ff, "Mathematical symbols"), + new ( + 0x2300, + 0x23ff, + "Miscellaneous Technical" + ), + new ( + 0x2500, + 0x25ff, + "Box Drawing & Geometric Shapes" + ), + new (0x2600, 0x26ff, "Miscellaneous Symbols"), + new (0x2700, 0x27ff, "Dingbats"), + new (0x2800, 0x28ff, "Braille"), + new ( + 0x2b00, + 0x2bff, + "Miscellaneous Symbols and Arrows" + ), + new ( + 0xFB00, + 0xFb4f, + "Alphabetic Presentation Forms" + ), + new ( + 0x12400, + 0x1240f, + "Cuneiform Numbers and Punctuation" + ), + new ( + (uint)(CharMap.MaxCodePoint - 16), + (uint)CharMap.MaxCodePoint, + "End" + ), + new (0x0020, 0x007F, "Basic Latin"), + new (0x00A0, 0x00FF, "Latin-1 Supplement"), + new (0x0100, 0x017F, "Latin Extended-A"), + new (0x0180, 0x024F, "Latin Extended-B"), + new (0x0250, 0x02AF, "IPA Extensions"), + new ( + 0x02B0, + 0x02FF, + "Spacing Modifier Letters" + ), + new ( + 0x0300, + 0x036F, + "Combining Diacritical Marks" + ), + new (0x0370, 0x03FF, "Greek and Coptic"), + new (0x0400, 0x04FF, "Cyrillic"), + new (0x0500, 0x052F, "Cyrillic Supplementary"), + new (0x0530, 0x058F, "Armenian"), + new (0x0590, 0x05FF, "Hebrew"), + new (0x0600, 0x06FF, "Arabic"), + new (0x0700, 0x074F, "Syriac"), + new (0x0780, 0x07BF, "Thaana"), + new (0x0900, 0x097F, "Devanagari"), + new (0x0980, 0x09FF, "Bengali"), + new (0x0A00, 0x0A7F, "Gurmukhi"), + new (0x0A80, 0x0AFF, "Gujarati"), + new (0x0B00, 0x0B7F, "Oriya"), + new (0x0B80, 0x0BFF, "Tamil"), + new (0x0C00, 0x0C7F, "Telugu"), + new (0x0C80, 0x0CFF, "Kannada"), + new (0x0D00, 0x0D7F, "Malayalam"), + new (0x0D80, 0x0DFF, "Sinhala"), + new (0x0E00, 0x0E7F, "Thai"), + new (0x0E80, 0x0EFF, "Lao"), + new (0x0F00, 0x0FFF, "Tibetan"), + new (0x1000, 0x109F, "Myanmar"), + new (0x10A0, 0x10FF, "Georgian"), + new (0x1100, 0x11FF, "Hangul Jamo"), + new (0x1200, 0x137F, "Ethiopic"), + new (0x13A0, 0x13FF, "Cherokee"), + new ( + 0x1400, + 0x167F, + "Unified Canadian Aboriginal Syllabics" + ), + new (0x1680, 0x169F, "Ogham"), + new (0x16A0, 0x16FF, "Runic"), + new (0x1700, 0x171F, "Tagalog"), + new (0x1720, 0x173F, "Hanunoo"), + new (0x1740, 0x175F, "Buhid"), + new (0x1760, 0x177F, "Tagbanwa"), + new (0x1780, 0x17FF, "Khmer"), + new (0x1800, 0x18AF, "Mongolian"), + new (0x1900, 0x194F, "Limbu"), + new (0x1950, 0x197F, "Tai Le"), + new (0x19E0, 0x19FF, "Khmer Symbols"), + new (0x1D00, 0x1D7F, "Phonetic Extensions"), + new ( + 0x1E00, + 0x1EFF, + "Latin Extended Additional" + ), + new (0x1F00, 0x1FFF, "Greek Extended"), + new (0x2000, 0x206F, "General Punctuation"), + new ( + 0x2070, + 0x209F, + "Superscripts and Subscripts" + ), + new (0x20A0, 0x20CF, "Currency Symbols"), + new ( + 0x20D0, + 0x20FF, + "Combining Diacritical Marks for Symbols" + ), + new (0x2100, 0x214F, "Letterlike Symbols"), + new (0x2150, 0x218F, "Number Forms"), + new (0x2190, 0x21FF, "Arrows"), + new (0x2200, 0x22FF, "Mathematical Operators"), + new ( + 0x2300, + 0x23FF, + "Miscellaneous Technical" + ), + new (0x2400, 0x243F, "Control Pictures"), + new ( + 0x2440, + 0x245F, + "Optical Character Recognition" + ), + new (0x2460, 0x24FF, "Enclosed Alphanumerics"), + new (0x2500, 0x257F, "Box Drawing"), + new (0x2580, 0x259F, "Block Elements"), + new (0x25A0, 0x25FF, "Geometric Shapes"), + new (0x2600, 0x26FF, "Miscellaneous Symbols"), + new (0x2700, 0x27BF, "Dingbats"), + new ( + 0x27C0, + 0x27EF, + "Miscellaneous Mathematical Symbols-A" + ), + new (0x27F0, 0x27FF, "Supplemental Arrows-A"), + new (0x2800, 0x28FF, "Braille Patterns"), + new (0x2900, 0x297F, "Supplemental Arrows-B"), + new ( + 0x2980, + 0x29FF, + "Miscellaneous Mathematical Symbols-B" + ), + new ( + 0x2A00, + 0x2AFF, + "Supplemental Mathematical Operators" + ), + new ( + 0x2B00, + 0x2BFF, + "Miscellaneous Symbols and Arrows" + ), + new ( + 0x2E80, + 0x2EFF, + "CJK Radicals Supplement" + ), + new (0x2F00, 0x2FDF, "Kangxi Radicals"), + new ( + 0x2FF0, + 0x2FFF, + "Ideographic Description Characters" + ), + new ( + 0x3000, + 0x303F, + "CJK Symbols and Punctuation" + ), + new (0x3040, 0x309F, "Hiragana"), + new (0x30A0, 0x30FF, "Katakana"), + new (0x3100, 0x312F, "Bopomofo"), + new ( + 0x3130, + 0x318F, + "Hangul Compatibility Jamo" + ), + new (0x3190, 0x319F, "Kanbun"), + new (0x31A0, 0x31BF, "Bopomofo Extended"), + new ( + 0x31F0, + 0x31FF, + "Katakana Phonetic Extensions" + ), + new ( + 0x3200, + 0x32FF, + "Enclosed CJK Letters and Months" + ), + new (0x3300, 0x33FF, "CJK Compatibility"), + new ( + 0x3400, + 0x4DBF, + "CJK Unified Ideographs Extension A" + ), + new ( + 0x4DC0, + 0x4DFF, + "Yijing Hexagram Symbols" + ), + new (0x4E00, 0x9FFF, "CJK Unified Ideographs"), + new (0xA000, 0xA48F, "Yi Syllables"), + new (0xA490, 0xA4CF, "Yi Radicals"), + new (0xAC00, 0xD7AF, "Hangul Syllables"), + new (0xD800, 0xDB7F, "High Surrogates"), + new ( + 0xDB80, + 0xDBFF, + "High Private Use Surrogates" + ), + new (0xDC00, 0xDFFF, "Low Surrogates"), + new (0xE000, 0xF8FF, "Private Use Area"), + new ( + 0xF900, + 0xFAFF, + "CJK Compatibility Ideographs" + ), + new ( + 0xFB00, + 0xFB4F, + "Alphabetic Presentation Forms" + ), + new ( + 0xFB50, + 0xFDFF, + "Arabic Presentation Forms-A" + ), + new (0xFE00, 0xFE0F, "Variation Selectors"), + new (0xFE20, 0xFE2F, "Combining Half Marks"), + new ( + 0xFE30, + 0xFE4F, + "CJK Compatibility Forms" + ), + new (0xFE50, 0xFE6F, "Small Form Variants"), + new ( + 0xFE70, + 0xFEFF, + "Arabic Presentation Forms-B" + ), + new ( + 0xFF00, + 0xFFEF, + "Halfwidth and Fullwidth Forms" + ), + new (0xFFF0, 0xFFFF, "Specials"), + new (0x10000, 0x1007F, "Linear B Syllabary"), + new (0x10080, 0x100FF, "Linear B Ideograms"), + new (0x10100, 0x1013F, "Aegean Numbers"), + new (0x10300, 0x1032F, "Old Italic"), + new (0x10330, 0x1034F, "Gothic"), + new (0x10380, 0x1039F, "Ugaritic"), + new (0x10400, 0x1044F, "Deseret"), + new (0x10450, 0x1047F, "Shavian"), + new (0x10480, 0x104AF, "Osmanya"), + new (0x10800, 0x1083F, "Cypriot Syllabary"), + new ( + 0x1D000, + 0x1D0FF, + "Byzantine Musical Symbols" + ), + new (0x1D100, 0x1D1FF, "Musical Symbols"), + new ( + 0x1D300, + 0x1D35F, + "Tai Xuan Jing Symbols" + ), + new ( + 0x1D400, + 0x1D7FF, + "Mathematical Alphanumeric Symbols" + ), + new (0x1F600, 0x1F532, "Emojis Symbols"), + new ( + 0x20000, + 0x2A6DF, + "CJK Unified Ideographs Extension B" + ), + new ( + 0x2F800, + 0x2FA1F, + "CJK Compatibility Ideographs Supplement" + ), + new (0xE0000, 0xE007F, "Tags") }; private ColorScheme _alternatingColorScheme; @@ -433,239 +433,239 @@ public class TableEditor : Scenario Win.Y = 1; // menu Win.Height = Dim.Fill (1); // status bar - _tableView = new TableView { X = 0, Y = 0, Width = Dim.Fill (), Height = Dim.Fill (1) }; + _tableView = new() { X = 0, Y = 0, Width = Dim.Fill (), Height = Dim.Fill (1) }; var menu = new MenuBar { Menus = [ - new MenuBarItem ( - "_File", - new MenuItem [] - { - new ( - "_OpenBigExample", - "", - () => OpenExample (true) - ), - new ( - "_OpenSmallExample", - "", - () => OpenExample (false) - ), - new ( - "OpenCharacter_Map", - "", - () => OpenUnicodeMap () - ), - new ( - "OpenTreeExample", - "", - () => OpenTreeExample () - ), - new ( - "_CloseExample", - "", - () => CloseExample () - ), - new ("_Quit", "", () => Quit ()) - } - ), - new MenuBarItem ( - "_View", - new [] - { - _miShowHeaders = - new MenuItem ( - "_ShowHeaders", - "", - () => ToggleShowHeaders () - ) - { - Checked = _tableView.Style.ShowHeaders, - CheckType = MenuItemCheckStyle.Checked - }, - _miAlwaysShowHeaders = - new MenuItem ( - "_AlwaysShowHeaders", - "", - () => ToggleAlwaysShowHeaders () - ) - { - Checked = _tableView.Style.AlwaysShowHeaders, - CheckType = MenuItemCheckStyle.Checked - }, - _miHeaderOverline = - new MenuItem ( - "_HeaderOverLine", - "", - () => ToggleOverline () - ) - { - Checked = _tableView.Style - .ShowHorizontalHeaderOverline, - CheckType = MenuItemCheckStyle.Checked - }, - _miHeaderMidline = new MenuItem ( - "_HeaderMidLine", - "", - () => ToggleHeaderMidline () - ) - { - Checked = _tableView.Style - .ShowVerticalHeaderLines, - CheckType = MenuItemCheckStyle.Checked - }, - _miHeaderUnderline = new MenuItem ( - "_HeaderUnderLine", - "", - () => ToggleUnderline () - ) - { - Checked = _tableView.Style - .ShowHorizontalHeaderUnderline, - CheckType = MenuItemCheckStyle.Checked - }, - _miBottomline = new MenuItem ( - "_BottomLine", - "", - () => ToggleBottomline () - ) - { - Checked = _tableView.Style - .ShowHorizontalBottomline, - CheckType = MenuItemCheckStyle - .Checked - }, - _miShowHorizontalScrollIndicators = - new MenuItem ( - "_HorizontalScrollIndicators", - "", - () => - ToggleHorizontalScrollIndicators () - ) - { - Checked = _tableView.Style - .ShowHorizontalScrollIndicators, - CheckType = MenuItemCheckStyle.Checked - }, - _miFullRowSelect = new MenuItem ( - "_FullRowSelect", - "", - () => ToggleFullRowSelect () - ) - { - Checked = _tableView.FullRowSelect, - CheckType = MenuItemCheckStyle.Checked - }, - _miCellLines = new MenuItem ( - "_CellLines", - "", - () => ToggleCellLines () - ) - { - Checked = _tableView.Style - .ShowVerticalCellLines, - CheckType = MenuItemCheckStyle - .Checked - }, - _miExpandLastColumn = - new MenuItem ( - "_ExpandLastColumn", - "", - () => ToggleExpandLastColumn () - ) - { - Checked = _tableView.Style.ExpandLastColumn, - CheckType = MenuItemCheckStyle.Checked - }, - _miAlwaysUseNormalColorForVerticalCellLines = - new MenuItem ( - "_AlwaysUseNormalColorForVerticalCellLines", - "", - () => - ToggleAlwaysUseNormalColorForVerticalCellLines () - ) - { - Checked = _tableView.Style - .AlwaysUseNormalColorForVerticalCellLines, - CheckType = MenuItemCheckStyle.Checked - }, - _miSmoothScrolling = - new MenuItem ( - "_SmoothHorizontalScrolling", - "", - () => ToggleSmoothScrolling () - ) - { - Checked = _tableView.Style - .SmoothHorizontalScrolling, - CheckType = MenuItemCheckStyle.Checked - }, - new ("_AllLines", "", () => ToggleAllCellLines ()), - new ("_NoLines", "", () => ToggleNoCellLines ()), - _miCheckboxes = new MenuItem ( - "_Checkboxes", - "", - () => ToggleCheckboxes (false) - ) - { - Checked = false, - CheckType = MenuItemCheckStyle.Checked - }, - _miRadioboxes = new MenuItem ( - "_Radioboxes", - "", - () => ToggleCheckboxes (true) - ) - { - Checked = false, - CheckType = MenuItemCheckStyle.Checked - }, - _miAlternatingColors = - new MenuItem ( - "Alternating Colors", - "", - () => ToggleAlternatingColors () - ) { CheckType = MenuItemCheckStyle.Checked }, - _miCursor = - new MenuItem ( - "Invert Selected Cell First Character", - "", - () => - ToggleInvertSelectedCellFirstCharacter () - ) - { - Checked = _tableView.Style - .InvertSelectedCellFirstCharacter, - CheckType = MenuItemCheckStyle.Checked - }, - new ( - "_ClearColumnStyles", - "", - () => ClearColumnStyles () - ), - new ("Sho_w All Columns", "", () => ShowAllColumns ()) - } - ), - new MenuBarItem ( - "_Column", - new MenuItem [] - { - new ("_Set Max Width", "", SetMaxWidth), - new ("_Set Min Width", "", SetMinWidth), - new ( - "_Set MinAcceptableWidth", - "", - SetMinAcceptableWidth - ), - new ( - "_Set All MinAcceptableWidth=1", - "", - SetMinAcceptableWidthToOne - ) - } - ) + new ( + "_File", + new MenuItem [] + { + new ( + "_OpenBigExample", + "", + () => OpenExample (true) + ), + new ( + "_OpenSmallExample", + "", + () => OpenExample (false) + ), + new ( + "OpenCharacter_Map", + "", + () => OpenUnicodeMap () + ), + new ( + "OpenTreeExample", + "", + () => OpenTreeExample () + ), + new ( + "_CloseExample", + "", + () => CloseExample () + ), + new ("_Quit", "", () => Quit ()) + } + ), + new ( + "_View", + new [] + { + _miShowHeaders = + new ( + "_ShowHeaders", + "", + () => ToggleShowHeaders () + ) + { + Checked = _tableView.Style.ShowHeaders, + CheckType = MenuItemCheckStyle.Checked + }, + _miAlwaysShowHeaders = + new ( + "_AlwaysShowHeaders", + "", + () => ToggleAlwaysShowHeaders () + ) + { + Checked = _tableView.Style.AlwaysShowHeaders, + CheckType = MenuItemCheckStyle.Checked + }, + _miHeaderOverline = + new ( + "_HeaderOverLine", + "", + () => ToggleOverline () + ) + { + Checked = _tableView.Style + .ShowHorizontalHeaderOverline, + CheckType = MenuItemCheckStyle.Checked + }, + _miHeaderMidline = new ( + "_HeaderMidLine", + "", + () => ToggleHeaderMidline () + ) + { + Checked = _tableView.Style + .ShowVerticalHeaderLines, + CheckType = MenuItemCheckStyle.Checked + }, + _miHeaderUnderline = new ( + "_HeaderUnderLine", + "", + () => ToggleUnderline () + ) + { + Checked = _tableView.Style + .ShowHorizontalHeaderUnderline, + CheckType = MenuItemCheckStyle.Checked + }, + _miBottomline = new ( + "_BottomLine", + "", + () => ToggleBottomline () + ) + { + Checked = _tableView.Style + .ShowHorizontalBottomline, + CheckType = MenuItemCheckStyle + .Checked + }, + _miShowHorizontalScrollIndicators = + new ( + "_HorizontalScrollIndicators", + "", + () => + ToggleHorizontalScrollIndicators () + ) + { + Checked = _tableView.Style + .ShowHorizontalScrollIndicators, + CheckType = MenuItemCheckStyle.Checked + }, + _miFullRowSelect = new ( + "_FullRowSelect", + "", + () => ToggleFullRowSelect () + ) + { + Checked = _tableView.FullRowSelect, + CheckType = MenuItemCheckStyle.Checked + }, + _miCellLines = new ( + "_CellLines", + "", + () => ToggleCellLines () + ) + { + Checked = _tableView.Style + .ShowVerticalCellLines, + CheckType = MenuItemCheckStyle + .Checked + }, + _miExpandLastColumn = + new ( + "_ExpandLastColumn", + "", + () => ToggleExpandLastColumn () + ) + { + Checked = _tableView.Style.ExpandLastColumn, + CheckType = MenuItemCheckStyle.Checked + }, + _miAlwaysUseNormalColorForVerticalCellLines = + new ( + "_AlwaysUseNormalColorForVerticalCellLines", + "", + () => + ToggleAlwaysUseNormalColorForVerticalCellLines () + ) + { + Checked = _tableView.Style + .AlwaysUseNormalColorForVerticalCellLines, + CheckType = MenuItemCheckStyle.Checked + }, + _miSmoothScrolling = + new ( + "_SmoothHorizontalScrolling", + "", + () => ToggleSmoothScrolling () + ) + { + Checked = _tableView.Style + .SmoothHorizontalScrolling, + CheckType = MenuItemCheckStyle.Checked + }, + new ("_AllLines", "", () => ToggleAllCellLines ()), + new ("_NoLines", "", () => ToggleNoCellLines ()), + _miCheckboxes = new ( + "_Checkboxes", + "", + () => ToggleCheckboxes (false) + ) + { + Checked = false, + CheckType = MenuItemCheckStyle.Checked + }, + _miRadioboxes = new ( + "_Radioboxes", + "", + () => ToggleCheckboxes (true) + ) + { + Checked = false, + CheckType = MenuItemCheckStyle.Checked + }, + _miAlternatingColors = + new ( + "Alternating Colors", + "", + () => ToggleAlternatingColors () + ) { CheckType = MenuItemCheckStyle.Checked }, + _miCursor = + new ( + "Invert Selected Cell First Character", + "", + () => + ToggleInvertSelectedCellFirstCharacter () + ) + { + Checked = _tableView.Style + .InvertSelectedCellFirstCharacter, + CheckType = MenuItemCheckStyle.Checked + }, + new ( + "_ClearColumnStyles", + "", + () => ClearColumnStyles () + ), + new ("Sho_w All Columns", "", () => ShowAllColumns ()) + } + ), + new ( + "_Column", + new MenuItem [] + { + new ("_Set Max Width", "", SetMaxWidth), + new ("_Set Min Width", "", SetMinWidth), + new ( + "_Set MinAcceptableWidth", + "", + SetMinAcceptableWidth + ), + new ( + "_Set All MinAcceptableWidth=1", + "", + SetMinAcceptableWidthToOne + ) + } + ) ] }; @@ -705,7 +705,7 @@ public class TableEditor : Scenario X = 0, Y = Pos.Bottom (_tableView), Text = "0,0", - AutoSize = false, + Width = Dim.Fill (), TextAlignment = TextAlignment.Right }; @@ -718,28 +718,28 @@ public class TableEditor : Scenario SetupScrollBar (); - _redColorScheme = new ColorScheme + _redColorScheme = new() { Disabled = Win.ColorScheme.Disabled, HotFocus = Win.ColorScheme.HotFocus, Focus = Win.ColorScheme.Focus, - Normal = new Attribute (Color.Red, Win.ColorScheme.Normal.Background) + Normal = new (Color.Red, Win.ColorScheme.Normal.Background) }; - _alternatingColorScheme = new ColorScheme + _alternatingColorScheme = new() { Disabled = Win.ColorScheme.Disabled, HotFocus = Win.ColorScheme.HotFocus, Focus = Win.ColorScheme.Focus, - Normal = new Attribute (Color.White, Color.BrightBlue) + Normal = new (Color.White, Color.BrightBlue) }; - _redColorSchemeAlt = new ColorScheme + _redColorSchemeAlt = new() { Disabled = Win.ColorScheme.Disabled, HotFocus = Win.ColorScheme.HotFocus, Focus = Win.ColorScheme.Focus, - Normal = new Attribute (Color.Red, Color.BrightBlue) + Normal = new (Color.Red, Color.BrightBlue) }; // if user clicks the mouse in TableView @@ -870,10 +870,10 @@ public class TableEditor : Scenario var ok = new Button { Text = "Ok", IsDefault = true }; ok.Accept += (s, e) => - { - okPressed = true; - Application.RequestStop (); - }; + { + okPressed = true; + Application.RequestStop (); + }; var cancel = new Button { Text = "Cancel" }; cancel.Accept += (s, e) => { Application.RequestStop (); }; var d = new Dialog { Title = title, Buttons = [ok, cancel] }; @@ -1017,7 +1017,7 @@ public class TableEditor : Scenario _tableView, "Name", tree, - new Dictionary> + new() { { "Extension", f => f.Extension }, { "CreationTime", f => f.CreationTime }, @@ -1068,10 +1068,10 @@ public class TableEditor : Scenario var ok = new Button { Text = "Ok", IsDefault = true }; ok.Accept += (s, e) => - { - accepted = true; - Application.RequestStop (); - }; + { + accepted = true; + Application.RequestStop (); + }; var cancel = new Button { Text = "Cancel" }; cancel.Accept += (s, e) => { Application.RequestStop (); }; var d = new Dialog { Title = prompt, Buttons = [ok, cancel] }; @@ -1254,25 +1254,25 @@ public class TableEditor : Scenario var contextMenu = new ContextMenu { - Position = new Point (e.MouseEvent.X + 1, e.MouseEvent.Y + 1), - MenuItems = new MenuBarItem ( - [ - new MenuItem ( - $"Hide {TrimArrows (colName)}", - "", - () => HideColumn (clickedCol) - ), - new MenuItem ( - $"Sort {StripArrows (sort)}", - "", - () => SortColumn ( - clickedCol, - sort, - isAsc - ) - ) - ] - ) + Position = new (e.MouseEvent.X + 1, e.MouseEvent.Y + 1), + MenuItems = new ( + [ + new ( + $"Hide {TrimArrows (colName)}", + "", + () => HideColumn (clickedCol) + ), + new ( + $"Sort {StripArrows (sort)}", + "", + () => SortColumn ( + clickedCol, + sort, + isAsc + ) + ) + ] + ) }; contextMenu.Show (); diff --git a/UICatalog/Scenarios/Text.cs b/UICatalog/Scenarios/Text.cs index bbc570642..19dddd847 100644 --- a/UICatalog/Scenarios/Text.cs +++ b/UICatalog/Scenarios/Text.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; @@ -23,6 +22,7 @@ public class Text : Scenario // TextField is a simple, single-line text input control var label = new Label { Text = "_TextField:" }; Win.Add (label); + var textField = new TextField { X = Pos.Right (label) + 1, @@ -37,6 +37,7 @@ public class Text : Scenario var singleWordGenerator = new SingleWordSuggestionGenerator (); textField.Autocomplete.SuggestionGenerator = singleWordGenerator; textField.TextChanging += TextField_TextChanging; + void TextField_TextChanging (object sender, StateEventArgs e) { singleWordGenerator.AllSuggestions = Regex.Matches (e.NewValue, "\\w+") @@ -44,13 +45,14 @@ public class Text : Scenario .Distinct () .ToList (); } + Win.Add (textField); var labelMirroringTextField = new Label { X = Pos.Right (textField) + 1, Y = Pos.Top (textField), - AutoSize = false, + Width = Dim.Fill (1) - 1, Height = 1, Text = textField.Text @@ -59,8 +61,9 @@ public class Text : Scenario textField.TextChanged += (s, prev) => { labelMirroringTextField.Text = textField.Text; }; // TextView is a rich (as in functionality, not formatting) text editing control - label = new Label { Text = "T_extView:", Y = Pos.Bottom (label) + 1 }; + label = new() { Text = "T_extView:", Y = Pos.Bottom (label) + 1 }; Win.Add (label); + var textView = new TextView { X = Pos.Right (label) + 1, Y = Pos.Bottom (textField) + 1, Width = Dim.Percent (50) - 1, Height = Dim.Percent (30) @@ -83,7 +86,7 @@ public class Text : Scenario { X = Pos.Right (textView) + 1, Y = Pos.Top (textView), - AutoSize = false, + Width = Dim.Fill (1) - 1, Height = Dim.Height (textView) - 1 }; @@ -163,7 +166,7 @@ public class Text : Scenario Win.Add (chxCaptureTabs); // Hex editor - label = new Label { Text = "_HexView:", Y = Pos.Bottom (chxMultiline) + 1 }; + label = new() { Text = "_HexView:", Y = Pos.Bottom (chxMultiline) + 1 }; Win.Add (label); var hexEditor = @@ -179,7 +182,7 @@ public class Text : Scenario { X = Pos.Right (hexEditor) + 1, Y = Pos.Top (hexEditor), - AutoSize = false, + Width = Dim.Fill (1) - 1, Height = Dim.Height (hexEditor) - 1 }; @@ -195,7 +198,7 @@ public class Text : Scenario Win.Add (labelMirroringHexEditor); // DateField - label = new Label { Text = "_DateField:", Y = Pos.Bottom (hexEditor) + 1 }; + label = new() { Text = "_DateField:", Y = Pos.Bottom (hexEditor) + 1 }; Win.Add (label); var dateField = new DateField (DateTime.Now) { X = Pos.Right (label) + 1, Y = Pos.Bottom (hexEditor) + 1, Width = 20 }; @@ -205,7 +208,7 @@ public class Text : Scenario { X = Pos.Right (dateField) + 1, Y = Pos.Top (dateField), - AutoSize = false, + Width = Dim.Width (dateField), Height = Dim.Height (dateField), Text = dateField.Text @@ -215,10 +218,10 @@ public class Text : Scenario dateField.TextChanged += (s, prev) => { labelMirroringDateField.Text = dateField.Text; }; // TimeField - label = new Label { Text = "T_imeField:", Y = Pos.Top (dateField), X = Pos.Right (labelMirroringDateField) + 5 }; + label = new() { Text = "T_imeField:", Y = Pos.Top (dateField), X = Pos.Right (labelMirroringDateField) + 5 }; Win.Add (label); - _timeField = new TimeField + _timeField = new() { X = Pos.Right (label) + 1, Y = Pos.Top (dateField), @@ -228,11 +231,11 @@ public class Text : Scenario }; Win.Add (_timeField); - _labelMirroringTimeField = new Label + _labelMirroringTimeField = new() { X = Pos.Right (_timeField) + 1, Y = Pos.Top (_timeField), - AutoSize = false, + Width = Dim.Width (_timeField), Height = Dim.Height (_timeField), Text = _timeField.Text @@ -262,7 +265,7 @@ public class Text : Scenario { X = Pos.Right (netProviderField) + 1, Y = Pos.Top (netProviderField), - AutoSize = false, + Width = Dim.Width (netProviderField), Height = Dim.Height (netProviderField), Text = netProviderField.Text @@ -296,7 +299,7 @@ public class Text : Scenario { X = Pos.Right (regexProviderField) + 1, Y = Pos.Top (regexProviderField), - AutoSize = false, + Width = Dim.Width (regexProviderField), Height = Dim.Height (regexProviderField), Text = regexProviderField.Text @@ -318,7 +321,7 @@ public class Text : Scenario appendAutocompleteTextField.Autocomplete.SuggestionGenerator = new SingleWordSuggestionGenerator { - AllSuggestions = new List + AllSuggestions = new() { "fish", "flipper", diff --git a/UICatalog/Scenarios/TextAlignments.cs b/UICatalog/Scenarios/TextAlignments.cs index ff7c5867c..92ee344e1 100644 --- a/UICatalog/Scenarios/TextAlignments.cs +++ b/UICatalog/Scenarios/TextAlignments.cs @@ -26,22 +26,22 @@ public class TextAlignments : Scenario foreach (TextAlignment alignment in alignments) { - singleLines [(int)alignment] = new Label + singleLines [(int)alignment] = new() { TextAlignment = alignment, X = 1, - AutoSize = false, + Width = Dim.Fill (1), Height = 1, ColorScheme = Colors.ColorSchemes ["Dialog"], Text = txt }; - multipleLines [(int)alignment] = new Label + multipleLines [(int)alignment] = new() { TextAlignment = alignment, X = 1, - AutoSize = false, + Width = Dim.Fill (1), Height = multiLineHeight, ColorScheme = Colors.ColorSchemes ["Dialog"], @@ -80,13 +80,13 @@ public class TextAlignments : Scenario var update = new Button { X = Pos.Right (edit) + 1, Y = Pos.Bottom (edit) - 1, Text = "_Update" }; update.Accept += (s, e) => - { - foreach (TextAlignment alignment in alignments) - { - singleLines [(int)alignment].Text = edit.Text; - multipleLines [(int)alignment].Text = edit.Text; - } - }; + { + foreach (TextAlignment alignment in alignments) + { + singleLines [(int)alignment].Text = edit.Text; + multipleLines [(int)alignment].Text = edit.Text; + } + }; Win.Add (update); var enableHotKeyCheckBox = new CheckBox @@ -104,7 +104,7 @@ public class TextAlignments : Scenario foreach (TextAlignment alignment in alignments) { - label = new Label { Y = Pos.Bottom (label), Text = $"{alignment}:" }; + label = new() { Y = Pos.Bottom (label), Text = $"{alignment}:" }; Win.Add (label); singleLines [(int)alignment].Y = Pos.Bottom (label); Win.Add (singleLines [(int)alignment]); @@ -112,12 +112,12 @@ public class TextAlignments : Scenario } txt += "\nSecond line\n\nFourth Line."; - label = new Label { Y = Pos.Bottom (label), Text = "Demonstrating multi-line and word wrap:" }; + label = new() { Y = Pos.Bottom (label), Text = "Demonstrating multi-line and word wrap:" }; Win.Add (label); foreach (TextAlignment alignment in alignments) { - label = new Label { Y = Pos.Bottom (label), Text = $"{alignment}:" }; + label = new() { Y = Pos.Bottom (label), Text = $"{alignment}:" }; Win.Add (label); multipleLines [(int)alignment].Y = Pos.Bottom (label); Win.Add (multipleLines [(int)alignment]); diff --git a/UICatalog/Scenarios/TextFormatterDemo.cs b/UICatalog/Scenarios/TextFormatterDemo.cs index 021359801..00029c033 100644 --- a/UICatalog/Scenarios/TextFormatterDemo.cs +++ b/UICatalog/Scenarios/TextFormatterDemo.cs @@ -14,9 +14,9 @@ public class TextFormatterDemo : Scenario { Application.Init (); - var app = new Window () + var app = new Window { - Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}", + Title = $"{Application.QuitKey} to Quit - Scenario: {GetName ()}" }; // Make Win smaller so sizing the window horizontally will make the @@ -34,9 +34,9 @@ public class TextFormatterDemo : Scenario ColorScheme = Colors.ColorSchemes ["TopLevel"], X = 0, Y = 0, - AutoSize = false, + Height = 10, - Width = Dim.Fill (), + Width = Dim.Fill () }; var block = new StringBuilder (); @@ -71,22 +71,22 @@ public class TextFormatterDemo : Scenario foreach (TextAlignment alignment in alignments) { - singleLines [(int)alignment] = new Label + singleLines [(int)alignment] = new() { TextAlignment = alignment, X = 0, - AutoSize = false, + Width = Dim.Fill (), Height = 1, ColorScheme = Colors.ColorSchemes ["Dialog"], Text = text }; - multipleLines [(int)alignment] = new Label + multipleLines [(int)alignment] = new() { TextAlignment = alignment, X = 0, - AutoSize = false, + Width = Dim.Fill (), Height = multiLineHeight, ColorScheme = Colors.ColorSchemes ["Dialog"], @@ -102,19 +102,19 @@ public class TextFormatterDemo : Scenario foreach (TextAlignment alignment in alignments) { - label = new Label { Y = Pos.Bottom (label), Text = $"{alignment}:" }; + label = new() { Y = Pos.Bottom (label), Text = $"{alignment}:" }; app.Add (label); singleLines [(int)alignment].Y = Pos.Bottom (label); app.Add (singleLines [(int)alignment]); label = singleLines [(int)alignment]; } - label = new Label { Y = Pos.Bottom (label), Text = "Demonstrating multi-line and word wrap:" }; + label = new() { Y = Pos.Bottom (label), Text = "Demonstrating multi-line and word wrap:" }; app.Add (label); foreach (TextAlignment alignment in alignments) { - label = new Label { Y = Pos.Bottom (label), Text = $"{alignment}:" }; + label = new() { Y = Pos.Bottom (label), Text = $"{alignment}:" }; app.Add (label); multipleLines [(int)alignment].Y = Pos.Bottom (label); app.Add (multipleLines [(int)alignment]); diff --git a/UICatalog/Scenarios/TileViewNesting.cs b/UICatalog/Scenarios/TileViewNesting.cs index f35aea0d6..6d2834088 100644 --- a/UICatalog/Scenarios/TileViewNesting.cs +++ b/UICatalog/Scenarios/TileViewNesting.cs @@ -26,29 +26,29 @@ public class TileViewNesting : Scenario Win.Y = 1; var lblViews = new Label { Text = "Number Of Views:" }; - _textField = new TextField { X = Pos.Right (lblViews), Width = 10, Text = "2" }; + _textField = new() { X = Pos.Right (lblViews), Width = 10, Text = "2" }; _textField.TextChanged += (s, e) => SetupTileView (); - _cbHorizontal = new CheckBox { X = Pos.Right (_textField) + 1, Text = "Horizontal" }; + _cbHorizontal = new() { X = Pos.Right (_textField) + 1, Text = "Horizontal" }; _cbHorizontal.Toggled += (s, e) => SetupTileView (); - _cbBorder = new CheckBox { X = Pos.Right (_cbHorizontal) + 1, Text = "Border" }; + _cbBorder = new() { X = Pos.Right (_cbHorizontal) + 1, Text = "Border" }; _cbBorder.Toggled += (s, e) => SetupTileView (); - _cbTitles = new CheckBox { X = Pos.Right (_cbBorder) + 1, Text = "Titles" }; + _cbTitles = new() { X = Pos.Right (_cbBorder) + 1, Text = "Titles" }; _cbTitles.Toggled += (s, e) => SetupTileView (); - _cbUseLabels = new CheckBox { X = Pos.Right (_cbTitles) + 1, Text = "Use Labels" }; + _cbUseLabels = new() { X = Pos.Right (_cbTitles) + 1, Text = "Use Labels" }; _cbUseLabels.Toggled += (s, e) => SetupTileView (); - _workArea = new View { X = 0, Y = 1, Width = Dim.Fill (), Height = Dim.Fill () }; + _workArea = new() { X = 0, Y = 1, Width = Dim.Fill (), Height = Dim.Fill () }; var menu = new MenuBar { Menus = [ - new MenuBarItem ("_File", new MenuItem [] { new ("_Quit", "", () => Quit ()) }) + new ("_File", new MenuItem [] { new ("_Quit", "", () => Quit ()) }) ] }; @@ -99,7 +99,7 @@ public class TileViewNesting : Scenario { Width = Dim.Fill (), Height = 1, - AutoSize = false, + Text = number.ToString ().Repeat (1000), CanFocus = true }; diff --git a/UICatalog/Scenarios/TimeAndDate.cs b/UICatalog/Scenarios/TimeAndDate.cs index 6b8bf601e..ddfc8fc7d 100644 --- a/UICatalog/Scenarios/TimeAndDate.cs +++ b/UICatalog/Scenarios/TimeAndDate.cs @@ -53,67 +53,67 @@ public class TimeAndDate : Scenario longDate.DateChanged += DateChanged; Win.Add (longDate); - _lblOldTime = new Label + _lblOldTime = new() { X = Pos.Center (), Y = Pos.Bottom (longDate) + 1, TextAlignment = TextAlignment.Centered, - AutoSize = false, + Width = Dim.Fill (), Text = "Old Time: " }; Win.Add (_lblOldTime); - _lblNewTime = new Label + _lblNewTime = new() { X = Pos.Center (), Y = Pos.Bottom (_lblOldTime) + 1, TextAlignment = TextAlignment.Centered, - AutoSize = false, + Width = Dim.Fill (), Text = "New Time: " }; Win.Add (_lblNewTime); - _lblTimeFmt = new Label + _lblTimeFmt = new() { X = Pos.Center (), Y = Pos.Bottom (_lblNewTime) + 1, TextAlignment = TextAlignment.Centered, - AutoSize = false, + Width = Dim.Fill (), Text = "Time Format: " }; Win.Add (_lblTimeFmt); - _lblOldDate = new Label + _lblOldDate = new() { X = Pos.Center (), Y = Pos.Bottom (_lblTimeFmt) + 2, TextAlignment = TextAlignment.Centered, - AutoSize = false, + Width = Dim.Fill (), Text = "Old Date: " }; Win.Add (_lblOldDate); - _lblNewDate = new Label + _lblNewDate = new() { X = Pos.Center (), Y = Pos.Bottom (_lblOldDate) + 1, TextAlignment = TextAlignment.Centered, - AutoSize = false, + Width = Dim.Fill (), Text = "New Date: " }; Win.Add (_lblNewDate); - _lblDateFmt = new Label + _lblDateFmt = new() { X = Pos.Center (), Y = Pos.Bottom (_lblNewDate) + 1, TextAlignment = TextAlignment.Centered, - AutoSize = false, + Width = Dim.Fill (), Text = "Date Format: " }; @@ -125,16 +125,16 @@ public class TimeAndDate : Scenario }; swapButton.Accept += (s, e) => - { - longTime.ReadOnly = !longTime.ReadOnly; - shortTime.ReadOnly = !shortTime.ReadOnly; + { + longTime.ReadOnly = !longTime.ReadOnly; + shortTime.ReadOnly = !shortTime.ReadOnly; - longTime.IsShortFormat = !longTime.IsShortFormat; - shortTime.IsShortFormat = !shortTime.IsShortFormat; + longTime.IsShortFormat = !longTime.IsShortFormat; + shortTime.IsShortFormat = !shortTime.IsShortFormat; - longDate.ReadOnly = !longDate.ReadOnly; - shortDate.ReadOnly = !shortDate.ReadOnly; - }; + longDate.ReadOnly = !longDate.ReadOnly; + shortDate.ReadOnly = !shortDate.ReadOnly; + }; Win.Add (swapButton); } diff --git a/UICatalog/Scenarios/Unicode.cs b/UICatalog/Scenarios/Unicode.cs index 00c139638..987c50934 100644 --- a/UICatalog/Scenarios/Unicode.cs +++ b/UICatalog/Scenarios/Unicode.cs @@ -32,32 +32,32 @@ public class UnicodeInMenu : Scenario { Menus = [ - new MenuBarItem ( - "_Файл", - new MenuItem [] - { - new ( - "_Создать", - "Creates new file", - null - ), - new ("_Открыть", "", null), - new ("Со_хранить", "", null), - new ( - "_Выход", - "", - () => Application.RequestStop () - ) - } - ), - new MenuBarItem ( - "_Edit", - new MenuItem [] - { - new ("_Copy", "", null), new ("C_ut", "", null), - new ("_糊", "hú (Paste)", null) - } - ) + new ( + "_Файл", + new MenuItem [] + { + new ( + "_Создать", + "Creates new file", + null + ), + new ("_Открыть", "", null), + new ("Со_хранить", "", null), + new ( + "_Выход", + "", + () => Application.RequestStop () + ) + } + ), + new ( + "_Edit", + new MenuItem [] + { + new ("_Copy", "", null), new ("C_ut", "", null), + new ("_糊", "hú (Paste)", null) + } + ) ] }; Top.Add (menu); @@ -83,43 +83,43 @@ public class UnicodeInMenu : Scenario { X = 20, Y = Pos.Y (label), - AutoSize = false, + Width = Dim.Percent (50), Text = gitString }; Win.Add (testlabel); - label = new Label { X = Pos.X (label), Y = Pos.Bottom (label) + 1, Text = "Label (CanFocus):" }; + label = new() { X = Pos.X (label), Y = Pos.Bottom (label) + 1, Text = "Label (CanFocus):" }; Win.Add (label); var sb = new StringBuilder (); sb.Append ('e'); sb.Append ('\u0301'); sb.Append ('\u0301'); - testlabel = new Label + testlabel = new() { X = 20, Y = Pos.Y (label), - AutoSize = false, + Width = Dim.Percent (50), CanFocus = true, - HotKeySpecifier = new Rune ('&'), + HotKeySpecifier = new ('&'), Text = $"Should be [e with two accents, but isn't due to #2616]: [{sb}]" }; Win.Add (testlabel); - label = new Label { X = Pos.X (label), Y = Pos.Bottom (label) + 1, Text = "Button:" }; + label = new() { X = Pos.X (label), Y = Pos.Bottom (label) + 1, Text = "Button:" }; Win.Add (label); var button = new Button { X = 20, Y = Pos.Y (label), Text = "A123456789♥♦♣♠JQK" }; Win.Add (button); - label = new Label { X = Pos.X (label), Y = Pos.Bottom (label) + 1, Text = "CheckBox:" }; + label = new() { X = Pos.X (label), Y = Pos.Bottom (label) + 1, Text = "CheckBox:" }; Win.Add (label); var checkBox = new CheckBox { X = 20, Y = Pos.Y (label), - AutoSize = false, + Width = Dim.Percent (50), Height = 1, Text = gitString @@ -129,7 +129,7 @@ public class UnicodeInMenu : Scenario { X = 20, Y = Pos.Bottom (checkBox), - AutoSize = false, + Width = Dim.Percent (50), Height = 1, TextAlignment = TextAlignment.Right, @@ -137,7 +137,7 @@ public class UnicodeInMenu : Scenario }; Win.Add (checkBox, checkBoxRight); - label = new Label { X = Pos.X (label), Y = Pos.Bottom (checkBoxRight) + 1, Text = "ComboBox:" }; + label = new() { X = Pos.X (label), Y = Pos.Bottom (checkBoxRight) + 1, Text = "ComboBox:" }; Win.Add (label); var comboBox = new ComboBox { X = 20, Y = Pos.Y (label), Width = Dim.Percent (50) }; comboBox.SetSource (new List { gitString, "Со_хранить" }); @@ -145,7 +145,7 @@ public class UnicodeInMenu : Scenario Win.Add (comboBox); comboBox.Text = gitString; - label = new Label { X = Pos.X (label), Y = Pos.Bottom (label) + 2, Text = "HexView:" }; + label = new() { X = Pos.X (label), Y = Pos.Bottom (label) + 2, Text = "HexView:" }; Win.Add (label); var hexView = new HexView (new MemoryStream (Encoding.ASCII.GetBytes (gitString + " Со_хранить"))) @@ -154,7 +154,7 @@ public class UnicodeInMenu : Scenario }; Win.Add (hexView); - label = new Label { X = Pos.X (label), Y = Pos.Bottom (hexView) + 1, Text = "ListView:" }; + label = new() { X = Pos.X (label), Y = Pos.Bottom (hexView) + 1, Text = "ListView:" }; Win.Add (label); var listView = new ListView @@ -169,7 +169,7 @@ public class UnicodeInMenu : Scenario }; Win.Add (listView); - label = new Label { X = Pos.X (label), Y = Pos.Bottom (listView) + 1, Text = "RadioGroup:" }; + label = new() { X = Pos.X (label), Y = Pos.Bottom (listView) + 1, Text = "RadioGroup:" }; Win.Add (label); var radioGroup = new RadioGroup @@ -181,7 +181,7 @@ public class UnicodeInMenu : Scenario }; Win.Add (radioGroup); - label = new Label { X = Pos.X (label), Y = Pos.Bottom (radioGroup) + 1, Text = "TextField:" }; + label = new() { X = Pos.X (label), Y = Pos.Bottom (radioGroup) + 1, Text = "TextField:" }; Win.Add (label); var textField = new TextField @@ -190,7 +190,7 @@ public class UnicodeInMenu : Scenario }; Win.Add (textField); - label = new Label { X = Pos.X (label), Y = Pos.Bottom (textField) + 1, Text = "TextView:" }; + label = new() { X = Pos.X (label), Y = Pos.Bottom (textField) + 1, Text = "TextView:" }; Win.Add (label); var textView = new TextView diff --git a/UICatalog/Scenarios/ViewExperiments.cs b/UICatalog/Scenarios/ViewExperiments.cs index b46fe2d0a..be9bbdf5c 100644 --- a/UICatalog/Scenarios/ViewExperiments.cs +++ b/UICatalog/Scenarios/ViewExperiments.cs @@ -22,7 +22,7 @@ public class ViewExperiments : Scenario { X = 0, Y = 0, - AutoSize = false, + Width = Dim.Fill (), Height = 3 }; @@ -41,14 +41,14 @@ public class ViewExperiments : Scenario //app.Add (view); - view.Margin.Thickness = new Thickness (2, 2, 2, 2); + view.Margin.Thickness = new (2, 2, 2, 2); view.Margin.ColorScheme = Colors.ColorSchemes ["Toplevel"]; view.Margin.Data = "Margin"; - view.Border.Thickness = new Thickness (3); + view.Border.Thickness = new (3); view.Border.LineStyle = LineStyle.Single; view.Border.ColorScheme = view.ColorScheme; view.Border.Data = "Border"; - view.Padding.Thickness = new Thickness (2); + view.Padding.Thickness = new (2); view.Padding.ColorScheme = Colors.ColorSchemes ["Error"]; view.Padding.Data = "Padding"; @@ -63,14 +63,14 @@ public class ViewExperiments : Scenario TextAlignment = TextAlignment.Centered }; - window1.Margin.Thickness = new Thickness (0); + window1.Margin.Thickness = new (0); window1.Margin.ColorScheme = Colors.ColorSchemes ["Toplevel"]; window1.Margin.Data = "Margin"; - window1.Border.Thickness = new Thickness (1); + window1.Border.Thickness = new (1); window1.Border.LineStyle = LineStyle.Single; window1.Border.ColorScheme = view.ColorScheme; window1.Border.Data = "Border"; - window1.Padding.Thickness = new Thickness (0); + window1.Padding.Thickness = new (0); window1.Padding.ColorScheme = Colors.ColorSchemes ["Error"]; window1.Padding.Data = "Padding"; @@ -88,14 +88,14 @@ public class ViewExperiments : Scenario }; //view3.InitializeFrames (); - window2.Margin.Thickness = new Thickness (1, 1, 0, 0); + window2.Margin.Thickness = new (1, 1, 0, 0); window2.Margin.ColorScheme = Colors.ColorSchemes ["Toplevel"]; window2.Margin.Data = "Margin"; - window2.Border.Thickness = new Thickness (1, 1, 1, 1); + window2.Border.Thickness = new (1, 1, 1, 1); window2.Border.LineStyle = LineStyle.Single; window2.Border.ColorScheme = view.ColorScheme; window2.Border.Data = "Border"; - window2.Padding.Thickness = new Thickness (1, 1, 0, 0); + window2.Padding.Thickness = new (1, 1, 0, 0); window2.Padding.ColorScheme = Colors.ColorSchemes ["Error"]; window2.Padding.Data = "Padding"; @@ -113,14 +113,14 @@ public class ViewExperiments : Scenario }; //view4.InitializeFrames (); - view4.Margin.Thickness = new Thickness (0, 0, 1, 1); + view4.Margin.Thickness = new (0, 0, 1, 1); view4.Margin.ColorScheme = Colors.ColorSchemes ["Toplevel"]; view4.Margin.Data = "Margin"; - view4.Border.Thickness = new Thickness (1, 1, 1, 1); + view4.Border.Thickness = new (1, 1, 1, 1); view4.Border.LineStyle = LineStyle.Single; view4.Border.ColorScheme = view.ColorScheme; view4.Border.Data = "Border"; - view4.Padding.Thickness = new Thickness (0, 0, 1, 1); + view4.Padding.Thickness = new (0, 0, 1, 1); view4.Padding.ColorScheme = Colors.ColorSchemes ["Error"]; view4.Padding.Data = "Padding"; @@ -138,14 +138,14 @@ public class ViewExperiments : Scenario }; //view5.InitializeFrames (); - view5.Margin.Thickness = new Thickness (0, 0, 0, 0); + view5.Margin.Thickness = new (0, 0, 0, 0); view5.Margin.ColorScheme = Colors.ColorSchemes ["Toplevel"]; view5.Margin.Data = "Margin"; - view5.Border.Thickness = new Thickness (1, 1, 1, 1); + view5.Border.Thickness = new (1, 1, 1, 1); view5.Border.LineStyle = LineStyle.Single; view5.Border.ColorScheme = view.ColorScheme; view5.Border.Data = "Border"; - view5.Padding.Thickness = new Thickness (0, 0, 0, 0); + view5.Padding.Thickness = new (0, 0, 0, 0); view5.Padding.ColorScheme = Colors.ColorSchemes ["Error"]; view5.Padding.Data = "Padding"; @@ -164,7 +164,7 @@ public class ViewExperiments : Scenario }; view.Add (edit); - edit = new TextField + edit = new() { Text = "Right (edit) + 1", X = Pos.Right (edit) + 1, @@ -183,11 +183,11 @@ public class ViewExperiments : Scenario Width = 30, TextAlignment = TextAlignment.Centered }; - label50.Border.Thickness = new Thickness (1, 3, 1, 1); + label50.Border.Thickness = new (1, 3, 1, 1); label50.Height = 5; view.Add (label50); - edit = new TextField + edit = new() { Text = "0 + Percent(50);70%", X = 0 + Pos.Percent (50), @@ -197,10 +197,10 @@ public class ViewExperiments : Scenario }; view.Add (edit); - edit = new TextField { Text = "AnchorEnd ();AnchorEnd ()", X = Pos.AnchorEnd(), Y = Pos.AnchorEnd (), Width = 30, Height = 1 }; + edit = new() { Text = "AnchorEnd ();AnchorEnd ()", X = Pos.AnchorEnd (), Y = Pos.AnchorEnd (), Width = 30, Height = 1 }; view.Add (edit); - edit = new TextField + edit = new() { Text = "Left;AnchorEnd (2)", X = 0, diff --git a/UICatalog/Scenarios/VkeyPacketSimulator.cs b/UICatalog/Scenarios/VkeyPacketSimulator.cs index bdcfc6fea..43aee6bf3 100644 --- a/UICatalog/Scenarios/VkeyPacketSimulator.cs +++ b/UICatalog/Scenarios/VkeyPacketSimulator.cs @@ -28,14 +28,14 @@ public class VkeyPacketSimulator : Scenario var inputHorizontalRuler = new Label { - Y = Pos.Bottom (btnInput), AutoSize = false, Width = Dim.Fill (), ColorScheme = Colors.ColorSchemes ["Error"] + Y = Pos.Bottom (btnInput), Width = Dim.Fill (), ColorScheme = Colors.ColorSchemes ["Error"] }; Win.Add (inputHorizontalRuler); var inputVerticalRuler = new Label { Y = Pos.Bottom (btnInput), - AutoSize = false, + Width = 1, ColorScheme = Colors.ColorSchemes ["Error"], TextDirection = TextDirection.TopBottom_LeftRight @@ -52,7 +52,7 @@ public class VkeyPacketSimulator : Scenario }; Win.Add (tvInput); - label = new Label { X = Pos.Center (), Y = Pos.Bottom (tvInput), Text = "Output" }; + label = new() { X = Pos.Center (), Y = Pos.Bottom (tvInput), Text = "Output" }; Win.Add (label); var btnOutput = new Button { X = Pos.AnchorEnd (17), Y = Pos.Top (label), Text = "Select Output" }; @@ -61,7 +61,7 @@ public class VkeyPacketSimulator : Scenario var outputHorizontalRuler = new Label { Y = Pos.Bottom (btnOutput), - AutoSize = false, + Width = Dim.Fill (), ColorScheme = Colors.ColorSchemes ["Error"] }; @@ -70,7 +70,7 @@ public class VkeyPacketSimulator : Scenario var outputVerticalRuler = new Label { Y = Pos.Bottom (btnOutput), - AutoSize = false, + Width = 1, Height = Dim.Fill (), ColorScheme = Colors.ColorSchemes ["Error"], @@ -113,12 +113,10 @@ public class VkeyPacketSimulator : Scenario Application.Invoke ( () => MessageBox.Query ( "Keys", - $"'{ - Key.ToString ( + $"'{Key.ToString ( e.KeyCode, MenuBar.ShortcutDelimiter - ) - }' pressed!", + )}' pressed!", "Ok" ) ); @@ -243,20 +241,20 @@ public class VkeyPacketSimulator : Scenario }; btnInput.Accept += (s, e) => - { - if (!tvInput.HasFocus && _keyboardStrokes.Count == 0) - { - tvInput.SetFocus (); - } - }; + { + if (!tvInput.HasFocus && _keyboardStrokes.Count == 0) + { + tvInput.SetFocus (); + } + }; btnOutput.Accept += (s, e) => - { - if (!tvOutput.HasFocus && _keyboardStrokes.Count == 0) - { - tvOutput.SetFocus (); - } - }; + { + if (!tvOutput.HasFocus && _keyboardStrokes.Count == 0) + { + tvOutput.SetFocus (); + } + }; tvInput.SetFocus (); diff --git a/UICatalog/Scenarios/Wizards.cs b/UICatalog/Scenarios/Wizards.cs index 304b9ad0c..22f7e042e 100644 --- a/UICatalog/Scenarios/Wizards.cs +++ b/UICatalog/Scenarios/Wizards.cs @@ -34,11 +34,11 @@ public class Wizards : Scenario }; frame.Add (widthEdit); - label = new Label + label = new() { X = 0, Y = Pos.Bottom (label), - AutoSize = false, + Width = Dim.Width (label), Height = 1, TextAlignment = TextAlignment.Right, @@ -56,11 +56,11 @@ public class Wizards : Scenario }; frame.Add (heightEdit); - label = new Label + label = new() { X = 0, Y = Pos.Bottom (label), - AutoSize = false, + Width = Dim.Width (label), Height = 1, TextAlignment = TextAlignment.Right, @@ -86,7 +86,7 @@ public class Wizards : Scenario Top.Loaded += Top_Loaded; - label = new Label + label = new() { X = Pos.Center (), Y = Pos.AnchorEnd (1), TextAlignment = TextAlignment.Right, Text = "Action:" }; @@ -104,258 +104,258 @@ public class Wizards : Scenario }; showWizardButton.Accept += (s, e) => - { - try - { - var width = 0; - int.TryParse (widthEdit.Text, out width); - var height = 0; - int.TryParse (heightEdit.Text, out height); + { + try + { + var width = 0; + int.TryParse (widthEdit.Text, out width); + var height = 0; + int.TryParse (heightEdit.Text, out height); - if (width < 1 || height < 1) - { - MessageBox.ErrorQuery ( - "Nope", - "Height and width must be greater than 0 (much bigger)", - "Ok" - ); + if (width < 1 || height < 1) + { + MessageBox.ErrorQuery ( + "Nope", + "Height and width must be greater than 0 (much bigger)", + "Ok" + ); - return; - } + return; + } - actionLabel.Text = string.Empty; + actionLabel.Text = string.Empty; - var wizard = new Wizard { Title = titleEdit.Text, Width = width, Height = height }; + var wizard = new Wizard { Title = titleEdit.Text, Width = width, Height = height }; - 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; - actionLabel.Text = "Finished"; - }; - - wizard.Cancelled += (s, args) => + wizard.MovingBack += (s, args) => { //args.Cancel = true; - actionLabel.Text = "Cancelled"; + actionLabel.Text = "Moving Back"; }; - // Add 1st step - var firstStep = new WizardStep { Title = "End User License Agreement" }; - firstStep.NextButtonText = "Accept!"; + wizard.MovingNext += (s, args) => + { + //args.Cancel = true; + actionLabel.Text = "Moving Next"; + }; - 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."; - wizard.AddStep (firstStep); - - // Add 2nd step - var secondStep = new 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 = 1, Y = 1 }; - - var button = new Button - { - Text = "Press Me to Rename Step", X = Pos.Right (buttonLbl), Y = Pos.Top (buttonLbl) - }; - - button.Accept += (s, e) => + wizard.Finished += (s, args) => { - secondStep.Title = "2nd Step"; - - MessageBox.Query ( - "Wizard Scenario", - "This Wizard Step's title was changed to '2nd Step'" - ); + //args.Cancel = true; + actionLabel.Text = "Finished"; }; - secondStep.Add (buttonLbl, button); - var lbl = new Label { Text = "First Name: ", X = 1, 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 = 1, Y = Pos.Bottom (lbl) }; - var lastNameField = new TextField { Text = "Six", Width = 30, X = Pos.Right (lbl), Y = Pos.Top (lbl) }; - secondStep.Add (lbl, lastNameField); + wizard.Cancelled += (s, args) => + { + //args.Cancel = true; + actionLabel.Text = "Cancelled"; + }; - var thirdStepEnabledCeckBox = new CheckBox - { - Text = "Enable Step _3", - Checked = false, - X = Pos.Left (lastNameField), - Y = Pos.Bottom (lastNameField) - }; - secondStep.Add (thirdStepEnabledCeckBox); + // Add 1st step + var firstStep = new WizardStep { Title = "End User License Agreement" }; + firstStep.NextButtonText = "Accept!"; - // Add a frame - var frame = new FrameView - { - X = 0, - Y = Pos.Bottom (thirdStepEnabledCeckBox) + 2, - Width = Dim.Fill (), - Height = 4, - Title = "A Broken Frame (by Depeche Mode)" - }; - frame.Add (new TextField { Text = "This is a TextField inside of the frame." }); - secondStep.Add (frame); + 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."; + wizard.AddStep (firstStep); - wizard.StepChanging += (s, args) => - { - if (args.OldStep == secondStep && string.IsNullOrEmpty (firstNameField.Text)) - { - args.Cancel = true; + // Add 2nd step + var secondStep = new WizardStep { Title = "Second Step" }; + wizard.AddStep (secondStep); - int btn = MessageBox.ErrorQuery ( - "Second Step", - "You must enter a First Name to continue", - "Ok" - ); - } - }; + 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."; - // Add 3rd (optional) step - var thirdStep = new WizardStep { Title = "Third Step (Optional)" }; - wizard.AddStep (thirdStep); + var buttonLbl = new Label { Text = "Second Step Button: ", X = 1, Y = 1 }; - thirdStep.HelpText = - "This is step is optional (WizardStep.Enabled = false). Enable it with the checkbox in Step 2."; - var step3Label = new Label { Text = "This step is optional.", X = 0, Y = 0 }; - thirdStep.Add (step3Label); - var progLbl = new Label { Text = "Third Step ProgressBar: ", X = 1, Y = 10 }; + var button = new Button + { + Text = "Press Me to Rename Step", X = Pos.Right (buttonLbl), Y = Pos.Top (buttonLbl) + }; - var progressBar = new ProgressBar - { - X = Pos.Right (progLbl), Y = Pos.Top (progLbl), Width = 40, Fraction = 0.42F - }; - thirdStep.Add (progLbl, progressBar); - thirdStep.Enabled = (bool)thirdStepEnabledCeckBox.Checked; - thirdStepEnabledCeckBox.Toggled += (s, e) => { thirdStep.Enabled = (bool)thirdStepEnabledCeckBox.Checked; }; + button.Accept += (s, e) => + { + secondStep.Title = "2nd Step"; - // Add 4th step - var fourthStep = new WizardStep { Title = "Step Four" }; - wizard.AddStep (fourthStep); + MessageBox.Query ( + "Wizard Scenario", + "This Wizard Step's title was changed to '2nd Step'" + ); + }; + secondStep.Add (buttonLbl, button); + var lbl = new Label { Text = "First Name: ", X = 1, Y = Pos.Bottom (buttonLbl) }; - var someText = new TextView - { - Text = - "This step (Step Four) shows how to show/hide the Help pane. The step contains this TextView (but it's hard to tell it's a TextView because of Issue #1800).", - X = 0, - Y = 0, - Width = Dim.Fill (), - Height = Dim.Fill (1), - WordWrap = true, - AllowsTab = false, - ColorScheme = Colors.ColorSchemes ["Base"] - }; - var help = "This is helpful."; - fourthStep.Add (someText); + var firstNameField = + new TextField { Text = "Number", Width = 30, X = Pos.Right (lbl), Y = Pos.Top (lbl) }; + secondStep.Add (lbl, firstNameField); + lbl = new() { Text = "Last Name: ", X = 1, Y = Pos.Bottom (lbl) }; + var lastNameField = new TextField { Text = "Six", Width = 30, X = Pos.Right (lbl), Y = Pos.Top (lbl) }; + secondStep.Add (lbl, lastNameField); - var hideHelpBtn = new Button - { - Text = "Press me to show/hide help", X = Pos.Center (), Y = Pos.AnchorEnd (1) - }; + var thirdStepEnabledCeckBox = new CheckBox + { + Text = "Enable Step _3", + Checked = false, + X = Pos.Left (lastNameField), + Y = Pos.Bottom (lastNameField) + }; + secondStep.Add (thirdStepEnabledCeckBox); - hideHelpBtn.Accept += (s, e) => - { - if (fourthStep.HelpText.Length > 0) - { - fourthStep.HelpText = string.Empty; - } - else - { - fourthStep.HelpText = help; - } - }; - fourthStep.Add (hideHelpBtn); - fourthStep.NextButtonText = "Go To Last Step"; - var scrollBar = new ScrollBarView (someText, true); + // Add a frame + var frame = new FrameView + { + X = 0, + Y = Pos.Bottom (thirdStepEnabledCeckBox) + 2, + Width = Dim.Fill (), + Height = 4, + Title = "A Broken Frame (by Depeche Mode)" + }; + frame.Add (new TextField { Text = "This is a TextField inside of the frame." }); + secondStep.Add (frame); - scrollBar.ChangedPosition += (s, e) => - { - someText.TopRow = scrollBar.Position; + wizard.StepChanging += (s, args) => + { + if (args.OldStep == secondStep && string.IsNullOrEmpty (firstNameField.Text)) + { + args.Cancel = true; - if (someText.TopRow != scrollBar.Position) - { - scrollBar.Position = someText.TopRow; - } + int btn = MessageBox.ErrorQuery ( + "Second Step", + "You must enter a First Name to continue", + "Ok" + ); + } + }; - someText.SetNeedsDisplay (); - }; + // Add 3rd (optional) step + var thirdStep = new WizardStep { Title = "Third Step (Optional)" }; + wizard.AddStep (thirdStep); - scrollBar.VisibleChanged += (s, e) => + thirdStep.HelpText = + "This is step is optional (WizardStep.Enabled = false). Enable it with the checkbox in Step 2."; + var step3Label = new Label { Text = "This step is optional.", X = 0, Y = 0 }; + thirdStep.Add (step3Label); + var progLbl = new Label { Text = "Third Step ProgressBar: ", X = 1, Y = 10 }; + + var progressBar = new ProgressBar + { + X = Pos.Right (progLbl), Y = Pos.Top (progLbl), Width = 40, Fraction = 0.42F + }; + thirdStep.Add (progLbl, progressBar); + thirdStep.Enabled = (bool)thirdStepEnabledCeckBox.Checked; + thirdStepEnabledCeckBox.Toggled += (s, e) => { thirdStep.Enabled = (bool)thirdStepEnabledCeckBox.Checked; }; + + // Add 4th step + var fourthStep = new WizardStep { Title = "Step Four" }; + wizard.AddStep (fourthStep); + + var someText = new TextView + { + Text = + "This step (Step Four) shows how to show/hide the Help pane. The step contains this TextView (but it's hard to tell it's a TextView because of Issue #1800).", + X = 0, + Y = 0, + Width = Dim.Fill (), + Height = Dim.Fill (1), + WordWrap = true, + AllowsTab = false, + ColorScheme = Colors.ColorSchemes ["Base"] + }; + var help = "This is helpful."; + fourthStep.Add (someText); + + var hideHelpBtn = new Button + { + Text = "Press me to show/hide help", X = Pos.Center (), Y = Pos.AnchorEnd (1) + }; + + hideHelpBtn.Accept += (s, e) => + { + if (fourthStep.HelpText.Length > 0) + { + fourthStep.HelpText = string.Empty; + } + else + { + fourthStep.HelpText = help; + } + }; + fourthStep.Add (hideHelpBtn); + fourthStep.NextButtonText = "Go To Last Step"; + var scrollBar = new ScrollBarView (someText, true); + + scrollBar.ChangedPosition += (s, e) => { - if (scrollBar.Visible && someText.RightOffset == 0) + someText.TopRow = scrollBar.Position; + + if (someText.TopRow != scrollBar.Position) { - someText.RightOffset = 1; - } - else if (!scrollBar.Visible && someText.RightOffset == 1) - { - someText.RightOffset = 0; + scrollBar.Position = someText.TopRow; } + + someText.SetNeedsDisplay (); }; - someText.DrawContent += (s, e) => - { - scrollBar.Size = someText.Lines; - scrollBar.Position = someText.TopRow; + scrollBar.VisibleChanged += (s, e) => + { + if (scrollBar.Visible && someText.RightOffset == 0) + { + someText.RightOffset = 1; + } + else if (!scrollBar.Visible && someText.RightOffset == 1) + { + someText.RightOffset = 0; + } + }; - if (scrollBar.OtherScrollBarView != null) - { - scrollBar.OtherScrollBarView.Size = someText.Maxlength; - scrollBar.OtherScrollBarView.Position = someText.LeftColumn; - } + someText.DrawContent += (s, e) => + { + scrollBar.Size = someText.Lines; + scrollBar.Position = someText.TopRow; - scrollBar.LayoutSubviews (); - scrollBar.Refresh (); - }; - fourthStep.Add (scrollBar); + if (scrollBar.OtherScrollBarView != null) + { + scrollBar.OtherScrollBarView.Size = someText.Maxlength; + scrollBar.OtherScrollBarView.Position = someText.LeftColumn; + } - // Add last step - var lastStep = new WizardStep { Title = "The last step" }; - wizard.AddStep (lastStep); + scrollBar.LayoutSubviews (); + scrollBar.Refresh (); + }; + fourthStep.Add (scrollBar); - lastStep.HelpText = - "The wizard is complete!\n\nPress the Finish button to continue.\n\nPressing ESC will cancel the wizard."; + // Add last step + var lastStep = new WizardStep { Title = "The last step" }; + wizard.AddStep (lastStep); - var finalFinalStepEnabledCeckBox = - new CheckBox { Text = "Enable _Final Final Step", Checked = false, X = 0, Y = 1 }; - lastStep.Add (finalFinalStepEnabledCeckBox); + lastStep.HelpText = + "The wizard is complete!\n\nPress the Finish button to continue.\n\nPressing ESC will cancel the wizard."; - // Add an optional FINAL last step - var finalFinalStep = new WizardStep { Title = "The VERY last step" }; - wizard.AddStep (finalFinalStep); + var finalFinalStepEnabledCeckBox = + new CheckBox { Text = "Enable _Final Final Step", Checked = false, X = 0, Y = 1 }; + lastStep.Add (finalFinalStepEnabledCeckBox); - finalFinalStep.HelpText = - "This step only shows if it was enabled on the other last step."; - finalFinalStep.Enabled = (bool)thirdStepEnabledCeckBox.Checked; + // Add an optional FINAL last step + var finalFinalStep = new WizardStep { Title = "The VERY last step" }; + wizard.AddStep (finalFinalStep); - finalFinalStepEnabledCeckBox.Toggled += (s, e) => - { - finalFinalStep.Enabled = (bool)finalFinalStepEnabledCeckBox.Checked; - }; + finalFinalStep.HelpText = + "This step only shows if it was enabled on the other last step."; + finalFinalStep.Enabled = (bool)thirdStepEnabledCeckBox.Checked; - Application.Run (wizard); - wizard.Dispose (); - } - catch (FormatException) - { - actionLabel.Text = "Invalid Options"; - } - }; + finalFinalStepEnabledCeckBox.Toggled += (s, e) => + { + finalFinalStep.Enabled = (bool)finalFinalStepEnabledCeckBox.Checked; + }; + + Application.Run (wizard); + wizard.Dispose (); + } + catch (FormatException) + { + actionLabel.Text = "Invalid Options"; + } + }; Win.Add (showWizardButton); } }