AutoSize is GONE!

This commit is contained in:
Tig
2024-05-03 14:55:29 -06:00
parent 031ffeed19
commit e6b6f77f9a
24 changed files with 1873 additions and 1912 deletions

View File

@@ -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
}

View File

@@ -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
}
/// <summary>
/// Provides a composable UI for editing the settings of an Adornment.
/// Provides a composable UI for editing the settings of an Adornment.
/// </summary>
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
}
/// <summary>
/// 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.
/// </summary>
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;
}
};

View File

@@ -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);
}

View File

@@ -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 ();

View File

@@ -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<DynamicMenuItemList> ();
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<DynamicMenuItemList> ();
_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<DynamicMenuItemList> ();
DataContext.Menus = new ();
SetListViewSource (_currentMenuBarItem, true);
_lblParent.Text = string.Empty;
}
void SetListViewSource (MenuItem _currentMenuBarItem, bool fill = false)
{
DataContext.Menus = new List<DynamicMenuItemList> ();
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<DynamicMenuItemList> ();
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 ())
);
}
}

View File

@@ -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<MenuItem> 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 (); };

View File

@@ -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,

View File

@@ -34,7 +34,6 @@ public class LineCanvasExperiment : Scenario
var win1 = new Window
{
AutoSize = false,
Title = "win1",
Text = "Win1 30%/50% Heavy",
X = 20,

View File

@@ -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] };

View File

@@ -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"
};

View File

@@ -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 ();
}

View File

@@ -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<string> btns = new ();
List<string> 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);

View File

@@ -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<MouseFlags> ()
Slider<MouseFlags> 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<MouseFlags> ()
.Where (value => !value.ToString ().Contains ("None") &&
!value.ToString().Contains("All"))
.Select (value => new SliderOption<MouseFlags>
{
Legend = value.ToString (),
Data = value,
})
.Where (value => !value.ToString ().Contains ("None") && !value.ToString ().Contains ("All"))
.Select (
value => new SliderOption<MouseFlags>
{
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<string> 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<string> 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); };
}
}
}

View File

@@ -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: "
};

File diff suppressed because it is too large Load Diff

View File

@@ -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<string> 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<string>
AllSuggestions = new()
{
"fish",
"flipper",

View File

@@ -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]);

View File

@@ -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]);

View File

@@ -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
};

View File

@@ -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);
}

View File

@@ -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<string> { 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

View File

@@ -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,

View File

@@ -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 ();

View File

@@ -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);
}
}