GraphicsPath.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. //
  2. // System.Drawing.Drawing2D.GraphicsPath.cs
  3. //
  4. // Authors:
  5. //
  6. // Miguel de Icaza ([email protected])
  7. // Duncan Mak ([email protected])
  8. // Jordi Mas i Hernandez ([email protected])
  9. //
  10. // (C) 2004 Novell, Inc
  11. //
  12. using System;
  13. using System.Drawing;
  14. using System.Runtime.InteropServices;
  15. namespace System.Drawing.Drawing2D
  16. {
  17. public sealed class GraphicsPath : MarshalByRefObject, ICloneable, IDisposable {
  18. internal IntPtr nativePath = IntPtr.Zero;
  19. GraphicsPath (IntPtr ptr)
  20. {
  21. nativePath = ptr;
  22. }
  23. public GraphicsPath ()
  24. {
  25. Status status = GDIPlus.GdipCreatePath (FillMode.Alternate, out nativePath);
  26. GDIPlus.CheckStatus (status);
  27. }
  28. [MonoTODO]
  29. public GraphicsPath (FillMode fillMode)
  30. {
  31. throw new NotImplementedException ();
  32. }
  33. [MonoTODO]
  34. public GraphicsPath (Point[] pts, byte[] types)
  35. {
  36. throw new NotImplementedException ();
  37. }
  38. [MonoTODO]
  39. public GraphicsPath (PointF[] pts, byte[] types)
  40. {
  41. throw new NotImplementedException ();
  42. }
  43. [MonoTODO]
  44. public GraphicsPath (Point[] pts, byte[] types, FillMode fillMode)
  45. {
  46. throw new NotImplementedException ();
  47. }
  48. [MonoTODO]
  49. public GraphicsPath(PointF[] pts, byte[] types, FillMode fillMode)
  50. {
  51. throw new NotImplementedException ();
  52. }
  53. public object Clone ()
  54. {
  55. IntPtr clone;
  56. Status status = GDIPlus.GdipClonePath (nativePath, out clone);
  57. GDIPlus.CheckStatus (status);
  58. return new GraphicsPath (clone);
  59. }
  60. public void Dispose ()
  61. {
  62. Dispose (true);
  63. System.GC.SuppressFinalize (this);
  64. }
  65. ~GraphicsPath ()
  66. {
  67. Dispose (false);
  68. }
  69. void Dispose (bool disposing)
  70. {
  71. }
  72. public FillMode FillMode {
  73. get {
  74. FillMode mode;
  75. Status status = GDIPlus.GdipGetPathFillMode (nativePath, out mode);
  76. GDIPlus.CheckStatus (status);
  77. return mode;
  78. }
  79. set {
  80. Status status = GDIPlus.GdipSetPathFillMode (nativePath, value);
  81. GDIPlus.CheckStatus (status);
  82. }
  83. }
  84. public PathData PathData {
  85. get {
  86. IntPtr tmp;
  87. Status status = GDIPlus.GdipGetPathData (nativePath, out tmp);
  88. GDIPlus.CheckStatus (status);
  89. throw new Exception ();
  90. }
  91. }
  92. public PointF [] PathPoints {
  93. get {
  94. int count;
  95. Status status = GDIPlus.GdipGetPointCount (nativePath, out count);
  96. GDIPlus.CheckStatus (status);
  97. PointF [] points = new PointF [count];
  98. status = GDIPlus.GdipGetPathPoints (nativePath, points, count);
  99. GDIPlus.CheckStatus (status);
  100. return points;
  101. }
  102. }
  103. public byte [] PathTypes {
  104. get {
  105. int count;
  106. Status status = GDIPlus.GdipGetPointCount (nativePath, out count);
  107. GDIPlus.CheckStatus (status);
  108. byte [] types = new byte [count];
  109. status = GDIPlus.GdipGetPathTypes (nativePath, types, count);
  110. GDIPlus.CheckStatus (status);
  111. return types;
  112. }
  113. }
  114. public int PointCount {
  115. get {
  116. int count;
  117. Status status = GDIPlus.GdipGetPointCount (nativePath, out count);
  118. GDIPlus.CheckStatus (status);
  119. return count;
  120. }
  121. }
  122. internal IntPtr NativeObject{
  123. get{
  124. return nativePath;
  125. }
  126. set {
  127. nativePath = value;
  128. }
  129. }
  130. //
  131. // AddArc
  132. //
  133. public void AddArc (Rectangle rect, float start_angle, float sweep_angle)
  134. {
  135. Status status = GDIPlus.GdipAddPathArcI (nativePath, rect.X, rect.Y, rect.Width, rect.Height, start_angle, sweep_angle);
  136. GDIPlus.CheckStatus (status);
  137. }
  138. public void AddArc (RectangleF rect, float start_angle, float sweep_angle)
  139. {
  140. Status status = GDIPlus.GdipAddPathArc (nativePath, rect.X, rect.Y, rect.Width, rect.Height, start_angle, sweep_angle);
  141. GDIPlus.CheckStatus (status);
  142. }
  143. public void AddArc (int x, int y, int width, int height, float start_angle, float sweep_angle)
  144. {
  145. Status status = GDIPlus.GdipAddPathArcI (nativePath, x, y, width, height, start_angle, sweep_angle);
  146. GDIPlus.CheckStatus (status);
  147. }
  148. public void AddArc (float x, float y, float width, float height, float start_angle, float sweep_angle)
  149. {
  150. Status status = GDIPlus.GdipAddPathArc (nativePath, x, y, width, height, start_angle, sweep_angle);
  151. GDIPlus.CheckStatus (status);
  152. }
  153. //
  154. // AddBezier
  155. //
  156. public void AddBezier (Point pt1, Point pt2, Point pt3, Point pt4)
  157. {
  158. Status status = GDIPlus.GdipAddPathBezierI (nativePath, pt1.X, pt1.Y,
  159. pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
  160. GDIPlus.CheckStatus (status);
  161. }
  162. public void AddBezier (PointF pt1, PointF pt2, PointF pt3, PointF pt4)
  163. {
  164. Status status = GDIPlus.GdipAddPathBezier (nativePath, pt1.X, pt1.Y,
  165. pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
  166. GDIPlus.CheckStatus (status);
  167. }
  168. public void AddBezier (int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
  169. {
  170. Status status = GDIPlus.GdipAddPathBezierI (nativePath, x1, y1, x2, y2, x3, y3, x4, y4);
  171. GDIPlus.CheckStatus (status);
  172. }
  173. public void AddBezier (float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
  174. {
  175. Status status = GDIPlus.GdipAddPathBezier (nativePath, x1, y1, x2, y2, x3, y3, x4, y4);
  176. GDIPlus.CheckStatus (status);
  177. }
  178. //
  179. // AddBeziers
  180. //
  181. public void AddBeziers (Point [] pts)
  182. {
  183. Status status = GDIPlus.GdipAddPathBeziersI (nativePath, pts, pts.Length);
  184. GDIPlus.CheckStatus (status);
  185. }
  186. public void AddBeziers (PointF [] pts)
  187. {
  188. Status status = GDIPlus.GdipAddPathBeziers (nativePath, pts, pts.Length);
  189. GDIPlus.CheckStatus (status);
  190. }
  191. //
  192. // AddEllipse
  193. //
  194. public void AddEllipse (RectangleF r)
  195. {
  196. Status status = GDIPlus.GdipAddPathEllipse (nativePath, r.X, r.Y, r.Width, r.Height);
  197. GDIPlus.CheckStatus (status);
  198. }
  199. public void AddEllipse (float x, float y, float width, float height)
  200. {
  201. Status status = GDIPlus.GdipAddPathEllipse (nativePath, x, y, width, height);
  202. GDIPlus.CheckStatus (status);
  203. }
  204. public void AddEllipse (Rectangle r)
  205. {
  206. Status status = GDIPlus.GdipAddPathEllipseI (nativePath, r.X, r.Y, r.Width, r.Height);
  207. GDIPlus.CheckStatus (status);
  208. }
  209. public void AddEllipse (int x, int y, int width, int height)
  210. {
  211. Status status = GDIPlus.GdipAddPathEllipseI (nativePath, x, y, width, height);
  212. GDIPlus.CheckStatus (status);
  213. }
  214. //
  215. // AddLine
  216. //
  217. public void AddLine (Point a, Point b)
  218. {
  219. Status status = GDIPlus.GdipAddPathLineI (nativePath, a.X, a.Y, b.X, b.Y);
  220. GDIPlus.CheckStatus (status);
  221. }
  222. public void AddLine (PointF a, PointF b)
  223. {
  224. Status status = GDIPlus.GdipAddPathLine (nativePath, a.X, a.Y, b.X,
  225. b.Y);
  226. GDIPlus.CheckStatus (status);
  227. }
  228. public void AddLine (int x1, int y1, int x2, int y2)
  229. {
  230. Status status = GDIPlus.GdipAddPathLineI (nativePath, x1, y1, x2, y2);
  231. GDIPlus.CheckStatus (status);
  232. }
  233. public void AddLine (float x1, float y1, float x2, float y2)
  234. {
  235. Status status = GDIPlus.GdipAddPathLine (nativePath, x1, y1, x2,
  236. y2);
  237. GDIPlus.CheckStatus (status);
  238. }
  239. //
  240. // AddLines
  241. //
  242. public void AddLines (Point [] points)
  243. {
  244. int length = points.Length;
  245. for (int i = 0; i < length - 2; i += 2) {
  246. int j = i + 1;
  247. Status status = GDIPlus.GdipAddPathLineI (nativePath, points [i].X, points [i].Y, points [j].X, points [j].Y);
  248. GDIPlus.CheckStatus (status);
  249. }
  250. }
  251. public void AddLines (PointF [] points)
  252. {
  253. int length = points.Length;
  254. for (int i = 0; i < length - 2; i += 2) {
  255. int j = i + 1;
  256. Status status = GDIPlus.GdipAddPathLine (nativePath, points [i].X, points [i].Y, points [j].X, points [j].Y);
  257. GDIPlus.CheckStatus (status);
  258. }
  259. }
  260. //
  261. // AddPie
  262. //
  263. public void AddPie (Rectangle rect, float startAngle, float sweepAngle)
  264. {
  265. Status status = GDIPlus.GdipAddPathPie (nativePath, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
  266. GDIPlus.CheckStatus (status);
  267. }
  268. public void AddPie (int x, int y, int width, int height, float startAngle, float sweepAngle)
  269. {
  270. Status status = GDIPlus.GdipAddPathPie (nativePath, x, y, width, height, startAngle, sweepAngle);
  271. GDIPlus.CheckStatus (status);
  272. }
  273. public void AddPie (float x, float y, float width, float height, float startAngle, float sweepAngle)
  274. {
  275. Status status = GDIPlus.GdipAddPathPie (nativePath, x, y, width, height, startAngle, sweepAngle);
  276. GDIPlus.CheckStatus (status);
  277. }
  278. //
  279. // AddPolygon
  280. //
  281. public void AddPolygon (Point [] points)
  282. {
  283. Status status = GDIPlus.GdipAddPathPolygonI (nativePath, points, points.Length);
  284. GDIPlus.CheckStatus (status);
  285. }
  286. public void AddPolygon (PointF [] points)
  287. {
  288. Status status = GDIPlus.GdipAddPathPolygon (nativePath, points, points.Length);
  289. GDIPlus.CheckStatus (status);
  290. }
  291. //
  292. // AddRectangle
  293. //
  294. public void AddRectangle (Rectangle rect)
  295. {
  296. Status status = GDIPlus.GdipAddPathRectangleI (nativePath, rect.X, rect.Y, rect.Width, rect.Height);
  297. GDIPlus.CheckStatus (status);
  298. }
  299. public void AddRectangle (RectangleF rect)
  300. {
  301. Status status = GDIPlus.GdipAddPathRectangle (nativePath, rect.X, rect.Y, rect.Width, rect.Height);
  302. GDIPlus.CheckStatus (status);
  303. }
  304. //
  305. // AddRectangles
  306. //
  307. public void AddRectangles (Rectangle [] rects)
  308. {
  309. Status status = GDIPlus.GdipAddPathRectanglesI (nativePath, rects, rects.Length);
  310. GDIPlus.CheckStatus (status);
  311. }
  312. public void AddRectangles (RectangleF [] rects)
  313. {
  314. Status status = GDIPlus.GdipAddPathRectangles (nativePath, rects, rects.Length);
  315. GDIPlus.CheckStatus (status);
  316. }
  317. //
  318. // AddPath
  319. //
  320. public void AddPath (GraphicsPath addingPath, bool connect)
  321. {
  322. Status status = GDIPlus.GdipAddPathPath (nativePath, addingPath.nativePath, connect);
  323. GDIPlus.CheckStatus (status);
  324. }
  325. public PointF GetLastPoint ()
  326. {
  327. PointF pt;
  328. Status status = GDIPlus.GdipGetPathLastPoint (nativePath, out pt);
  329. GDIPlus.CheckStatus (status);
  330. return pt;
  331. }
  332. //
  333. // AddClosedCurve
  334. //
  335. public void AddClosedCurve (Point [] points)
  336. {
  337. Status status = GDIPlus.GdipAddPathClosedCurveI (nativePath, points, points.Length);
  338. GDIPlus.CheckStatus (status);
  339. }
  340. public void AddClosedCurve (PointF [] points)
  341. {
  342. Status status = GDIPlus.GdipAddPathClosedCurve (nativePath, points, points.Length);
  343. GDIPlus.CheckStatus (status);
  344. }
  345. public void AddClosedCurve (Point [] points, float tension)
  346. {
  347. Status status = GDIPlus.GdipAddPathClosedCurve2I (nativePath, points, points.Length, tension);
  348. GDIPlus.CheckStatus (status);
  349. }
  350. public void AddClosedCurve (PointF [] points, float tension)
  351. {
  352. Status status = GDIPlus.GdipAddPathClosedCurve2 (nativePath, points, points.Length, tension);
  353. GDIPlus.CheckStatus (status);
  354. }
  355. //
  356. // AddCurve
  357. //
  358. public void AddCurve (Point [] points)
  359. {
  360. Status status = GDIPlus.GdipAddPathCurveI (nativePath, points, points.Length);
  361. GDIPlus.CheckStatus (status);
  362. }
  363. public void AddCurve (PointF [] points)
  364. {
  365. Status status = GDIPlus.GdipAddPathCurve (nativePath, points, points.Length);
  366. GDIPlus.CheckStatus (status);
  367. }
  368. public void AddCurve (Point [] points, float tension)
  369. {
  370. Status status = GDIPlus.GdipAddPathCurve2I (nativePath, points, points.Length, tension);
  371. GDIPlus.CheckStatus (status);
  372. }
  373. public void AddCurve (PointF [] points, float tension)
  374. {
  375. Status status = GDIPlus.GdipAddPathCurve2 (nativePath, points, points.Length, tension);
  376. GDIPlus.CheckStatus (status);
  377. }
  378. public void AddCurve (Point [] points, int offset, int numberOfSegments, float tension)
  379. {
  380. Status status = GDIPlus.GdipAddPathCurve3I (nativePath, points, points.Length,
  381. offset, numberOfSegments, tension);
  382. GDIPlus.CheckStatus (status);
  383. }
  384. public void AddCurve (PointF [] points, int offset, int numberOfSegments, float tension)
  385. {
  386. Status status = GDIPlus.GdipAddPathCurve3 (nativePath, points, points.Length,
  387. offset, numberOfSegments, tension);
  388. GDIPlus.CheckStatus (status);
  389. }
  390. public void Reset ()
  391. {
  392. Status status = GDIPlus.GdipResetPath (nativePath);
  393. GDIPlus.CheckStatus (status);
  394. }
  395. public void Reverse ()
  396. {
  397. Status status = GDIPlus.GdipReversePath (nativePath);
  398. GDIPlus.CheckStatus (status);
  399. }
  400. public void Transform (Matrix matrix)
  401. {
  402. Status status = GDIPlus.GdipTransformPath (nativePath, matrix.nativeMatrix);
  403. GDIPlus.CheckStatus (status);
  404. }
  405. [MonoTODO]
  406. public void AddString (string s, FontFamily family, int style, float emSize, Point origin, StringFormat format)
  407. {
  408. throw new NotImplementedException ();
  409. }
  410. [MonoTODO]
  411. public void AddString (string s, FontFamily family, int style, float emSize, PointF origin, StringFormat format)
  412. {
  413. throw new NotImplementedException ();
  414. }
  415. [MonoTODO]
  416. public void AddString (string s, FontFamily family, int style, float emSize, Rectangle layoutRect, StringFormat format)
  417. {
  418. throw new NotImplementedException ();
  419. }
  420. [MonoTODO]
  421. public void AddString (string s, FontFamily family, int style, float emSize, RectangleF layoutRect, StringFormat format)
  422. {
  423. throw new NotImplementedException ();
  424. }
  425. [MonoTODO]
  426. public void ClearMarkers()
  427. {
  428. throw new NotImplementedException ();
  429. }
  430. [MonoTODO]
  431. public void CloseAllFigures()
  432. {
  433. throw new NotImplementedException ();
  434. }
  435. [MonoTODO]
  436. public void Flatten ()
  437. {
  438. throw new NotImplementedException ();
  439. }
  440. [MonoTODO]
  441. public void Flatten (Matrix matrix)
  442. {
  443. throw new NotImplementedException ();
  444. }
  445. [MonoTODO]
  446. public void Flatten (Matrix matrix, float flatness)
  447. {
  448. throw new NotImplementedException ();
  449. }
  450. [MonoTODO]
  451. public RectangleF GetBounds ()
  452. {
  453. throw new NotImplementedException ();
  454. }
  455. [MonoTODO]
  456. public RectangleF GetBounds (Matrix matrix)
  457. {
  458. throw new NotImplementedException ();
  459. }
  460. [MonoTODO]
  461. public RectangleF GetBounds (Matrix matrix, Pen pen)
  462. {
  463. throw new NotImplementedException ();
  464. }
  465. [MonoTODO]
  466. public bool IsOutlineVisible (Point point, Pen pen)
  467. {
  468. throw new NotImplementedException ();
  469. }
  470. [MonoTODO]
  471. public bool IsOutlineVisible (PointF point, Pen pen)
  472. {
  473. throw new NotImplementedException ();
  474. }
  475. [MonoTODO]
  476. public bool IsOutlineVisible (int x, int y, Pen pen)
  477. {
  478. throw new NotImplementedException ();
  479. }
  480. [MonoTODO]
  481. public bool IsOutlineVisible (Point pt, Pen pen, Graphics graphics)
  482. {
  483. throw new NotImplementedException ();
  484. }
  485. [MonoTODO]
  486. public bool IsOutlineVisible (PointF pt, Pen pen, Graphics graphics)
  487. {
  488. throw new NotImplementedException ();
  489. }
  490. [MonoTODO]
  491. public bool IsOutlineVisible (float x, float y, Pen pen)
  492. {
  493. throw new NotImplementedException ();
  494. }
  495. [MonoTODO]
  496. public bool IsOutlineVisible (int x, int y, Pen pen, Graphics graphics)
  497. {
  498. throw new NotImplementedException ();
  499. }
  500. [MonoTODO]
  501. public bool IsOutlineVisible (float x, float y, Pen pen, Graphics graphics)
  502. {
  503. throw new NotImplementedException ();
  504. }
  505. [MonoTODO]
  506. public bool IsVisible (Point point)
  507. {
  508. throw new NotImplementedException ();
  509. }
  510. [MonoTODO]
  511. public bool IsVisible (PointF point)
  512. {
  513. throw new NotImplementedException ();
  514. }
  515. [MonoTODO]
  516. public bool IsVisible (int x, int y)
  517. {
  518. throw new NotImplementedException ();
  519. }
  520. [MonoTODO]
  521. public bool IsVisible (Point pt, Graphics graphics)
  522. {
  523. throw new NotImplementedException ();
  524. }
  525. [MonoTODO]
  526. public bool IsVisible (PointF pt, Graphics graphics)
  527. {
  528. throw new NotImplementedException ();
  529. }
  530. [MonoTODO]
  531. public bool IsVisible (float x, float y)
  532. {
  533. throw new NotImplementedException ();
  534. }
  535. [MonoTODO]
  536. public bool IsVisible (int x, int y, Graphics graphics)
  537. {
  538. throw new NotImplementedException ();
  539. }
  540. [MonoTODO]
  541. public bool IsVisible (float x, float y, Graphics graphics)
  542. {
  543. throw new NotImplementedException ();
  544. }
  545. [MonoTODO]
  546. public void SetMarkers()
  547. {
  548. throw new NotImplementedException ();
  549. }
  550. [MonoTODO]
  551. public void StartFigure()
  552. {
  553. throw new NotImplementedException ();
  554. }
  555. [MonoTODO]
  556. public void Warp (PointF[] destPoints, RectangleF srcRect)
  557. {
  558. throw new NotImplementedException ();
  559. }
  560. [MonoTODO]
  561. public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix)
  562. {
  563. throw new NotImplementedException ();
  564. }
  565. [MonoTODO]
  566. public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode)
  567. {
  568. throw new NotImplementedException ();
  569. }
  570. [MonoTODO]
  571. public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode, float flatness)
  572. {
  573. throw new NotImplementedException ();
  574. }
  575. [MonoTODO]
  576. public void Widen (Pen pen)
  577. {
  578. throw new NotImplementedException ();
  579. }
  580. [MonoTODO]
  581. public void Widen (Pen pen, Matrix matrix)
  582. {
  583. throw new NotImplementedException ();
  584. }
  585. [MonoTODO]
  586. public void Widen (Pen pen, Matrix matrix, float flatness)
  587. {
  588. throw new NotImplementedException ();
  589. }
  590. }
  591. }