CheckBoxTests.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. using System.ComponentModel;
  2. using Xunit.Abstractions;
  3. namespace Terminal.Gui.ViewsTests;
  4. public class CheckBoxTests
  5. {
  6. private readonly ITestOutputHelper _output;
  7. private static readonly Size _size25x1 = new (25, 1);
  8. public CheckBoxTests (ITestOutputHelper output) { _output = output; }
  9. // Test that Title and Text are the same
  10. [Fact]
  11. public void Text_Mirrors_Title ()
  12. {
  13. var view = new CheckBox ();
  14. view.Title = "Hello";
  15. Assert.Equal ("Hello", view.Title);
  16. Assert.Equal ($"Hello", view.TitleTextFormatter.Text);
  17. Assert.Equal ("Hello", view.Text);
  18. Assert.Equal ($"{CM.Glyphs.UnChecked} Hello", view.TextFormatter.Text);
  19. }
  20. [Fact]
  21. public void Title_Mirrors_Text ()
  22. {
  23. var view = new CheckBox ();
  24. view.Text = "Hello";
  25. Assert.Equal ("Hello", view.Text);
  26. Assert.Equal ($"{CM.Glyphs.UnChecked} Hello", view.TextFormatter.Text);
  27. Assert.Equal ("Hello", view.Title);
  28. Assert.Equal ($"Hello", view.TitleTextFormatter.Text);
  29. }
  30. [Fact]
  31. [AutoInitShutdown]
  32. public void AllowNullChecked_Get_Set ()
  33. {
  34. var checkBox = new CheckBox { Text = "Check this out 你" };
  35. Toplevel top = Application.Top;
  36. top.Add (checkBox);
  37. Application.Begin (top);
  38. Assert.False (checkBox.Checked);
  39. Assert.True (checkBox.NewKeyDownEvent (Key.Space));
  40. Assert.True (checkBox.Checked);
  41. Assert.True (checkBox.OnMouseEvent (new MouseEvent { X = 0, Y = 0, Flags = MouseFlags.Button1Clicked }));
  42. Assert.False (checkBox.Checked);
  43. checkBox.AllowNullChecked = true;
  44. Assert.True (checkBox.NewKeyDownEvent (Key.Space));
  45. Assert.Null (checkBox.Checked);
  46. Application.Refresh ();
  47. TestHelpers.AssertDriverContentsWithFrameAre (
  48. @$"
  49. {CM.Glyphs.NullChecked} Check this out 你",
  50. _output
  51. );
  52. Assert.True (checkBox.OnMouseEvent (new MouseEvent { X = 0, Y = 0, Flags = MouseFlags.Button1Clicked }));
  53. Assert.True (checkBox.Checked);
  54. Assert.True (checkBox.NewKeyDownEvent (Key.Space));
  55. Assert.False (checkBox.Checked);
  56. Assert.True (checkBox.OnMouseEvent (new MouseEvent { X = 0, Y = 0, Flags = MouseFlags.Button1Clicked }));
  57. Assert.Null (checkBox.Checked);
  58. checkBox.AllowNullChecked = false;
  59. Assert.False (checkBox.Checked);
  60. }
  61. [Fact]
  62. [AutoInitShutdown]
  63. public void AutoSize_Stays_True_AnchorEnd_With_HotKeySpecifier ()
  64. {
  65. var checkBox = new CheckBox { Y = Pos.Center (), Text = "C_heck this out 你" };
  66. checkBox.X = Pos.AnchorEnd () - Pos.Function (() => checkBox.GetSizeNeededForTextWithoutHotKey ().Width);
  67. var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
  68. win.Add (checkBox);
  69. Application.Top.Add (win);
  70. Assert.True (checkBox.AutoSize);
  71. Application.Begin (Application.Top);
  72. ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
  73. var expected = @$"
  74. ┌┤Test Demo 你├──────────────┐
  75. │ │
  76. │ {CM.Glyphs.UnChecked} Check this out 你│
  77. │ │
  78. └────────────────────────────┘
  79. ";
  80. TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
  81. Assert.True (checkBox.AutoSize);
  82. checkBox.Text = "Check this out 你 changed";
  83. Assert.True (checkBox.AutoSize);
  84. Application.Refresh ();
  85. expected = @$"
  86. ┌┤Test Demo 你├──────────────┐
  87. │ │
  88. │ {CM.Glyphs.UnChecked} Check this out 你 changed│
  89. │ │
  90. └────────────────────────────┘
  91. ";
  92. TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
  93. }
  94. [Fact]
  95. [AutoInitShutdown]
  96. public void AutoSize_Stays_True_AnchorEnd_Without_HotKeySpecifier ()
  97. {
  98. var checkBox = new CheckBox { Y = Pos.Center (), Text = "Check this out 你" };
  99. checkBox.X = Pos.AnchorEnd () - Pos.Function (() => checkBox.GetSizeNeededForTextWithoutHotKey ().Width);
  100. var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
  101. win.Add (checkBox);
  102. Application.Top.Add (win);
  103. Assert.True (checkBox.AutoSize);
  104. Application.Begin (Application.Top);
  105. ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
  106. var expected = @$"
  107. ┌┤Test Demo 你├──────────────┐
  108. │ │
  109. │ {CM.Glyphs.UnChecked} Check this out 你│
  110. │ │
  111. └────────────────────────────┘
  112. ";
  113. TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
  114. Assert.True (checkBox.AutoSize);
  115. checkBox.Text = "Check this out 你 changed";
  116. Assert.True (checkBox.AutoSize);
  117. Application.Refresh ();
  118. expected = @$"
  119. ┌┤Test Demo 你├──────────────┐
  120. │ │
  121. │ {CM.Glyphs.UnChecked} Check this out 你 changed│
  122. │ │
  123. └────────────────────────────┘
  124. ";
  125. TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
  126. }
  127. [Fact]
  128. [AutoInitShutdown]
  129. public void AutoSize_StaysVisible ()
  130. {
  131. var checkBox = new CheckBox { X = 1, Y = Pos.Center (), Text = "Check this out 你" };
  132. var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
  133. win.Add (checkBox);
  134. Application.Top.Add (win);
  135. Assert.False (checkBox.IsInitialized);
  136. RunState runstate = Application.Begin (Application.Top);
  137. ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
  138. Assert.True (checkBox.IsInitialized);
  139. Assert.Equal (new Rectangle (1, 1, 19, 1), checkBox.Frame);
  140. Assert.Equal ("Check this out 你", checkBox.Text);
  141. Assert.Equal ($"{CM.Glyphs.UnChecked} Check this out 你", checkBox.TextFormatter.Text);
  142. Assert.True (checkBox.AutoSize);
  143. Assert.Equal ("Absolute(19)", checkBox.Width.ToString ());
  144. checkBox.Checked = true;
  145. Assert.Equal ($"{CM.Glyphs.Checked} Check this out 你", checkBox.TextFormatter.Text);
  146. checkBox.AutoSize = false;
  147. // It isn't auto-size so the height is guaranteed by the SetMinWidthHeight
  148. checkBox.Text = "Check this out 你 changed";
  149. var firstIteration = false;
  150. Application.RunIteration (ref runstate, ref firstIteration);
  151. // BUGBUG - v2 - Autosize is busted; disabling tests for now
  152. Assert.Equal (new Rectangle (1, 1, 19, 1), checkBox.Frame);
  153. var expected = @"
  154. ┌┤Test Demo 你├──────────────┐
  155. │ │
  156. │ ☑ Check this out 你 │
  157. │ │
  158. └────────────────────────────┘";
  159. Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
  160. Assert.Equal (new Rectangle (0, 0, 30, 5), pos);
  161. checkBox.Width = 19;
  162. // It isn't auto-size so the height is guaranteed by the SetMinWidthHeight
  163. checkBox.Text = "Check this out 你 changed";
  164. Application.RunIteration (ref runstate, ref firstIteration);
  165. Assert.False (checkBox.AutoSize);
  166. Assert.Equal (new Rectangle (1, 1, 19, 1), checkBox.Frame);
  167. expected = @"
  168. ┌┤Test Demo 你├──────────────┐
  169. │ │
  170. │ ☑ Check this out 你 │
  171. │ │
  172. └────────────────────────────┘";
  173. pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
  174. Assert.Equal (new Rectangle (0, 0, 30, 5), pos);
  175. checkBox.AutoSize = true;
  176. Application.RunIteration (ref runstate, ref firstIteration);
  177. Assert.Equal (new Rectangle (1, 1, 27, 1), checkBox.Frame);
  178. expected = @"
  179. ┌┤Test Demo 你├──────────────┐
  180. │ │
  181. │ ☑ Check this out 你 changed│
  182. │ │
  183. └────────────────────────────┘";
  184. pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
  185. Assert.Equal (new Rectangle (0, 0, 30, 5), pos);
  186. }
  187. [Fact]
  188. public void Constructors_Defaults ()
  189. {
  190. var ckb = new CheckBox ();
  191. Assert.True (ckb.AutoSize);
  192. Assert.False (ckb.Checked);
  193. Assert.False (ckb.AllowNullChecked);
  194. Assert.Equal (string.Empty, ckb.Text);
  195. Assert.Equal ($"{CM.Glyphs.UnChecked} ", ckb.TextFormatter.Text);
  196. Assert.True (ckb.CanFocus);
  197. Assert.Equal (new Rectangle (0, 0, 2, 1), ckb.Frame);
  198. ckb = new CheckBox { Text = "Test", Checked = true };
  199. Assert.True (ckb.AutoSize);
  200. Assert.True (ckb.Checked);
  201. Assert.False (ckb.AllowNullChecked);
  202. Assert.Equal ("Test", ckb.Text);
  203. Assert.Equal ($"{CM.Glyphs.Checked} Test", ckb.TextFormatter.Text);
  204. Assert.True (ckb.CanFocus);
  205. Assert.Equal (new Rectangle (0, 0, 6, 1), ckb.Frame);
  206. ckb = new CheckBox { Text = "Test", X = 1, Y = 2 };
  207. Assert.True (ckb.AutoSize);
  208. Assert.False (ckb.Checked);
  209. Assert.False (ckb.AllowNullChecked);
  210. Assert.Equal ("Test", ckb.Text);
  211. Assert.Equal ($"{CM.Glyphs.UnChecked} Test", ckb.TextFormatter.Text);
  212. Assert.True (ckb.CanFocus);
  213. Assert.Equal (new Rectangle (1, 2, 6, 1), ckb.Frame);
  214. ckb = new CheckBox { Text = "Test", X = 3, Y = 4, Checked = true };
  215. Assert.True (ckb.AutoSize);
  216. Assert.True (ckb.Checked);
  217. Assert.False (ckb.AllowNullChecked);
  218. Assert.Equal ("Test", ckb.Text);
  219. Assert.Equal ($"{CM.Glyphs.Checked} Test", ckb.TextFormatter.Text);
  220. Assert.True (ckb.CanFocus);
  221. Assert.Equal (new Rectangle (3, 4, 6, 1), ckb.Frame);
  222. }
  223. [Fact]
  224. public void KeyBindings_Command ()
  225. {
  226. var toggled = false;
  227. var ckb = new CheckBox ();
  228. ckb.Toggled += (s, e) => toggled = true;
  229. Assert.False (ckb.Checked);
  230. Assert.False (toggled);
  231. Assert.Equal (Key.Empty, ckb.HotKey);
  232. ckb.Text = "_Test";
  233. Assert.Equal (Key.T, ckb.HotKey);
  234. Assert.True (ckb.NewKeyDownEvent (Key.T));
  235. Assert.True (ckb.Checked);
  236. Assert.True (toggled);
  237. ckb.Text = "T_est";
  238. toggled = false;
  239. Assert.Equal (Key.E, ckb.HotKey);
  240. Assert.True (ckb.NewKeyDownEvent (Key.E.WithAlt));
  241. Assert.True (toggled);
  242. Assert.False (ckb.Checked);
  243. toggled = false;
  244. Assert.Equal (Key.E, ckb.HotKey);
  245. Assert.True (ckb.NewKeyDownEvent (Key.E));
  246. Assert.True (toggled);
  247. Assert.True (ckb.Checked);
  248. toggled = false;
  249. Assert.True (ckb.NewKeyDownEvent (Key.Space));
  250. Assert.True (toggled);
  251. Assert.False (ckb.Checked);
  252. toggled = false;
  253. Assert.True (ckb.NewKeyDownEvent (Key.Space));
  254. Assert.True (toggled);
  255. Assert.True (ckb.Checked);
  256. toggled = false;
  257. Assert.False (ckb.NewKeyDownEvent (Key.Enter));
  258. Assert.False (toggled);
  259. Assert.True (ckb.Checked);
  260. }
  261. [Fact]
  262. public void Accept_Cancel_Event_OnAccept_Returns_True ()
  263. {
  264. var ckb = new CheckBox ();
  265. var acceptInvoked = false;
  266. ckb.Accept += ViewOnAccept;
  267. var ret = ckb.OnAccept ();
  268. Assert.True (ret);
  269. Assert.True (acceptInvoked);
  270. return;
  271. void ViewOnAccept (object sender, CancelEventArgs e)
  272. {
  273. acceptInvoked = true;
  274. e.Cancel = true;
  275. }
  276. }
  277. [Fact]
  278. [AutoInitShutdown]
  279. public void TextAlignment_Centered ()
  280. {
  281. var checkBox = new CheckBox
  282. {
  283. X = 1,
  284. Y = Pos.Center (),
  285. Text = "Check this out 你",
  286. TextAlignment = TextAlignment.Centered,
  287. AutoSize = false,
  288. Width = 25
  289. };
  290. var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
  291. win.Add (checkBox);
  292. Application.Top.Add (win);
  293. Application.Begin (Application.Top);
  294. ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
  295. Assert.Equal (TextAlignment.Centered, checkBox.TextAlignment);
  296. Assert.Equal (new (1, 1, 25, 1), checkBox.Frame);
  297. Assert.Equal (_size25x1, checkBox.TextFormatter.Size);
  298. Assert.False (checkBox.AutoSize);
  299. var expected = @$"
  300. ┌┤Test Demo 你├──────────────┐
  301. │ │
  302. │ {CM.Glyphs.UnChecked} Check this out 你 │
  303. │ │
  304. └────────────────────────────┘
  305. ";
  306. Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
  307. Assert.Equal (new (0, 0, 30, 5), pos);
  308. checkBox.Checked = true;
  309. Application.Refresh ();
  310. expected = @$"
  311. ┌┤Test Demo 你├──────────────┐
  312. │ │
  313. │ {CM.Glyphs.Checked} Check this out 你 │
  314. │ │
  315. └────────────────────────────┘
  316. ";
  317. pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
  318. Assert.Equal (new (0, 0, 30, 5), pos);
  319. }
  320. [Fact]
  321. [AutoInitShutdown]
  322. public void TextAlignment_Justified ()
  323. {
  324. var checkBox1 = new CheckBox
  325. {
  326. X = 1,
  327. Y = Pos.Center (),
  328. Text = "Check first out 你",
  329. TextAlignment = TextAlignment.Justified,
  330. AutoSize = false,
  331. Width = 25
  332. };
  333. var checkBox2 = new CheckBox
  334. {
  335. X = 1,
  336. Y = Pos.Bottom (checkBox1),
  337. Text = "Check second out 你",
  338. TextAlignment = TextAlignment.Justified,
  339. AutoSize = false,
  340. Width = 25
  341. };
  342. var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
  343. win.Add (checkBox1, checkBox2);
  344. Application.Top.Add (win);
  345. Application.Begin (Application.Top);
  346. ((FakeDriver)Application.Driver).SetBufferSize (30, 6);
  347. Assert.Equal (TextAlignment.Justified, checkBox1.TextAlignment);
  348. Assert.Equal (new (1, 1, 25, 1), checkBox1.Frame);
  349. Assert.Equal (_size25x1, checkBox1.TextFormatter.Size);
  350. Assert.Equal (TextAlignment.Justified, checkBox2.TextAlignment);
  351. Assert.Equal (new (1, 2, 25, 1), checkBox2.Frame);
  352. Assert.Equal (_size25x1, checkBox2.TextFormatter.Size);
  353. var expected = @$"
  354. ┌┤Test Demo 你├──────────────┐
  355. │ │
  356. │ {CM.Glyphs.UnChecked} Check first out 你 │
  357. │ {CM.Glyphs.UnChecked} Check second out 你 │
  358. │ │
  359. └────────────────────────────┘
  360. ";
  361. Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
  362. Assert.Equal (new (0, 0, 30, 6), pos);
  363. checkBox1.Checked = true;
  364. Assert.Equal (new (1, 1, 25, 1), checkBox1.Frame);
  365. Assert.Equal (_size25x1, checkBox1.TextFormatter.Size);
  366. checkBox2.Checked = true;
  367. Assert.Equal (new (1, 2, 25, 1), checkBox2.Frame);
  368. Assert.Equal (_size25x1, checkBox2.TextFormatter.Size);
  369. Application.Refresh ();
  370. expected = @$"
  371. ┌┤Test Demo 你├──────────────┐
  372. │ │
  373. │ {CM.Glyphs.Checked} Check first out 你 │
  374. │ {CM.Glyphs.Checked} Check second out 你 │
  375. │ │
  376. └────────────────────────────┘
  377. ";
  378. pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
  379. Assert.Equal (new (0, 0, 30, 6), pos);
  380. }
  381. [Fact]
  382. [AutoInitShutdown]
  383. public void TextAlignment_Left ()
  384. {
  385. var checkBox = new CheckBox
  386. {
  387. X = 1,
  388. Y = Pos.Center (),
  389. Text = "Check this out 你",
  390. AutoSize = false,
  391. Width = 25
  392. };
  393. var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
  394. win.Add (checkBox);
  395. Application.Top.Add (win);
  396. Application.Begin (Application.Top);
  397. ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
  398. Assert.Equal (TextAlignment.Left, checkBox.TextAlignment);
  399. Assert.Equal (new (1, 1, 25, 1), checkBox.Frame);
  400. Assert.Equal (_size25x1, checkBox.TextFormatter.Size);
  401. var expected = @$"
  402. ┌┤Test Demo 你├──────────────┐
  403. │ │
  404. │ {CM.Glyphs.UnChecked} Check this out 你 │
  405. │ │
  406. └────────────────────────────┘
  407. ";
  408. Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
  409. Assert.Equal (new (0, 0, 30, 5), pos);
  410. checkBox.Checked = true;
  411. Application.Refresh ();
  412. expected = @$"
  413. ┌┤Test Demo 你├──────────────┐
  414. │ │
  415. │ {CM.Glyphs.Checked} Check this out 你 │
  416. │ │
  417. └────────────────────────────┘
  418. ";
  419. pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
  420. Assert.Equal (new (0, 0, 30, 5), pos);
  421. }
  422. [Fact]
  423. [AutoInitShutdown]
  424. public void TextAlignment_Right ()
  425. {
  426. var checkBox = new CheckBox
  427. {
  428. X = 1,
  429. Y = Pos.Center (),
  430. Text = "Check this out 你",
  431. TextAlignment = TextAlignment.Right,
  432. AutoSize = false,
  433. Width = 25
  434. };
  435. var win = new Window { Width = Dim.Fill (), Height = Dim.Fill (), Title = "Test Demo 你" };
  436. win.Add (checkBox);
  437. Application.Top.Add (win);
  438. Application.Begin (Application.Top);
  439. ((FakeDriver)Application.Driver).SetBufferSize (30, 5);
  440. Assert.Equal (TextAlignment.Right, checkBox.TextAlignment);
  441. Assert.Equal (new (1, 1, 25, 1), checkBox.Frame);
  442. Assert.Equal (_size25x1, checkBox.TextFormatter.Size);
  443. Assert.False (checkBox.AutoSize);
  444. var expected = @$"
  445. ┌┤Test Demo 你├──────────────┐
  446. │ │
  447. │ Check this out 你 {CM.Glyphs.UnChecked} │
  448. │ │
  449. └────────────────────────────┘
  450. ";
  451. Rectangle pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
  452. Assert.Equal (new (0, 0, 30, 5), pos);
  453. checkBox.Checked = true;
  454. Application.Refresh ();
  455. expected = @$"
  456. ┌┤Test Demo 你├──────────────┐
  457. │ │
  458. │ Check this out 你 {CM.Glyphs.Checked} │
  459. │ │
  460. └────────────────────────────┘
  461. ";
  462. pos = TestHelpers.AssertDriverContentsWithFrameAre (expected, _output);
  463. Assert.Equal (new (0, 0, 30, 5), pos);
  464. }
  465. [Fact]
  466. public void HotKey_Command_Fires_Accept ()
  467. {
  468. var cb = new CheckBox ();
  469. var accepted = false;
  470. cb.Accept += ButtonOnAccept;
  471. cb.InvokeCommand (Command.HotKey);
  472. Assert.True (accepted);
  473. return;
  474. void ButtonOnAccept (object sender, CancelEventArgs e) { accepted = true; }
  475. }
  476. [Theory]
  477. [InlineData (true)]
  478. [InlineData (false)]
  479. [InlineData (null)]
  480. public void Toggled_Cancel_Event_Prevents_Toggle (bool? initialState)
  481. {
  482. var ckb = new CheckBox () { AllowNullChecked = true };
  483. var checkedInvoked = false;
  484. ckb.Toggled += CheckBoxToggled;
  485. ckb.Checked = initialState;
  486. Assert.Equal(initialState, ckb.Checked);
  487. var ret = ckb.OnToggled ();
  488. Assert.True (ret);
  489. Assert.True (checkedInvoked);
  490. Assert.Equal (initialState, ckb.Checked);
  491. return;
  492. void CheckBoxToggled (object sender, CancelEventArgs e)
  493. {
  494. checkedInvoked = true;
  495. e.Cancel = true;
  496. }
  497. }
  498. }