Pen.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  1. using System;
  2. using System.Drawing;
  3. using System.Drawing.Drawing2D;
  4. using NUnit.Framework;
  5. using DrawingTestHelper;
  6. namespace Test.Sys.Drawing
  7. {
  8. /// <summary>
  9. /// Summary description for Pen.
  10. /// </summary>
  11. [TestFixture]
  12. public class PenFixture {
  13. //TODO: Brush, CompoundArray, CustomEndCap, CustomStartCap,
  14. //StartCap, EndCap, PenType, Transform
  15. DrawingTest t;
  16. Pen p;
  17. protected int TOLERANCE = 3;
  18. [SetUp]
  19. public void SetUp () {
  20. t = DrawingTest.Create (256, 256);
  21. p = new Pen (Color.Blue);
  22. p.Width = 10;
  23. DrawingTest.ShowForms = false;
  24. }
  25. [TearDown]
  26. public void TearDown ()
  27. {
  28. if (t != null)
  29. t.Dispose ();
  30. }
  31. #region InitAlignment
  32. [Test]
  33. public void InitAlignment () {
  34. Pen p = new Pen (Color.Blue);
  35. Assert.AreEqual (PenAlignment.Center, p.Alignment);
  36. }
  37. #endregion
  38. #region PenWidth
  39. [Test]
  40. public void PenWidth_1()
  41. {
  42. Assert.AreEqual(10, p.Width);
  43. t.Graphics.DrawLine (p, 20, 200, 200, 20);
  44. t.Show();
  45. Assert.IsTrue (t.Compare (TOLERANCE * 1.5f)); //FIXME: Pen width in GH is not the same as in .NET
  46. }
  47. [Test]
  48. public void PenWidth_2()
  49. {
  50. p.Width = 25;
  51. t.Graphics.DrawLine (p, 20, 200, 200, 20);
  52. t.Show();
  53. Assert.IsTrue (t.Compare (TOLERANCE));
  54. }
  55. [Test]
  56. public void PenWidth_3 ()
  57. {
  58. t.Graphics.DrawLine (p, 10, 100, 200, 100);
  59. t.Show ();
  60. Assert.IsTrue (t.Compare (TOLERANCE));
  61. }
  62. #endregion
  63. #region DashStyle Tests
  64. [Test]
  65. public void DashStyleTest_1 ()
  66. {
  67. Assert.AreEqual (DashStyle.Solid, p.DashStyle);
  68. p.Width = 14;
  69. t.Graphics.DrawLine (p, 20, 100, 230, 100);
  70. t.Show ();
  71. Assert.IsTrue (t.Compare (TOLERANCE));
  72. }
  73. [Test]
  74. public void DashStyleTest_2 () {
  75. p.DashStyle = DashStyle.Dash;
  76. p.Width = 14;
  77. t.Graphics.DrawLine (p, 20, 100, 230, 100);
  78. t.Show ();
  79. Assert.IsTrue (t.Compare (TOLERANCE));
  80. }
  81. [Test]
  82. public void DashStyleTest_3 () {
  83. p.DashStyle = DashStyle.DashDot;
  84. p.Width = 14;
  85. t.Graphics.FillRectangle (Brushes.Black, 0, 0, 256, 256);
  86. t.Graphics.DrawLine (p, 20, 100, 230, 100);
  87. t.Show ();
  88. Assert.IsTrue (t.Compare (TOLERANCE));
  89. }
  90. [Test]
  91. public void DashStyleTest_4 () {
  92. p.DashStyle = DashStyle.DashDotDot;
  93. p.Width = 14;
  94. t.Graphics.FillRectangle (Brushes.Black, 0, 0, 256, 256);
  95. t.Graphics.DrawLine (p, 20, 100, 230, 100);
  96. t.Show ();
  97. Assert.IsTrue (t.Compare (TOLERANCE));
  98. }
  99. [Test]
  100. public void DashStyleTest_5 () {
  101. p.DashStyle = DashStyle.Dot;
  102. p.Width = 14;
  103. t.Graphics.FillRectangle (Brushes.Black, 0, 0, 256, 256);
  104. t.Graphics.DrawLine (p, 20, 100, 230, 100);
  105. t.Show ();
  106. Assert.IsTrue (t.Compare (TOLERANCE));
  107. }
  108. [Test]
  109. public void DashStyleTest_6 () {
  110. p.DashStyle = DashStyle.Custom;
  111. p.Width = 14;
  112. t.Graphics.FillRectangle (Brushes.Black, 0, 0, 256, 256);
  113. t.Graphics.DrawLine (p, 20, 100, 230, 100);
  114. t.Show ();
  115. Assert.IsTrue (t.Compare (TOLERANCE));
  116. }
  117. #endregion
  118. #region DashCustomStyle
  119. //The following tests DashOffset and DashPattern
  120. [Test]
  121. [Category ("NotWorking")]
  122. public void DashCustomStyle_1 () {
  123. p.DashStyle = DashStyle.Custom;
  124. p.Width = 10;
  125. Assert.AreEqual (new float [] {1F}, p.DashPattern);
  126. Assert.AreEqual (0F, p.DashOffset);
  127. }
  128. [Test]
  129. public void DashCustomStyle_2 () {
  130. p.DashPattern = new float [] {2, 3, 1.15F, 0.05F};
  131. t.Graphics.FillRectangle (Brushes.Black, 0, 0, 256, 256);
  132. t.Graphics.DrawLine (p, 20, 100, 200, 100);
  133. t.Show ();
  134. Assert.IsTrue (t.Compare (TOLERANCE));
  135. }
  136. [Test]
  137. public void DashCustomStyle_3 () {
  138. p.DashOffset = 10F;
  139. t.Graphics.DrawLine (p, 20, 100, 200, 100);
  140. t.Show ();
  141. Assert.IsTrue (t.Compare (TOLERANCE));
  142. }
  143. [Test]
  144. [Category ("NotWorking")]
  145. public void DashCustomStyle_4 () {
  146. p.DashPattern = new float [] {2, 3, 1.15F, 0.05F, 1.74321F};
  147. p.DashOffset = 10.2F;
  148. t.Graphics.DrawLine (p, 20, 100, 200, 100);
  149. t.Show ();
  150. Assert.IsTrue (t.Compare (TOLERANCE));
  151. }
  152. [Test]
  153. [Category ("NotWorking")]
  154. public void DashCustomStyle_5 () {
  155. p.DashPattern = new float [] {2, 3, 1.15F, 0.05F, 1.74321F};
  156. p.DashOffset = 10.2F;
  157. t.Graphics.DrawLine (p, 20, 100, 200, 100);
  158. t.Show ();
  159. Assert.IsTrue (t.Compare (TOLERANCE));
  160. }
  161. #endregion
  162. #region DashCapTest
  163. [Test]
  164. public void DashCapTest_Flat () {
  165. p.Width = 15;
  166. Assert.AreEqual (DashCap.Flat, p.DashCap);
  167. p.DashStyle = DashStyle.DashDot;
  168. t.Graphics.DrawLine (p, 10, 100, 230, 100);
  169. t.Show ();
  170. Assert.IsTrue (t.Compare (TOLERANCE));
  171. }
  172. [Test]
  173. [Category ("NotWorking")]
  174. public void DashCapTest_Round () {
  175. p.Width = 15;
  176. p.DashStyle = DashStyle.DashDot;
  177. p.DashCap = DashCap.Round;
  178. t.Graphics.DrawLine (p, 10, 100, 230, 100);
  179. t.Show ();
  180. Assert.IsTrue (t.Compare (TOLERANCE));
  181. }
  182. [Test]
  183. [Category ("NotWorking")]
  184. public void DashCapTest_Triangle () {
  185. p.Width = 15;
  186. p.DashStyle = DashStyle.DashDot;
  187. p.DashCap = DashCap.Triangle;
  188. t.Graphics.DrawLine (p, 10, 100, 230, 100);
  189. t.Show ();
  190. Assert.IsTrue (t.Compare (TOLERANCE));
  191. }
  192. #endregion
  193. #region LineJoin Round
  194. [Test]
  195. public void LineJoinTest_Round_1 () {
  196. Point [] points = new Point [] {
  197. new Point(100, 210), new Point (120, 50),
  198. new Point (140, 210)};
  199. p.Width = 25;
  200. p.LineJoin = LineJoin.Round;
  201. t.Graphics.DrawPolygon (p, points);
  202. t.Graphics.DrawPolygon (Pens.White, points);
  203. t.Show ();
  204. Assert.IsTrue (t.Compare (TOLERANCE));
  205. }
  206. [Test]
  207. public void LineJoinTest_Round_2 () {
  208. Point [] points = new Point [] {
  209. new Point(50, 210), new Point (120, 50),
  210. new Point (190, 210)};
  211. p.Width = 25;
  212. p.LineJoin = LineJoin.Round;
  213. t.Graphics.DrawPolygon (p, points);
  214. t.Graphics.DrawPolygon (Pens.White, points);
  215. t.Show ();
  216. Assert.IsTrue (t.Compare (TOLERANCE));
  217. }
  218. #endregion
  219. #region LineJoin Miter
  220. [Test]
  221. public void LineJoinTest_Miter_1 () {
  222. p.LineJoin = LineJoin.Miter;
  223. Point [] points = new Point [] {
  224. new Point(100, 217), new Point (130, 100),
  225. new Point (160, 217)};
  226. p.Width = 25;
  227. t.Graphics.DrawLines (p, points);
  228. t.Graphics.DrawLines (Pens.White, points);
  229. t.Show ();
  230. Assert.IsTrue (t.Compare (TOLERANCE));
  231. }
  232. [Test]
  233. [Category ("NotWorking")]
  234. public void LineJoinTest_Miter_2 () {
  235. p.LineJoin = LineJoin.Miter;
  236. Point [] points = new Point [] {
  237. new Point(120, 237), new Point (130, 100),
  238. new Point (140, 237)};
  239. p.Width = 10;
  240. t.Graphics.DrawLines (p, points);
  241. t.Graphics.DrawLines (Pens.White, points);
  242. t.Show ();
  243. Assert.IsTrue (t.Compare (TOLERANCE));
  244. }
  245. [Test]
  246. public void LineJoinTest_Miter_3 () {
  247. p.LineJoin = LineJoin.Miter;
  248. Point [] points = new Point [] {
  249. new Point(50, 217), new Point (100, 100),
  250. new Point (150, 217)};
  251. p.Width = 25;
  252. t.Graphics.DrawLines (p, points);
  253. t.Graphics.DrawLines (Pens.White, points);
  254. t.Show ();
  255. Assert.IsTrue (t.Compare (TOLERANCE));
  256. }
  257. #endregion
  258. #region LineJoin MiterClipped
  259. [Test]
  260. public void LineJoinTest_MiterClipped_1 () {
  261. p.LineJoin = LineJoin.MiterClipped;
  262. Point [] points = new Point [] {
  263. new Point(100, 217), new Point (130, 100),
  264. new Point (160, 217)};
  265. p.Width = 25;
  266. t.Graphics.DrawLines (p, points);
  267. t.Graphics.DrawLines (Pens.White, points);
  268. t.Show ();
  269. Assert.IsTrue (t.Compare (TOLERANCE));
  270. }
  271. [Test]
  272. public void LineJoinTest_MiterClipped_2 () {
  273. p.LineJoin = LineJoin.MiterClipped;
  274. Point [] points = new Point [] {
  275. new Point(120, 217), new Point (130, 80),
  276. new Point (140, 217)};
  277. p.Width = 25;
  278. t.Graphics.DrawLines (p, points);
  279. t.Graphics.DrawLines (Pens.White, points);
  280. t.Show ();
  281. Assert.IsTrue (t.Compare (TOLERANCE));
  282. }
  283. [Test]
  284. public void LineJoinTest_MiterClipped_3 () {
  285. p.LineJoin = LineJoin.MiterClipped;
  286. Point [] points = new Point [] {
  287. new Point(50, 217), new Point (100, 100),
  288. new Point (150, 217)};
  289. p.Width = 25;
  290. t.Graphics.DrawLines (p, points);
  291. t.Graphics.DrawLines (Pens.White, points);
  292. t.Show ();
  293. Assert.IsTrue (t.Compare (TOLERANCE));
  294. }
  295. #endregion
  296. #region "LineJoin Bevel"
  297. [Test]
  298. public void LineJoinTest_Bevel_1 () {
  299. p.LineJoin = LineJoin.Bevel;
  300. Point [] points = new Point [] {
  301. new Point(90, 217), new Point (115, 55),
  302. new Point (140, 217)};
  303. p.Width = 25;
  304. t.Graphics.DrawLines (p, points);
  305. t.Graphics.DrawLines (Pens.White, points);
  306. t.Show ();
  307. Assert.IsTrue (t.Compare (TOLERANCE));
  308. }
  309. [Test]
  310. public void LineJoinTest_Bevel_2 () {
  311. p.LineJoin = LineJoin.Bevel;
  312. Point [] points = new Point [] {
  313. new Point(110, 217), new Point (120, 75),
  314. new Point (130, 217)};
  315. p.Width = 25;
  316. t.Graphics.DrawLines (p, points);
  317. t.Graphics.DrawLines (Pens.White, points);
  318. t.Show ();
  319. Assert.IsTrue (t.Compare (TOLERANCE));
  320. }
  321. [Test]
  322. public void LineJoinTest_Bevel_3 () {
  323. p.LineJoin = LineJoin.Bevel;
  324. Point [] points = new Point [] {
  325. new Point(50, 217), new Point (100, 100),
  326. new Point (150, 217)};
  327. p.Width = 25;
  328. t.Graphics.DrawLines (p, points);
  329. t.Graphics.DrawLines (Pens.White, points);
  330. t.Show ();
  331. Assert.IsTrue (t.Compare (TOLERANCE));
  332. }
  333. [Test]
  334. public void LineJoinTest_Bevel_4 () {
  335. p.LineJoin = LineJoin.Bevel;
  336. Point [] points = new Point [] {
  337. new Point(143, 210), new Point (170, 100),
  338. new Point (180, 20)};
  339. p.Width = 25;
  340. t.Graphics.DrawLines (p, points);
  341. t.Graphics.DrawLines (Pens.White, points);
  342. t.Show ();
  343. Assert.IsTrue (t.Compare (TOLERANCE));
  344. }
  345. [Test]
  346. public void LineJoinTest_Bevel_5 () {
  347. p.LineJoin = LineJoin.Bevel;
  348. Point [] points = new Point [] {
  349. new Point(50, 100), new Point (150, 100),
  350. new Point (150, 20), new Point (200, 20)};
  351. p.Width = 25;
  352. t.Graphics.DrawLines (p, points);
  353. t.Graphics.DrawLines (Pens.White, points);
  354. t.Show ();
  355. Assert.IsTrue (t.Compare (TOLERANCE));
  356. }
  357. #endregion
  358. #region PenAlignment
  359. [Test]
  360. public void PenAlignmentTest_1 () {
  361. Assert.AreEqual (PenAlignment.Center, p.Alignment);
  362. Point [] points = new Point [] {
  363. new Point (30, 30), new Point (100, 100), new Point (170, 30),
  364. new Point (170, 200), new Point (30, 200)};
  365. GraphicsPath path = new GraphicsPath ();
  366. path.AddPolygon (points);
  367. p.Width = 25;
  368. t.Graphics.DrawPath (p, path);
  369. t.Graphics.DrawPath (Pens.White, path);
  370. t.Show ();
  371. Assert.IsTrue (t.Compare (TOLERANCE));
  372. }
  373. [Test]
  374. public void PenAlignmentTest_2 () {
  375. Point [] points = new Point [] {
  376. new Point (30, 30), new Point (100, 100), new Point (170, 30),
  377. new Point (170, 200), new Point (30, 200)};
  378. GraphicsPath path = new GraphicsPath ();
  379. path.AddPolygon (points);
  380. p.Width = 25;
  381. p.Alignment = PenAlignment.Left;
  382. t.Graphics.DrawPath (p, path);
  383. t.Graphics.DrawPath (Pens.White, path);
  384. t.Show ();
  385. Assert.IsTrue (t.Compare (TOLERANCE));
  386. }
  387. [Test]
  388. [Category ("NotWorking")]
  389. public void PenAlignmentTest_3 () {
  390. Point [] points = new Point [] {
  391. new Point (30, 30), new Point (100, 100), new Point (170, 30),
  392. new Point (170, 200), new Point (30, 200)};
  393. GraphicsPath path = new GraphicsPath ();
  394. path.AddPolygon (points);
  395. p.Width = 25;
  396. p.Alignment = PenAlignment.Inset;
  397. t.Graphics.DrawPath (p, path);
  398. t.Graphics.DrawPath (Pens.White, path);
  399. t.Show ();
  400. Assert.IsTrue (t.Compare (TOLERANCE));
  401. }
  402. [Test]
  403. public void PenAlignmentTest_4 () {
  404. Point [] points = new Point [] {
  405. new Point (30, 30), new Point (100, 100), new Point (170, 30),
  406. new Point (170, 200), new Point (30, 200)};
  407. GraphicsPath path = new GraphicsPath ();
  408. path.AddPolygon (points);
  409. p.Width = 25;
  410. p.Alignment = PenAlignment.Outset;
  411. t.Graphics.DrawPath (p, path);
  412. t.Graphics.DrawPath (Pens.White, path);
  413. t.Show ();
  414. Assert.IsTrue (t.Compare (TOLERANCE));
  415. }
  416. [Test]
  417. public void PenAlignmentTest_5 () {
  418. Point [] points = new Point [] {
  419. new Point (30, 30), new Point (100, 100), new Point (170, 30),
  420. new Point (170, 200), new Point (30, 200)};
  421. GraphicsPath path = new GraphicsPath ();
  422. path.AddPolygon (points);
  423. p.Width = 25;
  424. p.Alignment = PenAlignment.Right;
  425. t.Graphics.DrawPath (p, path);
  426. t.Graphics.DrawPath (Pens.White, path);
  427. t.Show ();
  428. Assert.IsTrue (t.Compare (TOLERANCE));
  429. }
  430. #endregion
  431. #region Color test
  432. [Test]
  433. public void ColorTest_1 () {
  434. Assert.AreEqual (Color.Blue, p.Color);
  435. p.Width = 25;
  436. t.Graphics.DrawLine (p, 10, 100, 230, 100);
  437. t.Show ();
  438. Assert.IsTrue (t.Compare (TOLERANCE));
  439. }
  440. [Test]
  441. public void ColorTest_2 () {
  442. p.Color = Color.Red;
  443. p.Width = 25;
  444. t.Graphics.DrawLine (p, 10, 100, 230, 100);
  445. t.Show ();
  446. Assert.IsTrue (t.Compare (TOLERANCE));
  447. }
  448. [Test]
  449. public void ColorTest_3 () {
  450. p.Color = Color.BurlyWood;
  451. p.Width = 25;
  452. t.Graphics.DrawLine (p, 10, 100, 230, 100);
  453. t.Show ();
  454. Assert.IsTrue (t.Compare (TOLERANCE));
  455. }
  456. [Test]
  457. public void ColorTest_4 () {
  458. p.Color = Color.FromArgb (100, 120, 255);
  459. p.Width = 25;
  460. t.Graphics.DrawLine (p, 10, 100, 230, 100);
  461. t.Show ();
  462. Assert.IsTrue (t.Compare (TOLERANCE));
  463. }
  464. [Test]
  465. public void ColorTest_5 () {
  466. p.Color = Color.FromArgb (128, Color.White);
  467. p.Width = 25;
  468. t.Graphics.DrawLine (p, 10, 100, 230, 100);
  469. t.Show ();
  470. Assert.IsTrue (t.Compare (TOLERANCE));
  471. }
  472. #endregion
  473. #region MiterLimit
  474. [Test]
  475. public void MitterLimit_1 () {
  476. p.LineJoin = LineJoin.MiterClipped;
  477. Point [] points = new Point [] {new Point (0,30), new Point (180, 30),
  478. new Point (0, 90)};
  479. p.Width = 25;
  480. Assert.AreEqual (10F, p.MiterLimit);
  481. t.Graphics.DrawLines (p, points);
  482. t.Graphics.DrawLines (Pens.White, points);
  483. t.Show ();
  484. Assert.IsTrue (t.Compare (TOLERANCE));
  485. }
  486. [Test]
  487. public void MitterLimit_2 () {
  488. p.MiterLimit=1F;
  489. p.LineJoin = LineJoin.MiterClipped;
  490. Point [] points = new Point [] {new Point (0,30), new Point (180, 30),
  491. new Point (0, 120)};
  492. p.Width = 25;
  493. t.Graphics.DrawLines (p, points);
  494. t.Graphics.DrawLines (Pens.White, points);
  495. t.Show ();
  496. Assert.IsTrue (t.Compare (TOLERANCE));
  497. }
  498. #endregion
  499. #region TRansform
  500. [Test]
  501. public void Transform () {
  502. p.ScaleTransform (0.5F, 2);
  503. t.Graphics.DrawArc (p, 70, 70, 100, 100, 0, 360);
  504. t.Graphics.DrawArc (Pens.White, 70, 70, 100, 100, 0, 360);
  505. t.Show ();
  506. Assert.IsTrue (t.Compare (TOLERANCE));
  507. }
  508. #endregion
  509. #region Line StartCap
  510. [Test]
  511. public void StartCap_Flat() {
  512. Assert.AreEqual(LineCap.Flat, p.StartCap);
  513. p.StartCap = LineCap.Flat;
  514. p.Width = 25;
  515. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  516. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  517. t.Show ();
  518. Assert.IsTrue (t.Compare (TOLERANCE));
  519. }
  520. [Test]
  521. [Category ("NotWorking")]
  522. public void StartCap_Round() {
  523. p.StartCap = LineCap.Round;
  524. p.Width = 25;
  525. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  526. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  527. t.Show ();
  528. Assert.IsTrue (t.Compare (TOLERANCE));
  529. }
  530. [Test]
  531. [Category ("NotWorking")]
  532. public void StartCap_Square() {
  533. p.StartCap = LineCap.Square;
  534. p.Width = 25;
  535. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  536. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  537. t.Show ();
  538. Assert.IsTrue (t.Compare (TOLERANCE));
  539. }
  540. [Test]
  541. public void StartCap_AnchorMask() {
  542. p.StartCap = LineCap.AnchorMask;
  543. p.Width = 25;
  544. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  545. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  546. t.Show ();
  547. Assert.IsTrue (t.Compare (TOLERANCE));
  548. }
  549. [Test]
  550. public void StartCap_ArrowAnchor() {
  551. p.StartCap = LineCap.ArrowAnchor;
  552. p.Width = 25;
  553. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  554. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  555. t.Show ();
  556. Assert.IsTrue (t.Compare (TOLERANCE));
  557. }
  558. [Test]
  559. [Category ("NotWorking")]
  560. public void StartCap_DiamondAnchor() {
  561. p.StartCap = LineCap.DiamondAnchor;
  562. p.Width = 25;
  563. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  564. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  565. t.Show ();
  566. Assert.IsTrue (t.Compare (TOLERANCE));
  567. }
  568. [Test]
  569. public void StartCap_NoAnchor() {
  570. p.StartCap = LineCap.NoAnchor;
  571. p.Width = 25;
  572. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  573. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  574. t.Show ();
  575. Assert.IsTrue (t.Compare (TOLERANCE));
  576. }
  577. [Test]
  578. [Category ("NotWorking")]
  579. public void StartCap_RoundAnchor() {
  580. p.StartCap = LineCap.RoundAnchor;
  581. p.Width = 25;
  582. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  583. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  584. t.Show ();
  585. Assert.IsTrue (t.Compare (TOLERANCE));
  586. }
  587. [Test]
  588. [Category ("NotWorking")]
  589. public void StartCap_SquareAnchor() {
  590. p.StartCap = LineCap.SquareAnchor;
  591. p.Width = 25;
  592. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  593. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  594. t.Show ();
  595. Assert.IsTrue (t.Compare (TOLERANCE));
  596. }
  597. [Test]
  598. public void StartCap_Triangle() {
  599. p.StartCap = LineCap.Triangle;
  600. p.Width = 25;
  601. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  602. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  603. t.Show ();
  604. Assert.IsTrue (t.Compare (TOLERANCE));
  605. }
  606. [Test]
  607. public void StartCap_Custom() {
  608. p.StartCap = LineCap.Custom;
  609. p.Width = 25;
  610. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  611. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  612. t.Show ();
  613. Assert.IsTrue (t.Compare (TOLERANCE));
  614. }
  615. #endregion
  616. #region Line EndCap
  617. [Test]
  618. public void EndCap_Flat()
  619. {
  620. Assert.AreEqual(LineCap.Flat, p.EndCap);
  621. p.EndCap = LineCap.Flat;
  622. p.Width = 25;
  623. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  624. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  625. t.Show ();
  626. Assert.IsTrue (t.Compare (TOLERANCE));
  627. }
  628. [Test]
  629. [Category ("NotWorking")]
  630. public void EndCap_Round()
  631. {
  632. p.EndCap = LineCap.Round;
  633. p.Width = 25;
  634. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  635. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  636. t.Show ();
  637. Assert.IsTrue (t.Compare (TOLERANCE));
  638. }
  639. [Test]
  640. [Category ("NotWorking")]
  641. public void EndCap_Square() {
  642. p.EndCap = LineCap.Square;
  643. p.Width = 25;
  644. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  645. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  646. t.Show ();
  647. Assert.IsTrue (t.Compare (TOLERANCE));
  648. }
  649. [Test]
  650. [Category ("NotWorking")]
  651. public void EndCap_AnchorMask() {
  652. p.EndCap = LineCap.AnchorMask;
  653. p.Width = 25;
  654. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  655. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  656. t.Show ();
  657. Assert.IsTrue (t.Compare (TOLERANCE));
  658. }
  659. [Test]
  660. [Category ("NotWorking")]
  661. public void EndCap_ArrowAnchor() {
  662. p.EndCap = LineCap.ArrowAnchor;
  663. p.Width = 25;
  664. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  665. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  666. t.Show ();
  667. Assert.IsTrue (t.Compare (TOLERANCE));
  668. }
  669. [Test]
  670. public void EndCap_DiamondAnchor() {
  671. p.EndCap = LineCap.DiamondAnchor;
  672. p.Width = 25;
  673. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  674. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  675. t.Show ();
  676. Assert.IsTrue (t.Compare (TOLERANCE));
  677. }
  678. [Test]
  679. [Category ("NotWorking")]
  680. public void EndCap_NoAnchor() {
  681. p.EndCap = LineCap.NoAnchor;
  682. p.Width = 25;
  683. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  684. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  685. t.Show ();
  686. Assert.IsTrue (t.Compare (TOLERANCE));
  687. }
  688. [Test]
  689. [Category ("NotWorking")]
  690. public void EndCap_RoundAnchor() {
  691. p.EndCap = LineCap.RoundAnchor;
  692. p.Width = 25;
  693. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  694. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  695. t.Show ();
  696. Assert.IsTrue (t.Compare (TOLERANCE));
  697. }
  698. [Test]
  699. public void EndCap_SquareAnchor() {
  700. p.EndCap = LineCap.SquareAnchor;
  701. p.Width = 25;
  702. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  703. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  704. t.Show ();
  705. Assert.IsTrue (t.Compare (TOLERANCE));
  706. }
  707. [Test]
  708. [Category ("NotWorking")]
  709. public void EndCap_Triangle() {
  710. p.EndCap = LineCap.Triangle;
  711. p.Width = 25;
  712. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  713. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  714. t.Show ();
  715. Assert.IsTrue (t.Compare (TOLERANCE));
  716. }
  717. [Test]
  718. [Category ("NotWorking")]
  719. public void EndCap_Custom() {
  720. p.EndCap = LineCap.Custom;
  721. p.Width = 25;
  722. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  723. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  724. t.Show ();
  725. Assert.IsTrue (t.Compare (TOLERANCE));
  726. }
  727. #endregion
  728. #region Basic LineCaps StartEnd
  729. [Test]
  730. public void StartEndCapBasic_Flat() {
  731. Assert.AreEqual(LineCap.Flat, p.StartCap);
  732. p.Width = 21;
  733. p.EndCap = LineCap.Flat;
  734. p.StartCap = LineCap.Flat;
  735. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  736. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  737. t.Show ();
  738. Assert.IsTrue (t.Compare (TOLERANCE));
  739. }
  740. [Test]
  741. public void StartEndCapBasic_Round() {
  742. p.Width = 21;
  743. p.EndCap = LineCap.Round;
  744. p.StartCap = LineCap.Round;
  745. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  746. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  747. t.Show ();
  748. Assert.IsTrue (t.Compare (TOLERANCE));
  749. }
  750. [Test]
  751. public void StartEndCapBasic_Square() {
  752. p.Width = 21;
  753. p.EndCap = LineCap.Square;
  754. p.StartCap = LineCap.Square;
  755. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  756. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  757. t.Show ();
  758. Assert.IsTrue (t.Compare (TOLERANCE));
  759. }
  760. [Test]
  761. public void SetLineCap_Flat() {
  762. Assert.AreEqual(LineCap.Flat, p.StartCap);
  763. p.Width = 21;
  764. p.SetLineCap(LineCap.Flat, LineCap.Flat, DashCap.Flat);
  765. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  766. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  767. t.Show ();
  768. Assert.IsTrue (t.Compare (TOLERANCE));
  769. }
  770. [Test]
  771. public void SetLineCap_Round() {
  772. p.Width = 21;
  773. p.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round);
  774. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  775. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  776. t.Show ();
  777. Assert.IsTrue (t.Compare (TOLERANCE));
  778. }
  779. [Test]
  780. public void SetLineCap_Square() {
  781. p.Width = 21;
  782. p.SetLineCap(LineCap.Square, LineCap.Square, DashCap.Flat);
  783. t.Graphics.DrawLine (p, 50, 100, 150, 100);
  784. t.Graphics.DrawLine (Pens.White, 50, 100, 150, 100);
  785. t.Show ();
  786. Assert.IsTrue (t.Compare (TOLERANCE));
  787. }
  788. #endregion
  789. }
  790. }