diff --git a/Terminal.Gui/Drawing/Glyphs.cs b/Terminal.Gui/Drawing/Glyphs.cs
index a42c1c40b..9064008a5 100644
--- a/Terminal.Gui/Drawing/Glyphs.cs
+++ b/Terminal.Gui/Drawing/Glyphs.cs
@@ -32,13 +32,13 @@ public class GlyphDefinitions
#region ----------------- Single Glyphs -----------------
/// Checked indicator (e.g. for and ).
- public Rune Checked { get; set; } = (Rune)'☑';
+ public Rune CheckStateChecked { get; set; } = (Rune)'☑';
/// Not Checked indicator (e.g. for and ).
- public Rune UnChecked { get; set; } = (Rune)'☐';
+ public Rune CheckStateUnChecked { get; set; } = (Rune)'☐';
/// Null Checked indicator (e.g. for and ).
- public Rune NullChecked { get; set; } = (Rune)'☒';
+ public Rune CheckStateNone { get; set; } = (Rune)'☒';
/// Selected indicator (e.g. for and ).
public Rune Selected { get; set; } = (Rune)'◉';
diff --git a/Terminal.Gui/Views/CheckBox.cs b/Terminal.Gui/Views/CheckBox.cs
index b6fef9763..72081785f 100644
--- a/Terminal.Gui/Views/CheckBox.cs
+++ b/Terminal.Gui/Views/CheckBox.cs
@@ -1,23 +1,33 @@
#nullable enable
namespace Terminal.Gui;
-/// The shows an on/off toggle that the user can set
+///
+/// Represents the state of a .
+///
+public enum CheckState
+{
+ None,
+ Checked,
+ UnChecked
+}
+
+/// Shows a check box that can be toggled.
public class CheckBox : View
{
private readonly Rune _charChecked;
- private readonly Rune _charNullChecked;
+ private readonly Rune _charNone;
private readonly Rune _charUnChecked;
- private bool _allowNullChecked;
- private bool? _checked = false;
+ private bool _allowNone;
+ private CheckState _checked = CheckState.UnChecked;
///
/// Initializes a new instance of .
///
public CheckBox ()
{
- _charNullChecked = Glyphs.NullChecked;
- _charChecked = Glyphs.Checked;
- _charUnChecked = Glyphs.UnChecked;
+ _charNone = Glyphs.CheckStateNone;
+ _charChecked = Glyphs.CheckStateChecked;
+ _charUnChecked = Glyphs.CheckStateUnChecked;
Width = Dim.Auto (DimAutoStyle.Text);
Height = Dim.Auto (DimAutoStyle.Text, minimumContentDim: 1);
@@ -63,16 +73,23 @@ public class CheckBox : View
}
///
- /// If allows to be null, true, or false. If
- /// only allows to be true or false.
+ /// If allows to be .
///
- public bool AllowNullChecked
+ public bool AllowCheckStateNone
{
- get => _allowNullChecked;
+ get => _allowNone;
set
{
- _allowNullChecked = value;
- Checked ??= false;
+ if (_allowNone == value)
+ {
+ return;
+ }
+ _allowNone = value;
+
+ if (State == CheckState.None)
+ {
+ State = CheckState.UnChecked;
+ }
}
}
@@ -81,24 +98,24 @@ public class CheckBox : View
///
///
///
- /// If and is , the
- /// will display the ConfigurationManager.Glyphs.NullChecked character (☒).
+ /// If is and , the
+ /// will display the ConfigurationManager.Glyphs.CheckStateNone character (☒).
///
///
- /// If , the
- /// will display the ConfigurationManager.Glyphs.UnChecked character (☐).
+ /// If , the
+ /// will display the ConfigurationManager.Glyphs.CheckStateUnChecked character (☐).
///
///
- /// If , the
- /// will display the ConfigurationManager.Glyphs.Checked character (☑).
+ /// If , the
+ /// will display the ConfigurationManager.Glyphs.CheckStateChecked character (☑).
///
///
- public bool? Checked
+ public CheckState State
{
get => _checked;
set
{
- if (value is null && !AllowNullChecked)
+ if (_checked == value || (value is CheckState.None && !AllowCheckStateNone))
{
return;
}
@@ -109,36 +126,39 @@ public class CheckBox : View
}
}
- /// Called when the property changes. Invokes the cancelable event.
+ /// Called when the property changes. Invokes the cancelable event.
///
///
/// If the event was canceled.
+ ///
+ /// Toggling cycles through the states , , and .
+ ///
public bool? OnToggle ()
{
- bool ? oldValue = Checked;
- CancelEventArgs e = new (ref _checked, ref oldValue);
+ CheckState oldValue = State;
+ CancelEventArgs e = new (ref _checked, ref oldValue);
- if (AllowNullChecked)
+ switch (State)
{
- switch (Checked)
- {
- case null:
- e.NewValue = true;
+ case CheckState.None:
+ e.NewValue = CheckState.Checked;
- break;
- case true:
- e.NewValue = false;
+ break;
+ case CheckState.Checked:
+ e.NewValue = CheckState.UnChecked;
- break;
- case false:
- e.NewValue = null;
+ break;
+ case CheckState.UnChecked:
+ if (AllowCheckStateNone)
+ {
+ e.NewValue = CheckState.None;
+ }
+ else
+ {
+ e.NewValue = CheckState.Checked;
+ }
- break;
- }
- }
- else
- {
- e.NewValue = !Checked;
+ break;
}
Toggle?.Invoke (this, e);
@@ -153,7 +173,7 @@ public class CheckBox : View
return true;
}
- Checked = e.NewValue;
+ State = e.NewValue;
return true;
}
@@ -164,7 +184,7 @@ public class CheckBox : View
/// This event can be cancelled. If cancelled, the will not change its state.
///
///
- public event EventHandler>? Toggle;
+ public event EventHandler>? Toggle;
///
protected override void UpdateTextFormatterText ()
@@ -186,11 +206,12 @@ public class CheckBox : View
private Rune GetCheckedState ()
{
- return Checked switch
+ return State switch
{
- true => _charChecked,
- false => _charUnChecked,
- var _ => _charNullChecked
+ CheckState.Checked => _charChecked,
+ CheckState.UnChecked => _charUnChecked,
+ CheckState.None => _charNone,
+ _ => throw new ArgumentOutOfRangeException ()
};
}
}
diff --git a/Terminal.Gui/Views/ComboBox.cs b/Terminal.Gui/Views/ComboBox.cs
index ecf097a82..aec9d5f81 100644
--- a/Terminal.Gui/Views/ComboBox.cs
+++ b/Terminal.Gui/Views/ComboBox.cs
@@ -929,8 +929,8 @@ public class ComboBox : View
if (AllowsMarking)
{
Driver.AddRune (
- Source.IsMarked (item) ? AllowsMultipleSelection ? Glyphs.Checked : Glyphs.Selected :
- AllowsMultipleSelection ? Glyphs.UnChecked : Glyphs.UnSelected
+ Source.IsMarked (item) ? AllowsMultipleSelection ? Glyphs.CheckStateChecked : Glyphs.Selected :
+ AllowsMultipleSelection ? Glyphs.CheckStateUnChecked : Glyphs.UnSelected
);
Driver.AddRune ((Rune)' ');
}
diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs
index 5701c3a8b..2e7287334 100644
--- a/Terminal.Gui/Views/ListView.cs
+++ b/Terminal.Gui/Views/ListView.cs
@@ -724,8 +724,8 @@ public class ListView : View
if (_allowsMarking)
{
Driver.AddRune (
- _source.IsMarked (item) ? AllowsMultipleSelection ? Glyphs.Checked : Glyphs.Selected :
- AllowsMultipleSelection ? Glyphs.UnChecked : Glyphs.UnSelected
+ _source.IsMarked (item) ? AllowsMultipleSelection ? Glyphs.CheckStateChecked : Glyphs.Selected :
+ AllowsMultipleSelection ? Glyphs.CheckStateUnChecked : Glyphs.UnSelected
);
Driver.AddRune ((Rune)' ');
}
diff --git a/Terminal.Gui/Views/Menu/Menu.cs b/Terminal.Gui/Views/Menu/Menu.cs
index 74bf85828..2da69bc01 100644
--- a/Terminal.Gui/Views/Menu/Menu.cs
+++ b/Terminal.Gui/Views/Menu/Menu.cs
@@ -447,14 +447,14 @@ internal sealed class Menu : View
}
string textToDraw = null;
- Rune nullCheckedChar = Glyphs.NullChecked;
+ Rune nullCheckedChar = Glyphs.CheckStateNone;
Rune checkChar = Glyphs.Selected;
Rune uncheckedChar = Glyphs.UnSelected;
if (item.CheckType.HasFlag (MenuItemCheckStyle.Checked))
{
- checkChar = Glyphs.Checked;
- uncheckedChar = Glyphs.UnChecked;
+ checkChar = Glyphs.CheckStateChecked;
+ uncheckedChar = Glyphs.CheckStateUnChecked;
}
// Support Checked even though CheckType wasn't set
diff --git a/Terminal.Gui/Views/TableView/CheckBoxTableSourceWrapper.cs b/Terminal.Gui/Views/TableView/CheckBoxTableSourceWrapper.cs
index 2ff566684..7d2379af8 100644
--- a/Terminal.Gui/Views/TableView/CheckBoxTableSourceWrapper.cs
+++ b/Terminal.Gui/Views/TableView/CheckBoxTableSourceWrapper.cs
@@ -33,9 +33,9 @@ public abstract class CheckBoxTableSourceWrapperBase : ITableSource
}
///
- /// Gets or sets the character to use for checked entries. Defaults to
+ /// Gets or sets the character to use for checked entries. Defaults to
///
- public Rune CheckedRune { get; set; } = Glyphs.Checked;
+ public Rune CheckedRune { get; set; } = Glyphs.CheckStateChecked;
///
/// Gets or sets the character to use for checked entry when is true. Defaults to
@@ -50,9 +50,9 @@ public abstract class CheckBoxTableSourceWrapperBase : ITableSource
public Rune RadioUnCheckedRune { get; set; } = Glyphs.UnSelected;
///
- /// Gets or sets the character to use for UnChecked entries. Defaults to
+ /// Gets or sets the character to use for UnChecked entries. Defaults to
///
- public Rune UnCheckedRune { get; set; } = Glyphs.UnChecked;
+ public Rune UnCheckedRune { get; set; } = Glyphs.CheckStateUnChecked;
/// Gets or sets whether to only allow a single row to be toggled at once (Radio button).
public bool UseRadioButtons { get; set; }
diff --git a/UICatalog/Scenarios/AdornmentsEditor.cs b/UICatalog/Scenarios/AdornmentsEditor.cs
index 1dab998e8..bfdbec5eb 100644
--- a/UICatalog/Scenarios/AdornmentsEditor.cs
+++ b/UICatalog/Scenarios/AdornmentsEditor.cs
@@ -90,11 +90,11 @@ public class AdornmentsEditor : View
Add (_paddingEditor);
_diagPaddingCheckBox = new () { Text = "_Diagnostic Padding" };
- _diagPaddingCheckBox.Checked = Diagnostics.FastHasFlags (ViewDiagnosticFlags.Padding);
+ _diagPaddingCheckBox.State = Diagnostics.FastHasFlags (ViewDiagnosticFlags.Padding) ? CheckState.Checked : CheckState.UnChecked;
_diagPaddingCheckBox.Toggle += (s, e) =>
{
- if (e.NewValue == true)
+ if (e.NewValue == CheckState.Checked)
{
Diagnostics |= ViewDiagnosticFlags.Padding;
}
@@ -108,11 +108,11 @@ public class AdornmentsEditor : View
_diagPaddingCheckBox.Y = Pos.Bottom (_paddingEditor);
_diagRulerCheckBox = new () { Text = "_Diagnostic Ruler" };
- _diagRulerCheckBox.Checked = Diagnostics.FastHasFlags (ViewDiagnosticFlags.Ruler);
+ _diagRulerCheckBox.State = Diagnostics.FastHasFlags(ViewDiagnosticFlags.Ruler) ? CheckState.Checked : CheckState.UnChecked;
_diagRulerCheckBox.Toggle += (s, e) =>
{
- if (e.NewValue == true)
+ if (e.NewValue == CheckState.Checked)
{
Diagnostics |= ViewDiagnosticFlags.Ruler;
}
diff --git a/UICatalog/Scenarios/BorderEditor.cs b/UICatalog/Scenarios/BorderEditor.cs
index c987210c8..a5ccae212 100644
--- a/UICatalog/Scenarios/BorderEditor.cs
+++ b/UICatalog/Scenarios/BorderEditor.cs
@@ -20,7 +20,7 @@ public class BorderEditor : AdornmentEditor
private void BorderEditor_AdornmentChanged (object sender, EventArgs e)
{
- _ckbTitle.Checked = ((Border)AdornmentToEdit).ShowTitle;
+ _ckbTitle.State = ((Border)AdornmentToEdit).ShowTitle ? CheckState.Checked : CheckState.UnChecked;
_rbBorderStyle.SelectedItem = (int)((Border)AdornmentToEdit).LineStyle;
}
@@ -51,7 +51,7 @@ public class BorderEditor : AdornmentEditor
X = 0,
Y = Pos.Bottom (_rbBorderStyle),
- Checked = true,
+ State = CheckState.Checked,
SuperViewRendersLineCanvas = true,
Text = "Show Title",
Enabled = AdornmentToEdit is { }
@@ -81,6 +81,6 @@ public class BorderEditor : AdornmentEditor
LayoutSubviews ();
}
- void OnCkbTitleOnToggle (object sender, CancelEventArgs args) { ((Border)AdornmentToEdit).ShowTitle = args.NewValue!.Value; }
+ void OnCkbTitleOnToggle (object sender, CancelEventArgs args) { ((Border)AdornmentToEdit).ShowTitle = args.NewValue == CheckState.Checked; }
}
}
\ No newline at end of file
diff --git a/UICatalog/Scenarios/Buttons.cs b/UICatalog/Scenarios/Buttons.cs
index a65b9bbaf..d719c9a45 100644
--- a/UICatalog/Scenarios/Buttons.cs
+++ b/UICatalog/Scenarios/Buttons.cs
@@ -385,7 +385,7 @@ public class Buttons : Scenario
X = Pos.Right (repeatButton) + 1,
Y = Pos.Top (repeatButton),
Title = "Enabled",
- Checked = true
+ State = CheckState.Checked
};
enableCB.Toggle += (s, e) => { repeatButton.Enabled = !repeatButton.Enabled; };
main.Add (label, repeatButton, enableCB);
diff --git a/UICatalog/Scenarios/ContentScrolling.cs b/UICatalog/Scenarios/ContentScrolling.cs
index e962f8f95..5c7a09826 100644
--- a/UICatalog/Scenarios/ContentScrolling.cs
+++ b/UICatalog/Scenarios/ContentScrolling.cs
@@ -135,12 +135,12 @@ public class ContentScrolling : Scenario
Y = 0,
CanFocus = false
};
- cbAllowNegativeX.Checked = view.ViewportSettings.HasFlag (ViewportSettings.AllowNegativeX);
+ cbAllowNegativeX.State = view.ViewportSettings.HasFlag(ViewportSettings.AllowNegativeX) ? CheckState.Checked : CheckState.UnChecked;
cbAllowNegativeX.Toggle += AllowNegativeX_Toggle;
- void AllowNegativeX_Toggle (object sender, CancelEventArgs e)
+ void AllowNegativeX_Toggle (object sender, CancelEventArgs e)
{
- if (e.NewValue == true)
+ if (e.NewValue == CheckState.Checked)
{
view.ViewportSettings |= ViewportSettings.AllowNegativeX;
}
@@ -159,12 +159,12 @@ public class ContentScrolling : Scenario
Y = 0,
CanFocus = false
};
- cbAllowNegativeY.Checked = view.ViewportSettings.HasFlag (ViewportSettings.AllowNegativeY);
+ cbAllowNegativeY.State = view.ViewportSettings.HasFlag(ViewportSettings.AllowNegativeY) ? CheckState.Checked : CheckState.UnChecked;
cbAllowNegativeY.Toggle += AllowNegativeY_Toggle;
- void AllowNegativeY_Toggle (object sender, CancelEventArgs e)
+ void AllowNegativeY_Toggle (object sender, CancelEventArgs e)
{
- if (e.NewValue == true)
+ if (e.NewValue == CheckState.Checked)
{
view.ViewportSettings |= ViewportSettings.AllowNegativeY;
}
@@ -182,12 +182,12 @@ public class ContentScrolling : Scenario
Y = Pos.Bottom (cbAllowNegativeX),
CanFocus = false
};
- cbAllowXGreaterThanContentWidth.Checked = view.ViewportSettings.HasFlag (ViewportSettings.AllowXGreaterThanContentWidth);
+ cbAllowXGreaterThanContentWidth.State = view.ViewportSettings.HasFlag(ViewportSettings.AllowXGreaterThanContentWidth) ? CheckState.Checked : CheckState.UnChecked;
cbAllowXGreaterThanContentWidth.Toggle += AllowXGreaterThanContentWidth_Toggle;
- void AllowXGreaterThanContentWidth_Toggle (object sender, CancelEventArgs e)
+ void AllowXGreaterThanContentWidth_Toggle (object sender, CancelEventArgs e)
{
- if (e.NewValue == true)
+ if (e.NewValue == CheckState.Checked)
{
view.ViewportSettings |= ViewportSettings.AllowXGreaterThanContentWidth;
}
@@ -206,12 +206,12 @@ public class ContentScrolling : Scenario
Y = Pos.Bottom (cbAllowNegativeX),
CanFocus = false
};
- cbAllowYGreaterThanContentHeight.Checked = view.ViewportSettings.HasFlag (ViewportSettings.AllowYGreaterThanContentHeight);
+ cbAllowYGreaterThanContentHeight.State = view.ViewportSettings.HasFlag(ViewportSettings.AllowYGreaterThanContentHeight) ? CheckState.Checked : CheckState.UnChecked;
cbAllowYGreaterThanContentHeight.Toggle += AllowYGreaterThanContentHeight_Toggle;
- void AllowYGreaterThanContentHeight_Toggle (object sender, CancelEventArgs e)
+ void AllowYGreaterThanContentHeight_Toggle (object sender, CancelEventArgs e)
{
- if (e.NewValue == true)
+ if (e.NewValue == CheckState.Checked)
{
view.ViewportSettings |= ViewportSettings.AllowYGreaterThanContentHeight;
}
@@ -284,12 +284,12 @@ public class ContentScrolling : Scenario
Y = Pos.Top (labelContentSize),
CanFocus = false
};
- cbClearOnlyVisible.Checked = view.ViewportSettings.HasFlag (ViewportSettings.ClearContentOnly);
+ cbClearOnlyVisible.State = view.ViewportSettings.HasFlag(ViewportSettings.ClearContentOnly) ? CheckState.Checked : CheckState.UnChecked;
cbClearOnlyVisible.Toggle += ClearVisibleContentOnly_Toggle;
- void ClearVisibleContentOnly_Toggle (object sender, CancelEventArgs e)
+ void ClearVisibleContentOnly_Toggle (object sender, CancelEventArgs e)
{
- if (e.NewValue == true)
+ if (e.NewValue == CheckState.Checked)
{
view.ViewportSettings |= ViewportSettings.ClearContentOnly;
}
@@ -306,12 +306,12 @@ public class ContentScrolling : Scenario
Y = Pos.Top (labelContentSize),
CanFocus = false
};
- cbDoNotClipContent.Checked = view.ViewportSettings.HasFlag (ViewportSettings.ClipContentOnly);
+ cbDoNotClipContent.State = view.ViewportSettings.HasFlag (ViewportSettings.ClipContentOnly) ? CheckState.Checked : CheckState.UnChecked;
cbDoNotClipContent.Toggle += ClipVisibleContentOnly_Toggle;
- void ClipVisibleContentOnly_Toggle (object sender, CancelEventArgs e)
+ void ClipVisibleContentOnly_Toggle (object sender, CancelEventArgs e)
{
- if (e.NewValue == true)
+ if (e.NewValue == CheckState.Checked)
{
view.ViewportSettings |= ViewportSettings.ClipContentOnly;
}
diff --git a/UICatalog/Scenarios/Dialogs.cs b/UICatalog/Scenarios/Dialogs.cs
index 0856e4166..082acb806 100644
--- a/UICatalog/Scenarios/Dialogs.cs
+++ b/UICatalog/Scenarios/Dialogs.cs
@@ -131,7 +131,7 @@ public class Dialogs : Scenario
Y = Pos.Bottom (numButtonsLabel),
TextAlignment = Alignment.End,
Text = $"_Add {char.ConvertFromUtf32 (CODE_POINT)} to button text to stress wide char support",
- Checked = false
+ State = CheckState.UnChecked
};
frame.Add (glyphsNotWords);
@@ -230,7 +230,7 @@ public class Dialogs : Scenario
int buttonId = i;
Button button = null;
- if (glyphsNotWords.Checked == true)
+ if (glyphsNotWords.State == CheckState.Checked)
{
buttonId = i;
@@ -281,7 +281,7 @@ public class Dialogs : Scenario
int buttonId = buttons.Count;
Button button;
- if (glyphsNotWords.Checked == true)
+ if (glyphsNotWords.State == CheckState.Checked)
{
button = new ()
{
diff --git a/UICatalog/Scenarios/DynamicMenuBar.cs b/UICatalog/Scenarios/DynamicMenuBar.cs
index 8a7efb72d..eda9d041b 100644
--- a/UICatalog/Scenarios/DynamicMenuBar.cs
+++ b/UICatalog/Scenarios/DynamicMenuBar.cs
@@ -142,7 +142,7 @@ public class DynamicMenuBar : Scenario
{
X = Pos.Left (_lblTitle),
Y = Pos.Bottom (CkbIsTopLevel),
- Checked = _menuItem == null ? !_hasParent : HasSubMenus (_menuItem),
+ State = (_menuItem == null ? !_hasParent : HasSubMenus (_menuItem)) ? CheckState.Checked : CheckState.UnChecked,
Text = "Has sub-menus"
};
Add (CkbSubMenu);
@@ -251,34 +251,34 @@ public class DynamicMenuBar : Scenario
CkbIsTopLevel.Toggle += (s, e) =>
{
- if ((_menuItem != null && _menuItem.Parent != null && (bool)CkbIsTopLevel.Checked)
- || (_menuItem == null && _hasParent && (bool)CkbIsTopLevel.Checked))
+ if ((_menuItem != null && _menuItem.Parent != null && CkbIsTopLevel.State == CheckState.Checked)
+ || (_menuItem == null && _hasParent && CkbIsTopLevel.State == CheckState.Checked))
{
MessageBox.ErrorQuery (
"Invalid IsTopLevel",
"Only menu bar can have top level menu item!",
"Ok"
);
- CkbIsTopLevel.Checked = false;
+ CkbIsTopLevel.State = CheckState.UnChecked;
return;
}
- if (CkbIsTopLevel.Checked == true)
+ if (CkbIsTopLevel.State == CheckState.Checked)
{
- CkbSubMenu.Checked = false;
+ CkbSubMenu.State = CheckState.UnChecked;
CkbSubMenu.SetNeedsDisplay ();
TextHelp.Enabled = true;
TextAction.Enabled = true;
TextShortcut.Enabled =
- CkbIsTopLevel.Checked == false && CkbSubMenu.Checked == false;
+ CkbIsTopLevel.State == CheckState.UnChecked && CkbSubMenu.State == CheckState.UnChecked;
}
else
{
if ((_menuItem == null && !_hasParent) || _menuItem.Parent == null)
{
- CkbSubMenu.Checked = true;
+ CkbSubMenu.State = CheckState.Checked;
CkbSubMenu.SetNeedsDisplay ();
TextShortcut.Enabled = false;
}
@@ -292,9 +292,9 @@ public class DynamicMenuBar : Scenario
CkbSubMenu.Toggle += (s, e) =>
{
- if ((bool)CkbSubMenu.Checked)
+ if (e.NewValue == CheckState.Checked)
{
- CkbIsTopLevel.Checked = false;
+ CkbIsTopLevel.State = CheckState.UnChecked;
CkbIsTopLevel.SetNeedsDisplay ();
TextHelp.Text = "";
TextHelp.Enabled = false;
@@ -307,7 +307,7 @@ public class DynamicMenuBar : Scenario
{
if (!_hasParent)
{
- CkbIsTopLevel.Checked = true;
+ CkbIsTopLevel.State = CheckState.Checked;
CkbIsTopLevel.SetNeedsDisplay ();
TextShortcut.Enabled = false;
}
@@ -316,7 +316,7 @@ public class DynamicMenuBar : Scenario
TextAction.Enabled = true;
TextShortcut.Enabled =
- CkbIsTopLevel.Checked == false && CkbSubMenu.Checked == false;
+ CkbIsTopLevel.State == CheckState.UnChecked && CkbSubMenu.State == CheckState.UnChecked;
}
};
@@ -324,7 +324,7 @@ public class DynamicMenuBar : Scenario
{
if (_menuItem != null)
{
- _menuItem.AllowNullChecked = (bool)CkbNullCheck.Checked;
+ _menuItem.AllowNullChecked = e.NewValue == CheckState.Checked;
}
};
@@ -394,14 +394,14 @@ public class DynamicMenuBar : Scenario
TextAction.Text = menuItem != null && menuItem.Action != null
? GetTargetAction (menuItem.Action)
: string.Empty;
- CkbIsTopLevel.Checked = IsTopLevel (menuItem);
- CkbSubMenu.Checked = HasSubMenus (menuItem);
- CkbNullCheck.Checked = menuItem.AllowNullChecked;
- TextHelp.Enabled = (bool)!CkbSubMenu.Checked;
- TextAction.Enabled = (bool)!CkbSubMenu.Checked;
+ CkbIsTopLevel.State = IsTopLevel (menuItem) ? CheckState.Checked : CheckState.UnChecked;
+ CkbSubMenu.State = HasSubMenus (menuItem) ? CheckState.Checked : CheckState.UnChecked;
+ CkbNullCheck.State = menuItem.AllowNullChecked ? CheckState.Checked : CheckState.UnChecked;
+ TextHelp.Enabled = CkbSubMenu.State == CheckState.Checked;
+ TextAction.Enabled = CkbSubMenu.State == CheckState.Checked;
RbChkStyle.SelectedItem = (int)(menuItem?.CheckType ?? MenuItemCheckStyle.NoCheck);
TextShortcut.Text = menuItem?.ShortcutTag ?? "";
- TextShortcut.Enabled = CkbIsTopLevel.Checked == false && CkbSubMenu.Checked == false;
+ TextShortcut.Enabled = CkbIsTopLevel.State == CheckState.UnChecked && CkbSubMenu.State == CheckState.UnChecked;
}
public DynamicMenuItem EnterMenuItem ()
@@ -414,9 +414,9 @@ public class DynamicMenuBar : Scenario
TextTitle.Text = m.Title;
TextHelp.Text = m.Help;
TextAction.Text = m.Action;
- CkbIsTopLevel.Checked = false;
- CkbSubMenu.Checked = !_hasParent;
- CkbNullCheck.Checked = false;
+ CkbIsTopLevel.State = CheckState.UnChecked;
+ CkbSubMenu.State = !_hasParent ? CheckState.Checked : CheckState.UnChecked;
+ CkbNullCheck.State = CheckState.UnChecked;
TextHelp.Enabled = _hasParent;
TextAction.Enabled = _hasParent;
TextShortcut.Enabled = _hasParent;
@@ -466,13 +466,13 @@ public class DynamicMenuBar : Scenario
Title = TextTitle.Text,
Help = TextHelp.Text,
Action = TextAction.Text,
- IsTopLevel = CkbIsTopLevel?.Checked ?? false,
- HasSubMenu = CkbSubMenu?.Checked ?? false,
+ IsTopLevel = CkbIsTopLevel?.State == CheckState.Checked,
+ HasSubMenu = CkbSubMenu?.State == CheckState.UnChecked,
CheckStyle = RbChkStyle.SelectedItem == 0 ? MenuItemCheckStyle.NoCheck :
RbChkStyle.SelectedItem == 1 ? MenuItemCheckStyle.Checked :
MenuItemCheckStyle.Radio,
Shortcut = TextShortcut.Text,
- AllowNullChecked = CkbNullCheck.Checked != null && (bool)CkbNullCheck.Checked
+ AllowNullChecked = CkbNullCheck?.State == CheckState.Checked,
};
}
@@ -515,8 +515,8 @@ public class DynamicMenuBar : Scenario
TextTitle.Text = "";
TextHelp.Text = "";
TextAction.Text = "";
- CkbIsTopLevel.Checked = false;
- CkbSubMenu.Checked = false;
+ CkbIsTopLevel.State = CheckState.UnChecked;
+ CkbSubMenu.State = CheckState.UnChecked;
RbChkStyle.SelectedItem = (int)MenuItemCheckStyle.NoCheck;
TextShortcut.Text = "";
}
@@ -835,8 +835,8 @@ public class DynamicMenuBar : Scenario
Title = _frmMenuDetails.TextTitle.Text,
Help = _frmMenuDetails.TextHelp.Text,
Action = _frmMenuDetails.TextAction.Text,
- IsTopLevel = _frmMenuDetails.CkbIsTopLevel?.Checked ?? false,
- HasSubMenu = _frmMenuDetails.CkbSubMenu?.Checked ?? false,
+ IsTopLevel = _frmMenuDetails.CkbIsTopLevel?.State == CheckState.UnChecked,
+ HasSubMenu = _frmMenuDetails.CkbSubMenu?.State == CheckState.UnChecked,
CheckStyle = _frmMenuDetails.RbChkStyle.SelectedItem == 0
? MenuItemCheckStyle.NoCheck
: _frmMenuDetails.RbChkStyle.SelectedItem == 1
diff --git a/UICatalog/Scenarios/Editor.cs b/UICatalog/Scenarios/Editor.cs
index c74e23bbd..aa23821c8 100644
--- a/UICatalog/Scenarios/Editor.cs
+++ b/UICatalog/Scenarios/Editor.cs
@@ -895,16 +895,16 @@ public class Editor : Scenario
var ckbMatchCase = new CheckBox
{
- X = 0, Y = Pos.Top (txtToFind) + 2, Checked = _matchCase, Text = "Match c_ase"
+ X = 0, Y = Pos.Top (txtToFind) + 2, State = _matchCase ? CheckState.Checked : CheckState.UnChecked, Text = "Match c_ase"
};
- ckbMatchCase.Toggle += (s, e) => _matchCase = (bool)ckbMatchCase.Checked;
+ ckbMatchCase.Toggle += (s, e) => _matchCase = e.NewValue == CheckState.Checked;
d.Add (ckbMatchCase);
var ckbMatchWholeWord = new CheckBox
{
- X = 0, Y = Pos.Top (ckbMatchCase) + 1, Checked = _matchWholeWord, Text = "Match _whole word"
+ X = 0, Y = Pos.Top (ckbMatchCase) + 1, State = _matchWholeWord ? CheckState.Checked : CheckState.UnChecked, Text = "Match _whole word"
};
- ckbMatchWholeWord.Toggle += (s, e) => _matchWholeWord = (bool)ckbMatchWholeWord.Checked;
+ ckbMatchWholeWord.Toggle += (s, e) => _matchWholeWord = e.NewValue == CheckState.Checked;
d.Add (ckbMatchWholeWord);
return d;
}
@@ -1153,16 +1153,16 @@ public class Editor : Scenario
var ckbMatchCase = new CheckBox
{
- X = 0, Y = Pos.Top (txtToFind) + 2, Checked = _matchCase, Text = "Match c_ase"
+ X = 0, Y = Pos.Top (txtToFind) + 2, State = _matchCase ? CheckState.Checked : CheckState.UnChecked, Text = "Match c_ase"
};
- ckbMatchCase.Toggle += (s, e) => _matchCase = (bool)ckbMatchCase.Checked;
+ ckbMatchCase.Toggle += (s, e) => _matchCase = e.NewValue == CheckState.Checked;
d.Add (ckbMatchCase);
var ckbMatchWholeWord = new CheckBox
{
- X = 0, Y = Pos.Top (ckbMatchCase) + 1, Checked = _matchWholeWord, Text = "Match _whole word"
+ X = 0, Y = Pos.Top (ckbMatchCase) + 1, State = _matchWholeWord ? CheckState.Checked : CheckState.UnChecked, Text = "Match _whole word"
};
- ckbMatchWholeWord.Toggle += (s, e) => _matchWholeWord = (bool)ckbMatchWholeWord.Checked;
+ ckbMatchWholeWord.Toggle += (s, e) => _matchWholeWord = e.NewValue == CheckState.Checked;
d.Add (ckbMatchWholeWord);
return d;
diff --git a/UICatalog/Scenarios/FileDialogExamples.cs b/UICatalog/Scenarios/FileDialogExamples.cs
index 65333b4fc..55fde0ca1 100644
--- a/UICatalog/Scenarios/FileDialogExamples.cs
+++ b/UICatalog/Scenarios/FileDialogExamples.cs
@@ -31,25 +31,25 @@ public class FileDialogExamples : Scenario
var y = 0;
var x = 1;
- _cbMustExist = new CheckBox { Checked = true, Y = y++, X = x, Text = "Must Exist" };
+ _cbMustExist = new CheckBox { State = CheckState.Checked, Y = y++, X = x, Text = "Must Exist" };
Win.Add (_cbMustExist);
- _cbUseColors = new CheckBox { Checked = FileDialogStyle.DefaultUseColors, Y = y++, X = x, Text = "Use Colors" };
+ _cbUseColors = new CheckBox { State = FileDialogStyle.DefaultUseColors ? CheckState.Checked : CheckState.UnChecked, Y = y++, X = x, Text = "Use Colors" };
Win.Add (_cbUseColors);
- _cbCaseSensitive = new CheckBox { Checked = false, Y = y++, X = x, Text = "Case Sensitive Search" };
+ _cbCaseSensitive = new CheckBox { State = CheckState.UnChecked, Y = y++, X = x, Text = "Case Sensitive Search" };
Win.Add (_cbCaseSensitive);
- _cbAllowMultipleSelection = new CheckBox { Checked = false, Y = y++, X = x, Text = "Multiple" };
+ _cbAllowMultipleSelection = new CheckBox { State = CheckState.UnChecked, Y = y++, X = x, Text = "Multiple" };
Win.Add (_cbAllowMultipleSelection);
- _cbShowTreeBranchLines = new CheckBox { Checked = true, Y = y++, X = x, Text = "Tree Branch Lines" };
+ _cbShowTreeBranchLines = new CheckBox { State = CheckState.Checked, Y = y++, X = x, Text = "Tree Branch Lines" };
Win.Add (_cbShowTreeBranchLines);
- _cbAlwaysTableShowHeaders = new CheckBox { Checked = true, Y = y++, X = x, Text = "Always Show Headers" };
+ _cbAlwaysTableShowHeaders = new CheckBox { State = CheckState.Checked, Y = y++, X = x, Text = "Always Show Headers" };
Win.Add (_cbAlwaysTableShowHeaders);
- _cbDrivesOnlyInTree = new CheckBox { Checked = false, Y = y++, X = x, Text = "Only Show Drives" };
+ _cbDrivesOnlyInTree = new CheckBox { State = CheckState.UnChecked, Y = y++, X = x, Text = "Only Show Drives" };
Win.Add (_cbDrivesOnlyInTree);
y = 0;
@@ -145,8 +145,8 @@ public class FileDialogExamples : Scenario
OpenMode = Enum.Parse (
_rgOpenMode.RadioLabels [_rgOpenMode.SelectedItem]
),
- MustExist = _cbMustExist.Checked ?? false,
- AllowsMultipleSelection = _cbAllowMultipleSelection.Checked ?? false
+ MustExist = _cbMustExist.State == CheckState.Checked,
+ AllowsMultipleSelection = _cbAllowMultipleSelection.State == CheckState.Checked
};
fd.Style.OkButtonText = _rgCaption.RadioLabels [_rgCaption.SelectedItem];
@@ -160,19 +160,19 @@ public class FileDialogExamples : Scenario
fd.Style.IconProvider.UseUnicodeCharacters = _rgIcons.SelectedItem == 1;
fd.Style.IconProvider.UseNerdIcons = _rgIcons.SelectedItem == 2;
- if (_cbCaseSensitive.Checked ?? false)
+ if (_cbCaseSensitive.State == CheckState.Checked)
{
fd.SearchMatcher = new CaseSensitiveSearchMatcher ();
}
- fd.Style.UseColors = _cbUseColors.Checked ?? false;
+ fd.Style.UseColors = _cbUseColors.State == CheckState.Checked;
- fd.Style.TreeStyle.ShowBranchLines = _cbShowTreeBranchLines.Checked ?? false;
- fd.Style.TableStyle.AlwaysShowHeaders = _cbAlwaysTableShowHeaders.Checked ?? false;
+ fd.Style.TreeStyle.ShowBranchLines = _cbShowTreeBranchLines.State == CheckState.Checked;
+ fd.Style.TableStyle.AlwaysShowHeaders = _cbAlwaysTableShowHeaders.State == CheckState.Checked;
IDirectoryInfoFactory dirInfoFactory = new FileSystem ().DirectoryInfo;
- if (_cbDrivesOnlyInTree.Checked ?? false)
+ if (_cbDrivesOnlyInTree.State == CheckState.Checked)
{
fd.Style.TreeRootGetter = () => { return Environment.GetLogicalDrives ().ToDictionary (dirInfoFactory.New, k => k); };
}
@@ -197,7 +197,7 @@ public class FileDialogExamples : Scenario
fd.Style.CancelButtonText = _tbCancelButton.Text;
}
- if (_cbFlipButtonOrder.Checked ?? false)
+ if (_cbFlipButtonOrder.State == CheckState.Checked)
{
fd.Style.FlipOkCancelButtonLayoutOrder = true;
}
@@ -219,7 +219,7 @@ public class FileDialogExamples : Scenario
"Ok"
);
}
- else if (_cbAllowMultipleSelection.Checked ?? false)
+ else if (_cbAllowMultipleSelection.State == CheckState.Checked)
{
MessageBox.Query (
"Chosen!",
diff --git a/UICatalog/Scenarios/GraphViewExample.cs b/UICatalog/Scenarios/GraphViewExample.cs
index 462bcabd8..7bef3e70e 100644
--- a/UICatalog/Scenarios/GraphViewExample.cs
+++ b/UICatalog/Scenarios/GraphViewExample.cs
@@ -202,7 +202,7 @@ public class GraphViewExample : Scenario
if (sender is Shortcut shortcut && shortcut.CommandView is CheckBox checkBox)
{
- checkBox.Checked = _miDiags.Checked;
+ checkBox.State = _miDiags.Checked ?? false ? CheckState.Checked : CheckState.UnChecked;
}
}
diff --git a/UICatalog/Scenarios/Images.cs b/UICatalog/Scenarios/Images.cs
index 070fb3f56..40f24d7e2 100644
--- a/UICatalog/Scenarios/Images.cs
+++ b/UICatalog/Scenarios/Images.cs
@@ -28,7 +28,7 @@ public class Images : Scenario
{
X = Pos.Right (lblDriverName) + 2,
Y = 0,
- Checked = canTrueColor,
+ State = canTrueColor ? CheckState.Checked : CheckState.UnChecked,
CanFocus = false,
Text = "supports true color "
};
@@ -38,11 +38,11 @@ public class Images : Scenario
{
X = Pos.Right (cbSupportsTrueColor) + 2,
Y = 0,
- Checked = !Application.Force16Colors,
+ State = !Application.Force16Colors ? CheckState.Checked : CheckState.UnChecked,
Enabled = canTrueColor,
Text = "Use true color"
};
- cbUseTrueColor.Toggle += (_, evt) => Application.Force16Colors = !evt.NewValue ?? false;
+ cbUseTrueColor.Toggle += (_, evt) => Application.Force16Colors = evt.NewValue == CheckState.UnChecked;
Win.Add (cbUseTrueColor);
var btnOpenImage = new Button { X = Pos.Right (cbUseTrueColor) + 2, Y = 0, Text = "Open Image" };
diff --git a/UICatalog/Scenarios/ListViewWithSelection.cs b/UICatalog/Scenarios/ListViewWithSelection.cs
index b187fee42..59bdaf28e 100644
--- a/UICatalog/Scenarios/ListViewWithSelection.cs
+++ b/UICatalog/Scenarios/ListViewWithSelection.cs
@@ -38,7 +38,7 @@ public class ListViewWithSelection : Scenario
_allowMarkingCB = new CheckBox
{
- X = Pos.Right (_customRenderCB) + 1, Y = 0, Text = "Allow Marking", AllowNullChecked = false
+ X = Pos.Right (_customRenderCB) + 1, Y = 0, Text = "Allow Marking", AllowCheckStateNone = false
};
_appWindow.Add (_allowMarkingCB);
_allowMarkingCB.Toggle += AllowMarkingCB_Toggle;
@@ -47,7 +47,7 @@ public class ListViewWithSelection : Scenario
{
X = Pos.Right (_allowMarkingCB) + 1,
Y = 0,
- Visible = (bool)_allowMarkingCB.Checked,
+ Visible = _allowMarkingCB.State == CheckState.Checked,
Text = "Allow Multi-Select"
};
_appWindow.Add (_allowMultipleCB);
@@ -108,9 +108,9 @@ public class ListViewWithSelection : Scenario
var keepCheckBox = new CheckBox
{
- X = Pos.AnchorEnd (k.Length + 3), Y = 0, Text = k, Checked = scrollBar.AutoHideScrollBars
+ X = Pos.AnchorEnd (k.Length + 3), Y = 0, Text = k, State = scrollBar.AutoHideScrollBars ? CheckState.Checked : CheckState.UnChecked
};
- keepCheckBox.Toggle += (s, e) => scrollBar.KeepContentAlwaysInViewport = (bool)keepCheckBox.Checked;
+ keepCheckBox.Toggle += (s, e) => scrollBar.KeepContentAlwaysInViewport = e.NewValue == CheckState.Checked;
_appWindow.Add (keepCheckBox);
Application.Run (_appWindow);
@@ -118,9 +118,9 @@ public class ListViewWithSelection : Scenario
Application.Shutdown ();
}
- private void _customRenderCB_Toggle (object sender, CancelEventArgs stateEventArgs)
+ private void _customRenderCB_Toggle (object sender, CancelEventArgs stateEventArgs)
{
- if (stateEventArgs.CurrentValue == true)
+ if (stateEventArgs.CurrentValue == CheckState.Checked)
{
_listView.SetSource (_scenarios);
}
@@ -132,16 +132,16 @@ public class ListViewWithSelection : Scenario
_appWindow.SetNeedsDisplay ();
}
- private void AllowMarkingCB_Toggle (object sender, [NotNull] CancelEventArgs stateEventArgs)
+ private void AllowMarkingCB_Toggle (object sender, [NotNull] CancelEventArgs stateEventArgs)
{
- _listView.AllowsMarking = (bool)!stateEventArgs.CurrentValue;
+ _listView.AllowsMarking = stateEventArgs.NewValue == CheckState.Checked;
_allowMultipleCB.Visible = _listView.AllowsMarking;
_appWindow.SetNeedsDisplay ();
}
- private void AllowMultipleCB_Toggle (object sender, [NotNull] CancelEventArgs stateEventArgs)
+ private void AllowMultipleCB_Toggle (object sender, [NotNull] CancelEventArgs stateEventArgs)
{
- _listView.AllowsMultipleSelection = (bool)!stateEventArgs.CurrentValue;
+ _listView.AllowsMultipleSelection = stateEventArgs.NewValue == CheckState.Checked;
_appWindow.SetNeedsDisplay ();
}
diff --git a/UICatalog/Scenarios/Localization.cs b/UICatalog/Scenarios/Localization.cs
index 691909410..3be7e41bb 100644
--- a/UICatalog/Scenarios/Localization.cs
+++ b/UICatalog/Scenarios/Localization.cs
@@ -141,7 +141,7 @@ public class Localization : Scenario
{
X = Pos.Right (textField) + 1,
Y = Pos.Bottom (textAndFileDialogLabel) + 1,
- Checked = false,
+ State = CheckState.UnChecked,
Text = "Allow any"
};
Win.Add (_allowAnyCheckBox);
@@ -183,7 +183,7 @@ public class Localization : Scenario
dialog.AllowedTypes =
[
- _allowAnyCheckBox.Checked ?? false
+ _allowAnyCheckBox.State == CheckState.Checked
? new AllowedTypeAny ()
: new AllowedType ("Dynamic link library", ".dll"),
new AllowedType ("Json", ".json"),
diff --git a/UICatalog/Scenarios/MessageBoxes.cs b/UICatalog/Scenarios/MessageBoxes.cs
index 1f3081990..d41c687a7 100644
--- a/UICatalog/Scenarios/MessageBoxes.cs
+++ b/UICatalog/Scenarios/MessageBoxes.cs
@@ -186,7 +186,7 @@ public class MessageBoxes : Scenario
var ckbWrapMessage = new CheckBox
{
- X = Pos.Right (label) + 1, Y = Pos.Bottom (styleRadioGroup), Text = "_Wrap Message", Checked = true
+ X = Pos.Right (label) + 1, Y = Pos.Bottom (styleRadioGroup), Text = "_Wrap Message", State = CheckState.Checked
};
frame.Add (ckbWrapMessage);
@@ -237,7 +237,7 @@ public class MessageBoxes : Scenario
titleEdit.Text,
messageEdit.Text,
defaultButton,
- (bool)ckbWrapMessage.Checked,
+ ckbWrapMessage.State == CheckState.Checked,
btns.ToArray ()
)}";
}
@@ -250,7 +250,7 @@ public class MessageBoxes : Scenario
titleEdit.Text,
messageEdit.Text,
defaultButton,
- (bool)ckbWrapMessage.Checked,
+ ckbWrapMessage.State == CheckState.Checked,
btns.ToArray ()
)}";
}
diff --git a/UICatalog/Scenarios/Mouse.cs b/UICatalog/Scenarios/Mouse.cs
index 85d48a75d..5ca838ad8 100644
--- a/UICatalog/Scenarios/Mouse.cs
+++ b/UICatalog/Scenarios/Mouse.cs
@@ -77,11 +77,11 @@ public class Mouse : Scenario
Y = Pos.Bottom (cbWantContinuousPresses),
Title = "_Highlight on Press"
};
- cbHighlightOnPress.Checked = win.HighlightStyle == (HighlightStyle.Pressed | HighlightStyle.PressedOutside);
+ cbHighlightOnPress.State = win.HighlightStyle == (HighlightStyle.Pressed | HighlightStyle.PressedOutside) ? CheckState.Checked : CheckState.UnChecked;
cbHighlightOnPress.Toggle += (s, e) =>
{
- if (e.NewValue == true)
+ if (e.NewValue == CheckState.Checked)
{
win.HighlightStyle = HighlightStyle.Pressed | HighlightStyle.PressedOutside;
}
diff --git a/UICatalog/Scenarios/PosAlignDemo.cs b/UICatalog/Scenarios/PosAlignDemo.cs
index 9927c3a06..d7ae5146e 100644
--- a/UICatalog/Scenarios/PosAlignDemo.cs
+++ b/UICatalog/Scenarios/PosAlignDemo.cs
@@ -87,13 +87,13 @@ public sealed class PosAlignDemo : Scenario
if (dimension == Dimension.Width)
{
- endToStartCheckBox.Checked = _horizAligner.AlignmentModes.HasFlag (AlignmentModes.EndToStart);
+ endToStartCheckBox.State = _horizAligner.AlignmentModes.HasFlag (AlignmentModes.EndToStart) ? CheckState.Checked : CheckState.UnChecked;
endToStartCheckBox.X = Pos.Align (_horizAligner.Alignment);
endToStartCheckBox.Y = Pos.Top (alignRadioGroup);
}
else
{
- endToStartCheckBox.Checked = _vertAligner.AlignmentModes.HasFlag (AlignmentModes.EndToStart);
+ endToStartCheckBox.State = _vertAligner.AlignmentModes.HasFlag (AlignmentModes.EndToStart) ? CheckState.Checked : CheckState.UnChecked;
endToStartCheckBox.X = Pos.Left (alignRadioGroup);
endToStartCheckBox.Y = Pos.Align (_vertAligner.Alignment);
}
@@ -102,18 +102,16 @@ public sealed class PosAlignDemo : Scenario
{
if (dimension == Dimension.Width)
{
- _horizAligner.AlignmentModes =
- e.NewValue is { } && e.NewValue.Value
- ? _horizAligner.AlignmentModes | AlignmentModes.EndToStart
- : _horizAligner.AlignmentModes & ~AlignmentModes.EndToStart;
+ _horizAligner.AlignmentModes = e.NewValue == CheckState.Checked
+ ? _horizAligner.AlignmentModes | AlignmentModes.EndToStart
+ : _horizAligner.AlignmentModes & ~AlignmentModes.EndToStart;
UpdatePosAlignObjects (appWindow, dimension, _horizAligner);
}
else
{
- _vertAligner.AlignmentModes =
- e.NewValue is { } && e.NewValue.Value
- ? _vertAligner.AlignmentModes | AlignmentModes.EndToStart
- : _vertAligner.AlignmentModes & ~AlignmentModes.EndToStart;
+ _vertAligner.AlignmentModes = e.NewValue == CheckState.Checked
+ ? _vertAligner.AlignmentModes | AlignmentModes.EndToStart
+ : _vertAligner.AlignmentModes & ~AlignmentModes.EndToStart;
UpdatePosAlignObjects (appWindow, dimension, _vertAligner);
}
};
@@ -127,13 +125,13 @@ public sealed class PosAlignDemo : Scenario
if (dimension == Dimension.Width)
{
- ignoreFirstOrLast.Checked = _horizAligner.AlignmentModes.HasFlag (AlignmentModes.IgnoreFirstOrLast);
+ ignoreFirstOrLast.State = _horizAligner.AlignmentModes.HasFlag (AlignmentModes.IgnoreFirstOrLast) ? CheckState.Checked : CheckState.UnChecked;
ignoreFirstOrLast.X = Pos.Align (_horizAligner.Alignment);
ignoreFirstOrLast.Y = Pos.Top (alignRadioGroup);
}
else
{
- ignoreFirstOrLast.Checked = _vertAligner.AlignmentModes.HasFlag (AlignmentModes.IgnoreFirstOrLast);
+ ignoreFirstOrLast.State = _vertAligner.AlignmentModes.HasFlag (AlignmentModes.IgnoreFirstOrLast) ? CheckState.Checked : CheckState.UnChecked;
ignoreFirstOrLast.X = Pos.Left (alignRadioGroup);
ignoreFirstOrLast.Y = Pos.Align (_vertAligner.Alignment);
}
@@ -142,18 +140,16 @@ public sealed class PosAlignDemo : Scenario
{
if (dimension == Dimension.Width)
{
- _horizAligner.AlignmentModes =
- e.NewValue is { } && e.NewValue.Value
+ _horizAligner.AlignmentModes = e.NewValue == CheckState.Checked
? _horizAligner.AlignmentModes | AlignmentModes.IgnoreFirstOrLast
: _horizAligner.AlignmentModes & ~AlignmentModes.IgnoreFirstOrLast;
UpdatePosAlignObjects (appWindow, dimension, _horizAligner);
}
else
{
- _vertAligner.AlignmentModes =
- e.NewValue is { } && e.NewValue.Value
- ? _vertAligner.AlignmentModes | AlignmentModes.IgnoreFirstOrLast
- : _vertAligner.AlignmentModes & ~AlignmentModes.IgnoreFirstOrLast;
+ _vertAligner.AlignmentModes = e.NewValue == CheckState.Checked
+ ? _vertAligner.AlignmentModes | AlignmentModes.IgnoreFirstOrLast
+ : _vertAligner.AlignmentModes & ~AlignmentModes.IgnoreFirstOrLast;
UpdatePosAlignObjects (appWindow, dimension, _vertAligner);
}
};
@@ -167,13 +163,13 @@ public sealed class PosAlignDemo : Scenario
if (dimension == Dimension.Width)
{
- addSpacesBetweenItems.Checked = _horizAligner.AlignmentModes.HasFlag (AlignmentModes.AddSpaceBetweenItems);
+ addSpacesBetweenItems.State = _horizAligner.AlignmentModes.HasFlag (AlignmentModes.AddSpaceBetweenItems) ? CheckState.Checked : CheckState.UnChecked;
addSpacesBetweenItems.X = Pos.Align (_horizAligner.Alignment);
addSpacesBetweenItems.Y = Pos.Top (alignRadioGroup);
}
else
{
- addSpacesBetweenItems.Checked = _vertAligner.AlignmentModes.HasFlag (AlignmentModes.AddSpaceBetweenItems);
+ addSpacesBetweenItems.State = _vertAligner.AlignmentModes.HasFlag (AlignmentModes.AddSpaceBetweenItems) ? CheckState.Checked : CheckState.UnChecked;
addSpacesBetweenItems.X = Pos.Left (alignRadioGroup);
addSpacesBetweenItems.Y = Pos.Align (_vertAligner.Alignment);
}
@@ -182,18 +178,16 @@ public sealed class PosAlignDemo : Scenario
{
if (dimension == Dimension.Width)
{
- _horizAligner.AlignmentModes =
- e.NewValue is { } && e.NewValue.Value
- ? _horizAligner.AlignmentModes | AlignmentModes.AddSpaceBetweenItems
- : _horizAligner.AlignmentModes & ~AlignmentModes.AddSpaceBetweenItems;
+ _horizAligner.AlignmentModes = e.NewValue == CheckState.Checked
+ ? _horizAligner.AlignmentModes | AlignmentModes.AddSpaceBetweenItems
+ : _horizAligner.AlignmentModes & ~AlignmentModes.AddSpaceBetweenItems;
UpdatePosAlignObjects (appWindow, dimension, _horizAligner);
}
else
{
- _vertAligner.AlignmentModes =
- e.NewValue is { } && e.NewValue.Value
- ? _vertAligner.AlignmentModes | AlignmentModes.AddSpaceBetweenItems
- : _vertAligner.AlignmentModes & ~AlignmentModes.AddSpaceBetweenItems;
+ _vertAligner.AlignmentModes = e.NewValue == CheckState.Checked
+ ? _vertAligner.AlignmentModes | AlignmentModes.AddSpaceBetweenItems
+ : _vertAligner.AlignmentModes & ~AlignmentModes.AddSpaceBetweenItems;
UpdatePosAlignObjects (appWindow, dimension, _vertAligner);
}
};
@@ -221,12 +215,12 @@ public sealed class PosAlignDemo : Scenario
{
if (dimension == Dimension.Width)
{
- _leftMargin = e.NewValue is { } && e.NewValue.Value ? 1 : 0;
+ _leftMargin = e.NewValue == CheckState.Checked ? 1 : 0;
UpdatePosAlignObjects (appWindow, dimension, _horizAligner);
}
else
{
- _topMargin = e.NewValue is { } && e.NewValue.Value ? 1 : 0;
+ _topMargin = e.NewValue == CheckState.Checked ? 1 : 0;
UpdatePosAlignObjects (appWindow, dimension, _vertAligner);
}
};
diff --git a/UICatalog/Scenarios/ProgressBarStyles.cs b/UICatalog/Scenarios/ProgressBarStyles.cs
index cb3508d8b..8e404a5fc 100644
--- a/UICatalog/Scenarios/ProgressBarStyles.cs
+++ b/UICatalog/Scenarios/ProgressBarStyles.cs
@@ -233,7 +233,7 @@ public class ProgressBarStyles : Scenario
var ckbBidirectional = new CheckBox
{
- X = Pos.Center (), Y = Pos.Bottom (continuousPB) + 1, Text = "BidirectionalMarquee", Checked = true
+ X = Pos.Center (), Y = Pos.Bottom (continuousPB) + 1, Text = "BidirectionalMarquee", State = CheckState.Checked
};
container.Add (ckbBidirectional);
@@ -276,7 +276,7 @@ public class ProgressBarStyles : Scenario
&& v.Title == (string)e.Value
);
};
-
+
rbPBFormat.SelectedItemChanged += (s, e) =>
{
@@ -287,10 +287,11 @@ public class ProgressBarStyles : Scenario
};
ckbBidirectional.Toggle += (s, e) =>
- {
- ckbBidirectional.Checked = marqueesBlocksPB.BidirectionalMarquee =
- marqueesContinuousPB.BidirectionalMarquee = (bool)!e.CurrentValue;
- };
+ {
+ ckbBidirectional.State = e.CurrentValue;
+ marqueesBlocksPB.BidirectionalMarquee =
+ marqueesContinuousPB.BidirectionalMarquee = e.CurrentValue == CheckState.Checked;
+ };
diff --git a/UICatalog/Scenarios/Scrolling.cs b/UICatalog/Scenarios/Scrolling.cs
index 5a598af68..c3fd173cb 100644
--- a/UICatalog/Scenarios/Scrolling.cs
+++ b/UICatalog/Scenarios/Scrolling.cs
@@ -148,7 +148,7 @@ public class Scrolling : Scenario
X = Pos.X (scrollView),
Y = Pos.Bottom (scrollView),
Text = "Horizontal Scrollbar",
- Checked = scrollView.ShowHorizontalScrollIndicator
+ State = scrollView.ShowHorizontalScrollIndicator ? CheckState.Checked : CheckState.UnChecked
};
app.Add (hCheckBox);
@@ -157,7 +157,7 @@ public class Scrolling : Scenario
X = Pos.Right (hCheckBox) + 3,
Y = Pos.Bottom (scrollView),
Text = "Vertical Scrollbar",
- Checked = scrollView.ShowVerticalScrollIndicator
+ State = scrollView.ShowVerticalScrollIndicator ? CheckState.Checked : CheckState.UnChecked
};
app.Add (vCheckBox);
@@ -165,50 +165,50 @@ public class Scrolling : Scenario
var ahCheckBox = new CheckBox
{
- X = Pos.Left (scrollView), Y = Pos.Bottom (hCheckBox), Text = t, Checked = scrollView.AutoHideScrollBars
+ X = Pos.Left (scrollView), Y = Pos.Bottom (hCheckBox), Text = t, State = scrollView.AutoHideScrollBars ? CheckState.Checked : CheckState.UnChecked
};
var k = "Keep Content Always In Viewport";
var keepCheckBox = new CheckBox
{
- X = Pos.Left (scrollView), Y = Pos.Bottom (ahCheckBox), Text = k, Checked = scrollView.AutoHideScrollBars
+ X = Pos.Left (scrollView), Y = Pos.Bottom (ahCheckBox), Text = k, State = scrollView.AutoHideScrollBars ? CheckState.Checked : CheckState.UnChecked
};
hCheckBox.Toggle += (s, e) =>
{
- if (ahCheckBox.Checked == false)
+ if (ahCheckBox.State == CheckState.UnChecked)
{
- scrollView.ShowHorizontalScrollIndicator = (bool)hCheckBox.Checked;
+ scrollView.ShowHorizontalScrollIndicator = e.NewValue == CheckState.Checked;
}
else
{
- hCheckBox.Checked = true;
+ hCheckBox.State = CheckState.Checked;
MessageBox.Query ("Message", "Disable Auto Hide Scrollbars first.", "Ok");
}
};
vCheckBox.Toggle += (s, e) =>
{
- if (ahCheckBox.Checked == false)
+ if (ahCheckBox.State == CheckState.UnChecked)
{
- scrollView.ShowVerticalScrollIndicator = (bool)vCheckBox.Checked;
+ scrollView.ShowVerticalScrollIndicator = e.NewValue == CheckState.Checked;
}
else
{
- vCheckBox.Checked = true;
+ vCheckBox.State = CheckState.Checked;
MessageBox.Query ("Message", "Disable Auto Hide Scrollbars first.", "Ok");
}
};
ahCheckBox.Toggle += (s, e) =>
{
- scrollView.AutoHideScrollBars = (bool)ahCheckBox.Checked;
- hCheckBox.Checked = true;
- vCheckBox.Checked = true;
+ scrollView.AutoHideScrollBars = e.NewValue == CheckState.Checked;
+ hCheckBox.State = CheckState.Checked;
+ vCheckBox.State = CheckState.Checked;
};
app.Add (ahCheckBox);
- keepCheckBox.Toggle += (s, e) => scrollView.KeepContentAlwaysInViewport = (bool)keepCheckBox.Checked;
+ keepCheckBox.Toggle += (s, e) => scrollView.KeepContentAlwaysInViewport = e.NewValue == CheckState.Checked;
app.Add (keepCheckBox);
var count = 0;
diff --git a/UICatalog/Scenarios/SendKeys.cs b/UICatalog/Scenarios/SendKeys.cs
index 0ab50106f..a453e9065 100644
--- a/UICatalog/Scenarios/SendKeys.cs
+++ b/UICatalog/Scenarios/SendKeys.cs
@@ -87,9 +87,9 @@ public class SendKeys : Scenario
Application.Driver.SendKeys (
r,
ck,
- (bool)ckbShift.Checked,
- (bool)ckbAlt.Checked,
- (bool)ckbControl.Checked
+ ckbShift.State == CheckState.Checked,
+ ckbAlt.State == CheckState.Checked,
+ ckbControl.State == CheckState.Checked
);
}
diff --git a/UICatalog/Scenarios/Shortcuts.cs b/UICatalog/Scenarios/Shortcuts.cs
index 3d660ad66..6ca7da22d 100644
--- a/UICatalog/Scenarios/Shortcuts.cs
+++ b/UICatalog/Scenarios/Shortcuts.cs
@@ -117,7 +117,7 @@ public class Shortcuts : Scenario
var max = 0;
var toAlign = Application.Top.Subviews.Where (v => v is Shortcut { Orientation: Orientation.Vertical, Width: not DimAbsolute });
- if (e.NewValue == true)
+ if (e.NewValue == CheckState.Checked)
{
foreach (Shortcut peer in toAlign)
{
@@ -177,7 +177,7 @@ public class Shortcuts : Scenario
{
if (peer.CanFocus)
{
- peer.CommandView.CanFocus = e.NewValue == true;
+ peer.CommandView.CanFocus = e.NewValue == CheckState.Checked;
}
}
}
diff --git a/UICatalog/Scenarios/SpinnerStyles.cs b/UICatalog/Scenarios/SpinnerStyles.cs
index 63eba3d94..f2e8fed4f 100644
--- a/UICatalog/Scenarios/SpinnerStyles.cs
+++ b/UICatalog/Scenarios/SpinnerStyles.cs
@@ -53,7 +53,7 @@ public class SpinnerViewStyles : Scenario
X = Pos.Center () - 7,
Y = Pos.Bottom (preview),
Enabled = false,
- Checked = true,
+ State = CheckState.Checked,
Text = "Ascii Only"
};
app.Add (ckbAscii);
@@ -63,20 +63,20 @@ public class SpinnerViewStyles : Scenario
X = Pos.Center () + 7,
Y = Pos.Bottom (preview),
Enabled = false,
- Checked = true,
+ State = CheckState.Checked,
Text = "No Special"
};
app.Add (ckbNoSpecial);
var ckbReverse = new CheckBox
{
- X = Pos.Center () - 22, Y = Pos.Bottom (preview) + 1, Checked = false, Text = "Reverse"
+ X = Pos.Center () - 22, Y = Pos.Bottom (preview) + 1, State = CheckState.UnChecked, Text = "Reverse"
};
app.Add (ckbReverse);
var ckbBounce = new CheckBox
{
- X = Pos.Right (ckbReverse) + 2, Y = Pos.Bottom (preview) + 1, Checked = false, Text = "Bounce"
+ X = Pos.Right (ckbReverse) + 2, Y = Pos.Bottom (preview) + 1, State = CheckState.UnChecked, Text = "Bounce"
};
app.Add (ckbBounce);
@@ -157,16 +157,16 @@ public class SpinnerViewStyles : Scenario
spinner.Visible = true;
spinner.Style = (SpinnerStyle)Activator.CreateInstance (styleDict [e.Item].Value);
delayField.Text = spinner.SpinDelay.ToString ();
- ckbBounce.Checked = spinner.SpinBounce;
- ckbNoSpecial.Checked = !spinner.HasSpecialCharacters;
- ckbAscii.Checked = spinner.IsAsciiOnly;
- ckbReverse.Checked = false;
+ ckbBounce.State = spinner.SpinBounce ? CheckState.Checked : CheckState.UnChecked;
+ ckbNoSpecial.State = !spinner.HasSpecialCharacters ? CheckState.Checked : CheckState.UnChecked;
+ ckbAscii.State = spinner.IsAsciiOnly ? CheckState.Checked : CheckState.UnChecked;
+ ckbReverse.State = CheckState.UnChecked;
}
};
- ckbReverse.Toggle += (s, e) => { spinner.SpinReverse = (bool)!e.CurrentValue; };
+ ckbReverse.Toggle += (s, e) => { spinner.SpinReverse = e.NewValue == CheckState.Checked; };
- ckbBounce.Toggle += (s, e) => { spinner.SpinBounce = (bool)!e.CurrentValue; };
+ ckbBounce.Toggle += (s, e) => { spinner.SpinBounce = e.NewValue == CheckState.Checked; };
app.Unloaded += App_Unloaded;
diff --git a/UICatalog/Scenarios/Text.cs b/UICatalog/Scenarios/Text.cs
index fbe39f55d..e61707488 100644
--- a/UICatalog/Scenarios/Text.cs
+++ b/UICatalog/Scenarios/Text.cs
@@ -105,7 +105,7 @@ public class Text : Scenario
// single-line mode.
var chxMultiline = new CheckBox
{
- X = Pos.Left (textView), Y = Pos.Bottom (textView), Checked = textView.Multiline, Text = "_Multiline"
+ X = Pos.Left (textView), Y = Pos.Bottom (textView), State = textView.Multiline ? CheckState.Checked : CheckState.UnChecked, Text = "_Multiline"
};
Win.Add (chxMultiline);
@@ -113,10 +113,10 @@ public class Text : Scenario
{
X = Pos.Right (chxMultiline) + 2,
Y = Pos.Top (chxMultiline),
- Checked = textView.WordWrap,
+ State = textView.WordWrap ? CheckState.Checked : CheckState.UnChecked,
Text = "_Word Wrap"
};
- chxWordWrap.Toggle += (s, e) => textView.WordWrap = (bool)e.NewValue;
+ chxWordWrap.Toggle += (s, e) => textView.WordWrap = e.NewValue == CheckState.Checked;
Win.Add (chxWordWrap);
// TextView captures Tabs (so users can enter /t into text) by default;
@@ -126,22 +126,22 @@ public class Text : Scenario
{
X = Pos.Right (chxWordWrap) + 2,
Y = Pos.Top (chxWordWrap),
- Checked = textView.AllowsTab,
+ State = textView.AllowsTab ? CheckState.Checked : CheckState.UnChecked,
Text = "_Capture Tabs"
};
chxMultiline.Toggle += (s, e) =>
{
- textView.Multiline = (bool)e.NewValue;
+ textView.Multiline = e.NewValue == CheckState.Checked;
- if (!textView.Multiline && (bool)chxWordWrap.Checked)
+ if (!textView.Multiline && chxWordWrap.State == CheckState.Checked)
{
- chxWordWrap.Checked = false;
+ chxWordWrap.State = CheckState.UnChecked;
}
- if (!textView.Multiline && (bool)chxCaptureTabs.Checked)
+ if (!textView.Multiline && chxCaptureTabs.State == CheckState.Checked)
{
- chxCaptureTabs.Checked = false;
+ chxCaptureTabs.State = CheckState.UnChecked;
}
};
@@ -150,7 +150,7 @@ public class Text : Scenario
chxCaptureTabs.Toggle += (s, e) =>
{
- if (e.NewValue == true)
+ if (e.NewValue == CheckState.Checked)
{
textView.KeyBindings.Add (keyTab, Command.Tab);
textView.KeyBindings.Add (keyBackTab, Command.BackTab);
@@ -161,7 +161,7 @@ public class Text : Scenario
textView.KeyBindings.Remove (keyBackTab);
}
- textView.AllowsTab = (bool)e.NewValue;
+ textView.AllowsTab = e.NewValue == CheckState.Checked;
};
Win.Add (chxCaptureTabs);
diff --git a/UICatalog/Scenarios/TextAlignmentAndDirection.cs b/UICatalog/Scenarios/TextAlignmentAndDirection.cs
index c885d0603..16933ec96 100644
--- a/UICatalog/Scenarios/TextAlignmentAndDirection.cs
+++ b/UICatalog/Scenarios/TextAlignmentAndDirection.cs
@@ -484,7 +484,7 @@ public class TextAlignmentAndDirection : Scenario
Enabled = false
};
- justifyCheckbox.Toggle += (s, e) => ToggleJustify (e.CurrentValue is { } && (bool)e.CurrentValue);
+ justifyCheckbox.Toggle += (s, e) => ToggleJustify (e.NewValue == CheckState.Checked);
justifyOptions.SelectedItemChanged += (s, e) => { ToggleJustify (false, true); };
@@ -500,11 +500,11 @@ public class TextAlignmentAndDirection : Scenario
Height = 1,
Text = "Word Wrap"
};
- wrapCheckbox.Checked = wrapCheckbox.TextFormatter.WordWrap;
+ wrapCheckbox.State = wrapCheckbox.TextFormatter.WordWrap ? CheckState.Checked : CheckState.UnChecked;
wrapCheckbox.Toggle += (s, e) =>
{
- if (e.CurrentValue == true)
+ if (e.CurrentValue == CheckState.Checked)
{
foreach (Label t in multiLineLabels)
{
@@ -532,11 +532,11 @@ public class TextAlignmentAndDirection : Scenario
Height = 1,
Text = "AutoSize"
};
- autoSizeCheckbox.Checked = autoSizeCheckbox.TextFormatter.AutoSize;
+ autoSizeCheckbox.State = autoSizeCheckbox.TextFormatter.AutoSize ? CheckState.Checked : CheckState.UnChecked;
autoSizeCheckbox.Toggle += (s, e) =>
{
- if (e.CurrentValue == true)
+ if (e.CurrentValue == CheckState.Checked)
{
foreach (Label t in multiLineLabels)
{
@@ -570,7 +570,7 @@ public class TextAlignmentAndDirection : Scenario
directionOptions.SelectedItemChanged += (s, ev) =>
{
- bool justChecked = justifyCheckbox.Checked is { } && (bool)justifyCheckbox.Checked;
+ bool justChecked = justifyCheckbox.State == CheckState.Checked;
if (justChecked)
{
diff --git a/UICatalog/Scenarios/TextFormatterDemo.cs b/UICatalog/Scenarios/TextFormatterDemo.cs
index ea9be18d8..ebf3659fb 100644
--- a/UICatalog/Scenarios/TextFormatterDemo.cs
+++ b/UICatalog/Scenarios/TextFormatterDemo.cs
@@ -58,7 +58,7 @@ public class TextFormatterDemo : Scenario
X = 0,
Y = Pos.Bottom (blockText) + 1,
Text = "Unicode",
- Checked = app.HotKeySpecifier == (Rune)' '
+ State = app.HotKeySpecifier == (Rune)' ' ? CheckState.Checked : CheckState.UnChecked
};
app.Add (unicodeCheckBox);
@@ -137,8 +137,8 @@ public class TextFormatterDemo : Scenario
{
for (int i = 0; i < alignments.Count; i++)
{
- singleLines [i].Text = e.CurrentValue == true ? text : unicode;
- multipleLines [i].Text = e.CurrentValue == true ? text : unicode;
+ singleLines [i].Text = e.CurrentValue == CheckState.Checked ? text : unicode;
+ multipleLines [i].Text = e.CurrentValue == CheckState.Checked ? text : unicode;
}
};
diff --git a/UICatalog/Scenarios/TileViewNesting.cs b/UICatalog/Scenarios/TileViewNesting.cs
index a2719f835..ab5ab4d22 100644
--- a/UICatalog/Scenarios/TileViewNesting.cs
+++ b/UICatalog/Scenarios/TileViewNesting.cs
@@ -91,7 +91,7 @@ public class TileViewNesting : Scenario
}
}
- private View CreateContentControl (int number) { return (bool)_cbUseLabels.Checked ? CreateLabelView (number) : CreateTextView (number); }
+ private View CreateContentControl (int number) { return _cbUseLabels.State == CheckState.Checked ? CreateLabelView (number) : CreateTextView (number); }
private View CreateLabelView (int number)
{
@@ -126,8 +126,8 @@ public class TileViewNesting : Scenario
Orientation = orientation
};
- toReturn.Tiles.ElementAt (0).Title = (bool)_cbTitles.Checked ? $"View {titleNumber}" : string.Empty;
- toReturn.Tiles.ElementAt (1).Title = (bool)_cbTitles.Checked ? $"View {titleNumber + 1}" : string.Empty;
+ toReturn.Tiles.ElementAt (0).Title = _cbTitles.State == CheckState.Checked ? $"View {titleNumber}" : string.Empty;
+ toReturn.Tiles.ElementAt (1).Title = _cbTitles.State == CheckState.Checked ? $"View {titleNumber + 1}" : string.Empty;
return toReturn;
}
@@ -148,9 +148,9 @@ public class TileViewNesting : Scenario
{
int numberOfViews = GetNumberOfViews ();
- bool? titles = _cbTitles.Checked;
- bool? border = _cbBorder.Checked;
- bool? startHorizontal = _cbHorizontal.Checked;
+ CheckState titles = _cbTitles.State;
+ CheckState border = _cbBorder.State;
+ CheckState startHorizontal = _cbHorizontal.State;
foreach (View sub in _workArea.Subviews)
{
@@ -164,14 +164,14 @@ public class TileViewNesting : Scenario
return;
}
- TileView root = CreateTileView (1, (bool)startHorizontal ? Orientation.Horizontal : Orientation.Vertical);
+ TileView root = CreateTileView (1, startHorizontal == CheckState.Checked ? Orientation.Horizontal : Orientation.Vertical);
root.Tiles.ElementAt (0).ContentView.Add (CreateContentControl (1));
- root.Tiles.ElementAt (0).Title = (bool)_cbTitles.Checked ? "View 1" : string.Empty;
+ root.Tiles.ElementAt (0).Title = _cbTitles.State == CheckState.Checked ? "View 1" : string.Empty;
root.Tiles.ElementAt (1).ContentView.Add (CreateContentControl (2));
- root.Tiles.ElementAt (1).Title = (bool)_cbTitles.Checked ? "View 2" : string.Empty;
+ root.Tiles.ElementAt (1).Title = _cbTitles.State == CheckState.Checked ? "View 2" : string.Empty;
- root.LineStyle = (bool)border ? LineStyle.Rounded : LineStyle.None;
+ root.LineStyle = border == CheckState.Checked? LineStyle.Rounded : LineStyle.None;
_workArea.Add (root);
@@ -215,7 +215,7 @@ public class TileViewNesting : Scenario
// During splitting the old Title will have been migrated to View1 so we only need
// to set the Title on View2 (the one that gets our new TextView)
- newView.Tiles.ElementAt (1).Title = (bool)_cbTitles.Checked ? $"View {_viewsCreated}" : string.Empty;
+ newView.Tiles.ElementAt (1).Title = _cbTitles.State == CheckState.Checked ? $"View {_viewsCreated}" : string.Empty;
// Flip orientation
newView.Orientation = to.Orientation == Orientation.Vertical
diff --git a/UICatalog/Scenarios/TrueColors.cs b/UICatalog/Scenarios/TrueColors.cs
index 82798e038..3a1446967 100644
--- a/UICatalog/Scenarios/TrueColors.cs
+++ b/UICatalog/Scenarios/TrueColors.cs
@@ -32,7 +32,7 @@ public class TrueColors : Scenario
{
X = x,
Y = y++,
- Checked = canTrueColor,
+ State = canTrueColor ? CheckState.Checked : CheckState.UnChecked,
CanFocus = false,
Text = "Driver supports true color "
};
@@ -42,11 +42,11 @@ public class TrueColors : Scenario
{
X = x,
Y = y++,
- Checked = Application.Force16Colors,
+ State = Application.Force16Colors ? CheckState.Checked : CheckState.UnChecked,
Enabled = canTrueColor,
Text = "Force 16 colors"
};
- cbUseTrueColor.Toggle += (_, evt) => { Application.Force16Colors = evt.NewValue ?? false; };
+ cbUseTrueColor.Toggle += (_, evt) => { Application.Force16Colors = evt.NewValue == CheckState.Checked; };
app.Add (cbUseTrueColor);
y += 2;
diff --git a/UICatalog/Scenarios/Wizards.cs b/UICatalog/Scenarios/Wizards.cs
index a57ee963c..fd52cf726 100644
--- a/UICatalog/Scenarios/Wizards.cs
+++ b/UICatalog/Scenarios/Wizards.cs
@@ -195,7 +195,7 @@ public class Wizards : Scenario
var thirdStepEnabledCeckBox = new CheckBox
{
Text = "Enable Step _3",
- Checked = false,
+ State = CheckState.UnChecked,
X = Pos.Left (lastNameField),
Y = Pos.Bottom (lastNameField)
};
@@ -242,8 +242,8 @@ public class Wizards : Scenario
X = Pos.Right (progLbl), Y = Pos.Top (progLbl), Width = 40, Fraction = 0.42F
};
thirdStep.Add (progLbl, progressBar);
- thirdStep.Enabled = (bool)thirdStepEnabledCeckBox.Checked;
- thirdStepEnabledCeckBox.Toggle += (s, e) => { thirdStep.Enabled = (bool)thirdStepEnabledCeckBox.Checked; };
+ thirdStep.Enabled = thirdStepEnabledCeckBox.State == CheckState.Checked;
+ thirdStepEnabledCeckBox.Toggle += (s, e) => { thirdStep.Enabled = thirdStepEnabledCeckBox.State == CheckState.Checked; };
// Add 4th step
var fourthStep = new WizardStep { Title = "Step Four" };
@@ -320,7 +320,7 @@ public class Wizards : Scenario
"The wizard is complete!\n\nPress the Finish button to continue.\n\nPressing ESC will cancel the wizard.";
var finalFinalStepEnabledCeckBox =
- new CheckBox { Text = "Enable _Final Final Step", Checked = false, X = 0, Y = 1 };
+ new CheckBox { Text = "Enable _Final Final Step", State = CheckState.UnChecked, X = 0, Y = 1 };
lastStep.Add (finalFinalStepEnabledCeckBox);
// Add an optional FINAL last step
@@ -329,11 +329,11 @@ public class Wizards : Scenario
finalFinalStep.HelpText =
"This step only shows if it was enabled on the other last step.";
- finalFinalStep.Enabled = (bool)thirdStepEnabledCeckBox.Checked;
+ finalFinalStep.Enabled = thirdStepEnabledCeckBox.State == CheckState.Checked;
finalFinalStepEnabledCeckBox.Toggle += (s, e) =>
{
- finalFinalStep.Enabled = (bool)finalFinalStepEnabledCeckBox.Checked;
+ finalFinalStep.Enabled = finalFinalStepEnabledCeckBox.State == CheckState.Checked;
};
Application.Run (wizard);
diff --git a/UICatalog/UICatalog.cs b/UICatalog/UICatalog.cs
index 4c90c2c2e..ddb4c656f 100644
--- a/UICatalog/UICatalog.cs
+++ b/UICatalog/UICatalog.cs
@@ -475,20 +475,18 @@ internal class UICatalogApp
CommandView = new CheckBox ()
{
Title = "16 color mode",
- Checked = Application.Force16Colors,
+ State = Application.Force16Colors ? CheckState.Checked : CheckState.UnChecked,
CanFocus = false,
},
HelpText = "",
Key = Key.F6,
};
- ShForce16Colors.Accept += (sender, args) =>
+ ((CheckBox)ShForce16Colors.CommandView).Toggle += (sender, args) =>
{
- ((CheckBox)ShForce16Colors.CommandView).Checked =
- Application.Force16Colors = (bool)!((CheckBox)ShForce16Colors.CommandView).Checked!;
+ Application.Force16Colors = args.NewValue == CheckState.Checked;
MiForce16Colors!.Checked = Application.Force16Colors;
Application.Refresh ();
-
};
//ShDiagnostics = new Shortcut ()
@@ -1008,7 +1006,7 @@ internal class UICatalogApp
MiForce16Colors.Action += () =>
{
MiForce16Colors.Checked = Application.Force16Colors = (bool)!MiForce16Colors.Checked!;
- ((CheckBox)ShForce16Colors!.CommandView!).Checked = Application.Force16Colors;
+ ((CheckBox)ShForce16Colors!.CommandView!).State = Application.Force16Colors ? CheckState.Checked : CheckState.UnChecked;
Application.Refresh ();
};
menuItems.Add (MiForce16Colors);
diff --git a/UnitTests/Views/CheckBoxTests.cs b/UnitTests/Views/CheckBoxTests.cs
index 4b24768ab..c7739272d 100644
--- a/UnitTests/Views/CheckBoxTests.cs
+++ b/UnitTests/Views/CheckBoxTests.cs
@@ -77,7 +77,7 @@ public class CheckBoxTests (ITestOutputHelper output)
Assert.Equal ("Hello", view.TitleTextFormatter.Text);
Assert.Equal ("Hello", view.Text);
- Assert.Equal ($"{CM.Glyphs.UnChecked} Hello", view.TextFormatter.Text);
+ Assert.Equal ($"{CM.Glyphs.CheckStateUnChecked} Hello", view.TextFormatter.Text);
}
[Fact]
@@ -86,7 +86,7 @@ public class CheckBoxTests (ITestOutputHelper output)
var view = new CheckBox ();
view.Text = "Hello";
Assert.Equal ("Hello", view.Text);
- Assert.Equal ($"{CM.Glyphs.UnChecked} Hello", view.TextFormatter.Text);
+ Assert.Equal ($"{CM.Glyphs.CheckStateUnChecked} Hello", view.TextFormatter.Text);
Assert.Equal ("Hello", view.Title);
Assert.Equal ("Hello", view.TitleTextFormatter.Text);
@@ -94,35 +94,35 @@ public class CheckBoxTests (ITestOutputHelper output)
[Fact]
[SetupFakeDriver]
- public void AllowNullChecked_Get_Set ()
+ public void AllowNoneChecked_Get_Set ()
{
var checkBox = new CheckBox { Text = "Check this out 你" };
- Assert.False (checkBox.Checked);
+ Assert.Equal (CheckState.UnChecked, checkBox.State);
Assert.True (checkBox.NewKeyDownEvent (Key.Space));
- Assert.True (checkBox.Checked);
- Assert.True (checkBox.NewMouseEvent (new() { Position = new (0, 0), Flags = MouseFlags.Button1Clicked }));
- Assert.False (checkBox.Checked);
+ Assert.Equal (CheckState.Checked, checkBox.State);
+ Assert.True (checkBox.NewMouseEvent (new () { Position = new (0, 0), Flags = MouseFlags.Button1Clicked }));
+ Assert.Equal (CheckState.UnChecked, checkBox.State);
- checkBox.AllowNullChecked = true;
+ checkBox.AllowCheckStateNone = true;
Assert.True (checkBox.NewKeyDownEvent (Key.Space));
- Assert.Null (checkBox.Checked);
- checkBox.Draw();
+ Assert.Equal (CheckState.None, checkBox.State);
+ checkBox.Draw ();
TestHelpers.AssertDriverContentsWithFrameAre (
@$"
-{CM.Glyphs.NullChecked} Check this out 你",
+{CM.Glyphs.CheckStateNone} Check this out 你",
output
);
- Assert.True (checkBox.NewMouseEvent (new() { Position = new (0, 0), Flags = MouseFlags.Button1Clicked }));
- Assert.True (checkBox.Checked);
+ Assert.True (checkBox.NewMouseEvent (new () { Position = new (0, 0), Flags = MouseFlags.Button1Clicked }));
+ Assert.Equal (CheckState.Checked, checkBox.State);
Assert.True (checkBox.NewKeyDownEvent (Key.Space));
- Assert.False (checkBox.Checked);
- Assert.True (checkBox.NewMouseEvent (new() { Position = new (0, 0), Flags = MouseFlags.Button1Clicked }));
- Assert.Null (checkBox.Checked);
+ Assert.Equal (CheckState.UnChecked, checkBox.State);
+ Assert.True (checkBox.NewMouseEvent (new () { Position = new (0, 0), Flags = MouseFlags.Button1Clicked }));
+ Assert.Equal (CheckState.None, checkBox.State);
- checkBox.AllowNullChecked = false;
- Assert.False (checkBox.Checked);
+ checkBox.AllowCheckStateNone = false;
+ Assert.Equal (CheckState.UnChecked, checkBox.State);
}
[Fact]
@@ -131,40 +131,40 @@ public class CheckBoxTests (ITestOutputHelper output)
var ckb = new CheckBox ();
Assert.True (ckb.Width is DimAuto);
Assert.True (ckb.Height is DimAuto);
- Assert.False (ckb.Checked);
- Assert.False (ckb.AllowNullChecked);
+ Assert.Equal (CheckState.UnChecked, ckb.State);
+ Assert.False (ckb.AllowCheckStateNone);
Assert.Equal (string.Empty, ckb.Text);
- Assert.Equal ($"{CM.Glyphs.UnChecked} ", ckb.TextFormatter.Text);
+ Assert.Equal ($"{CM.Glyphs.CheckStateUnChecked} ", ckb.TextFormatter.Text);
Assert.True (ckb.CanFocus);
Assert.Equal (new (0, 0, 2, 1), ckb.Frame);
- ckb = new() { Text = "Test", Checked = true };
+ ckb = new () { Text = "Test", State = CheckState.Checked };
Assert.True (ckb.Width is DimAuto);
Assert.True (ckb.Height is DimAuto);
- Assert.True (ckb.Checked);
- Assert.False (ckb.AllowNullChecked);
+ Assert.Equal (CheckState.Checked, ckb.State);
+ Assert.False (ckb.AllowCheckStateNone);
Assert.Equal ("Test", ckb.Text);
- Assert.Equal ($"{CM.Glyphs.Checked} Test", ckb.TextFormatter.Text);
+ Assert.Equal ($"{CM.Glyphs.CheckStateChecked} Test", ckb.TextFormatter.Text);
Assert.True (ckb.CanFocus);
Assert.Equal (new (0, 0, 6, 1), ckb.Frame);
- ckb = new() { Text = "Test", X = 1, Y = 2 };
+ ckb = new () { Text = "Test", X = 1, Y = 2 };
Assert.True (ckb.Width is DimAuto);
Assert.True (ckb.Height is DimAuto);
- Assert.False (ckb.Checked);
- Assert.False (ckb.AllowNullChecked);
+ Assert.Equal (CheckState.UnChecked, ckb.State);
+ Assert.False (ckb.AllowCheckStateNone);
Assert.Equal ("Test", ckb.Text);
- Assert.Equal ($"{CM.Glyphs.UnChecked} Test", ckb.TextFormatter.Text);
+ Assert.Equal ($"{CM.Glyphs.CheckStateUnChecked} Test", ckb.TextFormatter.Text);
Assert.True (ckb.CanFocus);
Assert.Equal (new (1, 2, 6, 1), ckb.Frame);
- ckb = new() { Text = "Test", X = 3, Y = 4, Checked = true };
+ ckb = new () { Text = "Test", X = 3, Y = 4, State = CheckState.Checked };
Assert.True (ckb.Width is DimAuto);
Assert.True (ckb.Height is DimAuto);
- Assert.True (ckb.Checked);
- Assert.False (ckb.AllowNullChecked);
+ Assert.Equal (CheckState.Checked, ckb.State);
+ Assert.False (ckb.AllowCheckStateNone);
Assert.Equal ("Test", ckb.Text);
- Assert.Equal ($"{CM.Glyphs.Checked} Test", ckb.TextFormatter.Text);
+ Assert.Equal ($"{CM.Glyphs.CheckStateChecked} Test", ckb.TextFormatter.Text);
Assert.True (ckb.CanFocus);
Assert.Equal (new (3, 4, 6, 1), ckb.Frame);
}
@@ -176,14 +176,14 @@ public class CheckBoxTests (ITestOutputHelper output)
var ckb = new CheckBox ();
ckb.Toggle += (s, e) => toggled = true;
- Assert.False (ckb.Checked);
+ Assert.Equal (CheckState.UnChecked, ckb.State);
Assert.False (toggled);
Assert.Equal (Key.Empty, ckb.HotKey);
ckb.Text = "_Test";
Assert.Equal (Key.T, ckb.HotKey);
Assert.True (ckb.NewKeyDownEvent (Key.T));
- Assert.True (ckb.Checked);
+ Assert.Equal (CheckState.Checked, ckb.State);
Assert.True (toggled);
ckb.Text = "T_est";
@@ -191,28 +191,28 @@ public class CheckBoxTests (ITestOutputHelper output)
Assert.Equal (Key.E, ckb.HotKey);
Assert.True (ckb.NewKeyDownEvent (Key.E.WithAlt));
Assert.True (toggled);
- Assert.False (ckb.Checked);
+ Assert.Equal (CheckState.UnChecked, ckb.State);
toggled = false;
Assert.Equal (Key.E, ckb.HotKey);
Assert.True (ckb.NewKeyDownEvent (Key.E));
Assert.True (toggled);
- Assert.True (ckb.Checked);
+ Assert.Equal (CheckState.Checked, ckb.State);
toggled = false;
Assert.True (ckb.NewKeyDownEvent (Key.Space));
Assert.True (toggled);
- Assert.False (ckb.Checked);
+ Assert.Equal (CheckState.UnChecked, ckb.State);
toggled = false;
Assert.True (ckb.NewKeyDownEvent (Key.Space));
Assert.True (toggled);
- Assert.True (ckb.Checked);
+ Assert.Equal (CheckState.Checked, ckb.State);
toggled = false;
Assert.False (ckb.NewKeyDownEvent (Key.Enter));
Assert.False (toggled);
- Assert.True (ckb.Checked);
+ Assert.Equal (CheckState.Checked, ckb.State);
}
[Fact]
@@ -263,7 +263,7 @@ public class CheckBoxTests (ITestOutputHelper output)
var expected = @$"
┌┤Test Demo 你├──────────────┐
│ │
-│ {CM.Glyphs.UnChecked} Check this out 你 │
+│ {CM.Glyphs.CheckStateUnChecked} Check this out 你 │
│ │
└────────────────────────────┘
";
@@ -271,13 +271,13 @@ public class CheckBoxTests (ITestOutputHelper output)
Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new (0, 0, 30, 5), pos);
- checkBox.Checked = true;
+ checkBox.State = CheckState.Checked;
Application.Refresh ();
expected = @$"
┌┤Test Demo 你├──────────────┐
│ │
-│ {CM.Glyphs.Checked} Check this out 你 │
+│ {CM.Glyphs.CheckStateChecked} Check this out 你 │
│ │
└────────────────────────────┘
";
@@ -324,8 +324,8 @@ public class CheckBoxTests (ITestOutputHelper output)
var expected = @$"
┌┤Test Demo 你├──────────────┐
│ │
-│ {CM.Glyphs.UnChecked} Check first out 你 │
-│ {CM.Glyphs.UnChecked} Check second out 你 │
+│ {CM.Glyphs.CheckStateUnChecked} Check first out 你 │
+│ {CM.Glyphs.CheckStateUnChecked} Check second out 你 │
│ │
└────────────────────────────┘
";
@@ -333,10 +333,10 @@ public class CheckBoxTests (ITestOutputHelper output)
Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new (0, 0, 30, 6), pos);
- checkBox1.Checked = true;
+ checkBox1.State = CheckState.Checked;
Assert.Equal (new (1, 1, 25, 1), checkBox1.Frame);
Assert.Equal (_size25x1, checkBox1.TextFormatter.Size);
- checkBox2.Checked = true;
+ checkBox2.State = CheckState.Checked;
Assert.Equal (new (1, 2, 25, 1), checkBox2.Frame);
Assert.Equal (_size25x1, checkBox2.TextFormatter.Size);
Application.Refresh ();
@@ -344,8 +344,8 @@ public class CheckBoxTests (ITestOutputHelper output)
expected = @$"
┌┤Test Demo 你├──────────────┐
│ │
-│ {CM.Glyphs.Checked} Check first out 你 │
-│ {CM.Glyphs.Checked} Check second out 你 │
+│ {CM.Glyphs.CheckStateChecked} Check first out 你 │
+│ {CM.Glyphs.CheckStateChecked} Check second out 你 │
│ │
└────────────────────────────┘
";
@@ -381,7 +381,7 @@ public class CheckBoxTests (ITestOutputHelper output)
var expected = @$"
┌┤Test Demo 你├──────────────┐
│ │
-│ {CM.Glyphs.UnChecked} Check this out 你 │
+│ {CM.Glyphs.CheckStateUnChecked} Check this out 你 │
│ │
└────────────────────────────┘
";
@@ -389,13 +389,13 @@ public class CheckBoxTests (ITestOutputHelper output)
Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new (0, 0, 30, 5), pos);
- checkBox.Checked = true;
+ checkBox.State = CheckState.Checked;
Application.Refresh ();
expected = @$"
┌┤Test Demo 你├──────────────┐
│ │
-│ {CM.Glyphs.Checked} Check this out 你 │
+│ {CM.Glyphs.CheckStateChecked} Check this out 你 │
│ │
└────────────────────────────┘
";
@@ -432,7 +432,7 @@ public class CheckBoxTests (ITestOutputHelper output)
var expected = @$"
┌┤Test Demo 你├──────────────┐
│ │
-│ Check this out 你 {CM.Glyphs.UnChecked} │
+│ Check this out 你 {CM.Glyphs.CheckStateUnChecked} │
│ │
└────────────────────────────┘
";
@@ -440,13 +440,13 @@ public class CheckBoxTests (ITestOutputHelper output)
Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
Assert.Equal (new (0, 0, 30, 5), pos);
- checkBox.Checked = true;
+ checkBox.State = CheckState.Checked;
Application.Refresh ();
expected = @$"
┌┤Test Demo 你├──────────────┐
│ │
-│ Check this out 你 {CM.Glyphs.Checked} │
+│ Check this out 你 {CM.Glyphs.CheckStateChecked} │
│ │
└────────────────────────────┘
";
@@ -473,22 +473,22 @@ public class CheckBoxTests (ITestOutputHelper output)
}
[Theory]
- [InlineData (true)]
- [InlineData (false)]
- [InlineData (null)]
- public void Toggled_Cancel_Event_Prevents_Toggle (bool? initialState)
+ [InlineData (CheckState.Checked)]
+ [InlineData (CheckState.UnChecked)]
+ [InlineData (CheckState.None)]
+ public void Toggled_Cancel_Event_Prevents_Toggle (CheckState initialState)
{
- var ckb = new CheckBox { AllowNullChecked = true };
+ var ckb = new CheckBox { AllowCheckStateNone = true };
var checkedInvoked = false;
ckb.Toggle += CheckBoxToggle;
- ckb.Checked = initialState;
- Assert.Equal (initialState, ckb.Checked);
+ ckb.State = initialState;
+ Assert.Equal (initialState, ckb.State);
bool? ret = ckb.OnToggle ();
Assert.True (ret);
Assert.True (checkedInvoked);
- Assert.Equal (initialState, ckb.Checked);
+ Assert.Equal (initialState, ckb.State);
return;
diff --git a/UnitTests/Views/MenuBarTests.cs b/UnitTests/Views/MenuBarTests.cs
index f7356f1da..8be35667f 100644
--- a/UnitTests/Views/MenuBarTests.cs
+++ b/UnitTests/Views/MenuBarTests.cs
@@ -64,7 +64,7 @@ public class MenuBarTests (ITestOutputHelper output)
Nullable Checked
┌──────────────────────┐
│ {
- CM.Glyphs.NullChecked
+ CM.Glyphs.CheckStateNone
} Check this out 你 │
└──────────────────────┘",
output
diff --git a/UnitTests/Views/TreeTableSourceTests.cs b/UnitTests/Views/TreeTableSourceTests.cs
index 3e9fa62ad..0b54be84d 100644
--- a/UnitTests/Views/TreeTableSourceTests.cs
+++ b/UnitTests/Views/TreeTableSourceTests.cs
@@ -13,16 +13,16 @@ public class TreeTableSourceTests : IDisposable
{
_output = output;
- _origChecked = ConfigurationManager.Glyphs.Checked;
- _origUnchecked = ConfigurationManager.Glyphs.UnChecked;
- ConfigurationManager.Glyphs.Checked = new Rune ('☑');
- ConfigurationManager.Glyphs.UnChecked = new Rune ('☐');
+ _origChecked = ConfigurationManager.Glyphs.CheckStateChecked;
+ _origUnchecked = ConfigurationManager.Glyphs.CheckStateUnChecked;
+ ConfigurationManager.Glyphs.CheckStateChecked = new Rune ('☑');
+ ConfigurationManager.Glyphs.CheckStateUnChecked = new Rune ('☐');
}
public void Dispose ()
{
- ConfigurationManager.Glyphs.Checked = _origChecked;
- ConfigurationManager.Glyphs.UnChecked = _origUnchecked;
+ ConfigurationManager.Glyphs.CheckStateChecked = _origChecked;
+ ConfigurationManager.Glyphs.CheckStateUnChecked = _origUnchecked;
}
[Fact]