DragAndDropTest.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. //
  2. // DragAndDropTest.cs: tests for general drag and drop operations.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining
  5. // a copy of this software and associated documentation files (the
  6. // "Software"), to deal in the Software without restriction, including
  7. // without limitation the rights to use, copy, modify, merge, publish,
  8. // distribute, sublicense, and/or sell copies of the Software, and to
  9. // permit persons to whom the Software is furnished to do so, subject to
  10. // the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be
  13. // included in all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. //
  23. // Author:
  24. // Carlos Alberto Cortez <[email protected]>
  25. //
  26. // (C) 2008 Novell, Inc. (http://www.novell.com)
  27. //
  28. // NOTE: Since this is an interactive set of tests, I didn't include it as part
  29. // of the MWF test suite build. You will need to build it by yourself and then
  30. // use nunit-console, since the nunit GUI has some problems with DND (basically a COM
  31. // issue).
  32. //
  33. using System;
  34. using System.Drawing;
  35. using System.Reflection;
  36. using System.Windows.Forms;
  37. using NUnit.Framework;
  38. namespace MonoTests.System.Windows.Forms
  39. {
  40. [TestFixture]
  41. public class DragAndDropTest
  42. {
  43. [Test]
  44. public void DropCancelledByEsc ()
  45. {
  46. DNDForm form = new DNDForm ();
  47. form.Text = MethodBase.GetCurrentMethod ().Name;
  48. form.InstructionsText =
  49. "Instructions:" + Environment.NewLine + Environment.NewLine +
  50. "1. Click with left button on the control on the left, holding it." + Environment.NewLine +
  51. "2. Move mouse pointer to the control in the right. " + Environment.NewLine +
  52. "3. While still pressing the mouse button, press ESC." + Environment.NewLine +
  53. "4. Close the form.";
  54. form.DragControl.DragData = "hello";
  55. form.DragControl.AllowedEffects = DragDropEffects.All;
  56. form.DropControl.DropEffect = DragDropEffects.Copy;
  57. Application.Run (form);
  58. Assert.AreEqual (DragDropEffects.None, form.DragControl.PerformedEffect, "A1");
  59. Assert.AreEqual (1, form.DropControl.EnterFiredCount, "A2");
  60. Assert.AreEqual (1, form.DropControl.LeaveFiredCount, "A3");
  61. Assert.AreEqual (0, form.DropControl.DropFiredCount, "A4");
  62. }
  63. [Test]
  64. public void DropCancelledByQuery ()
  65. {
  66. DNDForm form = new DNDForm ();
  67. form.Text = MethodBase.GetCurrentMethod ().Name;
  68. form.InstructionsText =
  69. "Instructions:" + Environment.NewLine + Environment.NewLine +
  70. "1. Click with left button on the control on the left, holding it." + Environment.NewLine +
  71. "2. Move mouse pointer to the control in the right. " + Environment.NewLine +
  72. "3. The drop should be cancelled after some seconds." + Environment.NewLine +
  73. "4. Close the form.";
  74. form.DragControl.DragData = "hello";
  75. form.DragControl.AllowedEffects = DragDropEffects.All;
  76. form.DropControl.DropEffect = DragDropEffects.Copy;
  77. query_counter = 0;
  78. form.DragControl.QueryContinueDrag += new QueryContinueDragEventHandler (DragControl_QueryContinueDrag);
  79. Application.Run (form);
  80. Assert.AreEqual (DragDropEffects.None, form.DragControl.PerformedEffect, "A1");
  81. Assert.AreEqual (1, form.DropControl.EnterFiredCount, "A2");
  82. Assert.AreEqual (1, form.DropControl.LeaveFiredCount, "A3");
  83. Assert.AreEqual (0, form.DropControl.DropFiredCount, "A4");
  84. }
  85. int query_counter = 0;
  86. void DragControl_QueryContinueDrag (object sender, QueryContinueDragEventArgs e)
  87. {
  88. DragDropControl c = (DragDropControl)sender;
  89. DNDForm f = (DNDForm)c.Parent;
  90. if (f.DropControl.EnterFiredCount == 0)
  91. return;
  92. // Cancel dnd operation AFTER we have reached the drop control
  93. if (query_counter++ >= 32)
  94. e.Action = DragAction.Cancel;
  95. }
  96. [Test]
  97. public void EventsAfterDrop ()
  98. {
  99. DNDForm form = new DNDForm ();
  100. form.Text = MethodBase.GetCurrentMethod ().Name;
  101. form.InstructionsText =
  102. "Instructions:" + Environment.NewLine + Environment.NewLine +
  103. "1. Click with left button on the control on the left, holding it." + Environment.NewLine +
  104. "2. Move mouse pointer to the control in the right. " + Environment.NewLine +
  105. "3. Move the pointer around and then release the mouse button." + Environment.NewLine +
  106. "4. Close the form.";
  107. form.DragControl.DragData = "hello";
  108. form.DragControl.AllowedEffects = DragDropEffects.All;
  109. form.DropControl.DropEffect = DragDropEffects.Copy;
  110. // These should clear the event counters AND
  111. // thus the event counters should remain at 0 after drop occurred
  112. // AND we should get any MouseUp event.
  113. mouse_up_counter = 0;
  114. form.DropControl.DragDrop += new DragEventHandler (DropControl_DragDrop);
  115. form.DropControl.MouseUp += new MouseEventHandler (DropControl_MouseUp);
  116. Application.Run (form);
  117. Assert.AreEqual (DragDropEffects.Copy, form.DragControl.PerformedEffect, "A1");
  118. Assert.AreEqual (0, form.DropControl.EnterFiredCount, "A2");
  119. Assert.AreEqual (0, form.DropControl.LeaveFiredCount, "A3");
  120. Assert.AreEqual (0, form.DropControl.DropFiredCount, "A4");
  121. Assert.AreEqual (0, form.DropControl.DragOverFiredCount, "A5");
  122. Assert.AreEqual (0, mouse_up_counter, "A6");
  123. }
  124. void DropControl_DragDrop (object sender, DragEventArgs e)
  125. {
  126. DragDropControl c = (DragDropControl)sender;
  127. c.ResetEventCounters ();
  128. }
  129. int mouse_up_counter;
  130. void DropControl_MouseUp (object sender, MouseEventArgs e)
  131. {
  132. mouse_up_counter++;
  133. }
  134. [Test]
  135. public void SimpleDragDrop ()
  136. {
  137. DNDForm form = new DNDForm ();
  138. form.Text = MethodBase.GetCurrentMethod ().Name;
  139. form.InstructionsText =
  140. "Instructions:" + Environment.NewLine + Environment.NewLine +
  141. "1. Click with left button on the control on the left, holding it." + Environment.NewLine +
  142. "2. Move mouse pointer to the control in the right. " + Environment.NewLine +
  143. "3. Drop on the right control." + Environment.NewLine +
  144. "4. Close the form.";
  145. form.DragControl.DragData = "SimpleDragDropMessage";
  146. form.DragControl.AllowedEffects = DragDropEffects.Copy;
  147. form.DropControl.DropEffect = DragDropEffects.Copy;
  148. Application.Run (form);
  149. Assert.AreEqual (DragDropEffects.Copy, form.DragControl.PerformedEffect, "A1");
  150. Assert.IsTrue (form.DropControl.Data != null, "A2");
  151. Assert.AreEqual (true, form.DropControl.Data.GetDataPresent (typeof (string)), "A3");
  152. Assert.AreEqual ("SimpleDragDropMessage", form.DropControl.Data.GetData (typeof (string)), "A4");
  153. }
  154. [Test]
  155. public void SimpleLeave ()
  156. {
  157. DNDForm form = new DNDForm ();
  158. form.Text = MethodBase.GetCurrentMethod ().Name;
  159. form.InstructionsText =
  160. "Instructions:" + Environment.NewLine + Environment.NewLine +
  161. "1. Click with left button on the control on the left, holding it." + Environment.NewLine +
  162. "2. Move mouse pointer to the control in the right. " + Environment.NewLine +
  163. "3. Move the mouse pointer outside the drop control." + Environment.NewLine +
  164. "5. Release mouse button." + Environment.NewLine +
  165. "6. Close the form.";
  166. form.DragControl.DragData = "hello";
  167. form.DragControl.AllowedEffects = DragDropEffects.All;
  168. form.DropControl.DropEffect = DragDropEffects.Copy;
  169. Application.Run (form);
  170. Assert.AreEqual (DragDropEffects.None, form.DragControl.PerformedEffect, "A1");
  171. Assert.AreEqual (1, form.DropControl.EnterFiredCount, "A2");
  172. Assert.AreEqual (1, form.DropControl.LeaveFiredCount, "A3");
  173. Assert.AreEqual (0, form.DropControl.DropFiredCount, "A4");
  174. }
  175. [Test]
  176. public void NotAllowedDropEffect ()
  177. {
  178. DNDForm form = new DNDForm ();
  179. form.Text = MethodBase.GetCurrentMethod ().Name;
  180. form.InstructionsText =
  181. "Instructions:" + Environment.NewLine + Environment.NewLine +
  182. "1. Click with left button on the control on the left, holding it." + Environment.NewLine +
  183. "2. Move mouse pointer to the control in the right. " + Environment.NewLine +
  184. "3. Drop on the right control." + Environment.NewLine +
  185. "4. Close the form.";
  186. form.DragControl.DragData = "SimpleDragDropMessage";
  187. form.DragControl.AllowedEffects = DragDropEffects.Copy;
  188. form.DropControl.DropEffect = DragDropEffects.Move;
  189. Application.Run (form);
  190. Assert.AreEqual (DragDropEffects.None, form.DragControl.PerformedEffect, "A1");
  191. Assert.AreEqual (1, form.DropControl.EnterFiredCount, "A2");
  192. Assert.AreEqual (0, form.DropControl.DropFiredCount, "A3");
  193. Assert.AreEqual (1, form.DropControl.LeaveFiredCount, "A4");
  194. }
  195. // This test should probably include a 'log' check
  196. [Test]
  197. public void SequentialOperations ()
  198. {
  199. DNDForm form = new DNDForm ();
  200. form.Text = MethodBase.GetCurrentMethod ().Name;
  201. form.InstructionsText =
  202. "Instructions:" + Environment.NewLine + Environment.NewLine +
  203. "1. Click with left button on the control on the left, holding it." + Environment.NewLine +
  204. "2. Drag on the control on the right. " + Environment.NewLine + Environment.NewLine +
  205. "3. Click with left button on the control on the left again, holding it." + Environment.NewLine +
  206. "4. Move the mouse pointer to the control in the right." + Environment.NewLine +
  207. "5. Move the mouse pointer outside the drop control." + Environment.NewLine +
  208. "6. Release mouse button." + Environment.NewLine + Environment.NewLine +
  209. "7. Click with left button on the control on the left again, holding it." + Environment.NewLine +
  210. "8. Drag on the control on the right. " + Environment.NewLine + Environment.NewLine +
  211. "9. Close the form.";
  212. form.DragControl.DragData = "SimpleDragDropMessage";
  213. form.DragControl.AllowedEffects = DragDropEffects.Move;
  214. form.DropControl.DropEffect = DragDropEffects.Move;
  215. Application.Run (form);
  216. Assert.AreEqual (2, form.DropControl.DropFiredCount, "A1");
  217. Assert.AreEqual (1, form.DropControl.LeaveFiredCount, "A2");
  218. Assert.AreEqual (DragDropEffects.Move, form.DragControl.PerformedEffect, "A3");
  219. }
  220. [Test]
  221. public void DropWithoutMovement ()
  222. {
  223. DNDForm form = new DNDForm ();
  224. form.Text = MethodBase.GetCurrentMethod ().Name;
  225. form.InstructionsText =
  226. "Instructions:" + Environment.NewLine + Environment.NewLine +
  227. "1. Click with left button on the control on the left, holding it, WITHOUT MOVING IT." + Environment.NewLine +
  228. "2. Release the button." + Environment.NewLine +
  229. "3. Close the form.";
  230. form.DragControl.DragData = "no movement";
  231. form.DragControl.AllowDrop = true;
  232. form.DragControl.AllowedEffects = DragDropEffects.Move;
  233. form.DragControl.DropEffect = DragDropEffects.Move;
  234. // Force to automatically do a dnd operation when mouse is pressed,
  235. // instead of waiting for movement
  236. form.DragControl.MouseDown += new MouseEventHandler (DragControl_MouseDown);
  237. Application.Run (form);
  238. Assert.AreEqual (1, form.DragControl.EnterFiredCount, "A1");
  239. Assert.AreEqual (0, form.DragControl.LeaveFiredCount, "A2");
  240. Assert.AreEqual (1, form.DragControl.DropFiredCount, "A3");
  241. Assert.AreEqual (0, form.DragControl.DragOverFiredCount, "A4");
  242. Assert.AreEqual (true, form.DragControl.Data != null, "A5");
  243. // The assertion below is weird: We had a successfully drop, but the returned value is None
  244. Assert.AreEqual (DragDropEffects.None, form.DragControl.PerformedEffect, "A6");
  245. }
  246. void DragControl_MouseDown (object sender, MouseEventArgs e)
  247. {
  248. DragDropControl ctrl = (DragDropControl)sender;
  249. ctrl.DoDragDrop (ctrl.DragData, ctrl.AllowedEffects);
  250. }
  251. [Test]
  252. public void DragDropInSameControl ()
  253. {
  254. DNDForm form = new DNDForm ();
  255. form.Text = MethodBase.GetCurrentMethod ().Name;
  256. form.InstructionsText =
  257. "Instructions:" + Environment.NewLine + Environment.NewLine +
  258. "1. Click with left button on the control on the left, holding it." + Environment.NewLine +
  259. "2. Move the mouse inside left control. " + Environment.NewLine +
  260. "3. Drop on left control (same)." + Environment.NewLine + Environment.NewLine +
  261. "4. Click with left button on the control on the left again, holding it." + Environment.NewLine +
  262. "5. Move the mouse inside the left control. " + Environment.NewLine +
  263. "6. Press ESC, release mouse button and move mouse pointer outside control." + Environment.NewLine +
  264. "7. Close the form.";
  265. form.DragControl.DragData = "SameControl";
  266. form.DragControl.AllowDrop = true;
  267. form.DragControl.AllowedEffects = DragDropEffects.Copy;
  268. data = null;
  269. drag_enter_count = drag_leave_count = 0;
  270. form.DragControl.DragEnter += new DragEventHandler (DragDropInSameControl_DragEnter);
  271. form.DragControl.DragLeave += new EventHandler (DragDropInSameControl_DragLeave);
  272. form.DragControl.DragDrop += new DragEventHandler (DragDropInSameControl_DragDrop);
  273. Application.Run (form);
  274. Assert.AreEqual (2, drag_enter_count, "A1");
  275. Assert.AreEqual (1, drag_leave_count, "A2");
  276. Assert.AreEqual (1, drag_drop_count, "A3");
  277. Assert.AreEqual ("SameControl", data, "A4");
  278. }
  279. int drag_enter_count;
  280. int drag_leave_count;
  281. int drag_drop_count;
  282. object data;
  283. void DragDropInSameControl_DragDrop (object sender, DragEventArgs e)
  284. {
  285. drag_drop_count++;
  286. data = e.Data.GetData (typeof (string));
  287. }
  288. void DragDropInSameControl_DragLeave (object sender, EventArgs e)
  289. {
  290. drag_leave_count++;
  291. }
  292. void DragDropInSameControl_DragEnter (object sender, DragEventArgs e)
  293. {
  294. e.Effect = DragDropEffects.Copy;
  295. drag_enter_count++;
  296. }
  297. }
  298. public class DNDForm : Form
  299. {
  300. DragDropControl drag_control;
  301. DragDropControl drop_control;
  302. TextBox instructions_tb;
  303. Label test_name;
  304. public DNDForm ()
  305. {
  306. test_name = new Label ();
  307. test_name.Location = new Point (5, 5);
  308. test_name.AutoSize = true;
  309. test_name.Font = new Font (Font, FontStyle.Bold | Font.Style);
  310. test_name.Text = Text;
  311. instructions_tb = new TextBox ();
  312. instructions_tb.Multiline = true;
  313. instructions_tb.ScrollBars = ScrollBars.Vertical;
  314. instructions_tb.Location = new Point (5, test_name.Bottom + 5);
  315. instructions_tb.Size = new Size (460, 180);
  316. drag_control = new DragDropControl ();
  317. drag_control.Location = new Point (5, instructions_tb.Bottom + 10);
  318. drag_control.Size = new Size (220, 180);
  319. drag_control.BackColor = Color.LightYellow;
  320. drag_control.DragDropColor = Color.Yellow;
  321. drag_control.Text = "Drag Control";
  322. drag_control.DoDrag = true;
  323. drop_control = new DragDropControl ();
  324. drop_control.Location = new Point (drag_control.Right + 20, instructions_tb.Bottom + 10);
  325. drop_control.Size = new Size (220, 180);
  326. drop_control.BackColor = Color.LightGreen;
  327. drop_control.DragDropColor = Color.Green;
  328. drop_control.Text = "Drop Control";
  329. drop_control.AllowDrop = true;
  330. Controls.AddRange (new Control [] { test_name, instructions_tb, drag_control, drop_control });
  331. Size = new Size (480, 440);
  332. }
  333. public string InstructionsText {
  334. get {
  335. return instructions_tb.Text;
  336. }
  337. set {
  338. instructions_tb.Text = value;
  339. }
  340. }
  341. public DragDropControl DragControl {
  342. get {
  343. return drag_control;
  344. }
  345. }
  346. public DragDropControl DropControl {
  347. get {
  348. return drop_control;
  349. }
  350. }
  351. protected override void OnTextChanged (EventArgs args)
  352. {
  353. base.OnTextChanged (args);
  354. test_name.Text = Text;
  355. }
  356. }
  357. public class DragDropControl : Control
  358. {
  359. DragDropEffects effect;
  360. DragDropEffects allowed_effects;
  361. DragDropEffects performed_effect;
  362. object drag_data;
  363. IDataObject data;
  364. Color drop_color;
  365. Color prev_color;
  366. Rectangle drag_rect;
  367. bool do_drag;
  368. int drop_fired_count;
  369. int leave_fired_count;
  370. int drag_over_fired_count;
  371. int enter_fired_count;
  372. public DragDropControl ()
  373. {
  374. drag_rect = new Rectangle (new Point (-1, -1), SystemInformation.DragSize);
  375. }
  376. // to call or not DoDragDrop when mouse movement is detected. Only handle dnd events otherwise.
  377. public bool DoDrag {
  378. get {
  379. return do_drag;
  380. }
  381. set {
  382. do_drag = value;
  383. }
  384. }
  385. // Color of the control when an operation is having place
  386. public Color DragDropColor {
  387. get {
  388. return drop_color;
  389. }
  390. set {
  391. drop_color = value;
  392. }
  393. }
  394. // Data to pass to Control.DoDragDrop
  395. public object DragData {
  396. get {
  397. return drag_data;
  398. }
  399. set {
  400. drag_data = value;
  401. }
  402. }
  403. // Effects passed to Control.DoDragDrop
  404. public DragDropEffects AllowedEffects {
  405. get {
  406. return allowed_effects;
  407. }
  408. set {
  409. allowed_effects = value;
  410. }
  411. }
  412. // Effect returned by Control.DoDragDrop
  413. public DragDropEffects PerformedEffect {
  414. get {
  415. return performed_effect;
  416. }
  417. }
  418. // The value DragEventArgs.Effect gets in DragEnter event
  419. public DragDropEffects DropEffect {
  420. get {
  421. return effect;
  422. }
  423. set {
  424. effect = value;
  425. }
  426. }
  427. // The value in DragEventArgs.Data
  428. public IDataObject Data {
  429. get {
  430. return data;
  431. }
  432. }
  433. public int DropFiredCount {
  434. get {
  435. return drop_fired_count;
  436. }
  437. }
  438. public int EnterFiredCount {
  439. get {
  440. return enter_fired_count;
  441. }
  442. }
  443. public int LeaveFiredCount {
  444. get {
  445. return leave_fired_count;
  446. }
  447. }
  448. public int DragOverFiredCount {
  449. get {
  450. return drag_over_fired_count;
  451. }
  452. }
  453. public void ResetEventCounters ()
  454. {
  455. drop_fired_count = enter_fired_count = leave_fired_count = drag_over_fired_count = 0;
  456. }
  457. protected override void OnDragEnter (DragEventArgs drgevent)
  458. {
  459. if (!do_drag) {
  460. prev_color = BackColor;
  461. BackColor = drop_color;
  462. }
  463. enter_fired_count++;
  464. drgevent.Effect = effect;
  465. base.OnDragEnter (drgevent);
  466. }
  467. protected override void OnDragOver (DragEventArgs drgevent)
  468. {
  469. drag_over_fired_count++;
  470. base.OnDragOver (drgevent);
  471. }
  472. protected override void OnDragLeave (EventArgs e)
  473. {
  474. data = null;
  475. leave_fired_count++;
  476. if (!do_drag)
  477. BackColor = prev_color;
  478. base.OnDragLeave (e);
  479. }
  480. protected override void OnDragDrop (DragEventArgs drgevent)
  481. {
  482. data = drgevent.Data;
  483. drop_fired_count++;
  484. if (!do_drag)
  485. BackColor = prev_color;
  486. base.OnDragDrop (drgevent);
  487. }
  488. protected override void OnMouseMove (MouseEventArgs e)
  489. {
  490. base.OnMouseMove (e);
  491. if (!do_drag)
  492. return;
  493. if (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right) {
  494. if (drag_rect.X == -1 && drag_rect.Y == -1)
  495. drag_rect.Location = new Point (e.X, e.Y);
  496. else {
  497. if (!drag_rect.Contains (new Point (e.X, e.Y))) {
  498. Color prev_color = BackColor;
  499. BackColor = drop_color;
  500. performed_effect = DoDragDrop (drag_data, allowed_effects);
  501. drag_rect.Location = new Point (-1, -1);
  502. BackColor = prev_color;
  503. }
  504. }
  505. }
  506. }
  507. protected override void OnPaint (PaintEventArgs e)
  508. {
  509. base.OnPaint (e);
  510. Graphics g = e.Graphics;
  511. StringFormat sf = new StringFormat ();
  512. sf.Alignment = StringAlignment.Center;
  513. sf.LineAlignment = StringAlignment.Center;
  514. g.DrawString (Text, SystemFonts.DefaultFont, SystemBrushes.ControlDark,
  515. ClientRectangle, sf);
  516. sf.Dispose ();
  517. }
  518. }
  519. }