瀏覽代碼

Merge pull request #2313 from BDisp/nullable-bool-checked

Nullable bool checked
Tig 2 年之前
父節點
當前提交
5ca74089bb
共有 37 個文件被更改,包括 535 次插入299 次删除
  1. 5 0
      Terminal.Gui/Core/ConsoleDriver.cs
  2. 51 12
      Terminal.Gui/Views/CheckBox.cs
  3. 60 4
      Terminal.Gui/Views/Menu.cs
  4. 2 2
      UICatalog/Scenarios/AllViewsTester.cs
  5. 3 3
      UICatalog/Scenarios/AutoSizeAndDirectionText.cs
  6. 1 1
      UICatalog/Scenarios/BackgroundWorkerCollection.cs
  7. 4 4
      UICatalog/Scenarios/Borders.cs
  8. 2 2
      UICatalog/Scenarios/BordersOnFrameView.cs
  9. 2 2
      UICatalog/Scenarios/BordersOnToplevel.cs
  10. 2 2
      UICatalog/Scenarios/BordersOnWindow.cs
  11. 2 2
      UICatalog/Scenarios/ClassExplorer.cs
  12. 2 2
      UICatalog/Scenarios/CollectionNavigatorTester.cs
  13. 1 1
      UICatalog/Scenarios/ContextMenus.cs
  14. 5 5
      UICatalog/Scenarios/Dialogs.cs
  15. 33 16
      UICatalog/Scenarios/DynamicMenuBar.cs
  16. 12 12
      UICatalog/Scenarios/Editor.cs
  17. 2 2
      UICatalog/Scenarios/HexEditor.cs
  18. 8 8
      UICatalog/Scenarios/ListViewWithSelection.cs
  19. 1 1
      UICatalog/Scenarios/MessageBoxes.cs
  20. 1 1
      UICatalog/Scenarios/ProgressBarStyles.cs
  21. 6 6
      UICatalog/Scenarios/Scrolling.cs
  22. 2 2
      UICatalog/Scenarios/SendKeys.cs
  23. 1 1
      UICatalog/Scenarios/SyntaxHighlighting.cs
  24. 3 3
      UICatalog/Scenarios/TabViewExample.cs
  25. 147 156
      UICatalog/Scenarios/TableEditor.cs
  26. 8 8
      UICatalog/Scenarios/Text.cs
  27. 5 5
      UICatalog/Scenarios/TextAlignments.cs
  28. 1 1
      UICatalog/Scenarios/TextAlignmentsAndDirection.cs
  29. 3 3
      UICatalog/Scenarios/TextFormatterDemo.cs
  30. 11 11
      UICatalog/Scenarios/TextViewAutocompletePopup.cs
  31. 9 9
      UICatalog/Scenarios/TreeViewFileSystem.cs
  32. 4 2
      UICatalog/Scenarios/Unicode.cs
  33. 4 4
      UICatalog/Scenarios/Wizards.cs
  34. 5 5
      UICatalog/UICatalog.cs
  35. 91 0
      UnitTests/Menus/MenuTests.cs
  36. 1 1
      UnitTests/UICatalog/ScenarioTests.cs
  37. 35 0
      UnitTests/Views/CheckBoxTests.cs

+ 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 → 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;
 		}
 		}

+ 60 - 4
Terminal.Gui/Views/Menu.cs

@@ -33,6 +33,9 @@ namespace Terminal.Gui {
 	public class MenuItem {
 	public class MenuItem {
 		ustring title;
 		ustring title;
 		ShortcutHelper shortcutHelper;
 		ShortcutHelper shortcutHelper;
+		bool allowNullChecked;
+		MenuItemCheckStyle checkType;
+
 		internal int TitleLength => GetMenuBarItemLength (Title);
 		internal int TitleLength => GetMenuBarItemLength (Title);
 
 
 		/// <summary>
 		/// <summary>
@@ -158,19 +161,42 @@ namespace Terminal.Gui {
 		internal int Width => 1 + // space before Title
 		internal int Width => 1 + // space before Title
 			TitleLength +
 			TitleLength +
 			2 + // space after Title - BUGBUG: This should be 1 
 			2 + // space after Title - BUGBUG: This should be 1 
-			(Checked || CheckType.HasFlag (MenuItemCheckStyle.Checked) || CheckType.HasFlag (MenuItemCheckStyle.Radio) ? 2 : 0) + // check glyph + space 
+			(Checked == true || CheckType.HasFlag (MenuItemCheckStyle.Checked) || CheckType.HasFlag (MenuItemCheckStyle.Radio) ? 2 : 0) + // check glyph + space 
 			(Help.ConsoleWidth > 0 ? 2 + Help.ConsoleWidth : 0) + // Two spaces before Help
 			(Help.ConsoleWidth > 0 ? 2 + Help.ConsoleWidth : 0) + // Two spaces before Help
 			(ShortcutTag.ConsoleWidth > 0 ? 2 + ShortcutTag.ConsoleWidth : 0); // Pad two spaces before shortcut tag (which are also aligned right)
 			(ShortcutTag.ConsoleWidth > 0 ? 2 + ShortcutTag.ConsoleWidth : 0); // Pad two spaces before shortcut tag (which are also aligned right)
 
 
 		/// <summary>
 		/// <summary>
 		/// Sets or gets whether the <see cref="MenuItem"/> shows a check indicator or not. See <see cref="MenuItemCheckStyle"/>.
 		/// Sets or gets whether the <see cref="MenuItem"/> shows a check indicator or not. See <see cref="MenuItemCheckStyle"/>.
 		/// </summary>
 		/// </summary>
-		public bool Checked { set; get; }
+		public bool? Checked { set; get; }
+
+		/// <summary>
+		/// Used only if <see cref="CheckType"/> is of <see cref="MenuItemCheckStyle.Checked"/> type.
+		/// 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;
+				}
+			}
+		}
 
 
 		/// <summary>
 		/// <summary>
 		/// Sets or gets the <see cref="MenuItemCheckStyle"/> of a menu item where <see cref="Checked"/> is set to <see langword="true"/>.
 		/// Sets or gets the <see cref="MenuItemCheckStyle"/> of a menu item where <see cref="Checked"/> is set to <see langword="true"/>.
 		/// </summary>
 		/// </summary>
-		public MenuItemCheckStyle CheckType { get; set; }
+		public MenuItemCheckStyle CheckType {
+			get => checkType;
+			set {
+				checkType = value;
+				if (checkType == MenuItemCheckStyle.Checked && !allowNullChecked && Checked == null) {
+					Checked = false;
+				}
+			}
+		}
 
 
 		/// <summary>
 		/// <summary>
 		/// Gets the parent for this <see cref="MenuItem"/>.
 		/// Gets the parent for this <see cref="MenuItem"/>.
@@ -199,6 +225,33 @@ namespace Terminal.Gui {
 			return IsFromSubMenu;
 			return IsFromSubMenu;
 		}
 		}
 
 
+		/// <summary>
+		/// Toggle the <see cref="Checked"/> between three states if <see cref="AllowNullChecked"/> is <see langword="true"/>
+		/// or between two states if <see cref="AllowNullChecked"/> is <see langword="false"/>.
+		/// </summary>
+		public void ToggleChecked ()
+		{
+			if (checkType != MenuItemCheckStyle.Checked) {
+				throw new InvalidOperationException ("This isn't a Checked MenuItemCheckStyle!");
+			}
+			var previousChecked = Checked;
+			if (AllowNullChecked) {
+				switch (previousChecked) {
+				case null:
+					Checked = true;
+					break;
+				case true:
+					Checked = false;
+					break;
+				case false:
+					Checked = null;
+					break;
+				}
+			} else {
+				Checked = !Checked;
+			}
+		}
+
 		void GetHotKey ()
 		void GetHotKey ()
 		{
 		{
 			bool nextIsHot = false;
 			bool nextIsHot = false;
@@ -500,6 +553,7 @@ namespace Terminal.Gui {
 				}
 				}
 
 
 				ustring textToDraw;
 				ustring textToDraw;
+				var nullCheckedChar = Driver.NullChecked;
 				var checkChar = Driver.Selected;
 				var checkChar = Driver.Selected;
 				var uncheckedChar = Driver.UnSelected;
 				var uncheckedChar = Driver.UnSelected;
 
 
@@ -509,7 +563,9 @@ namespace Terminal.Gui {
 				}
 				}
 
 
 				// Support Checked even though CheckType wasn't set
 				// Support Checked even though CheckType wasn't set
-				if (item.Checked) {
+				if (item.CheckType == MenuItemCheckStyle.Checked && item.Checked == null) {
+					textToDraw = ustring.Make (new Rune [] { nullCheckedChar, ' ' }) + item.Title;
+				} else if (item.Checked == true) {
 					textToDraw = ustring.Make (new Rune [] { checkChar, ' ' }) + item.Title;
 					textToDraw = ustring.Make (new Rune [] { checkChar, ' ' }) + item.Title;
 				} else if (item.CheckType.HasFlag (MenuItemCheckStyle.Checked) || item.CheckType.HasFlag (MenuItemCheckStyle.Radio)) {
 				} else if (item.CheckType.HasFlag (MenuItemCheckStyle.Checked) || item.CheckType.HasFlag (MenuItemCheckStyle.Radio)) {
 					textToDraw = ustring.Make (new Rune [] { uncheckedChar, ' ' }) + item.Title;
 					textToDraw = ustring.Make (new Rune [] { uncheckedChar, ' ' }) + item.Title;

+ 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;

+ 1 - 1
UICatalog/Scenarios/BackgroundWorkerCollection.cs

@@ -105,7 +105,7 @@ namespace UICatalog.Scenarios {
 				}
 				}
 				item.Action += () => {
 				item.Action += () => {
 					var top = Application.MdiChildes.Find ((x) => x.Data.ToString () == "WorkerApp");
 					var top = Application.MdiChildes.Find ((x) => x.Data.ToString () == "WorkerApp");
-					item.Checked = top.Visible = !item.Checked;
+					item.Checked = top.Visible = (bool)!item.Checked;
 					if (top.Visible) {
 					if (top.Visible) {
 						top.ShowChild ();
 						top.ShowChild ();
 					} else {
 					} else {

+ 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 { }
 			};
 			};
 
 

+ 2 - 2
UICatalog/Scenarios/ClassExplorer.cs

@@ -78,7 +78,7 @@ namespace UICatalog.Scenarios {
 					highlightModelTextOnly = new MenuItem ("_Highlight Model Text Only", "", () => OnCheckHighlightModelTextOnly()) {
 					highlightModelTextOnly = new MenuItem ("_Highlight Model Text Only", "", () => OnCheckHighlightModelTextOnly()) {
 						CheckType = MenuItemCheckStyle.Checked
 						CheckType = MenuItemCheckStyle.Checked
 					},
 					},
-				}) 
+				})
 			});
 			});
 			Application.Top.Add (menu);
 			Application.Top.Add (menu);
 
 
@@ -122,7 +122,7 @@ namespace UICatalog.Scenarios {
 
 
 		private BindingFlags GetFlags ()
 		private BindingFlags GetFlags ()
 		{
 		{
-			if (miShowPrivate.Checked) {
+			if (miShowPrivate.Checked == true) {
 				return BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
 				return BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
 			}
 			}
 
 

+ 2 - 2
UICatalog/Scenarios/CollectionNavigatorTester.cs

@@ -90,7 +90,7 @@ namespace UICatalog.Scenarios {
 				Checked = false
 				Checked = false
 			};
 			};
 			allowMultiSelection.Action = () => allowMultiSelection.Checked = _listView.AllowsMultipleSelection = !_listView.AllowsMultipleSelection;
 			allowMultiSelection.Action = () => allowMultiSelection.Checked = _listView.AllowsMultipleSelection = !_listView.AllowsMultipleSelection;
-			allowMultiSelection.CanExecute = () => allowMarking.Checked;
+			allowMultiSelection.CanExecute = () => (bool)allowMarking.Checked;
 
 
 			var menu = new MenuBar (new MenuBarItem [] {
 			var menu = new MenuBar (new MenuBarItem [] {
 				new MenuBarItem ("_Configure", new MenuItem [] {
 				new MenuBarItem ("_Configure", new MenuItem [] {
@@ -156,7 +156,7 @@ namespace UICatalog.Scenarios {
 				TextAlignment = TextAlignment.Centered,
 				TextAlignment = TextAlignment.Centered,
 				X = Pos.Right (_listView) + 2,
 				X = Pos.Right (_listView) + 2,
 				Y = 1, // for menu
 				Y = 1, // for menu
-				Width = Dim.Percent	 (50),
+				Width = Dim.Percent (50),
 				Height = 1,
 				Height = 1,
 			};
 			};
 			Application.Top.Add (label);
 			Application.Top.Add (label);

+ 1 - 1
UICatalog/Scenarios/ContextMenus.cs

@@ -106,7 +106,7 @@ namespace UICatalog.Scenarios {
 						tfBottomRight.ContextMenu.ForceMinimumPosToZero = forceMinimumPosToZero;
 						tfBottomRight.ContextMenu.ForceMinimumPosToZero = forceMinimumPosToZero;
 					}) { CheckType = MenuItemCheckStyle.Checked, Checked = forceMinimumPosToZero },
 					}) { CheckType = MenuItemCheckStyle.Checked, Checked = forceMinimumPosToZero },
 					miUseSubMenusSingleFrame = new MenuItem ("Use_SubMenusSingleFrame", "",
 					miUseSubMenusSingleFrame = new MenuItem ("Use_SubMenusSingleFrame", "",
-						() => contextMenu.UseSubMenusSingleFrame = miUseSubMenusSingleFrame.Checked = useSubMenusSingleFrame = !useSubMenusSingleFrame) {
+						() => contextMenu.UseSubMenusSingleFrame = (bool)(miUseSubMenusSingleFrame.Checked = useSubMenusSingleFrame = !useSubMenusSingleFrame)) {
 							CheckType = MenuItemCheckStyle.Checked, Checked = useSubMenusSingleFrame
 							CheckType = MenuItemCheckStyle.Checked, Checked = useSubMenusSingleFrame
 						},
 						},
 					null,
 					null,

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

+ 33 - 16
UICatalog/Scenarios/DynamicMenuBar.cs

@@ -42,6 +42,7 @@ namespace UICatalog.Scenarios {
 			public bool hasSubMenu;
 			public bool hasSubMenu;
 			public MenuItemCheckStyle checkStyle;
 			public MenuItemCheckStyle checkStyle;
 			public ustring shortcut;
 			public ustring shortcut;
+			public bool allowNullChecked;
 
 
 			public DynamicMenuItem () { }
 			public DynamicMenuItem () { }
 
 
@@ -51,7 +52,7 @@ namespace UICatalog.Scenarios {
 				this.hasSubMenu = hasSubMenu;
 				this.hasSubMenu = hasSubMenu;
 			}
 			}
 
 
-			public DynamicMenuItem (ustring title, ustring help, ustring action, bool isTopLevel, bool hasSubMenu, MenuItemCheckStyle checkStyle = MenuItemCheckStyle.NoCheck, ustring shortcut = null)
+			public DynamicMenuItem (ustring title, ustring help, ustring action, bool isTopLevel, bool hasSubMenu, MenuItemCheckStyle checkStyle = MenuItemCheckStyle.NoCheck, ustring shortcut = null, bool allowNullChecked = false)
 			{
 			{
 				this.title = title;
 				this.title = title;
 				this.help = help;
 				this.help = help;
@@ -60,6 +61,7 @@ namespace UICatalog.Scenarios {
 				this.hasSubMenu = hasSubMenu;
 				this.hasSubMenu = hasSubMenu;
 				this.checkStyle = checkStyle;
 				this.checkStyle = checkStyle;
 				this.shortcut = shortcut;
 				this.shortcut = shortcut;
+				this.allowNullChecked = allowNullChecked;
 			}
 			}
 		}
 		}
 
 
@@ -310,8 +312,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,
@@ -564,6 +566,7 @@ namespace UICatalog.Scenarios {
 						newMenu.CheckType = item.checkStyle;
 						newMenu.CheckType = item.checkStyle;
 						newMenu.Action = _frmMenuDetails.CreateAction (newMenu, item);
 						newMenu.Action = _frmMenuDetails.CreateAction (newMenu, item);
 						newMenu.Shortcut = ShortcutHelper.GetShortcutFromTag (item.shortcut);
 						newMenu.Shortcut = ShortcutHelper.GetShortcutFromTag (item.shortcut);
+						newMenu.AllowNullChecked = item.allowNullChecked;
 					} else if (item.isTopLevel) {
 					} else if (item.isTopLevel) {
 						newMenu = new MenuBarItem (item.title, item.help, null);
 						newMenu = new MenuBarItem (item.title, item.help, null);
 						newMenu.Action = _frmMenuDetails.CreateAction (newMenu, item);
 						newMenu.Action = _frmMenuDetails.CreateAction (newMenu, item);
@@ -635,6 +638,7 @@ namespace UICatalog.Scenarios {
 			public TextView _txtAction;
 			public TextView _txtAction;
 			public CheckBox _ckbIsTopLevel;
 			public CheckBox _ckbIsTopLevel;
 			public CheckBox _ckbSubMenu;
 			public CheckBox _ckbSubMenu;
+			public CheckBox _ckbNullCheck;
 			public RadioGroup _rbChkStyle;
 			public RadioGroup _rbChkStyle;
 			public TextField _txtShortcut;
 			public TextField _txtShortcut;
 
 
@@ -700,6 +704,12 @@ namespace UICatalog.Scenarios {
 				};
 				};
 				Add (_ckbSubMenu);
 				Add (_ckbSubMenu);
 
 
+				_ckbNullCheck = new CheckBox ("Allow null checked") {
+					X = Pos.Left (_lblTitle),
+					Y = Pos.Bottom (_ckbSubMenu)
+				};
+				Add (_ckbNullCheck);
+
 				var _rChkLabels = new ustring [] { "NoCheck", "Checked", "Radio" };
 				var _rChkLabels = new ustring [] { "NoCheck", "Checked", "Radio" };
 				_rbChkStyle = new RadioGroup (_rChkLabels) {
 				_rbChkStyle = new RadioGroup (_rChkLabels) {
 					X = Pos.Left (_lblTitle),
 					X = Pos.Left (_lblTitle),
@@ -780,18 +790,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 +815,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 +832,12 @@ 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;
+					}
+				};
+				_ckbNullCheck.Toggled += (e) => {
+					if (_menuItem != null) {
+						_menuItem.AllowNullChecked = (bool)_ckbNullCheck.Checked;
 					}
 					}
 				};
 				};
 
 
@@ -842,6 +857,7 @@ namespace UICatalog.Scenarios {
 					_txtAction.Text = m.action;
 					_txtAction.Text = m.action;
 					_ckbIsTopLevel.Checked = false;
 					_ckbIsTopLevel.Checked = false;
 					_ckbSubMenu.Checked = !hasParent;
 					_ckbSubMenu.Checked = !hasParent;
+					_ckbNullCheck.Checked = false;
 					_txtHelp.Enabled = hasParent;
 					_txtHelp.Enabled = hasParent;
 					_txtAction.Enabled = hasParent;
 					_txtAction.Enabled = hasParent;
 					_txtShortcut.Enabled = hasParent;
 					_txtShortcut.Enabled = hasParent;
@@ -876,11 +892,11 @@ 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, (bool)_ckbNullCheck.Checked);
 				} else {
 				} else {
 					return null;
 					return null;
 				}
 				}
@@ -903,11 +919,12 @@ 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;
+				_ckbNullCheck.Checked = menuItem.AllowNullChecked;
+				_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 ()
@@ -963,7 +980,7 @@ namespace UICatalog.Scenarios {
 				case MenuItemCheckStyle.NoCheck:
 				case MenuItemCheckStyle.NoCheck:
 					return new Action (() => MessageBox.ErrorQuery (item.title, item.action, "Ok"));
 					return new Action (() => MessageBox.ErrorQuery (item.title, item.action, "Ok"));
 				case MenuItemCheckStyle.Checked:
 				case MenuItemCheckStyle.Checked:
-					return new Action (() => menuItem.Checked = !menuItem.Checked);
+					return new Action (menuItem.ToggleChecked);
 				case MenuItemCheckStyle.Radio:
 				case MenuItemCheckStyle.Radio:
 					break;
 					break;
 				}
 				}

+ 12 - 12
UICatalog/Scenarios/Editor.cs

@@ -514,7 +514,7 @@ namespace UICatalog.Scenarios {
 			item.Title = "Keep Content Always In Viewport";
 			item.Title = "Keep Content Always In Viewport";
 			item.CheckType |= MenuItemCheckStyle.Checked;
 			item.CheckType |= MenuItemCheckStyle.Checked;
 			item.Checked = true;
 			item.Checked = true;
-			item.Action += () => _scrollBar.KeepContentAlwaysInViewport = item.Checked = !item.Checked;
+			item.Action += () => _scrollBar.KeepContentAlwaysInViewport = (bool)(item.Checked = !item.Checked);
 
 
 			return new MenuItem [] { item };
 			return new MenuItem [] { item };
 		}
 		}
@@ -527,7 +527,7 @@ namespace UICatalog.Scenarios {
 			item.CheckType |= MenuItemCheckStyle.Checked;
 			item.CheckType |= MenuItemCheckStyle.Checked;
 			item.Checked = _textView.WordWrap;
 			item.Checked = _textView.WordWrap;
 			item.Action += () => {
 			item.Action += () => {
-				_textView.WordWrap = item.Checked = !item.Checked;
+				_textView.WordWrap = (bool)(item.Checked = !item.Checked);
 				if (_textView.WordWrap) {
 				if (_textView.WordWrap) {
 					_scrollBar.OtherScrollBarView.ShowScrollIndicator = false;
 					_scrollBar.OtherScrollBarView.ShowScrollIndicator = false;
 					_textView.BottomOffset = 0;
 					_textView.BottomOffset = 0;
@@ -546,7 +546,7 @@ namespace UICatalog.Scenarios {
 			auto.CheckType |= MenuItemCheckStyle.Checked;
 			auto.CheckType |= MenuItemCheckStyle.Checked;
 			auto.Checked = false;
 			auto.Checked = false;
 			auto.Action += () => {
 			auto.Action += () => {
-				if (auto.Checked = !auto.Checked) {
+				if ((bool)(auto.Checked = !auto.Checked)) {
 					// setup autocomplete with all words currently in the editor
 					// setup autocomplete with all words currently in the editor
 					_textView.Autocomplete.AllSuggestions =
 					_textView.Autocomplete.AllSuggestions =
 
 
@@ -570,7 +570,7 @@ namespace UICatalog.Scenarios {
 			item.CheckType |= MenuItemCheckStyle.Checked;
 			item.CheckType |= MenuItemCheckStyle.Checked;
 			item.Checked = _textView.AllowsTab;
 			item.Checked = _textView.AllowsTab;
 			item.Action += () => {
 			item.Action += () => {
-				_textView.AllowsTab = item.Checked = !item.Checked;
+				_textView.AllowsTab = (bool)(item.Checked = !item.Checked);
 			};
 			};
 
 
 			return item;
 			return item;
@@ -583,7 +583,7 @@ namespace UICatalog.Scenarios {
 			};
 			};
 			item.CheckType |= MenuItemCheckStyle.Checked;
 			item.CheckType |= MenuItemCheckStyle.Checked;
 			item.Checked = _textView.ReadOnly;
 			item.Checked = _textView.ReadOnly;
-			item.Action += () => _textView.ReadOnly = item.Checked = !item.Checked;
+			item.Action += () => _textView.ReadOnly = (bool)(item.Checked = !item.Checked);
 
 
 			return item;
 			return item;
 		}
 		}
@@ -596,7 +596,7 @@ namespace UICatalog.Scenarios {
 			item.CheckType |= MenuItemCheckStyle.Checked;
 			item.CheckType |= MenuItemCheckStyle.Checked;
 			item.Checked = _textView.CanFocus;
 			item.Checked = _textView.CanFocus;
 			item.Action += () => {
 			item.Action += () => {
-				_textView.CanFocus = item.Checked = !item.Checked;
+				_textView.CanFocus = (bool)(item.Checked = !item.Checked);
 				if (_textView.CanFocus) {
 				if (_textView.CanFocus) {
 					_textView.SetFocus ();
 					_textView.SetFocus ();
 				}
 				}
@@ -613,7 +613,7 @@ namespace UICatalog.Scenarios {
 			item.CheckType |= MenuItemCheckStyle.Checked;
 			item.CheckType |= MenuItemCheckStyle.Checked;
 			item.Checked = _textView.Enabled;
 			item.Checked = _textView.Enabled;
 			item.Action += () => {
 			item.Action += () => {
-				_textView.Enabled = item.Checked = !item.Checked;
+				_textView.Enabled = (bool)(item.Checked = !item.Checked);
 				if (_textView.Enabled) {
 				if (_textView.Enabled) {
 					_textView.SetFocus ();
 					_textView.SetFocus ();
 				}
 				}
@@ -630,7 +630,7 @@ namespace UICatalog.Scenarios {
 			item.CheckType |= MenuItemCheckStyle.Checked;
 			item.CheckType |= MenuItemCheckStyle.Checked;
 			item.Checked = _textView.Visible;
 			item.Checked = _textView.Visible;
 			item.Action += () => {
 			item.Action += () => {
-				_textView.Visible = item.Checked = !item.Checked;
+				_textView.Visible = (bool)(item.Checked = !item.Checked);
 				if (_textView.Visible) {
 				if (_textView.Visible) {
 					_textView.SetFocus ();
 					_textView.SetFocus ();
 				}
 				}
@@ -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;

+ 2 - 2
UICatalog/Scenarios/HexEditor.cs

@@ -72,7 +72,7 @@ namespace UICatalog.Scenarios {
 
 
 		private void ToggleAllowEdits ()
 		private void ToggleAllowEdits ()
 		{
 		{
-			_hexView.AllowEdits = miAllowEdits.Checked = !miAllowEdits.Checked;
+			_hexView.AllowEdits = (bool)(miAllowEdits.Checked = !miAllowEdits.Checked);
 		}
 		}
 
 
 		private void _hexView_Edited (System.Collections.Generic.KeyValuePair<long, byte> obj)
 		private void _hexView_Edited (System.Collections.Generic.KeyValuePair<long, byte> obj)
@@ -171,7 +171,7 @@ namespace UICatalog.Scenarios {
 			sb.Append ("Hello world.\n");
 			sb.Append ("Hello world.\n");
 			sb.Append ("This is a test of the Emergency Broadcast System.\n");
 			sb.Append ("This is a test of the Emergency Broadcast System.\n");
 
 
-			byte [] buffer = Encoding.Unicode.GetBytes (sb.ToString());
+			byte [] buffer = Encoding.Unicode.GetBytes (sb.ToString ());
 			MemoryStream ms = new MemoryStream (buffer);
 			MemoryStream ms = new MemoryStream (buffer);
 			FileStream file = new FileStream (fileName, FileMode.Create, FileAccess.Write);
 			FileStream file = new FileStream (fileName, FileMode.Create, FileAccess.Write);
 			ms.WriteTo (file);
 			ms.WriteTo (file);

+ 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;

+ 1 - 1
UICatalog/Scenarios/SyntaxHighlighting.cs

@@ -55,7 +55,7 @@ namespace UICatalog.Scenarios {
 		private void WordWrap ()
 		private void WordWrap ()
 		{
 		{
 			miWrap.Checked = !miWrap.Checked;
 			miWrap.Checked = !miWrap.Checked;
-			textView.WordWrap = miWrap.Checked;
+			textView.WordWrap = (bool)miWrap.Checked;
 		}
 		}
 
 
 		private void Quit ()
 		private void Quit ()

+ 3 - 3
UICatalog/Scenarios/TabViewExample.cs

@@ -176,21 +176,21 @@ namespace UICatalog.Scenarios {
 		{
 		{
 			miShowTopLine.Checked = !miShowTopLine.Checked;
 			miShowTopLine.Checked = !miShowTopLine.Checked;
 
 
-			tabView.Style.ShowTopLine = miShowTopLine.Checked;
+			tabView.Style.ShowTopLine = (bool)miShowTopLine.Checked;
 			tabView.ApplyStyleChanges ();
 			tabView.ApplyStyleChanges ();
 		}
 		}
 		private void ShowBorder ()
 		private void ShowBorder ()
 		{
 		{
 			miShowBorder.Checked = !miShowBorder.Checked;
 			miShowBorder.Checked = !miShowBorder.Checked;
 
 
-			tabView.Style.ShowBorder = miShowBorder.Checked;
+			tabView.Style.ShowBorder = (bool)miShowBorder.Checked;
 			tabView.ApplyStyleChanges ();
 			tabView.ApplyStyleChanges ();
 		}
 		}
 		private void SetTabsOnBottom ()
 		private void SetTabsOnBottom ()
 		{
 		{
 			miTabsOnBottom.Checked = !miTabsOnBottom.Checked;
 			miTabsOnBottom.Checked = !miTabsOnBottom.Checked;
 
 
-			tabView.Style.TabsOnBottom = miTabsOnBottom.Checked;
+			tabView.Style.TabsOnBottom = (bool)miTabsOnBottom.Checked;
 			tabView.ApplyStyleChanges ();
 			tabView.ApplyStyleChanges ();
 		}
 		}
 
 

+ 147 - 156
UICatalog/Scenarios/TableEditor.cs

@@ -14,8 +14,7 @@ namespace UICatalog.Scenarios {
 	[ScenarioCategory ("Dialogs")]
 	[ScenarioCategory ("Dialogs")]
 	[ScenarioCategory ("Text and Formatting")]
 	[ScenarioCategory ("Text and Formatting")]
 	[ScenarioCategory ("Top Level Windows")]
 	[ScenarioCategory ("Top Level Windows")]
-	public class TableEditor : Scenario 
-	{
+	public class TableEditor : Scenario {
 		TableView tableView;
 		TableView tableView;
 		private MenuItem miAlwaysShowHeaders;
 		private MenuItem miAlwaysShowHeaders;
 		private MenuItem miHeaderOverline;
 		private MenuItem miHeaderOverline;
@@ -35,7 +34,7 @@ namespace UICatalog.Scenarios {
 
 
 		public override void Setup ()
 		public override void Setup ()
 		{
 		{
-			Win.Title = this.GetName();
+			Win.Title = this.GetName ();
 			Win.Y = 1; // menu
 			Win.Y = 1; // menu
 			Win.Height = Dim.Fill (1); // status bar
 			Win.Height = Dim.Fill (1); // status bar
 			Application.Top.LayoutSubviews ();
 			Application.Top.LayoutSubviews ();
@@ -93,43 +92,43 @@ namespace UICatalog.Scenarios {
 
 
 			Win.Add (tableView);
 			Win.Add (tableView);
 
 
-			var selectedCellLabel = new Label(){
+			var selectedCellLabel = new Label () {
 				X = 0,
 				X = 0,
-				Y = Pos.Bottom(tableView),
+				Y = Pos.Bottom (tableView),
 				Text = "0,0",
 				Text = "0,0",
-				Width = Dim.Fill(),
+				Width = Dim.Fill (),
 				TextAlignment = TextAlignment.Right
 				TextAlignment = TextAlignment.Right
-				
+
 			};
 			};
 
 
-			Win.Add(selectedCellLabel);
+			Win.Add (selectedCellLabel);
 
 
 			tableView.SelectedCellChanged += (e) => { selectedCellLabel.Text = $"{tableView.SelectedRow},{tableView.SelectedColumn}"; };
 			tableView.SelectedCellChanged += (e) => { selectedCellLabel.Text = $"{tableView.SelectedRow},{tableView.SelectedColumn}"; };
 			tableView.CellActivated += EditCurrentCell;
 			tableView.CellActivated += EditCurrentCell;
 			tableView.KeyPress += TableViewKeyPress;
 			tableView.KeyPress += TableViewKeyPress;
 
 
-			SetupScrollBar();
+			SetupScrollBar ();
 
 
-			redColorScheme = new ColorScheme(){
+			redColorScheme = new ColorScheme () {
 				Disabled = Win.ColorScheme.Disabled,
 				Disabled = Win.ColorScheme.Disabled,
 				HotFocus = Win.ColorScheme.HotFocus,
 				HotFocus = Win.ColorScheme.HotFocus,
 				Focus = Win.ColorScheme.Focus,
 				Focus = Win.ColorScheme.Focus,
-				Normal = Application.Driver.MakeAttribute(Color.Red,Win.ColorScheme.Normal.Background)
+				Normal = Application.Driver.MakeAttribute (Color.Red, Win.ColorScheme.Normal.Background)
 			};
 			};
 
 
-			alternatingColorScheme = new ColorScheme(){
+			alternatingColorScheme = new ColorScheme () {
 
 
 				Disabled = Win.ColorScheme.Disabled,
 				Disabled = Win.ColorScheme.Disabled,
 				HotFocus = Win.ColorScheme.HotFocus,
 				HotFocus = Win.ColorScheme.HotFocus,
 				Focus = Win.ColorScheme.Focus,
 				Focus = Win.ColorScheme.Focus,
-				Normal = Application.Driver.MakeAttribute(Color.White,Color.BrightBlue)
+				Normal = Application.Driver.MakeAttribute (Color.White, Color.BrightBlue)
 			};
 			};
-			redColorSchemeAlt = new ColorScheme(){
+			redColorSchemeAlt = new ColorScheme () {
 
 
 				Disabled = Win.ColorScheme.Disabled,
 				Disabled = Win.ColorScheme.Disabled,
 				HotFocus = Win.ColorScheme.HotFocus,
 				HotFocus = Win.ColorScheme.HotFocus,
 				Focus = Win.ColorScheme.Focus,
 				Focus = Win.ColorScheme.Focus,
-				Normal = Application.Driver.MakeAttribute(Color.Red,Color.BrightBlue)
+				Normal = Application.Driver.MakeAttribute (Color.Red, Color.BrightBlue)
 			};
 			};
 
 
 			// if user clicks the mouse in TableView
 			// if user clicks the mouse in TableView
@@ -139,7 +138,7 @@ namespace UICatalog.Scenarios {
 
 
 				if (clickedCol != null) {
 				if (clickedCol != null) {
 					if (e.MouseEvent.Flags.HasFlag (MouseFlags.Button1Clicked)) {
 					if (e.MouseEvent.Flags.HasFlag (MouseFlags.Button1Clicked)) {
-						
+
 						// left click in a header
 						// left click in a header
 						SortColumn (clickedCol);
 						SortColumn (clickedCol);
 					} else if (e.MouseEvent.Flags.HasFlag (MouseFlags.Button3Clicked)) {
 					} else if (e.MouseEvent.Flags.HasFlag (MouseFlags.Button3Clicked)) {
@@ -153,7 +152,7 @@ namespace UICatalog.Scenarios {
 
 
 		private void ShowAllColumns ()
 		private void ShowAllColumns ()
 		{
 		{
-			foreach(var colStyle in tableView.Style.ColumnStyles) {
+			foreach (var colStyle in tableView.Style.ColumnStyles) {
 				colStyle.Value.Visible = true;
 				colStyle.Value.Visible = true;
 			}
 			}
 			tableView.Update ();
 			tableView.Update ();
@@ -181,7 +180,7 @@ namespace UICatalog.Scenarios {
 			foreach (DataColumn col in tableView.Table.Columns) {
 			foreach (DataColumn col in tableView.Table.Columns) {
 
 
 				// remove any lingering sort indicator
 				// remove any lingering sort indicator
-				col.ColumnName = TrimArrows(col.ColumnName);
+				col.ColumnName = TrimArrows (col.ColumnName);
 
 
 				// add a new one if this the one that is being sorted
 				// add a new one if this the one that is being sorted
 				if (col == clickedCol) {
 				if (col == clickedCol) {
@@ -250,8 +249,7 @@ namespace UICatalog.Scenarios {
 
 
 		private void SetMinAcceptableWidthToOne ()
 		private void SetMinAcceptableWidthToOne ()
 		{
 		{
-			foreach (DataColumn c in tableView.Table.Columns) 
-			{
+			foreach (DataColumn c in tableView.Table.Columns) {
 				var style = tableView.Style.GetOrCreateColumnStyle (c);
 				var style = tableView.Style.GetOrCreateColumnStyle (c);
 				style.MinAcceptableWidth = 1;
 				style.MinAcceptableWidth = 1;
 			}
 			}
@@ -259,7 +257,7 @@ namespace UICatalog.Scenarios {
 		private void SetMinAcceptableWidth ()
 		private void SetMinAcceptableWidth ()
 		{
 		{
 			var col = GetColumn ();
 			var col = GetColumn ();
-			RunColumnWidthDialog (col, "MinAcceptableWidth", (s,v)=>s.MinAcceptableWidth = v,(s)=>s.MinAcceptableWidth);
+			RunColumnWidthDialog (col, "MinAcceptableWidth", (s, v) => s.MinAcceptableWidth = v, (s) => s.MinAcceptableWidth);
 		}
 		}
 
 
 		private void SetMinWidth ()
 		private void SetMinWidth ()
@@ -274,7 +272,7 @@ namespace UICatalog.Scenarios {
 			RunColumnWidthDialog (col, "MaxWidth", (s, v) => s.MaxWidth = v, (s) => s.MaxWidth);
 			RunColumnWidthDialog (col, "MaxWidth", (s, v) => s.MaxWidth = v, (s) => s.MaxWidth);
 		}
 		}
 
 
-		private void RunColumnWidthDialog (DataColumn col, string prompt, Action<ColumnStyle,int> setter,Func<ColumnStyle,int> getter)
+		private void RunColumnWidthDialog (DataColumn col, string prompt, Action<ColumnStyle, int> setter, Func<ColumnStyle, int> getter)
 		{
 		{
 			var accepted = false;
 			var accepted = false;
 			var ok = new Button ("Ok", is_default: true);
 			var ok = new Button ("Ok", is_default: true);
@@ -292,7 +290,7 @@ namespace UICatalog.Scenarios {
 			};
 			};
 
 
 			var tf = new TextField () {
 			var tf = new TextField () {
-				Text = getter(style).ToString (),
+				Text = getter (style).ToString (),
 				X = 0,
 				X = 0,
 				Y = 2,
 				Y = 2,
 				Width = Dim.Fill ()
 				Width = Dim.Fill ()
@@ -306,7 +304,7 @@ namespace UICatalog.Scenarios {
 			if (accepted) {
 			if (accepted) {
 
 
 				try {
 				try {
-					setter (style, int.Parse (tf.Text.ToString()));
+					setter (style, int.Parse (tf.Text.ToString ()));
 				} catch (Exception ex) {
 				} catch (Exception ex) {
 					MessageBox.ErrorQuery (60, 20, "Failed to set", ex.Message, "Ok");
 					MessageBox.ErrorQuery (60, 20, "Failed to set", ex.Message, "Ok");
 				}
 				}
@@ -336,35 +334,32 @@ namespace UICatalog.Scenarios {
 			};*/
 			};*/
 
 
 			tableView.DrawContent += (e) => {
 			tableView.DrawContent += (e) => {
-				_scrollBar.Size = tableView.Table?.Rows?.Count ??0;
+				_scrollBar.Size = tableView.Table?.Rows?.Count ?? 0;
 				_scrollBar.Position = tableView.RowOffset;
 				_scrollBar.Position = tableView.RowOffset;
-			//	_scrollBar.OtherScrollBarView.Size = _listView.Maxlength - 1;
-			//	_scrollBar.OtherScrollBarView.Position = _listView.LeftItem;
+				//	_scrollBar.OtherScrollBarView.Size = _listView.Maxlength - 1;
+				//	_scrollBar.OtherScrollBarView.Position = _listView.LeftItem;
 				_scrollBar.Refresh ();
 				_scrollBar.Refresh ();
 			};
 			};
-		
+
 		}
 		}
 
 
 		private void TableViewKeyPress (View.KeyEventEventArgs e)
 		private void TableViewKeyPress (View.KeyEventEventArgs e)
 		{
 		{
-			if(e.KeyEvent.Key == Key.DeleteChar){
+			if (e.KeyEvent.Key == Key.DeleteChar) {
 
 
-				if(tableView.FullRowSelect)
-				{
+				if (tableView.FullRowSelect) {
 					// Delete button deletes all rows when in full row mode
 					// Delete button deletes all rows when in full row mode
-					foreach(int toRemove in tableView.GetAllSelectedCells().Select(p=>p.Y).Distinct().OrderByDescending(i=>i))
-						tableView.Table.Rows.RemoveAt(toRemove);
-				}
-				else{
+					foreach (int toRemove in tableView.GetAllSelectedCells ().Select (p => p.Y).Distinct ().OrderByDescending (i => i))
+						tableView.Table.Rows.RemoveAt (toRemove);
+				} else {
 
 
 					// otherwise set all selected cells to null
 					// otherwise set all selected cells to null
-					foreach(var pt in tableView.GetAllSelectedCells())
-					{
-						tableView.Table.Rows[pt.Y][pt.X] = DBNull.Value;
+					foreach (var pt in tableView.GetAllSelectedCells ()) {
+						tableView.Table.Rows [pt.Y] [pt.X] = DBNull.Value;
 					}
 					}
 				}
 				}
 
 
-				tableView.Update();
+				tableView.Update ();
 				e.Handled = true;
 				e.Handled = true;
 			}
 			}
 
 
@@ -373,85 +368,85 @@ namespace UICatalog.Scenarios {
 
 
 		private void ClearColumnStyles ()
 		private void ClearColumnStyles ()
 		{
 		{
-			tableView.Style.ColumnStyles.Clear();
-			tableView.Update();
+			tableView.Style.ColumnStyles.Clear ();
+			tableView.Update ();
 		}
 		}
 
 
 		private void ToggleAlwaysShowHeader ()
 		private void ToggleAlwaysShowHeader ()
 		{
 		{
 			miAlwaysShowHeaders.Checked = !miAlwaysShowHeaders.Checked;
 			miAlwaysShowHeaders.Checked = !miAlwaysShowHeaders.Checked;
-			tableView.Style.AlwaysShowHeaders = miAlwaysShowHeaders.Checked;
-			tableView.Update();
+			tableView.Style.AlwaysShowHeaders = (bool)miAlwaysShowHeaders.Checked;
+			tableView.Update ();
 		}
 		}
 
 
 		private void ToggleOverline ()
 		private void ToggleOverline ()
 		{
 		{
 			miHeaderOverline.Checked = !miHeaderOverline.Checked;
 			miHeaderOverline.Checked = !miHeaderOverline.Checked;
-			tableView.Style.ShowHorizontalHeaderOverline = miHeaderOverline.Checked;
-			tableView.Update();
+			tableView.Style.ShowHorizontalHeaderOverline = (bool)miHeaderOverline.Checked;
+			tableView.Update ();
 		}
 		}
 		private void ToggleHeaderMidline ()
 		private void ToggleHeaderMidline ()
 		{
 		{
 			miHeaderMidline.Checked = !miHeaderMidline.Checked;
 			miHeaderMidline.Checked = !miHeaderMidline.Checked;
-			tableView.Style.ShowVerticalHeaderLines = miHeaderMidline.Checked;
-			tableView.Update();
+			tableView.Style.ShowVerticalHeaderLines = (bool)miHeaderMidline.Checked;
+			tableView.Update ();
 		}
 		}
 		private void ToggleUnderline ()
 		private void ToggleUnderline ()
 		{
 		{
 			miHeaderUnderline.Checked = !miHeaderUnderline.Checked;
 			miHeaderUnderline.Checked = !miHeaderUnderline.Checked;
-			tableView.Style.ShowHorizontalHeaderUnderline = miHeaderUnderline.Checked;
-			tableView.Update();
+			tableView.Style.ShowHorizontalHeaderUnderline = (bool)miHeaderUnderline.Checked;
+			tableView.Update ();
 		}
 		}
 		private void ToggleHorizontalScrollIndicators ()
 		private void ToggleHorizontalScrollIndicators ()
 		{
 		{
 			miShowHorizontalScrollIndicators.Checked = !miShowHorizontalScrollIndicators.Checked;
 			miShowHorizontalScrollIndicators.Checked = !miShowHorizontalScrollIndicators.Checked;
-			tableView.Style.ShowHorizontalScrollIndicators = miShowHorizontalScrollIndicators.Checked;
-			tableView.Update();
+			tableView.Style.ShowHorizontalScrollIndicators = (bool)miShowHorizontalScrollIndicators.Checked;
+			tableView.Update ();
 		}
 		}
 		private void ToggleFullRowSelect ()
 		private void ToggleFullRowSelect ()
 		{
 		{
 			miFullRowSelect.Checked = !miFullRowSelect.Checked;
 			miFullRowSelect.Checked = !miFullRowSelect.Checked;
-			tableView.FullRowSelect= miFullRowSelect.Checked;
-			tableView.Update();
+			tableView.FullRowSelect = (bool)miFullRowSelect.Checked;
+			tableView.Update ();
 		}
 		}
 
 
-		private void ToggleExpandLastColumn()
+		private void ToggleExpandLastColumn ()
 		{
 		{
 			miExpandLastColumn.Checked = !miExpandLastColumn.Checked;
 			miExpandLastColumn.Checked = !miExpandLastColumn.Checked;
-			tableView.Style.ExpandLastColumn = miExpandLastColumn.Checked;
+			tableView.Style.ExpandLastColumn = (bool)miExpandLastColumn.Checked;
 
 
-			tableView.Update();
+			tableView.Update ();
 
 
 		}
 		}
-		private void ToggleSmoothScrolling()
+		private void ToggleSmoothScrolling ()
 		{
 		{
 			miSmoothScrolling.Checked = !miSmoothScrolling.Checked;
 			miSmoothScrolling.Checked = !miSmoothScrolling.Checked;
-			tableView.Style.SmoothHorizontalScrolling = miSmoothScrolling.Checked;
+			tableView.Style.SmoothHorizontalScrolling = (bool)miSmoothScrolling.Checked;
 
 
 			tableView.Update ();
 			tableView.Update ();
 
 
 		}
 		}
-		private void ToggleCellLines()
+		private void ToggleCellLines ()
 		{
 		{
 			miCellLines.Checked = !miCellLines.Checked;
 			miCellLines.Checked = !miCellLines.Checked;
-			tableView.Style.ShowVerticalCellLines = miCellLines.Checked;
-			tableView.Update();
+			tableView.Style.ShowVerticalCellLines = (bool)miCellLines.Checked;
+			tableView.Update ();
 		}
 		}
-		private void ToggleAllCellLines()
+		private void ToggleAllCellLines ()
 		{
 		{
 			tableView.Style.ShowHorizontalHeaderOverline = true;
 			tableView.Style.ShowHorizontalHeaderOverline = true;
 			tableView.Style.ShowVerticalHeaderLines = true;
 			tableView.Style.ShowVerticalHeaderLines = true;
 			tableView.Style.ShowHorizontalHeaderUnderline = true;
 			tableView.Style.ShowHorizontalHeaderUnderline = true;
 			tableView.Style.ShowVerticalCellLines = true;
 			tableView.Style.ShowVerticalCellLines = true;
-						
+
 			miHeaderOverline.Checked = true;
 			miHeaderOverline.Checked = true;
 			miHeaderMidline.Checked = true;
 			miHeaderMidline.Checked = true;
 			miHeaderUnderline.Checked = true;
 			miHeaderUnderline.Checked = true;
 			miCellLines.Checked = true;
 			miCellLines.Checked = true;
 
 
-			tableView.Update();
+			tableView.Update ();
 		}
 		}
-		private void ToggleNoCellLines()
+		private void ToggleNoCellLines ()
 		{
 		{
 			tableView.Style.ShowHorizontalHeaderOverline = false;
 			tableView.Style.ShowHorizontalHeaderOverline = false;
 			tableView.Style.ShowVerticalHeaderLines = false;
 			tableView.Style.ShowVerticalHeaderLines = false;
@@ -463,29 +458,27 @@ namespace UICatalog.Scenarios {
 			miHeaderUnderline.Checked = false;
 			miHeaderUnderline.Checked = false;
 			miCellLines.Checked = false;
 			miCellLines.Checked = false;
 
 
-			tableView.Update();
+			tableView.Update ();
 		}
 		}
 
 
-		private void ToggleAlternatingColors()
+		private void ToggleAlternatingColors ()
 		{
 		{
 			//toggle menu item
 			//toggle menu item
 			miAlternatingColors.Checked = !miAlternatingColors.Checked;
 			miAlternatingColors.Checked = !miAlternatingColors.Checked;
 
 
-			if(miAlternatingColors.Checked){
-				tableView.Style.RowColorGetter = (a)=> {return a.RowIndex%2==0 ? alternatingColorScheme : null;};
-			}
-			else
-			{
+			if (miAlternatingColors.Checked == true) {
+				tableView.Style.RowColorGetter = (a) => { return a.RowIndex % 2 == 0 ? alternatingColorScheme : null; };
+			} else {
 				tableView.Style.RowColorGetter = null;
 				tableView.Style.RowColorGetter = null;
 			}
 			}
-			tableView.SetNeedsDisplay();
+			tableView.SetNeedsDisplay ();
 		}
 		}
 
 
 		private void ToggleInvertSelectedCellFirstCharacter ()
 		private void ToggleInvertSelectedCellFirstCharacter ()
 		{
 		{
 			//toggle menu item
 			//toggle menu item
 			miCursor.Checked = !miCursor.Checked;
 			miCursor.Checked = !miCursor.Checked;
-			tableView.Style.InvertSelectedCellFirstCharacter = miCursor.Checked;
+			tableView.Style.InvertSelectedCellFirstCharacter = (bool)miCursor.Checked;
 			tableView.SetNeedsDisplay ();
 			tableView.SetNeedsDisplay ();
 		}
 		}
 		private void CloseExample ()
 		private void CloseExample ()
@@ -500,11 +493,11 @@ namespace UICatalog.Scenarios {
 
 
 		private void OpenExample (bool big)
 		private void OpenExample (bool big)
 		{
 		{
-			tableView.Table = BuildDemoDataTable(big ? 30 : 5, big ? 1000 : 5);
-			SetDemoTableStyles();
+			tableView.Table = BuildDemoDataTable (big ? 30 : 5, big ? 1000 : 5);
+			SetDemoTableStyles ();
 		}
 		}
 
 
-		private void OpenUnicodeMap()
+		private void OpenUnicodeMap ()
 		{
 		{
 			tableView.Table = BuildUnicodeMap ();
 			tableView.Table = BuildUnicodeMap ();
 			tableView.Update ();
 			tableView.Update ();
@@ -515,7 +508,7 @@ namespace UICatalog.Scenarios {
 			var dt = new DataTable ();
 			var dt = new DataTable ();
 
 
 			// add cols called 0 to 9
 			// add cols called 0 to 9
-			for (int i = 0; i < 10;i++) {
+			for (int i = 0; i < 10; i++) {
 
 
 				var col = dt.Columns.Add (i.ToString (), typeof (uint));
 				var col = dt.Columns.Add (i.ToString (), typeof (uint));
 				var style = tableView.Style.GetOrCreateColumnStyle (col);
 				var style = tableView.Style.GetOrCreateColumnStyle (col);
@@ -523,9 +516,9 @@ namespace UICatalog.Scenarios {
 			}
 			}
 
 
 			// add cols called a to z
 			// add cols called a to z
-			for (int i = 'a'; i < 'a'+26; i++) {
-				
-				var col =dt.Columns.Add (((char)i).ToString (), typeof (uint));
+			for (int i = 'a'; i < 'a' + 26; i++) {
+
+				var col = dt.Columns.Add (((char)i).ToString (), typeof (uint));
 				var style = tableView.Style.GetOrCreateColumnStyle (col);
 				var style = tableView.Style.GetOrCreateColumnStyle (col);
 				style.RepresentationGetter = (o) => new Rune ((uint)o).ToString ();
 				style.RepresentationGetter = (o) => new Rune ((uint)o).ToString ();
 			}
 			}
@@ -533,19 +526,19 @@ namespace UICatalog.Scenarios {
 			// now add table contents
 			// now add table contents
 			List<uint> runes = new List<uint> ();
 			List<uint> runes = new List<uint> ();
 
 
-			foreach(var range in Ranges) {
-				for(uint i=range.Start;i<=range.End;i++) {
+			foreach (var range in Ranges) {
+				for (uint i = range.Start; i <= range.End; i++) {
 					runes.Add (i);
 					runes.Add (i);
 				}
 				}
 			}
 			}
 
 
 			DataRow dr = null;
 			DataRow dr = null;
 
 
-			for(int i = 0; i<runes.Count;i++) {
-				if(dr == null || i% dt.Columns.Count == 0) {
+			for (int i = 0; i < runes.Count; i++) {
+				if (dr == null || i % dt.Columns.Count == 0) {
 					dr = dt.Rows.Add ();
 					dr = dt.Rows.Add ();
 				}
 				}
-				dr [i % dt.Columns.Count] = runes [i].ToString();
+				dr [i % dt.Columns.Count] = runes [i].ToString ();
 			}
 			}
 
 
 			return dt;
 			return dt;
@@ -716,52 +709,52 @@ namespace UICatalog.Scenarios {
 
 
 			var dateFormatStyle = new TableView.ColumnStyle () {
 			var dateFormatStyle = new TableView.ColumnStyle () {
 				Alignment = TextAlignment.Right,
 				Alignment = TextAlignment.Right,
-				RepresentationGetter = (v)=> v is DateTime d ? d.ToString("yyyy-MM-dd"):v.ToString()
+				RepresentationGetter = (v) => v is DateTime d ? d.ToString ("yyyy-MM-dd") : v.ToString ()
 			};
 			};
 
 
 			var negativeRight = new TableView.ColumnStyle () {
 			var negativeRight = new TableView.ColumnStyle () {
-				
+
 				Format = "0.##",
 				Format = "0.##",
 				MinWidth = 10,
 				MinWidth = 10,
-				AlignmentGetter = (v)=>v is double d ? 
+				AlignmentGetter = (v) => v is double d ?
 								// align negative values right
 								// align negative values right
-								d < 0 ? TextAlignment.Right : 
+								d < 0 ? TextAlignment.Right :
 								// align positive values left
 								// align positive values left
-								TextAlignment.Left:
+								TextAlignment.Left :
 								// not a double
 								// not a double
 								TextAlignment.Left,
 								TextAlignment.Left,
-				
-				ColorGetter = (a)=> a.CellValue is double d ? 
+
+				ColorGetter = (a) => a.CellValue is double d ?
 								// color 0 and negative values red
 								// color 0 and negative values red
-								d <= 0.0000001 ? a.RowIndex%2==0 && miAlternatingColors.Checked ? redColorSchemeAlt: redColorScheme : 
+								d <= 0.0000001 ? a.RowIndex % 2 == 0 && miAlternatingColors.Checked == true ? redColorSchemeAlt : redColorScheme :
 								// use normal scheme for positive values
 								// use normal scheme for positive values
-								null:
+								null :
 								// not a double
 								// not a double
 								null
 								null
 			};
 			};
-			
-			tableView.Style.ColumnStyles.Add(tableView.Table.Columns["DateCol"],dateFormatStyle);
-			tableView.Style.ColumnStyles.Add(tableView.Table.Columns["DoubleCol"],negativeRight);
-			tableView.Style.ColumnStyles.Add(tableView.Table.Columns["NullsCol"],alignMid);
-			tableView.Style.ColumnStyles.Add(tableView.Table.Columns["IntCol"],alignRight);
-			
-			tableView.Update();
+
+			tableView.Style.ColumnStyles.Add (tableView.Table.Columns ["DateCol"], dateFormatStyle);
+			tableView.Style.ColumnStyles.Add (tableView.Table.Columns ["DoubleCol"], negativeRight);
+			tableView.Style.ColumnStyles.Add (tableView.Table.Columns ["NullsCol"], alignMid);
+			tableView.Style.ColumnStyles.Add (tableView.Table.Columns ["IntCol"], alignRight);
+
+			tableView.Update ();
 		}
 		}
 
 
 		private void OpenSimple (bool big)
 		private void OpenSimple (bool big)
 		{
 		{
-			tableView.Table = BuildSimpleDataTable(big ? 30 : 5, big ? 1000 : 5);
+			tableView.Table = BuildSimpleDataTable (big ? 30 : 5, big ? 1000 : 5);
 		}
 		}
 
 
 		private void EditCurrentCell (TableView.CellActivatedEventArgs e)
 		private void EditCurrentCell (TableView.CellActivatedEventArgs e)
 		{
 		{
-			if(e.Table == null)
+			if (e.Table == null)
 				return;
 				return;
 			var o = e.Table.Rows [e.Row] [e.Col];
 			var o = e.Table.Rows [e.Row] [e.Col];
 
 
-			var title = o is uint u ? GetUnicodeCategory(u) + $"(0x{o:X4})" : "Enter new value";
+			var title = o is uint u ? GetUnicodeCategory (u) + $"(0x{o:X4})" : "Enter new value";
 
 
-			var oldValue = e.Table.Rows[e.Row][e.Col].ToString();
+			var oldValue = e.Table.Rows [e.Row] [e.Col].ToString ();
 			bool okPressed = false;
 			bool okPressed = false;
 
 
 			var ok = new Button ("Ok", is_default: true);
 			var ok = new Button ("Ok", is_default: true);
@@ -770,35 +763,33 @@ namespace UICatalog.Scenarios {
 			cancel.Clicked += () => { Application.RequestStop (); };
 			cancel.Clicked += () => { Application.RequestStop (); };
 			var d = new Dialog (title, 60, 20, ok, cancel);
 			var d = new Dialog (title, 60, 20, ok, cancel);
 
 
-			var lbl = new Label() {
+			var lbl = new Label () {
 				X = 0,
 				X = 0,
 				Y = 1,
 				Y = 1,
-				Text = e.Table.Columns[e.Col].ColumnName
+				Text = e.Table.Columns [e.Col].ColumnName
 			};
 			};
 
 
-			var tf = new TextField()
-				{
-					Text = oldValue,
-					X = 0,
-					Y = 2,
-					Width = Dim.Fill()
-				};
-			
-			d.Add (lbl,tf);
-			tf.SetFocus();
+			var tf = new TextField () {
+				Text = oldValue,
+				X = 0,
+				Y = 2,
+				Width = Dim.Fill ()
+			};
+
+			d.Add (lbl, tf);
+			tf.SetFocus ();
 
 
 			Application.Run (d);
 			Application.Run (d);
 
 
-			if(okPressed) {
+			if (okPressed) {
 
 
 				try {
 				try {
-					e.Table.Rows[e.Row][e.Col] = string.IsNullOrWhiteSpace(tf.Text.ToString()) ? DBNull.Value : (object)tf.Text;
-				}
-				catch(Exception ex) {
-					MessageBox.ErrorQuery(60,20,"Failed to set text", ex.Message,"Ok");
+					e.Table.Rows [e.Row] [e.Col] = string.IsNullOrWhiteSpace (tf.Text.ToString ()) ? DBNull.Value : (object)tf.Text;
+				} catch (Exception ex) {
+					MessageBox.ErrorQuery (60, 20, "Failed to set text", ex.Message, "Ok");
 				}
 				}
-				
-				tableView.Update();
+
+				tableView.Update ();
 			}
 			}
 		}
 		}
 
 
@@ -813,27 +804,27 @@ namespace UICatalog.Scenarios {
 		/// <param name="cols"></param>
 		/// <param name="cols"></param>
 		/// <param name="rows"></param>
 		/// <param name="rows"></param>
 		/// <returns></returns>
 		/// <returns></returns>
-		public static DataTable BuildDemoDataTable(int cols, int rows)
+		public static DataTable BuildDemoDataTable (int cols, int rows)
 		{
 		{
-			var dt = new DataTable();
+			var dt = new DataTable ();
 
 
 			int explicitCols = 6;
 			int explicitCols = 6;
-			dt.Columns.Add(new DataColumn("StrCol",typeof(string)));
-			dt.Columns.Add(new DataColumn("DateCol",typeof(DateTime)));
-			dt.Columns.Add(new DataColumn("IntCol",typeof(int)));
-			dt.Columns.Add(new DataColumn("DoubleCol",typeof(double)));
-			dt.Columns.Add(new DataColumn("NullsCol",typeof(string)));
-			dt.Columns.Add(new DataColumn("Unicode",typeof(string)));
-
-			for(int i=0;i< cols -explicitCols; i++) {
-				dt.Columns.Add("Column" + (i+explicitCols));
+			dt.Columns.Add (new DataColumn ("StrCol", typeof (string)));
+			dt.Columns.Add (new DataColumn ("DateCol", typeof (DateTime)));
+			dt.Columns.Add (new DataColumn ("IntCol", typeof (int)));
+			dt.Columns.Add (new DataColumn ("DoubleCol", typeof (double)));
+			dt.Columns.Add (new DataColumn ("NullsCol", typeof (string)));
+			dt.Columns.Add (new DataColumn ("Unicode", typeof (string)));
+
+			for (int i = 0; i < cols - explicitCols; i++) {
+				dt.Columns.Add ("Column" + (i + explicitCols));
 			}
 			}
-			
-			var r = new Random(100);
 
 
-			for(int i=0;i< rows;i++) {
-				
-				List<object> row = new List<object>(){ 
+			var r = new Random (100);
+
+			for (int i = 0; i < rows; i++) {
+
+				List<object> row = new List<object> (){
 					"Some long text that is super cool",
 					"Some long text that is super cool",
 					new DateTime(2000+i,12,25),
 					new DateTime(2000+i,12,25),
 					r.Next(i),
 					r.Next(i),
@@ -841,12 +832,12 @@ namespace UICatalog.Scenarios {
 					DBNull.Value,
 					DBNull.Value,
 					"Les Mise" + Char.ConvertFromUtf32(Int32.Parse("0301", NumberStyles.HexNumber)) + "rables"
 					"Les Mise" + Char.ConvertFromUtf32(Int32.Parse("0301", NumberStyles.HexNumber)) + "rables"
 				};
 				};
-				
-				for(int j=0;j< cols -explicitCols; j++) {
-					row.Add("SomeValue" + r.Next(100));
+
+				for (int j = 0; j < cols - explicitCols; j++) {
+					row.Add ("SomeValue" + r.Next (100));
 				}
 				}
 
 
-				dt.Rows.Add(row.ToArray());
+				dt.Rows.Add (row.ToArray ());
 			}
 			}
 
 
 			return dt;
 			return dt;
@@ -858,24 +849,24 @@ namespace UICatalog.Scenarios {
 		/// <param name="cols"></param>
 		/// <param name="cols"></param>
 		/// <param name="rows"></param>
 		/// <param name="rows"></param>
 		/// <returns></returns>
 		/// <returns></returns>
-		public static DataTable BuildSimpleDataTable(int cols, int rows)
+		public static DataTable BuildSimpleDataTable (int cols, int rows)
 		{
 		{
-			var dt = new DataTable();
+			var dt = new DataTable ();
 
 
-			for(int c = 0; c < cols; c++) {
-				dt.Columns.Add("Col"+c);
+			for (int c = 0; c < cols; c++) {
+				dt.Columns.Add ("Col" + c);
 			}
 			}
-				
-			for(int r = 0; r < rows; r++) {
-				var newRow = dt.NewRow();
 
 
-				for(int c = 0; c < cols; c++) {
-					newRow[c] = $"R{r}C{c}";
+			for (int r = 0; r < rows; r++) {
+				var newRow = dt.NewRow ();
+
+				for (int c = 0; c < cols; c++) {
+					newRow [c] = $"R{r}C{c}";
 				}
 				}
 
 
-				dt.Rows.Add(newRow);
+				dt.Rows.Add (newRow);
 			}
 			}
-			
+
 			return dt;
 			return dt;
 		}
 		}
 	}
 	}

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

+ 11 - 11
UICatalog/Scenarios/TextViewAutocompletePopup.cs

@@ -101,7 +101,7 @@ namespace UICatalog.Scenarios {
 			SetMultilineStatusText ();
 			SetMultilineStatusText ();
 			SetWrapStatusText ();
 			SetWrapStatusText ();
 
 
-			if (miMultiline.Checked) {
+			if (miMultiline.Checked == true) {
 				height = 10;
 				height = 10;
 			} else {
 			} else {
 				height = 1;
 				height = 1;
@@ -155,21 +155,21 @@ namespace UICatalog.Scenarios {
 		{
 		{
 			miMultiline.Checked = !miMultiline.Checked;
 			miMultiline.Checked = !miMultiline.Checked;
 			SetMultilineStatusText ();
 			SetMultilineStatusText ();
-			textViewTopLeft.Multiline = miMultiline.Checked;
-			textViewTopRight.Multiline = miMultiline.Checked;
-			textViewBottomLeft.Multiline = miMultiline.Checked;
-			textViewBottomRight.Multiline = miMultiline.Checked;
-			textViewCentered.Multiline = miMultiline.Checked;
+			textViewTopLeft.Multiline = (bool)miMultiline.Checked;
+			textViewTopRight.Multiline = (bool)miMultiline.Checked;
+			textViewBottomLeft.Multiline = (bool)miMultiline.Checked;
+			textViewBottomRight.Multiline = (bool)miMultiline.Checked;
+			textViewCentered.Multiline = (bool)miMultiline.Checked;
 		}
 		}
 
 
 		private void WordWrap ()
 		private void WordWrap ()
 		{
 		{
 			miWrap.Checked = !miWrap.Checked;
 			miWrap.Checked = !miWrap.Checked;
-			textViewTopLeft.WordWrap = miWrap.Checked;
-			textViewTopRight.WordWrap = miWrap.Checked;
-			textViewBottomLeft.WordWrap = miWrap.Checked;
-			textViewBottomRight.WordWrap = miWrap.Checked;
-			textViewCentered.WordWrap = miWrap.Checked;
+			textViewTopLeft.WordWrap = (bool)miWrap.Checked;
+			textViewTopRight.WordWrap = (bool)miWrap.Checked;
+			textViewBottomLeft.WordWrap = (bool)miWrap.Checked;
+			textViewBottomRight.WordWrap = (bool)miWrap.Checked;
+			textViewCentered.WordWrap = (bool)miWrap.Checked;
 			miWrap.Checked = textViewTopLeft.WordWrap;
 			miWrap.Checked = textViewTopLeft.WordWrap;
 			SetWrapStatusText ();
 			SetWrapStatusText ();
 		}
 		}

+ 9 - 9
UICatalog/Scenarios/TreeViewFileSystem.cs

@@ -164,7 +164,7 @@ namespace UICatalog.Scenarios {
 			{
 			{
 				Title = "Details";
 				Title = "Details";
 				Visible = true;
 				Visible = true;
-				CanFocus = true;				
+				CanFocus = true;
 			}
 			}
 
 
 			public FileSystemInfo FileInfo {
 			public FileSystemInfo FileInfo {
@@ -251,7 +251,7 @@ namespace UICatalog.Scenarios {
 		{
 		{
 			miShowLines.Checked = !miShowLines.Checked;
 			miShowLines.Checked = !miShowLines.Checked;
 
 
-			treeViewFiles.Style.ShowBranchLines = miShowLines.Checked;
+			treeViewFiles.Style.ShowBranchLines = (bool)miShowLines.Checked;
 			treeViewFiles.SetNeedsDisplay ();
 			treeViewFiles.SetNeedsDisplay ();
 		}
 		}
 
 
@@ -270,14 +270,14 @@ namespace UICatalog.Scenarios {
 		{
 		{
 			miColoredSymbols.Checked = !miColoredSymbols.Checked;
 			miColoredSymbols.Checked = !miColoredSymbols.Checked;
 
 
-			treeViewFiles.Style.ColorExpandSymbol = miColoredSymbols.Checked;
+			treeViewFiles.Style.ColorExpandSymbol = (bool)miColoredSymbols.Checked;
 			treeViewFiles.SetNeedsDisplay ();
 			treeViewFiles.SetNeedsDisplay ();
 		}
 		}
 		private void InvertExpandableSymbols ()
 		private void InvertExpandableSymbols ()
 		{
 		{
 			miInvertSymbols.Checked = !miInvertSymbols.Checked;
 			miInvertSymbols.Checked = !miInvertSymbols.Checked;
 
 
-			treeViewFiles.Style.InvertExpandSymbolColors = miInvertSymbols.Checked;
+			treeViewFiles.Style.InvertExpandSymbolColors = (bool)miInvertSymbols.Checked;
 			treeViewFiles.SetNeedsDisplay ();
 			treeViewFiles.SetNeedsDisplay ();
 		}
 		}
 
 
@@ -285,7 +285,7 @@ namespace UICatalog.Scenarios {
 		{
 		{
 			miFullPaths.Checked = !miFullPaths.Checked;
 			miFullPaths.Checked = !miFullPaths.Checked;
 
 
-			if (miFullPaths.Checked) {
+			if (miFullPaths.Checked == true) {
 				treeViewFiles.AspectGetter = (f) => f.FullName;
 				treeViewFiles.AspectGetter = (f) => f.FullName;
 			} else {
 			} else {
 				treeViewFiles.AspectGetter = (f) => f.Name;
 				treeViewFiles.AspectGetter = (f) => f.Name;
@@ -296,17 +296,17 @@ namespace UICatalog.Scenarios {
 		private void SetLeaveLastRow ()
 		private void SetLeaveLastRow ()
 		{
 		{
 			miLeaveLastRow.Checked = !miLeaveLastRow.Checked;
 			miLeaveLastRow.Checked = !miLeaveLastRow.Checked;
-			treeViewFiles.Style.LeaveLastRow = miLeaveLastRow.Checked;
+			treeViewFiles.Style.LeaveLastRow = (bool)miLeaveLastRow.Checked;
 		}
 		}
 		private void SetCursor ()
 		private void SetCursor ()
 		{
 		{
 			miCursor.Checked = !miCursor.Checked;
 			miCursor.Checked = !miCursor.Checked;
-			treeViewFiles.DesiredCursorVisibility = miCursor.Checked ? CursorVisibility.Default : CursorVisibility.Invisible;
+			treeViewFiles.DesiredCursorVisibility = miCursor.Checked == true ? CursorVisibility.Default : CursorVisibility.Invisible;
 		}
 		}
 		private void SetMultiSelect ()
 		private void SetMultiSelect ()
 		{
 		{
 			miMultiSelect.Checked = !miMultiSelect.Checked;
 			miMultiSelect.Checked = !miMultiSelect.Checked;
-			treeViewFiles.MultiSelect = miMultiSelect.Checked;
+			treeViewFiles.MultiSelect = (bool)miMultiSelect.Checked;
 		}
 		}
 
 
 
 
@@ -319,7 +319,7 @@ namespace UICatalog.Scenarios {
 
 
 			miCustomColors.Checked = !miCustomColors.Checked;
 			miCustomColors.Checked = !miCustomColors.Checked;
 
 
-			if (miCustomColors.Checked) {
+			if (miCustomColors.Checked == true) {
 				treeViewFiles.ColorGetter = (m) => {
 				treeViewFiles.ColorGetter = (m) => {
 					if (m is DirectoryInfo && m.Attributes.HasFlag (FileAttributes.Hidden)) return hidden;
 					if (m is DirectoryInfo && m.Attributes.HasFlag (FileAttributes.Hidden)) return hidden;
 					if (m is FileInfo && m.Attributes.HasFlag (FileAttributes.Hidden)) return hidden;
 					if (m is FileInfo && m.Attributes.HasFlag (FileAttributes.Hidden)) return hidden;

+ 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);

+ 5 - 5
UICatalog/UICatalog.cs

@@ -178,7 +178,7 @@ namespace UICatalog {
 							"About UI Catalog", () =>  MessageBox.Query ("About UI Catalog", _aboutMessage.ToString(), "_Ok"), null, null, Key.CtrlMask | Key.A),
 							"About UI Catalog", () =>  MessageBox.Query ("About UI Catalog", _aboutMessage.ToString(), "_Ok"), null, null, Key.CtrlMask | Key.A),
 					}),
 					}),
 				});
 				});
-				
+
 				Capslock = new StatusItem (Key.CharMask, "Caps", null);
 				Capslock = new StatusItem (Key.CharMask, "Caps", null);
 				Numlock = new StatusItem (Key.CharMask, "Num", null);
 				Numlock = new StatusItem (Key.CharMask, "Num", null);
 				Scrolllock = new StatusItem (Key.CharMask, "Scroll", null);
 				Scrolllock = new StatusItem (Key.CharMask, "Scroll", null);
@@ -330,7 +330,7 @@ namespace UICatalog {
 				miIsMouseDisabled.Shortcut = Key.CtrlMask | Key.AltMask | (Key)miIsMouseDisabled.Title.ToString ().Substring (1, 1) [0];
 				miIsMouseDisabled.Shortcut = Key.CtrlMask | Key.AltMask | (Key)miIsMouseDisabled.Title.ToString ().Substring (1, 1) [0];
 				miIsMouseDisabled.CheckType |= MenuItemCheckStyle.Checked;
 				miIsMouseDisabled.CheckType |= MenuItemCheckStyle.Checked;
 				miIsMouseDisabled.Action += () => {
 				miIsMouseDisabled.Action += () => {
-					miIsMouseDisabled.Checked = Application.IsMouseDisabled = !miIsMouseDisabled.Checked;
+					miIsMouseDisabled.Checked = Application.IsMouseDisabled = (bool)!miIsMouseDisabled.Checked;
 				};
 				};
 				menuItems.Add (miIsMouseDisabled);
 				menuItems.Add (miIsMouseDisabled);
 
 
@@ -363,7 +363,7 @@ namespace UICatalog {
 				miHeightAsBuffer.CheckType |= MenuItemCheckStyle.Checked;
 				miHeightAsBuffer.CheckType |= MenuItemCheckStyle.Checked;
 				miHeightAsBuffer.Action += () => {
 				miHeightAsBuffer.Action += () => {
 					miHeightAsBuffer.Checked = !miHeightAsBuffer.Checked;
 					miHeightAsBuffer.Checked = !miHeightAsBuffer.Checked;
-					Application.HeightAsBuffer = miHeightAsBuffer.Checked;
+					Application.HeightAsBuffer = (bool)miHeightAsBuffer.Checked;
 				};
 				};
 				menuItems.Add (miHeightAsBuffer);
 				menuItems.Add (miHeightAsBuffer);
 
 
@@ -392,10 +392,10 @@ namespace UICatalog {
 					}
 					}
 					item.Action += () => {
 					item.Action += () => {
 						var t = GetDiagnosticsTitle (ConsoleDriver.DiagnosticFlags.Off);
 						var t = GetDiagnosticsTitle (ConsoleDriver.DiagnosticFlags.Off);
-						if (item.Title == t && !item.Checked) {
+						if (item.Title == t && item.Checked == false) {
 							_diagnosticFlags &= ~(ConsoleDriver.DiagnosticFlags.FramePadding | ConsoleDriver.DiagnosticFlags.FrameRuler);
 							_diagnosticFlags &= ~(ConsoleDriver.DiagnosticFlags.FramePadding | ConsoleDriver.DiagnosticFlags.FrameRuler);
 							item.Checked = true;
 							item.Checked = true;
-						} else if (item.Title == t && item.Checked) {
+						} else if (item.Title == t && item.Checked == true) {
 							_diagnosticFlags |= (ConsoleDriver.DiagnosticFlags.FramePadding | ConsoleDriver.DiagnosticFlags.FrameRuler);
 							_diagnosticFlags |= (ConsoleDriver.DiagnosticFlags.FramePadding | ConsoleDriver.DiagnosticFlags.FrameRuler);
 							item.Checked = false;
 							item.Checked = false;
 						} else {
 						} else {

+ 91 - 0
UnitTests/Menus/MenuTests.cs

@@ -1734,5 +1734,96 @@ Edit
 │                                      │
 │                                      │
 └──────────────────────────────────────┘", output);
 └──────────────────────────────────────┘", output);
 		}
 		}
+
+		[Fact, AutoInitShutdown]
+		public void AllowNullChecked_Get_Set ()
+		{
+			MenuItem mi = new MenuItem ("Check this out 你", "", null) {
+				CheckType = MenuItemCheckStyle.Checked
+			};
+			mi.Action = mi.ToggleChecked;
+			var menu = new MenuBar (new MenuBarItem [] {
+				new MenuBarItem("Nullable Checked",new MenuItem [] {
+					mi
+				})
+			});
+			new CheckBox ();
+			var top = Application.Top;
+			top.Add (menu);
+			Application.Begin (top);
+
+			Assert.False (mi.Checked);
+			Assert.True (menu.ProcessHotKey (new KeyEvent (Key.F9, new KeyModifiers ())));
+			Assert.True (menu.openMenu.ProcessKey (new KeyEvent (Key.Enter, new KeyModifiers ())));
+			Application.MainLoop.MainIteration ();
+			Assert.True (mi.Checked);
+			Assert.True (menu.MouseEvent (new MouseEvent () {
+				X = 0,
+				Y = 0,
+				Flags = MouseFlags.Button1Pressed,
+				View = menu
+			}));
+			Assert.True (menu.openMenu.MouseEvent (new MouseEvent () {
+				X = 0,
+				Y = 1,
+				Flags = MouseFlags.Button1Clicked,
+				View = menu.openMenu
+			}));
+			Application.MainLoop.MainIteration ();
+			Assert.False (mi.Checked);
+
+			mi.AllowNullChecked = true;
+			Assert.True (menu.ProcessHotKey (new KeyEvent (Key.F9, new KeyModifiers ())));
+			Assert.True (menu.openMenu.ProcessKey (new KeyEvent (Key.Enter, new KeyModifiers ())));
+			Application.MainLoop.MainIteration ();
+			Assert.Null (mi.Checked);
+			Assert.True (menu.MouseEvent (new MouseEvent () {
+				X = 0,
+				Y = 0,
+				Flags = MouseFlags.Button1Pressed,
+				View = menu
+			}));
+			Application.Refresh ();
+			TestHelpers.AssertDriverContentsWithFrameAre (@"
+ Nullable Checked       
+┌──────────────────────┐
+│ ⍰ Check this out 你  │
+└──────────────────────┘", output);
+			Assert.True (menu.openMenu.MouseEvent (new MouseEvent () {
+				X = 0,
+				Y = 1,
+				Flags = MouseFlags.Button1Clicked,
+				View = menu.openMenu
+			}));
+			Application.MainLoop.MainIteration ();
+			Assert.True (mi.Checked);
+			Assert.True (menu.ProcessHotKey (new KeyEvent (Key.F9, new KeyModifiers ())));
+			Assert.True (menu.openMenu.ProcessKey (new KeyEvent (Key.Enter, new KeyModifiers ())));
+			Application.MainLoop.MainIteration ();
+			Assert.False (mi.Checked);
+			Assert.True (menu.MouseEvent (new MouseEvent () {
+				X = 0,
+				Y = 0,
+				Flags = MouseFlags.Button1Pressed,
+				View = menu
+			}));
+			Assert.True (menu.openMenu.MouseEvent (new MouseEvent () {
+				X = 0,
+				Y = 1,
+				Flags = MouseFlags.Button1Clicked,
+				View = menu.openMenu
+			}));
+			Application.MainLoop.MainIteration ();
+			Assert.Null (mi.Checked);
+
+			mi.AllowNullChecked = false;
+			Assert.False (mi.Checked);
+
+			mi.CheckType = MenuItemCheckStyle.NoCheck;
+			Assert.Throws<InvalidOperationException> (mi.ToggleChecked);
+
+			mi.CheckType = MenuItemCheckStyle.Radio;
+			Assert.Throws<InvalidOperationException> (mi.ToggleChecked);
+		}
 	}
 	}
 }
 }

+ 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 → 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);
+		}
 	}
 	}
 }
 }