Browse Source

Implementing nullable bool checked on CheckBox.

BDisp 2 years ago
parent
commit
9d1a429676

+ 5 - 0
Terminal.Gui/Core/ConsoleDriver.cs

@@ -1077,6 +1077,11 @@ namespace Terminal.Gui {
 		/// </summary>
 		/// </summary>
 		public Rune UnChecked = '\u2574';
 		public Rune UnChecked = '\u2574';
 
 
+		/// <summary>
+		/// Null-checked checkmark.
+		/// </summary>
+		public Rune NullChecked = '\u2370';
+
 		/// <summary>
 		/// <summary>
 		/// Selected mark.
 		/// Selected mark.
 		/// </summary>
 		/// </summary>

+ 51 - 12
Terminal.Gui/Views/Checkbox.cs

@@ -13,9 +13,11 @@ namespace Terminal.Gui {
 	/// The <see cref="CheckBox"/> <see cref="View"/> shows an on/off toggle that the user can set
 	/// The <see cref="CheckBox"/> <see cref="View"/> shows an on/off toggle that the user can set
 	/// </summary>
 	/// </summary>
 	public class CheckBox : View {
 	public class CheckBox : View {
+		Rune charNullChecked;
 		Rune charChecked;
 		Rune charChecked;
 		Rune charUnChecked;
 		Rune charUnChecked;
-		bool @checked;
+		bool? @checked;
+		bool allowNullChecked;
 
 
 		/// <summary>
 		/// <summary>
 		///   Toggled event, raised when the <see cref="CheckBox"/>  is toggled.
 		///   Toggled event, raised when the <see cref="CheckBox"/>  is toggled.
@@ -25,12 +27,12 @@ namespace Terminal.Gui {
 		///   raised when the <see cref="CheckBox"/> is activated either with
 		///   raised when the <see cref="CheckBox"/> is activated either with
 		///   the mouse or the keyboard. The passed <c>bool</c> contains the previous state. 
 		///   the mouse or the keyboard. The passed <c>bool</c> contains the previous state. 
 		/// </remarks>
 		/// </remarks>
-		public event Action<bool> Toggled;
+		public event Action<bool?> Toggled;
 
 
 		/// <summary>
 		/// <summary>
 		/// Called when the <see cref="Checked"/> property changes. Invokes the <see cref="Toggled"/> event.
 		/// Called when the <see cref="Checked"/> property changes. Invokes the <see cref="Toggled"/> event.
 		/// </summary>
 		/// </summary>
-		public virtual void OnToggled (bool previousChecked)
+		public virtual void OnToggled (bool? previousChecked)
 		{
 		{
 			Toggled?.Invoke (previousChecked);
 			Toggled?.Invoke (previousChecked);
 		}
 		}
@@ -75,6 +77,7 @@ namespace Terminal.Gui {
 
 
 		void Initialize (ustring s, bool is_checked)
 		void Initialize (ustring s, bool is_checked)
 		{
 		{
+			charNullChecked = new Rune (Driver != null ? Driver.NullChecked : '?');
 			charChecked = new Rune (Driver != null ? Driver.Checked : '√');
 			charChecked = new Rune (Driver != null ? Driver.Checked : '√');
 			charUnChecked = new Rune (Driver != null ? Driver.UnChecked : '╴');
 			charUnChecked = new Rune (Driver != null ? Driver.UnChecked : '╴');
 			Checked = is_checked;
 			Checked = is_checked;
@@ -100,14 +103,23 @@ namespace Terminal.Gui {
 			case TextAlignment.Left:
 			case TextAlignment.Left:
 			case TextAlignment.Centered:
 			case TextAlignment.Centered:
 			case TextAlignment.Justified:
 			case TextAlignment.Justified:
-				TextFormatter.Text = ustring.Make (Checked ? charChecked : charUnChecked) + " " + GetFormatterText ();
+				TextFormatter.Text = ustring.Make (GetCheckedState ()) + " " + GetFormatterText ();
 				break;
 				break;
 			case TextAlignment.Right:
 			case TextAlignment.Right:
-				TextFormatter.Text = GetFormatterText () + " " + ustring.Make (Checked ? charChecked : charUnChecked);
+				TextFormatter.Text = GetFormatterText () + " " + ustring.Make (GetCheckedState ());
 				break;
 				break;
 			}
 			}
 		}
 		}
 
 
+		Rune GetCheckedState ()
+		{
+			switch (Checked) {
+			case true: return charChecked;
+			case false: return charUnChecked;
+			default: return charNullChecked;
+			}
+		}
+
 		ustring GetFormatterText ()
 		ustring GetFormatterText ()
 		{
 		{
 			if (AutoSize || ustring.IsNullOrEmpty (Text) || Frame.Width <= 2) {
 			if (AutoSize || ustring.IsNullOrEmpty (Text) || Frame.Width <= 2) {
@@ -119,15 +131,32 @@ namespace Terminal.Gui {
 		/// <summary>
 		/// <summary>
 		///    The state of the <see cref="CheckBox"/>
 		///    The state of the <see cref="CheckBox"/>
 		/// </summary>
 		/// </summary>
-		public bool Checked {
+		public bool? Checked {
 			get => @checked;
 			get => @checked;
 			set {
 			set {
+				if (value == null && !AllowNullChecked) {
+					return;
+				}
 				@checked = value;
 				@checked = value;
 				UpdateTextFormatterText ();
 				UpdateTextFormatterText ();
 				ProcessResizeView ();
 				ProcessResizeView ();
 			}
 			}
 		}
 		}
 
 
+		/// <summary>
+		/// If <see langword="true"/> allows <see cref="Checked"/> to be null, true or false.
+		/// If <see langword="false"/> only allows <see cref="Checked"/> to be true or false.
+		/// </summary>
+		public bool AllowNullChecked {
+			get => allowNullChecked;
+			set {
+				allowNullChecked = value;
+				if (Checked == null) {
+					Checked = false;
+				}
+			}
+		}
+
 		///<inheritdoc/>
 		///<inheritdoc/>
 		public override void PositionCursor ()
 		public override void PositionCursor ()
 		{
 		{
@@ -159,7 +188,21 @@ namespace Terminal.Gui {
 				SetFocus ();
 				SetFocus ();
 			}
 			}
 			var previousChecked = Checked;
 			var previousChecked = Checked;
-			Checked = !Checked;
+			if (AllowNullChecked) {
+				switch (previousChecked) {
+				case null:
+					Checked = true;
+					break;
+				case true:
+					Checked = false;
+					break;
+				case false:
+					Checked = null;
+					break;
+				}
+			} else {
+				Checked = !Checked;
+			}
 			OnToggled (previousChecked);
 			OnToggled (previousChecked);
 			SetNeedsDisplay ();
 			SetNeedsDisplay ();
 			return true;
 			return true;
@@ -171,11 +214,7 @@ namespace Terminal.Gui {
 			if (!me.Flags.HasFlag (MouseFlags.Button1Clicked) || !CanFocus)
 			if (!me.Flags.HasFlag (MouseFlags.Button1Clicked) || !CanFocus)
 				return false;
 				return false;
 
 
-			SetFocus ();
-			var previousChecked = Checked;
-			Checked = !Checked;
-			OnToggled (previousChecked);
-			SetNeedsDisplay ();
+			ToggleChecked ();
 
 
 			return true;
 			return true;
 		}
 		}

+ 2 - 2
UICatalog/Scenarios/AllViewsTester.cs

@@ -45,7 +45,7 @@ namespace UICatalog.Scenarios {
 			Application.Init ();
 			Application.Init ();
 			// Don't create a sub-win; just use Applicatiion.Top
 			// Don't create a sub-win; just use Applicatiion.Top
 		}
 		}
-		
+
 		public override void Setup ()
 		public override void Setup ()
 		{
 		{
 			var statusBar = new StatusBar (new StatusItem [] {
 			var statusBar = new StatusBar (new StatusItem [] {
@@ -103,7 +103,7 @@ namespace UICatalog.Scenarios {
 			_computedCheckBox = new CheckBox ("Computed Layout", true) { X = 0, Y = 0 };
 			_computedCheckBox = new CheckBox ("Computed Layout", true) { X = 0, Y = 0 };
 			_computedCheckBox.Toggled += (previousState) => {
 			_computedCheckBox.Toggled += (previousState) => {
 				if (_curView != null) {
 				if (_curView != null) {
-					_curView.LayoutStyle = previousState ? LayoutStyle.Absolute : LayoutStyle.Computed;
+					_curView.LayoutStyle = previousState == true ? LayoutStyle.Absolute : LayoutStyle.Computed;
 					_hostPane.LayoutSubviews ();
 					_hostPane.LayoutSubviews ();
 				}
 				}
 			};
 			};

+ 3 - 3
UICatalog/Scenarios/AutoSizeAndDirectionText.cs

@@ -60,7 +60,7 @@ namespace UICatalog.Scenarios {
 				Y = Pos.Center () + 5,
 				Y = Pos.Center () + 5,
 				Checked = labelH.AutoSize = labelV.AutoSize
 				Checked = labelH.AutoSize = labelV.AutoSize
 			};
 			};
-			ckbAutoSize.Toggled += (_) => labelH.AutoSize = labelV.AutoSize = ckbAutoSize.Checked;
+			ckbAutoSize.Toggled += (_) => labelH.AutoSize = labelV.AutoSize = (bool)ckbAutoSize.Checked;
 			Win.Add (ckbAutoSize);
 			Win.Add (ckbAutoSize);
 
 
 			var ckbPreserveTrailingSpaces = new CheckBox ("Preserve Trailing Spaces") {
 			var ckbPreserveTrailingSpaces = new CheckBox ("Preserve Trailing Spaces") {
@@ -69,7 +69,7 @@ namespace UICatalog.Scenarios {
 				Checked = labelH.PreserveTrailingSpaces = labelV.PreserveTrailingSpaces
 				Checked = labelH.PreserveTrailingSpaces = labelV.PreserveTrailingSpaces
 			};
 			};
 			ckbPreserveTrailingSpaces.Toggled += (_) =>
 			ckbPreserveTrailingSpaces.Toggled += (_) =>
-					labelH.PreserveTrailingSpaces = labelV.PreserveTrailingSpaces = ckbPreserveTrailingSpaces.Checked;
+					labelH.PreserveTrailingSpaces = labelV.PreserveTrailingSpaces = (bool)ckbPreserveTrailingSpaces.Checked;
 			Win.Add (ckbPreserveTrailingSpaces);
 			Win.Add (ckbPreserveTrailingSpaces);
 
 
 			var ckbWideText = new CheckBox ("Use wide runes") {
 			var ckbWideText = new CheckBox ("Use wide runes") {
@@ -77,7 +77,7 @@ namespace UICatalog.Scenarios {
 				Y = Pos.Center () + 9
 				Y = Pos.Center () + 9
 			};
 			};
 			ckbWideText.Toggled += (_) => {
 			ckbWideText.Toggled += (_) => {
-				if (ckbWideText.Checked) {
+				if (ckbWideText.Checked == true) {
 					labelH.Text = labelV.Text = editText.Text = wideText;
 					labelH.Text = labelV.Text = editText.Text = wideText;
 					labelH.Width = 14;
 					labelH.Width = 14;
 					labelV.Height = 13;
 					labelV.Height = 13;

+ 4 - 4
UICatalog/Scenarios/Borders.cs

@@ -206,7 +206,7 @@ namespace UICatalog.Scenarios {
 				Y = Pos.Y (replacePadding) + 3,
 				Y = Pos.Y (replacePadding) + 3,
 				Checked = smartPanel.UsePanelFrame
 				Checked = smartPanel.UsePanelFrame
 			};
 			};
-			cbUseUsePanelFrame.Toggled += (e) => smartPanel.UsePanelFrame = !e;
+			cbUseUsePanelFrame.Toggled += (e) => smartPanel.UsePanelFrame = (bool)!e;
 			Win.Add (cbUseUsePanelFrame);
 			Win.Add (cbUseUsePanelFrame);
 
 
 			Win.Add (new Label ("Border:") {
 			Win.Add (new Label ("Border:") {
@@ -339,8 +339,8 @@ namespace UICatalog.Scenarios {
 			};
 			};
 			cbDrawMarginFrame.Toggled += (e) => {
 			cbDrawMarginFrame.Toggled += (e) => {
 				try {
 				try {
-					smartPanel.Child.Border.DrawMarginFrame = cbDrawMarginFrame.Checked;
-					smartView.Border.DrawMarginFrame = cbDrawMarginFrame.Checked;
+					smartPanel.Child.Border.DrawMarginFrame = (bool)cbDrawMarginFrame.Checked;
+					smartView.Border.DrawMarginFrame = (bool)cbDrawMarginFrame.Checked;
 					if (cbDrawMarginFrame.Checked != smartView.Border.DrawMarginFrame) {
 					if (cbDrawMarginFrame.Checked != smartView.Border.DrawMarginFrame) {
 						cbDrawMarginFrame.Checked = smartView.Border.DrawMarginFrame;
 						cbDrawMarginFrame.Checked = smartView.Border.DrawMarginFrame;
 					}
 					}
@@ -423,7 +423,7 @@ namespace UICatalog.Scenarios {
 			cbEffect3D.Toggled += (e) => {
 			cbEffect3D.Toggled += (e) => {
 				try {
 				try {
 					smartPanel.Child.Border.Effect3D = smartView.Border.Effect3D = effect3DOffsetX.Enabled =
 					smartPanel.Child.Border.Effect3D = smartView.Border.Effect3D = effect3DOffsetX.Enabled =
-						effect3DOffsetY.Enabled = cbEffect3D.Checked;
+						effect3DOffsetY.Enabled = (bool)cbEffect3D.Checked;
 				} catch { }
 				} catch { }
 			};
 			};
 
 

+ 2 - 2
UICatalog/Scenarios/BordersOnFrameView.cs

@@ -267,7 +267,7 @@ namespace UICatalog.Scenarios {
 			};
 			};
 			cbDrawMarginFrame.Toggled += (e) => {
 			cbDrawMarginFrame.Toggled += (e) => {
 				try {
 				try {
-					smartView.Border.DrawMarginFrame = cbDrawMarginFrame.Checked;
+					smartView.Border.DrawMarginFrame = (bool)cbDrawMarginFrame.Checked;
 					if (cbDrawMarginFrame.Checked != smartView.Border.DrawMarginFrame) {
 					if (cbDrawMarginFrame.Checked != smartView.Border.DrawMarginFrame) {
 						cbDrawMarginFrame.Checked = smartView.Border.DrawMarginFrame;
 						cbDrawMarginFrame.Checked = smartView.Border.DrawMarginFrame;
 					}
 					}
@@ -343,7 +343,7 @@ namespace UICatalog.Scenarios {
 			cbEffect3D.Toggled += (e) => {
 			cbEffect3D.Toggled += (e) => {
 				try {
 				try {
 					smartView.Border.Effect3D = effect3DOffsetX.Enabled =
 					smartView.Border.Effect3D = effect3DOffsetX.Enabled =
-						effect3DOffsetY.Enabled = cbEffect3D.Checked;
+						effect3DOffsetY.Enabled = (bool)cbEffect3D.Checked;
 				} catch { }
 				} catch { }
 			};
 			};
 
 

+ 2 - 2
UICatalog/Scenarios/BordersOnToplevel.cs

@@ -267,7 +267,7 @@ namespace UICatalog.Scenarios {
 			};
 			};
 			cbDrawMarginFrame.Toggled += (e) => {
 			cbDrawMarginFrame.Toggled += (e) => {
 				try {
 				try {
-					smartView.Border.DrawMarginFrame = cbDrawMarginFrame.Checked;
+					smartView.Border.DrawMarginFrame = (bool)cbDrawMarginFrame.Checked;
 					if (cbDrawMarginFrame.Checked != smartView.Border.DrawMarginFrame) {
 					if (cbDrawMarginFrame.Checked != smartView.Border.DrawMarginFrame) {
 						cbDrawMarginFrame.Checked = smartView.Border.DrawMarginFrame;
 						cbDrawMarginFrame.Checked = smartView.Border.DrawMarginFrame;
 					}
 					}
@@ -343,7 +343,7 @@ namespace UICatalog.Scenarios {
 			cbEffect3D.Toggled += (e) => {
 			cbEffect3D.Toggled += (e) => {
 				try {
 				try {
 					smartView.Border.Effect3D = effect3DOffsetX.Enabled =
 					smartView.Border.Effect3D = effect3DOffsetX.Enabled =
-						effect3DOffsetY.Enabled = cbEffect3D.Checked;
+						effect3DOffsetY.Enabled = (bool)cbEffect3D.Checked;
 				} catch { }
 				} catch { }
 			};
 			};
 
 

+ 2 - 2
UICatalog/Scenarios/BordersOnWindow.cs

@@ -267,7 +267,7 @@ namespace UICatalog.Scenarios {
 			};
 			};
 			cbDrawMarginFrame.Toggled += (e) => {
 			cbDrawMarginFrame.Toggled += (e) => {
 				try {
 				try {
-					smartView.Border.DrawMarginFrame = cbDrawMarginFrame.Checked;
+					smartView.Border.DrawMarginFrame = (bool)cbDrawMarginFrame.Checked;
 					if (cbDrawMarginFrame.Checked != smartView.Border.DrawMarginFrame) {
 					if (cbDrawMarginFrame.Checked != smartView.Border.DrawMarginFrame) {
 						cbDrawMarginFrame.Checked = smartView.Border.DrawMarginFrame;
 						cbDrawMarginFrame.Checked = smartView.Border.DrawMarginFrame;
 					}
 					}
@@ -343,7 +343,7 @@ namespace UICatalog.Scenarios {
 			cbEffect3D.Toggled += (e) => {
 			cbEffect3D.Toggled += (e) => {
 				try {
 				try {
 					smartView.Border.Effect3D = effect3DOffsetX.Enabled =
 					smartView.Border.Effect3D = effect3DOffsetX.Enabled =
-						effect3DOffsetY.Enabled = cbEffect3D.Checked;
+						effect3DOffsetY.Enabled = (bool)cbEffect3D.Checked;
 				} catch { }
 				} catch { }
 			};
 			};
 
 

+ 5 - 5
UICatalog/Scenarios/Dialogs.cs

@@ -92,7 +92,7 @@ namespace UICatalog.Scenarios {
 			};
 			};
 			frame.Add (numButtonsEdit);
 			frame.Add (numButtonsEdit);
 
 
-			var glyphsNotWords = new CheckBox ($"Add {Char.ConvertFromUtf32(CODE_POINT)} to button text to stress wide char support", false) {
+			var glyphsNotWords = new CheckBox ($"Add {Char.ConvertFromUtf32 (CODE_POINT)} to button text to stress wide char support", false) {
 				X = Pos.Left (numButtonsEdit),
 				X = Pos.Left (numButtonsEdit),
 				Y = Pos.Bottom (label),
 				Y = Pos.Bottom (label),
 				TextAlignment = Terminal.Gui.TextAlignment.Right,
 				TextAlignment = Terminal.Gui.TextAlignment.Right,
@@ -115,7 +115,7 @@ namespace UICatalog.Scenarios {
 			void Top_Loaded ()
 			void Top_Loaded ()
 			{
 			{
 				frame.Height = Dim.Height (widthEdit) + Dim.Height (heightEdit) + Dim.Height (titleEdit)
 				frame.Height = Dim.Height (widthEdit) + Dim.Height (heightEdit) + Dim.Height (titleEdit)
-					+ Dim.Height (numButtonsEdit) + Dim.Height (styleRadioGroup) + Dim.Height(glyphsNotWords) + 2;
+					+ Dim.Height (numButtonsEdit) + Dim.Height (styleRadioGroup) + Dim.Height (glyphsNotWords) + 2;
 				Application.Top.Loaded -= Top_Loaded;
 				Application.Top.Loaded -= Top_Loaded;
 			}
 			}
 			Application.Top.Loaded += Top_Loaded;
 			Application.Top.Loaded += Top_Loaded;
@@ -160,7 +160,7 @@ namespace UICatalog.Scenarios {
 					for (int i = 0; i < numButtons; i++) {
 					for (int i = 0; i < numButtons; i++) {
 						int buttonId = i;
 						int buttonId = i;
 						Button button = null;
 						Button button = null;
-						if (glyphsNotWords.Checked) {
+						if (glyphsNotWords.Checked == true) {
 							buttonId = i;
 							buttonId = i;
 							button = new Button (NumberToWords.Convert (buttonId) + " " + Char.ConvertFromUtf32 (buttonId + CODE_POINT),
 							button = new Button (NumberToWords.Convert (buttonId) + " " + Char.ConvertFromUtf32 (buttonId + CODE_POINT),
 								is_default: buttonId == 0);
 								is_default: buttonId == 0);
@@ -196,7 +196,7 @@ namespace UICatalog.Scenarios {
 					add.Clicked += () => {
 					add.Clicked += () => {
 						var buttonId = buttons.Count;
 						var buttonId = buttons.Count;
 						Button button;
 						Button button;
-						if (glyphsNotWords.Checked) {
+						if (glyphsNotWords.Checked == true) {
 							button = new Button (NumberToWords.Convert (buttonId) + " " + Char.ConvertFromUtf32 (buttonId + CODE_POINT),
 							button = new Button (NumberToWords.Convert (buttonId) + " " + Char.ConvertFromUtf32 (buttonId + CODE_POINT),
 								is_default: buttonId == 0);
 								is_default: buttonId == 0);
 						} else {
 						} else {
@@ -216,7 +216,7 @@ namespace UICatalog.Scenarios {
 					};
 					};
 					dialog.Add (add);
 					dialog.Add (add);
 
 
-					var addChar = new Button ($"Add a {Char.ConvertFromUtf32(CODE_POINT)} to each button") {
+					var addChar = new Button ($"Add a {Char.ConvertFromUtf32 (CODE_POINT)} to each button") {
 						X = Pos.Center (),
 						X = Pos.Center (),
 						Y = Pos.Center () + 1
 						Y = Pos.Center () + 1
 					};
 					};

+ 13 - 13
UICatalog/Scenarios/DynamicMenuBar.cs

@@ -310,8 +310,8 @@ namespace UICatalog.Scenarios {
 					} else if (_currentEditMenuBarItem != null) {
 					} else if (_currentEditMenuBarItem != null) {
 						var menuItem = new DynamicMenuItem (_frmMenuDetails._txtTitle.Text, _frmMenuDetails._txtHelp.Text,
 						var menuItem = new DynamicMenuItem (_frmMenuDetails._txtTitle.Text, _frmMenuDetails._txtHelp.Text,
 							_frmMenuDetails._txtAction.Text,
 							_frmMenuDetails._txtAction.Text,
-							_frmMenuDetails._ckbIsTopLevel != null ? _frmMenuDetails._ckbIsTopLevel.Checked : false,
-							_frmMenuDetails._ckbSubMenu != null ? _frmMenuDetails._ckbSubMenu.Checked : false,
+							_frmMenuDetails._ckbIsTopLevel != null ? (bool)_frmMenuDetails._ckbIsTopLevel.Checked : false,
+							_frmMenuDetails._ckbSubMenu != null ? (bool)_frmMenuDetails._ckbSubMenu.Checked : false,
 							_frmMenuDetails._rbChkStyle.SelectedItem == 0 ? MenuItemCheckStyle.NoCheck :
 							_frmMenuDetails._rbChkStyle.SelectedItem == 0 ? MenuItemCheckStyle.NoCheck :
 							_frmMenuDetails._rbChkStyle.SelectedItem == 1 ? MenuItemCheckStyle.Checked :
 							_frmMenuDetails._rbChkStyle.SelectedItem == 1 ? MenuItemCheckStyle.Checked :
 							MenuItemCheckStyle.Radio,
 							MenuItemCheckStyle.Radio,
@@ -780,18 +780,18 @@ namespace UICatalog.Scenarios {
 				Add (_btnShortcut);
 				Add (_btnShortcut);
 
 
 				_ckbIsTopLevel.Toggled += (e) => {
 				_ckbIsTopLevel.Toggled += (e) => {
-					if ((_menuItem != null && _menuItem.Parent != null && _ckbIsTopLevel.Checked) ||
-						_menuItem == null && hasParent && _ckbIsTopLevel.Checked) {
+					if ((_menuItem != null && _menuItem.Parent != null && (bool)_ckbIsTopLevel.Checked) ||
+						_menuItem == null && hasParent && (bool)_ckbIsTopLevel.Checked) {
 						MessageBox.ErrorQuery ("Invalid IsTopLevel", "Only menu bar can have top level menu item!", "Ok");
 						MessageBox.ErrorQuery ("Invalid IsTopLevel", "Only menu bar can have top level menu item!", "Ok");
 						_ckbIsTopLevel.Checked = false;
 						_ckbIsTopLevel.Checked = false;
 						return;
 						return;
 					}
 					}
-					if (_ckbIsTopLevel.Checked) {
+					if (_ckbIsTopLevel.Checked == true) {
 						_ckbSubMenu.Checked = false;
 						_ckbSubMenu.Checked = false;
 						_ckbSubMenu.SetNeedsDisplay ();
 						_ckbSubMenu.SetNeedsDisplay ();
 						_txtHelp.Enabled = true;
 						_txtHelp.Enabled = true;
 						_txtAction.Enabled = true;
 						_txtAction.Enabled = true;
-						_txtShortcut.Enabled = !_ckbIsTopLevel.Checked && !_ckbSubMenu.Checked;
+						_txtShortcut.Enabled = _ckbIsTopLevel.Checked == false && _ckbSubMenu.Checked == false;
 					} else {
 					} else {
 						if (_menuItem == null && !hasParent || _menuItem.Parent == null) {
 						if (_menuItem == null && !hasParent || _menuItem.Parent == null) {
 							_ckbSubMenu.Checked = true;
 							_ckbSubMenu.Checked = true;
@@ -805,7 +805,7 @@ namespace UICatalog.Scenarios {
 					}
 					}
 				};
 				};
 				_ckbSubMenu.Toggled += (e) => {
 				_ckbSubMenu.Toggled += (e) => {
-					if (_ckbSubMenu.Checked) {
+					if ((bool)_ckbSubMenu.Checked) {
 						_ckbIsTopLevel.Checked = false;
 						_ckbIsTopLevel.Checked = false;
 						_ckbIsTopLevel.SetNeedsDisplay ();
 						_ckbIsTopLevel.SetNeedsDisplay ();
 						_txtHelp.Text = "";
 						_txtHelp.Text = "";
@@ -822,7 +822,7 @@ namespace UICatalog.Scenarios {
 						}
 						}
 						_txtHelp.Enabled = true;
 						_txtHelp.Enabled = true;
 						_txtAction.Enabled = true;
 						_txtAction.Enabled = true;
-						_txtShortcut.Enabled = !_ckbIsTopLevel.Checked && !_ckbSubMenu.Checked;
+						_txtShortcut.Enabled = _ckbIsTopLevel.Checked == false && _ckbSubMenu.Checked == false;
 					}
 					}
 				};
 				};
 
 
@@ -876,8 +876,8 @@ namespace UICatalog.Scenarios {
 
 
 				if (valid) {
 				if (valid) {
 					return new DynamicMenuItem (_txtTitle.Text, _txtHelp.Text, _txtAction.Text,
 					return new DynamicMenuItem (_txtTitle.Text, _txtHelp.Text, _txtAction.Text,
-						_ckbIsTopLevel != null ? _ckbIsTopLevel.Checked : false,
-						_ckbSubMenu != null ? _ckbSubMenu.Checked : false,
+						_ckbIsTopLevel != null ? (bool)_ckbIsTopLevel.Checked : false,
+						_ckbSubMenu != null ? (bool)_ckbSubMenu.Checked : false,
 						_rbChkStyle.SelectedItem == 0 ? MenuItemCheckStyle.NoCheck :
 						_rbChkStyle.SelectedItem == 0 ? MenuItemCheckStyle.NoCheck :
 						_rbChkStyle.SelectedItem == 1 ? MenuItemCheckStyle.Checked : MenuItemCheckStyle.Radio,
 						_rbChkStyle.SelectedItem == 1 ? MenuItemCheckStyle.Checked : MenuItemCheckStyle.Radio,
 						_txtShortcut.Text);
 						_txtShortcut.Text);
@@ -903,11 +903,11 @@ namespace UICatalog.Scenarios {
 				_txtAction.Text = menuItem != null && menuItem.Action != null ? GetTargetAction (menuItem.Action) : ustring.Empty;
 				_txtAction.Text = menuItem != null && menuItem.Action != null ? GetTargetAction (menuItem.Action) : ustring.Empty;
 				_ckbIsTopLevel.Checked = IsTopLevel (menuItem);
 				_ckbIsTopLevel.Checked = IsTopLevel (menuItem);
 				_ckbSubMenu.Checked = HasSubMenus (menuItem);
 				_ckbSubMenu.Checked = HasSubMenus (menuItem);
-				_txtHelp.Enabled = !_ckbSubMenu.Checked;
-				_txtAction.Enabled = !_ckbSubMenu.Checked;
+				_txtHelp.Enabled = (bool)!_ckbSubMenu.Checked;
+				_txtAction.Enabled = (bool)!_ckbSubMenu.Checked;
 				_rbChkStyle.SelectedItem = (int)(menuItem?.CheckType ?? MenuItemCheckStyle.NoCheck);
 				_rbChkStyle.SelectedItem = (int)(menuItem?.CheckType ?? MenuItemCheckStyle.NoCheck);
 				_txtShortcut.Text = menuItem?.ShortcutTag ?? "";
 				_txtShortcut.Text = menuItem?.ShortcutTag ?? "";
-				_txtShortcut.Enabled = !_ckbIsTopLevel.Checked && !_ckbSubMenu.Checked;
+				_txtShortcut.Enabled = _ckbIsTopLevel.Checked == false && _ckbSubMenu.Checked == false;
 			}
 			}
 
 
 			void CleanEditMenuBarItem ()
 			void CleanEditMenuBarItem ()

+ 4 - 4
UICatalog/Scenarios/Editor.cs

@@ -837,7 +837,7 @@ namespace UICatalog.Scenarios {
 				Y = Pos.Top (txtToFind) + 2,
 				Y = Pos.Top (txtToFind) + 2,
 				Checked = _matchCase
 				Checked = _matchCase
 			};
 			};
-			ckbMatchCase.Toggled += (e) => _matchCase = ckbMatchCase.Checked;
+			ckbMatchCase.Toggled += (e) => _matchCase = (bool)ckbMatchCase.Checked;
 			d.Add (ckbMatchCase);
 			d.Add (ckbMatchCase);
 
 
 			var ckbMatchWholeWord = new CheckBox ("Match _whole word") {
 			var ckbMatchWholeWord = new CheckBox ("Match _whole word") {
@@ -845,7 +845,7 @@ namespace UICatalog.Scenarios {
 				Y = Pos.Top (ckbMatchCase) + 1,
 				Y = Pos.Top (ckbMatchCase) + 1,
 				Checked = _matchWholeWord
 				Checked = _matchWholeWord
 			};
 			};
-			ckbMatchWholeWord.Toggled += (e) => _matchWholeWord = ckbMatchWholeWord.Checked;
+			ckbMatchWholeWord.Toggled += (e) => _matchWholeWord = (bool)ckbMatchWholeWord.Checked;
 			d.Add (ckbMatchWholeWord);
 			d.Add (ckbMatchWholeWord);
 
 
 			d.Width = label.Width + txtToFind.Width + btnFindNext.Width + 2;
 			d.Width = label.Width + txtToFind.Width + btnFindNext.Width + 2;
@@ -958,7 +958,7 @@ namespace UICatalog.Scenarios {
 				Y = Pos.Top (txtToFind) + 2,
 				Y = Pos.Top (txtToFind) + 2,
 				Checked = _matchCase
 				Checked = _matchCase
 			};
 			};
-			ckbMatchCase.Toggled += (e) => _matchCase = ckbMatchCase.Checked;
+			ckbMatchCase.Toggled += (e) => _matchCase = (bool)ckbMatchCase.Checked;
 			d.Add (ckbMatchCase);
 			d.Add (ckbMatchCase);
 
 
 			var ckbMatchWholeWord = new CheckBox ("Match _whole word") {
 			var ckbMatchWholeWord = new CheckBox ("Match _whole word") {
@@ -966,7 +966,7 @@ namespace UICatalog.Scenarios {
 				Y = Pos.Top (ckbMatchCase) + 1,
 				Y = Pos.Top (ckbMatchCase) + 1,
 				Checked = _matchWholeWord
 				Checked = _matchWholeWord
 			};
 			};
-			ckbMatchWholeWord.Toggled += (e) => _matchWholeWord = ckbMatchWholeWord.Checked;
+			ckbMatchWholeWord.Toggled += (e) => _matchWholeWord = (bool)ckbMatchWholeWord.Checked;
 			d.Add (ckbMatchWholeWord);
 			d.Add (ckbMatchWholeWord);
 
 
 			d.Width = lblWidth + txtToFind.Width + btnFindNext.Width + 2;
 			d.Width = lblWidth + txtToFind.Width + btnFindNext.Width + 2;

+ 8 - 8
UICatalog/Scenarios/ListViewWithSelection.cs

@@ -43,7 +43,7 @@ namespace UICatalog.Scenarios {
 				X = Pos.Right (_allowMarkingCB) + 1,
 				X = Pos.Right (_allowMarkingCB) + 1,
 				Y = 0,
 				Y = 0,
 				Height = 1,
 				Height = 1,
-				Visible = _allowMarkingCB.Checked
+				Visible = (bool)_allowMarkingCB.Checked
 			};
 			};
 			Win.Add (_allowMultipleCB);
 			Win.Add (_allowMultipleCB);
 			_allowMultipleCB.Toggled += AllowMultipleCB_Toggled;
 			_allowMultipleCB.Toggled += AllowMultipleCB_Toggled;
@@ -93,7 +93,7 @@ namespace UICatalog.Scenarios {
 				X = Pos.AnchorEnd (k.Length + 3),
 				X = Pos.AnchorEnd (k.Length + 3),
 				Y = 0,
 				Y = 0,
 			};
 			};
-			keepCheckBox.Toggled += (_) => _scrollBar.KeepContentAlwaysInViewport = keepCheckBox.Checked;
+			keepCheckBox.Toggled += (_) => _scrollBar.KeepContentAlwaysInViewport = (bool)keepCheckBox.Checked;
 			Win.Add (keepCheckBox);
 			Win.Add (keepCheckBox);
 		}
 		}
 
 
@@ -113,9 +113,9 @@ namespace UICatalog.Scenarios {
 			}
 			}
 		}
 		}
 
 
-		private void _customRenderCB_Toggled (bool prev)
+		private void _customRenderCB_Toggled (bool? prev)
 		{
 		{
-			if (prev) {
+			if (prev == true) {
 				_listView.SetSource (_scenarios);
 				_listView.SetSource (_scenarios);
 			} else {
 			} else {
 				_listView.Source = new ScenarioListDataSource (_scenarios);
 				_listView.Source = new ScenarioListDataSource (_scenarios);
@@ -124,16 +124,16 @@ namespace UICatalog.Scenarios {
 			Win.SetNeedsDisplay ();
 			Win.SetNeedsDisplay ();
 		}
 		}
 
 
-		private void AllowMarkingCB_Toggled (bool prev)
+		private void AllowMarkingCB_Toggled (bool? prev)
 		{
 		{
-			_listView.AllowsMarking = !prev;
+			_listView.AllowsMarking = (bool)!prev;
 			_allowMultipleCB.Visible = _listView.AllowsMarking;
 			_allowMultipleCB.Visible = _listView.AllowsMarking;
 			Win.SetNeedsDisplay ();
 			Win.SetNeedsDisplay ();
 		}
 		}
 
 
-		private void AllowMultipleCB_Toggled (bool prev)
+		private void AllowMultipleCB_Toggled (bool? prev)
 		{
 		{
-			_listView.AllowsMultipleSelection = !prev;
+			_listView.AllowsMultipleSelection = (bool)!prev;
 			Win.SetNeedsDisplay ();
 			Win.SetNeedsDisplay ();
 		}
 		}
 
 

+ 1 - 1
UICatalog/Scenarios/MessageBoxes.cs

@@ -148,7 +148,7 @@ namespace UICatalog.Scenarios {
 				Y = Pos.Top (label) + 2
 				Y = Pos.Top (label) + 2
 			};
 			};
 			ckbEffect3D.Toggled += (e) => {
 			ckbEffect3D.Toggled += (e) => {
-				border.Effect3D = !e;
+				border.Effect3D = (bool)!e;
 			};
 			};
 			frame.Add (ckbEffect3D);
 			frame.Add (ckbEffect3D);
 
 

+ 1 - 1
UICatalog/Scenarios/ProgressBarStyles.cs

@@ -121,7 +121,7 @@ namespace UICatalog.Scenarios {
 			};
 			};
 
 
 			ckbBidirectional.Toggled += (e) => {
 			ckbBidirectional.Toggled += (e) => {
-				ckbBidirectional.Checked = marqueesBlocksPB.BidirectionalMarquee = marqueesContinuousPB.BidirectionalMarquee = !e;
+				ckbBidirectional.Checked = marqueesBlocksPB.BidirectionalMarquee = marqueesContinuousPB.BidirectionalMarquee = (bool)!e;
 			};
 			};
 
 
 			_pulseTimer = new Timer ((_) => {
 			_pulseTimer = new Timer ((_) => {

+ 6 - 6
UICatalog/Scenarios/Scrolling.cs

@@ -237,29 +237,29 @@ namespace UICatalog.Scenarios {
 				Y = Pos.Bottom (scrollView) + 4,
 				Y = Pos.Bottom (scrollView) + 4,
 			};
 			};
 			hCheckBox.Toggled += (_) => {
 			hCheckBox.Toggled += (_) => {
-				if (!ahCheckBox.Checked) {
-					scrollView.ShowHorizontalScrollIndicator = hCheckBox.Checked;
+				if (ahCheckBox.Checked == false) {
+					scrollView.ShowHorizontalScrollIndicator = (bool)hCheckBox.Checked;
 				} else {
 				} else {
 					hCheckBox.Checked = true;
 					hCheckBox.Checked = true;
 					MessageBox.Query ("Message", "Disable Auto Hide Scrollbars first.", "Ok");
 					MessageBox.Query ("Message", "Disable Auto Hide Scrollbars first.", "Ok");
 				}
 				}
 			};
 			};
 			vCheckBox.Toggled += (_) => {
 			vCheckBox.Toggled += (_) => {
-				if (!ahCheckBox.Checked) {
-					scrollView.ShowVerticalScrollIndicator = vCheckBox.Checked;
+				if (ahCheckBox.Checked == false) {
+					scrollView.ShowVerticalScrollIndicator = (bool)vCheckBox.Checked;
 				} else {
 				} else {
 					vCheckBox.Checked = true;
 					vCheckBox.Checked = true;
 					MessageBox.Query ("Message", "Disable Auto Hide Scrollbars first.", "Ok");
 					MessageBox.Query ("Message", "Disable Auto Hide Scrollbars first.", "Ok");
 				}
 				}
 			};
 			};
 			ahCheckBox.Toggled += (_) => {
 			ahCheckBox.Toggled += (_) => {
-				scrollView.AutoHideScrollBars = ahCheckBox.Checked;
+				scrollView.AutoHideScrollBars = (bool)ahCheckBox.Checked;
 				hCheckBox.Checked = true;
 				hCheckBox.Checked = true;
 				vCheckBox.Checked = true;
 				vCheckBox.Checked = true;
 			};
 			};
 			Win.Add (ahCheckBox);
 			Win.Add (ahCheckBox);
 
 
-			keepCheckBox.Toggled += (_) => scrollView.KeepContentAlwaysInViewport = keepCheckBox.Checked;
+			keepCheckBox.Toggled += (_) => scrollView.KeepContentAlwaysInViewport = (bool)keepCheckBox.Checked;
 			Win.Add (keepCheckBox);
 			Win.Add (keepCheckBox);
 
 
 			var scrollView2 = new ScrollView (new Rect (55, 2, 20, 8)) {
 			var scrollView2 = new ScrollView (new Rect (55, 2, 20, 8)) {

+ 2 - 2
UICatalog/Scenarios/SendKeys.cs

@@ -106,8 +106,8 @@ namespace UICatalog.Scenarios {
 				foreach (var r in txtInput.Text.ToString ()) {
 				foreach (var r in txtInput.Text.ToString ()) {
 					var ck = char.IsLetter (r)
 					var ck = char.IsLetter (r)
 						? (ConsoleKey)char.ToUpper (r) : (ConsoleKey)r;
 						? (ConsoleKey)char.ToUpper (r) : (ConsoleKey)r;
-					Application.Driver.SendKeys (r, ck, ckbShift.Checked,
-						ckbAlt.Checked, ckbControl.Checked);
+					Application.Driver.SendKeys (r, ck, (bool)ckbShift.Checked,
+						(bool)ckbAlt.Checked, (bool)ckbControl.Checked);
 				}
 				}
 				lblShippedKeys.Text = rKeys;
 				lblShippedKeys.Text = rKeys;
 				lblShippedControlKeys.Text = rControlKeys;
 				lblShippedControlKeys.Text = rControlKeys;

+ 8 - 8
UICatalog/Scenarios/Text.cs

@@ -52,7 +52,7 @@ namespace UICatalog.Scenarios {
 				Width = Dim.Percent (50) - 1,
 				Width = Dim.Percent (50) - 1,
 				Height = Dim.Percent (30),
 				Height = Dim.Percent (30),
 			};
 			};
-			textView.Text = "TextView with some more test text. Unicode shouldn't 𝔹Aℝ𝔽!" ;
+			textView.Text = "TextView with some more test text. Unicode shouldn't 𝔹Aℝ𝔽!";
 			textView.DrawContent += TextView_DrawContent;
 			textView.DrawContent += TextView_DrawContent;
 
 
 			// This shows how to enable autocomplete in TextView.
 			// This shows how to enable autocomplete in TextView.
@@ -84,17 +84,17 @@ namespace UICatalog.Scenarios {
 			// single-line mode.
 			// single-line mode.
 			var chxMultiline = new CheckBox ("Multiline") {
 			var chxMultiline = new CheckBox ("Multiline") {
 				X = Pos.Left (textView),
 				X = Pos.Left (textView),
-				Y = Pos.Bottom (textView), 
+				Y = Pos.Bottom (textView),
 				Checked = true
 				Checked = true
 			};
 			};
-			chxMultiline.Toggled += (b) => textView.Multiline = b;
+			chxMultiline.Toggled += (b) => textView.Multiline = (bool)b;
 			Win.Add (chxMultiline);
 			Win.Add (chxMultiline);
 
 
 			var chxWordWrap = new CheckBox ("Word Wrap") {
 			var chxWordWrap = new CheckBox ("Word Wrap") {
 				X = Pos.Right (chxMultiline) + 2,
 				X = Pos.Right (chxMultiline) + 2,
 				Y = Pos.Top (chxMultiline)
 				Y = Pos.Top (chxMultiline)
 			};
 			};
-			chxWordWrap.Toggled += (b) => textView.WordWrap = b;
+			chxWordWrap.Toggled += (b) => textView.WordWrap = (bool)b;
 			Win.Add (chxWordWrap);
 			Win.Add (chxWordWrap);
 
 
 			// TextView captures Tabs (so users can enter /t into text) by default;
 			// TextView captures Tabs (so users can enter /t into text) by default;
@@ -108,15 +108,15 @@ namespace UICatalog.Scenarios {
 
 
 			Key keyTab = textView.GetKeyFromCommand (Command.Tab);
 			Key keyTab = textView.GetKeyFromCommand (Command.Tab);
 			Key keyBackTab = textView.GetKeyFromCommand (Command.BackTab);
 			Key keyBackTab = textView.GetKeyFromCommand (Command.BackTab);
-			chxCaptureTabs.Toggled += (b) => { 
-				if (b) {
+			chxCaptureTabs.Toggled += (b) => {
+				if (b == true) {
 					textView.AddKeyBinding (keyTab, Command.Tab);
 					textView.AddKeyBinding (keyTab, Command.Tab);
 					textView.AddKeyBinding (keyBackTab, Command.BackTab);
 					textView.AddKeyBinding (keyBackTab, Command.BackTab);
 				} else {
 				} else {
 					textView.ClearKeybinding (keyTab);
 					textView.ClearKeybinding (keyTab);
 					textView.ClearKeybinding (keyBackTab);
 					textView.ClearKeybinding (keyBackTab);
 				}
 				}
-				textView.WordWrap = b; 
+				textView.WordWrap = (bool)b;
 			};
 			};
 			Win.Add (chxCaptureTabs);
 			Win.Add (chxCaptureTabs);
 
 
@@ -138,7 +138,7 @@ namespace UICatalog.Scenarios {
 			labelMirroringHexEditor.Text = Encoding.UTF8.GetString (array, 0, array.Length);
 			labelMirroringHexEditor.Text = Encoding.UTF8.GetString (array, 0, array.Length);
 			hexEditor.Edited += (kv) => {
 			hexEditor.Edited += (kv) => {
 				hexEditor.ApplyEdits ();
 				hexEditor.ApplyEdits ();
-				var array = ((MemoryStream)hexEditor.Source).ToArray (); 
+				var array = ((MemoryStream)hexEditor.Source).ToArray ();
 				labelMirroringHexEditor.Text = Encoding.UTF8.GetString (array, 0, array.Length);
 				labelMirroringHexEditor.Text = Encoding.UTF8.GetString (array, 0, array.Length);
 			};
 			};
 			Win.Add (labelMirroringHexEditor);
 			Win.Add (labelMirroringHexEditor);

+ 5 - 5
UICatalog/Scenarios/TextAlignments.cs

@@ -60,12 +60,12 @@ namespace UICatalog.Scenarios {
 			var update = new Button ("_Update") {
 			var update = new Button ("_Update") {
 				X = Pos.Right (edit) + 1,
 				X = Pos.Right (edit) + 1,
 				Y = Pos.Bottom (edit) - 1,
 				Y = Pos.Bottom (edit) - 1,
-				
+
 			};
 			};
 			update.Clicked += () => {
 			update.Clicked += () => {
 				foreach (var alignment in alignments) {
 				foreach (var alignment in alignments) {
-					singleLines [(int) alignment].Text = edit.Text;
-					multipleLines [(int) alignment].Text = edit.Text;
+					singleLines [(int)alignment].Text = edit.Text;
+					multipleLines [(int)alignment].Text = edit.Text;
 				}
 				}
 			};
 			};
 			Win.Add (update);
 			Win.Add (update);
@@ -100,8 +100,8 @@ namespace UICatalog.Scenarios {
 
 
 			enableHotKeyCheckBox.Toggled += (previous) => {
 			enableHotKeyCheckBox.Toggled += (previous) => {
 				foreach (var alignment in alignments) {
 				foreach (var alignment in alignments) {
-					singleLines [(int)alignment].HotKeySpecifier = previous ? (Rune)0xffff : (Rune)'_';
-					multipleLines [(int)alignment].HotKeySpecifier = previous ? (Rune)0xffff : (Rune)'_';
+					singleLines [(int)alignment].HotKeySpecifier = previous == true ? (Rune)0xffff : (Rune)'_';
+					multipleLines [(int)alignment].HotKeySpecifier = previous == true ? (Rune)0xffff : (Rune)'_';
 				}
 				}
 				Win.SetNeedsDisplay ();
 				Win.SetNeedsDisplay ();
 				Win.LayoutSubviews ();
 				Win.LayoutSubviews ();

+ 1 - 1
UICatalog/Scenarios/TextAlignmentsAndDirection.cs

@@ -142,7 +142,7 @@ namespace UICatalog.Scenarios {
 			};
 			};
 
 
 			justifyCheckbox.Toggled += (prevtoggled) => {
 			justifyCheckbox.Toggled += (prevtoggled) => {
-				if (prevtoggled) {
+				if (prevtoggled == true) {
 					foreach (var t in mtxts) {
 					foreach (var t in mtxts) {
 						t.TextAlignment = (TextAlignment)((dynamic)t.Data).h;
 						t.TextAlignment = (TextAlignment)((dynamic)t.Data).h;
 						t.VerticalTextAlignment = (VerticalTextAlignment)((dynamic)t.Data).v;
 						t.VerticalTextAlignment = (VerticalTextAlignment)((dynamic)t.Data).v;

+ 3 - 3
UICatalog/Scenarios/TextFormatterDemo.cs

@@ -38,7 +38,7 @@ namespace UICatalog.Scenarios {
 			block.AppendLine ("  ░   ░ ░░▒░ ░ ░  ▒ ░ ░▒    ░  ▒   ░ ░▒  ░ ░");
 			block.AppendLine ("  ░   ░ ░░▒░ ░ ░  ▒ ░ ░▒    ░  ▒   ░ ░▒  ░ ░");
 			block.AppendLine ("░ ░   ░  ░░░ ░ ░  ▒ ░ ░   ░        ░  ░  ░  ");
 			block.AppendLine ("░ ░   ░  ░░░ ░ ░  ▒ ░ ░   ░        ░  ░  ░  ");
 			block.AppendLine ("      ░    ░      ░    ░  ░ ░            ░  ");
 			block.AppendLine ("      ░    ░      ░    ░  ░ ░            ░  ");
-			block.AppendLine ("                       ░  ░                 "); 
+			block.AppendLine ("                       ░  ░                 ");
 			blockText.Text = ustring.Make (block.ToString ()); // .Replace(" ", "\u00A0"); // \u00A0 is 'non-breaking space
 			blockText.Text = ustring.Make (block.ToString ()); // .Replace(" ", "\u00A0"); // \u00A0 is 'non-breaking space
 			Win.Add (blockText);
 			Win.Add (blockText);
 
 
@@ -82,8 +82,8 @@ namespace UICatalog.Scenarios {
 
 
 			unicodeCheckBox.Toggled += (previous) => {
 			unicodeCheckBox.Toggled += (previous) => {
 				foreach (var alignment in alignments) {
 				foreach (var alignment in alignments) {
-					singleLines [(int)alignment].Text = previous ? text : unicode;
-					multipleLines [(int)alignment].Text = previous ? text : unicode;
+					singleLines [(int)alignment].Text = previous == true ? text : unicode;
+					multipleLines [(int)alignment].Text = previous == true ? text : unicode;
 				}
 				}
 			};
 			};
 		}
 		}

+ 4 - 2
UICatalog/Scenarios/Unicode.cs

@@ -50,7 +50,7 @@ namespace UICatalog.Scenarios {
 
 
 			label = new Label ("Label (CanFocus):") { X = Pos.X (label), Y = Pos.Bottom (label) + 1 };
 			label = new Label ("Label (CanFocus):") { X = Pos.X (label), Y = Pos.Bottom (label) + 1 };
 			Win.Add (label);
 			Win.Add (label);
-			testlabel = new Label ("Стоял &он, дум великих полн") { X = 20, Y = Pos.Y (label), Width = Dim.Percent (50), CanFocus = true, HotKeySpecifier = new System.Rune('&') };
+			testlabel = new Label ("Стоял &он, дум великих полн") { X = 20, Y = Pos.Y (label), Width = Dim.Percent (50), CanFocus = true, HotKeySpecifier = new System.Rune ('&') };
 			Win.Add (testlabel);
 			Win.Add (testlabel);
 
 
 			label = new Label ("Button:") { X = Pos.X (label), Y = Pos.Bottom (label) + 1 };
 			label = new Label ("Button:") { X = Pos.X (label), Y = Pos.Bottom (label) + 1 };
@@ -61,7 +61,9 @@ namespace UICatalog.Scenarios {
 			label = new Label ("CheckBox:") { X = Pos.X (label), Y = Pos.Bottom (label) + 1 };
 			label = new Label ("CheckBox:") { X = Pos.X (label), Y = Pos.Bottom (label) + 1 };
 			Win.Add (label);
 			Win.Add (label);
 			var checkBox = new CheckBox (gitString) { X = 20, Y = Pos.Y (label), Width = Dim.Percent (50) };
 			var checkBox = new CheckBox (gitString) { X = 20, Y = Pos.Y (label), Width = Dim.Percent (50) };
-			Win.Add (checkBox);
+			var ckbAllowNull = new CheckBox ("Allow null checked") { X = Pos.Right (checkBox) + 1, Y = Pos.Y (label) };
+			ckbAllowNull.Toggled += (e) => checkBox.AllowNullChecked = (bool)!e;
+			Win.Add (checkBox, ckbAllowNull);
 
 
 			label = new Label ("ComboBox:") { X = Pos.X (label), Y = Pos.Bottom (label) + 1 };
 			label = new Label ("ComboBox:") { X = Pos.X (label), Y = Pos.Bottom (label) + 1 };
 			Win.Add (label);
 			Win.Add (label);

+ 4 - 4
UICatalog/Scenarios/Wizards.cs

@@ -201,9 +201,9 @@ namespace UICatalog.Scenarios {
 						Fraction = 0.42F
 						Fraction = 0.42F
 					};
 					};
 					thirdStep.Add (progLbl, progressBar);
 					thirdStep.Add (progLbl, progressBar);
-					thirdStep.Enabled = thirdStepEnabledCeckBox.Checked;
+					thirdStep.Enabled = (bool)thirdStepEnabledCeckBox.Checked;
 					thirdStepEnabledCeckBox.Toggled += (args) => {
 					thirdStepEnabledCeckBox.Toggled += (args) => {
-						thirdStep.Enabled = thirdStepEnabledCeckBox.Checked;
+						thirdStep.Enabled = (bool)thirdStepEnabledCeckBox.Checked;
 					};
 					};
 
 
 					// Add 4th step
 					// Add 4th step
@@ -276,9 +276,9 @@ namespace UICatalog.Scenarios {
 					var finalFinalStep = new Wizard.WizardStep ("The VERY last step");
 					var finalFinalStep = new Wizard.WizardStep ("The VERY last step");
 					wizard.AddStep (finalFinalStep);
 					wizard.AddStep (finalFinalStep);
 					finalFinalStep.HelpText = "This step only shows if it was enabled on the other last step.";
 					finalFinalStep.HelpText = "This step only shows if it was enabled on the other last step.";
-					finalFinalStep.Enabled = thirdStepEnabledCeckBox.Checked;
+					finalFinalStep.Enabled = (bool)thirdStepEnabledCeckBox.Checked;
 					finalFinalStepEnabledCeckBox.Toggled += (args) => {
 					finalFinalStepEnabledCeckBox.Toggled += (args) => {
-						finalFinalStep.Enabled = finalFinalStepEnabledCeckBox.Checked;
+						finalFinalStep.Enabled = (bool)finalFinalStepEnabledCeckBox.Checked;
 					};
 					};
 
 
 					Application.Run (wizard);
 					Application.Run (wizard);

+ 1 - 1
UnitTests/UICatalog/ScenarioTests.cs

@@ -299,7 +299,7 @@ namespace UICatalog.Tests {
 
 
 			_computedCheckBox.Toggled += (previousState) => {
 			_computedCheckBox.Toggled += (previousState) => {
 				if (_curView != null) {
 				if (_curView != null) {
-					_curView.LayoutStyle = previousState ? LayoutStyle.Absolute : LayoutStyle.Computed;
+					_curView.LayoutStyle = previousState == true ? LayoutStyle.Absolute : LayoutStyle.Computed;
 					_hostPane.LayoutSubviews ();
 					_hostPane.LayoutSubviews ();
 				}
 				}
 			};
 			};

+ 35 - 0
UnitTests/Views/CheckboxTests.cs

@@ -21,6 +21,7 @@ namespace Terminal.Gui.ViewTests {
 			var ckb = new CheckBox ();
 			var ckb = new CheckBox ();
 			Assert.True (ckb.AutoSize);
 			Assert.True (ckb.AutoSize);
 			Assert.False (ckb.Checked);
 			Assert.False (ckb.Checked);
+			Assert.False (ckb.AllowNullChecked);
 			Assert.Equal (string.Empty, ckb.Text);
 			Assert.Equal (string.Empty, ckb.Text);
 			Assert.Equal ("╴ ", ckb.TextFormatter.Text);
 			Assert.Equal ("╴ ", ckb.TextFormatter.Text);
 			Assert.True (ckb.CanFocus);
 			Assert.True (ckb.CanFocus);
@@ -29,6 +30,7 @@ namespace Terminal.Gui.ViewTests {
 			ckb = new CheckBox ("Test", true);
 			ckb = new CheckBox ("Test", true);
 			Assert.True (ckb.AutoSize);
 			Assert.True (ckb.AutoSize);
 			Assert.True (ckb.Checked);
 			Assert.True (ckb.Checked);
+			Assert.False (ckb.AllowNullChecked);
 			Assert.Equal ("Test", ckb.Text);
 			Assert.Equal ("Test", ckb.Text);
 			Assert.Equal ("√ Test", ckb.TextFormatter.Text);
 			Assert.Equal ("√ Test", ckb.TextFormatter.Text);
 			Assert.True (ckb.CanFocus);
 			Assert.True (ckb.CanFocus);
@@ -37,6 +39,7 @@ namespace Terminal.Gui.ViewTests {
 			ckb = new CheckBox (1, 2, "Test");
 			ckb = new CheckBox (1, 2, "Test");
 			Assert.True (ckb.AutoSize);
 			Assert.True (ckb.AutoSize);
 			Assert.False (ckb.Checked);
 			Assert.False (ckb.Checked);
+			Assert.False (ckb.AllowNullChecked);
 			Assert.Equal ("Test", ckb.Text);
 			Assert.Equal ("Test", ckb.Text);
 			Assert.Equal ("╴ Test", ckb.TextFormatter.Text);
 			Assert.Equal ("╴ Test", ckb.TextFormatter.Text);
 			Assert.True (ckb.CanFocus);
 			Assert.True (ckb.CanFocus);
@@ -45,6 +48,7 @@ namespace Terminal.Gui.ViewTests {
 			ckb = new CheckBox (3, 4, "Test", true);
 			ckb = new CheckBox (3, 4, "Test", true);
 			Assert.True (ckb.AutoSize);
 			Assert.True (ckb.AutoSize);
 			Assert.True (ckb.Checked);
 			Assert.True (ckb.Checked);
+			Assert.False (ckb.AllowNullChecked);
 			Assert.Equal ("Test", ckb.Text);
 			Assert.Equal ("Test", ckb.Text);
 			Assert.Equal ("√ Test", ckb.TextFormatter.Text);
 			Assert.Equal ("√ Test", ckb.TextFormatter.Text);
 			Assert.True (ckb.CanFocus);
 			Assert.True (ckb.CanFocus);
@@ -532,5 +536,36 @@ namespace Terminal.Gui.ViewTests {
 
 
 			TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
 			TestHelpers.AssertDriverContentsWithFrameAre (expected, output);
 		}
 		}
+
+		[Fact, AutoInitShutdown]
+		public void AllowNullChecked_Get_Set ()
+		{
+			var checkBox = new CheckBox ("Check this out 你");
+			var top = Application.Top;
+			top.Add (checkBox);
+			Application.Begin (top);
+
+			Assert.False (checkBox.Checked);
+			Assert.True (checkBox.ProcessKey (new KeyEvent (Key.Space, new KeyModifiers ())));
+			Assert.True (checkBox.Checked);
+			Assert.True (checkBox.MouseEvent (new MouseEvent () { X = 0, Y = 0, Flags = MouseFlags.Button1Clicked }));
+			Assert.False (checkBox.Checked);
+
+			checkBox.AllowNullChecked = true;
+			Assert.True (checkBox.ProcessKey (new KeyEvent (Key.Space, new KeyModifiers ())));
+			Assert.Null (checkBox.Checked);
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre (@"
+⍰ Check this out 你", output);
+			Assert.True (checkBox.MouseEvent (new MouseEvent () { X = 0, Y = 0, Flags = MouseFlags.Button1Clicked }));
+			Assert.True (checkBox.Checked);
+			Assert.True (checkBox.ProcessKey (new KeyEvent (Key.Space, new KeyModifiers ())));
+			Assert.False (checkBox.Checked);
+			Assert.True (checkBox.MouseEvent (new MouseEvent () { X = 0, Y = 0, Flags = MouseFlags.Button1Clicked }));
+			Assert.Null (checkBox.Checked);
+
+			checkBox.AllowNullChecked = false;
+			Assert.False (checkBox.Checked);
+		}
 	}
 	}
 }
 }