GraphicsPath.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893
  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. // Ravindra ([email protected])
  10. // Sebastien Pouliot <[email protected]>
  11. //
  12. // Copyright (C) 2004,2006 Novell, Inc (http://www.novell.com)
  13. //
  14. // Permission is hereby granted, free of charge, to any person obtaining
  15. // a copy of this software and associated documentation files (the
  16. // "Software"), to deal in the Software without restriction, including
  17. // without limitation the rights to use, copy, modify, merge, publish,
  18. // distribute, sublicense, and/or sell copies of the Software, and to
  19. // permit persons to whom the Software is furnished to do so, subject to
  20. // the following conditions:
  21. //
  22. // The above copyright notice and this permission notice shall be
  23. // included in all copies or substantial portions of the Software.
  24. //
  25. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  26. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  28. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  29. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  30. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  31. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  32. //
  33. using System.ComponentModel;
  34. using System.Runtime.InteropServices;
  35. namespace System.Drawing.Drawing2D
  36. {
  37. public sealed class GraphicsPath : MarshalByRefObject, ICloneable, IDisposable
  38. {
  39. // 1/4 is the FlatnessDefault as defined in GdiPlusEnums.h
  40. private const float FlatnessDefault = 1.0f / 4.0f;
  41. internal IntPtr nativePath = IntPtr.Zero;
  42. GraphicsPath (IntPtr ptr)
  43. {
  44. nativePath = ptr;
  45. }
  46. public GraphicsPath ()
  47. {
  48. Status status = GDIPlus.GdipCreatePath (FillMode.Alternate, out nativePath);
  49. GDIPlus.CheckStatus (status);
  50. }
  51. public GraphicsPath (FillMode fillMode)
  52. {
  53. Status status = GDIPlus.GdipCreatePath (fillMode, out nativePath);
  54. GDIPlus.CheckStatus (status);
  55. }
  56. public GraphicsPath (Point[] pts, byte[] types)
  57. : this (pts, types, FillMode.Alternate)
  58. {
  59. }
  60. public GraphicsPath (PointF[] pts, byte[] types)
  61. : this (pts, types, FillMode.Alternate)
  62. {
  63. }
  64. public GraphicsPath (Point[] pts, byte[] types, FillMode fillMode)
  65. {
  66. if (pts == null)
  67. throw new ArgumentNullException ("pts");
  68. if (pts.Length != types.Length)
  69. throw new ArgumentException ("Invalid parameter passed. Number of points and types must be same.");
  70. Status status = GDIPlus.GdipCreatePath2I (pts, types, pts.Length, fillMode, out nativePath);
  71. GDIPlus.CheckStatus (status);
  72. }
  73. public GraphicsPath (PointF[] pts, byte[] types, FillMode fillMode)
  74. {
  75. if (pts == null)
  76. throw new ArgumentNullException ("pts");
  77. if (pts.Length != types.Length)
  78. throw new ArgumentException ("Invalid parameter passed. Number of points and types must be same.");
  79. Status status = GDIPlus.GdipCreatePath2 (pts, types, pts.Length, fillMode, out nativePath);
  80. GDIPlus.CheckStatus (status);
  81. }
  82. public object Clone ()
  83. {
  84. IntPtr clone;
  85. Status status = GDIPlus.GdipClonePath (nativePath, out clone);
  86. GDIPlus.CheckStatus (status);
  87. return new GraphicsPath (clone);
  88. }
  89. public void Dispose ()
  90. {
  91. Dispose (true);
  92. System.GC.SuppressFinalize (this);
  93. }
  94. ~GraphicsPath ()
  95. {
  96. Dispose (false);
  97. }
  98. void Dispose (bool disposing)
  99. {
  100. Status status;
  101. if (nativePath != IntPtr.Zero) {
  102. status = GDIPlus.GdipDeletePath (nativePath);
  103. GDIPlus.CheckStatus (status);
  104. nativePath = IntPtr.Zero;
  105. }
  106. }
  107. public FillMode FillMode {
  108. get {
  109. FillMode mode;
  110. Status status = GDIPlus.GdipGetPathFillMode (nativePath, out mode);
  111. GDIPlus.CheckStatus (status);
  112. return mode;
  113. }
  114. set {
  115. if ((value < FillMode.Alternate) || (value > FillMode.Winding))
  116. throw new InvalidEnumArgumentException ("FillMode", (int)value, typeof (FillMode));
  117. Status status = GDIPlus.GdipSetPathFillMode (nativePath, value);
  118. GDIPlus.CheckStatus (status);
  119. }
  120. }
  121. public PathData PathData {
  122. get {
  123. int count;
  124. Status status = GDIPlus.GdipGetPointCount (nativePath, out count);
  125. GDIPlus.CheckStatus (status);
  126. PointF [] points = new PointF [count];
  127. status = GDIPlus.GdipGetPathPoints (nativePath, points, count);
  128. GDIPlus.CheckStatus (status);
  129. byte [] types = new byte [count];
  130. status = GDIPlus.GdipGetPathTypes (nativePath, types, count);
  131. GDIPlus.CheckStatus (status);
  132. PathData pdata = new PathData ();
  133. pdata.Points = points;
  134. pdata.Types = types;
  135. return pdata;
  136. }
  137. }
  138. public PointF [] PathPoints {
  139. get {
  140. int count;
  141. Status status = GDIPlus.GdipGetPointCount (nativePath, out count);
  142. GDIPlus.CheckStatus (status);
  143. if (count == 0)
  144. throw new ArgumentException ("PathPoints");
  145. PointF [] points = new PointF [count];
  146. status = GDIPlus.GdipGetPathPoints (nativePath, points, count);
  147. GDIPlus.CheckStatus (status);
  148. return points;
  149. }
  150. }
  151. public byte [] PathTypes {
  152. get {
  153. int count;
  154. Status status = GDIPlus.GdipGetPointCount (nativePath, out count);
  155. GDIPlus.CheckStatus (status);
  156. if (count == 0)
  157. throw new ArgumentException ("PathTypes");
  158. byte [] types = new byte [count];
  159. status = GDIPlus.GdipGetPathTypes (nativePath, types, count);
  160. GDIPlus.CheckStatus (status);
  161. return types;
  162. }
  163. }
  164. public int PointCount {
  165. get {
  166. int count;
  167. Status status = GDIPlus.GdipGetPointCount (nativePath, out count);
  168. GDIPlus.CheckStatus (status);
  169. return count;
  170. }
  171. }
  172. internal IntPtr NativeObject {
  173. get {
  174. return nativePath;
  175. }
  176. set {
  177. nativePath = value;
  178. }
  179. }
  180. //
  181. // AddArc
  182. //
  183. public void AddArc (Rectangle rect, float start_angle, float sweep_angle)
  184. {
  185. Status status = GDIPlus.GdipAddPathArcI (nativePath, rect.X, rect.Y, rect.Width, rect.Height, start_angle, sweep_angle);
  186. GDIPlus.CheckStatus (status);
  187. }
  188. public void AddArc (RectangleF rect, float start_angle, float sweep_angle)
  189. {
  190. Status status = GDIPlus.GdipAddPathArc (nativePath, rect.X, rect.Y, rect.Width, rect.Height, start_angle, sweep_angle);
  191. GDIPlus.CheckStatus (status);
  192. }
  193. public void AddArc (int x, int y, int width, int height, float start_angle, float sweep_angle)
  194. {
  195. Status status = GDIPlus.GdipAddPathArcI (nativePath, x, y, width, height, start_angle, sweep_angle);
  196. GDIPlus.CheckStatus (status);
  197. }
  198. public void AddArc (float x, float y, float width, float height, float start_angle, float sweep_angle)
  199. {
  200. Status status = GDIPlus.GdipAddPathArc (nativePath, x, y, width, height, start_angle, sweep_angle);
  201. GDIPlus.CheckStatus (status);
  202. }
  203. //
  204. // AddBezier
  205. //
  206. public void AddBezier (Point pt1, Point pt2, Point pt3, Point pt4)
  207. {
  208. Status status = GDIPlus.GdipAddPathBezierI (nativePath, pt1.X, pt1.Y,
  209. pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
  210. GDIPlus.CheckStatus (status);
  211. }
  212. public void AddBezier (PointF pt1, PointF pt2, PointF pt3, PointF pt4)
  213. {
  214. Status status = GDIPlus.GdipAddPathBezier (nativePath, pt1.X, pt1.Y,
  215. pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
  216. GDIPlus.CheckStatus (status);
  217. }
  218. public void AddBezier (int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
  219. {
  220. Status status = GDIPlus.GdipAddPathBezierI (nativePath, x1, y1, x2, y2, x3, y3, x4, y4);
  221. GDIPlus.CheckStatus (status);
  222. }
  223. public void AddBezier (float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
  224. {
  225. Status status = GDIPlus.GdipAddPathBezier (nativePath, x1, y1, x2, y2, x3, y3, x4, y4);
  226. GDIPlus.CheckStatus (status);
  227. }
  228. //
  229. // AddBeziers
  230. //
  231. public void AddBeziers (Point [] pts)
  232. {
  233. if (pts == null)
  234. throw new ArgumentNullException ("pts");
  235. Status status = GDIPlus.GdipAddPathBeziersI (nativePath, pts, pts.Length);
  236. GDIPlus.CheckStatus (status);
  237. }
  238. public void AddBeziers (PointF [] pts)
  239. {
  240. if (pts == null)
  241. throw new ArgumentNullException ("pts");
  242. Status status = GDIPlus.GdipAddPathBeziers (nativePath, pts, pts.Length);
  243. GDIPlus.CheckStatus (status);
  244. }
  245. //
  246. // AddEllipse
  247. //
  248. public void AddEllipse (RectangleF r)
  249. {
  250. Status status = GDIPlus.GdipAddPathEllipse (nativePath, r.X, r.Y, r.Width, r.Height);
  251. GDIPlus.CheckStatus (status);
  252. }
  253. public void AddEllipse (float x, float y, float width, float height)
  254. {
  255. Status status = GDIPlus.GdipAddPathEllipse (nativePath, x, y, width, height);
  256. GDIPlus.CheckStatus (status);
  257. }
  258. public void AddEllipse (Rectangle r)
  259. {
  260. Status status = GDIPlus.GdipAddPathEllipseI (nativePath, r.X, r.Y, r.Width, r.Height);
  261. GDIPlus.CheckStatus (status);
  262. }
  263. public void AddEllipse (int x, int y, int width, int height)
  264. {
  265. Status status = GDIPlus.GdipAddPathEllipseI (nativePath, x, y, width, height);
  266. GDIPlus.CheckStatus (status);
  267. }
  268. //
  269. // AddLine
  270. //
  271. public void AddLine (Point a, Point b)
  272. {
  273. Status status = GDIPlus.GdipAddPathLineI (nativePath, a.X, a.Y, b.X, b.Y);
  274. GDIPlus.CheckStatus (status);
  275. }
  276. public void AddLine (PointF a, PointF b)
  277. {
  278. Status status = GDIPlus.GdipAddPathLine (nativePath, a.X, a.Y, b.X,
  279. b.Y);
  280. GDIPlus.CheckStatus (status);
  281. }
  282. public void AddLine (int x1, int y1, int x2, int y2)
  283. {
  284. Status status = GDIPlus.GdipAddPathLineI (nativePath, x1, y1, x2, y2);
  285. GDIPlus.CheckStatus (status);
  286. }
  287. public void AddLine (float x1, float y1, float x2, float y2)
  288. {
  289. Status status = GDIPlus.GdipAddPathLine (nativePath, x1, y1, x2,
  290. y2);
  291. GDIPlus.CheckStatus (status);
  292. }
  293. //
  294. // AddLines
  295. //
  296. public void AddLines (Point [] points)
  297. {
  298. if (points == null)
  299. throw new ArgumentNullException ("points");
  300. if (points.Length == 0)
  301. throw new ArgumentException ("points");
  302. int length = points.Length;
  303. for (int i = 0; i < length - 1; i++) {
  304. int j = i + 1;
  305. Status status = GDIPlus.GdipAddPathLineI (
  306. nativePath, points [i].X, points [i].Y, points [j].X, points [j].Y);
  307. GDIPlus.CheckStatus (status);
  308. }
  309. }
  310. public void AddLines (PointF [] points)
  311. {
  312. if (points == null)
  313. throw new ArgumentNullException ("points");
  314. if (points.Length == 0)
  315. throw new ArgumentException ("points");
  316. int length = points.Length;
  317. for (int i = 0; i < length - 1; i++) {
  318. int j = i + 1;
  319. Status status = GDIPlus.GdipAddPathLine (
  320. nativePath, points [i].X, points [i].Y, points [j].X, points [j].Y);
  321. GDIPlus.CheckStatus (status);
  322. }
  323. }
  324. //
  325. // AddPie
  326. //
  327. public void AddPie (Rectangle rect, float startAngle, float sweepAngle)
  328. {
  329. Status status = GDIPlus.GdipAddPathPie (
  330. nativePath, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
  331. GDIPlus.CheckStatus (status);
  332. }
  333. public void AddPie (int x, int y, int width, int height, float startAngle, float sweepAngle)
  334. {
  335. Status status = GDIPlus.GdipAddPathPieI (nativePath, x, y, width, height, startAngle, sweepAngle);
  336. GDIPlus.CheckStatus (status);
  337. }
  338. public void AddPie (float x, float y, float width, float height, float startAngle, float sweepAngle)
  339. {
  340. Status status = GDIPlus.GdipAddPathPie (nativePath, x, y, width, height, startAngle, sweepAngle);
  341. GDIPlus.CheckStatus (status);
  342. }
  343. //
  344. // AddPolygon
  345. //
  346. public void AddPolygon (Point [] points)
  347. {
  348. if (points == null)
  349. throw new ArgumentNullException ("points");
  350. Status status = GDIPlus.GdipAddPathPolygonI (nativePath, points, points.Length);
  351. GDIPlus.CheckStatus (status);
  352. }
  353. public void AddPolygon (PointF [] points)
  354. {
  355. if (points == null)
  356. throw new ArgumentNullException ("points");
  357. Status status = GDIPlus.GdipAddPathPolygon (nativePath, points, points.Length);
  358. GDIPlus.CheckStatus (status);
  359. }
  360. //
  361. // AddRectangle
  362. //
  363. public void AddRectangle (Rectangle rect)
  364. {
  365. Status status = GDIPlus.GdipAddPathRectangleI (nativePath, rect.X, rect.Y, rect.Width, rect.Height);
  366. GDIPlus.CheckStatus (status);
  367. }
  368. public void AddRectangle (RectangleF rect)
  369. {
  370. Status status = GDIPlus.GdipAddPathRectangle (nativePath, rect.X, rect.Y, rect.Width, rect.Height);
  371. GDIPlus.CheckStatus (status);
  372. }
  373. //
  374. // AddRectangles
  375. //
  376. public void AddRectangles (Rectangle [] rects)
  377. {
  378. if (rects == null)
  379. throw new ArgumentNullException ("rects");
  380. if (rects.Length == 0)
  381. throw new ArgumentException ("rects");
  382. Status status = GDIPlus.GdipAddPathRectanglesI (nativePath, rects, rects.Length);
  383. GDIPlus.CheckStatus (status);
  384. }
  385. public void AddRectangles (RectangleF [] rects)
  386. {
  387. if (rects == null)
  388. throw new ArgumentNullException ("rects");
  389. if (rects.Length == 0)
  390. throw new ArgumentException ("rects");
  391. Status status = GDIPlus.GdipAddPathRectangles (nativePath, rects, rects.Length);
  392. GDIPlus.CheckStatus (status);
  393. }
  394. //
  395. // AddPath
  396. //
  397. public void AddPath (GraphicsPath addingPath, bool connect)
  398. {
  399. if (addingPath == null)
  400. throw new ArgumentNullException ("addingPath");
  401. Status status = GDIPlus.GdipAddPathPath (nativePath, addingPath.nativePath, connect);
  402. GDIPlus.CheckStatus (status);
  403. }
  404. public PointF GetLastPoint ()
  405. {
  406. PointF pt;
  407. Status status = GDIPlus.GdipGetPathLastPoint (nativePath, out pt);
  408. GDIPlus.CheckStatus (status);
  409. return pt;
  410. }
  411. //
  412. // AddClosedCurve
  413. //
  414. public void AddClosedCurve (Point [] points)
  415. {
  416. if (points == null)
  417. throw new ArgumentNullException ("points");
  418. Status status = GDIPlus.GdipAddPathClosedCurveI (nativePath, points, points.Length);
  419. GDIPlus.CheckStatus (status);
  420. }
  421. public void AddClosedCurve (PointF [] points)
  422. {
  423. if (points == null)
  424. throw new ArgumentNullException ("points");
  425. Status status = GDIPlus.GdipAddPathClosedCurve (nativePath, points, points.Length);
  426. GDIPlus.CheckStatus (status);
  427. }
  428. public void AddClosedCurve (Point [] points, float tension)
  429. {
  430. if (points == null)
  431. throw new ArgumentNullException ("points");
  432. Status status = GDIPlus.GdipAddPathClosedCurve2I (nativePath, points, points.Length, tension);
  433. GDIPlus.CheckStatus (status);
  434. }
  435. public void AddClosedCurve (PointF [] points, float tension)
  436. {
  437. if (points == null)
  438. throw new ArgumentNullException ("points");
  439. Status status = GDIPlus.GdipAddPathClosedCurve2 (nativePath, points, points.Length, tension);
  440. GDIPlus.CheckStatus (status);
  441. }
  442. //
  443. // AddCurve
  444. //
  445. public void AddCurve (Point [] points)
  446. {
  447. if (points == null)
  448. throw new ArgumentNullException ("points");
  449. Status status = GDIPlus.GdipAddPathCurveI (nativePath, points, points.Length);
  450. GDIPlus.CheckStatus (status);
  451. }
  452. public void AddCurve (PointF [] points)
  453. {
  454. if (points == null)
  455. throw new ArgumentNullException ("points");
  456. Status status = GDIPlus.GdipAddPathCurve (nativePath, points, points.Length);
  457. GDIPlus.CheckStatus (status);
  458. }
  459. public void AddCurve (Point [] points, float tension)
  460. {
  461. if (points == null)
  462. throw new ArgumentNullException ("points");
  463. Status status = GDIPlus.GdipAddPathCurve2I (nativePath, points, points.Length, tension);
  464. GDIPlus.CheckStatus (status);
  465. }
  466. public void AddCurve (PointF [] points, float tension)
  467. {
  468. if (points == null)
  469. throw new ArgumentNullException ("points");
  470. Status status = GDIPlus.GdipAddPathCurve2 (nativePath, points, points.Length, tension);
  471. GDIPlus.CheckStatus (status);
  472. }
  473. public void AddCurve (Point [] points, int offset, int numberOfSegments, float tension)
  474. {
  475. if (points == null)
  476. throw new ArgumentNullException ("points");
  477. Status status = GDIPlus.GdipAddPathCurve3I (nativePath, points, points.Length,
  478. offset, numberOfSegments, tension);
  479. GDIPlus.CheckStatus (status);
  480. }
  481. public void AddCurve (PointF [] points, int offset, int numberOfSegments, float tension)
  482. {
  483. if (points == null)
  484. throw new ArgumentNullException ("points");
  485. Status status = GDIPlus.GdipAddPathCurve3 (nativePath, points, points.Length,
  486. offset, numberOfSegments, tension);
  487. GDIPlus.CheckStatus (status);
  488. }
  489. public void Reset ()
  490. {
  491. Status status = GDIPlus.GdipResetPath (nativePath);
  492. GDIPlus.CheckStatus (status);
  493. }
  494. public void Reverse ()
  495. {
  496. Status status = GDIPlus.GdipReversePath (nativePath);
  497. GDIPlus.CheckStatus (status);
  498. }
  499. public void Transform (Matrix matrix)
  500. {
  501. if (matrix == null)
  502. throw new ArgumentNullException ("matrix");
  503. Status status = GDIPlus.GdipTransformPath (nativePath, matrix.nativeMatrix);
  504. GDIPlus.CheckStatus (status);
  505. }
  506. [MonoTODO]
  507. public void AddString (string s, FontFamily family, int style, float emSize, Point origin, StringFormat format)
  508. {
  509. throw new NotImplementedException ();
  510. }
  511. [MonoTODO]
  512. public void AddString (string s, FontFamily family, int style, float emSize, PointF origin, StringFormat format)
  513. {
  514. throw new NotImplementedException ();
  515. }
  516. [MonoTODO]
  517. public void AddString (string s, FontFamily family, int style, float emSize, Rectangle layoutRect, StringFormat format)
  518. {
  519. throw new NotImplementedException ();
  520. }
  521. [MonoTODO]
  522. public void AddString (string s, FontFamily family, int style, float emSize, RectangleF layoutRect, StringFormat format)
  523. {
  524. throw new NotImplementedException ();
  525. }
  526. public void ClearMarkers()
  527. {
  528. Status s = GDIPlus.GdipClearPathMarkers (nativePath);
  529. GDIPlus.CheckStatus (s);
  530. }
  531. public void CloseAllFigures()
  532. {
  533. Status s = GDIPlus.GdipClosePathFigures (nativePath);
  534. GDIPlus.CheckStatus (s);
  535. }
  536. public void CloseFigure()
  537. {
  538. Status s = GDIPlus.GdipClosePathFigure (nativePath);
  539. GDIPlus.CheckStatus (s);
  540. }
  541. public void Flatten ()
  542. {
  543. Flatten (null, FlatnessDefault);
  544. }
  545. public void Flatten (Matrix matrix)
  546. {
  547. Flatten (matrix, FlatnessDefault);
  548. }
  549. public void Flatten (Matrix matrix, float flatness)
  550. {
  551. IntPtr m = (matrix == null) ? IntPtr.Zero : matrix.nativeMatrix;
  552. Status status = GDIPlus.GdipFlattenPath (nativePath, m, flatness);
  553. GDIPlus.CheckStatus (status);
  554. }
  555. public RectangleF GetBounds ()
  556. {
  557. return GetBounds (null, null);
  558. }
  559. public RectangleF GetBounds (Matrix matrix)
  560. {
  561. return GetBounds (matrix, null);
  562. }
  563. [MonoTODO ("GdipGetPathWorldBounds doesn't support pens in libgdiplus (missing GdipWidenPath)")]
  564. public RectangleF GetBounds (Matrix matrix, Pen pen)
  565. {
  566. RectangleF retval;
  567. IntPtr m = (matrix == null) ? IntPtr.Zero : matrix.nativeMatrix;
  568. IntPtr p = (pen == null) ? IntPtr.Zero : pen.nativeObject;
  569. Status s = GDIPlus.GdipGetPathWorldBounds (nativePath, out retval, m, p);
  570. GDIPlus.CheckStatus (s);
  571. return retval;
  572. }
  573. [MonoTODO ("GdipIsOutlineVisiblePathPoint[I] isn't implemented in libgdiplus")]
  574. public bool IsOutlineVisible (Point point, Pen pen)
  575. {
  576. return IsOutlineVisible (point.X, point.Y, pen, null);
  577. }
  578. [MonoTODO ("GdipIsOutlineVisiblePathPoint[I] isn't implemented in libgdiplus")]
  579. public bool IsOutlineVisible (PointF point, Pen pen)
  580. {
  581. return IsOutlineVisible (point.X, point.Y, pen, null);
  582. }
  583. [MonoTODO ("GdipIsOutlineVisiblePathPoint[I] isn't implemented in libgdiplus")]
  584. public bool IsOutlineVisible (int x, int y, Pen pen)
  585. {
  586. return IsOutlineVisible (x, y, pen, null);
  587. }
  588. [MonoTODO ("GdipIsOutlineVisiblePathPoint[I] isn't implemented in libgdiplus")]
  589. public bool IsOutlineVisible (float x, float y, Pen pen)
  590. {
  591. return IsOutlineVisible (x, y, pen, null);
  592. }
  593. [MonoTODO ("GdipIsOutlineVisiblePathPoint[I] isn't implemented in libgdiplus")]
  594. public bool IsOutlineVisible (Point pt, Pen pen, Graphics graphics)
  595. {
  596. return IsOutlineVisible (pt.X, pt.Y, pen, graphics);
  597. }
  598. [MonoTODO ("GdipIsOutlineVisiblePathPoint[I] isn't implemented in libgdiplus")]
  599. public bool IsOutlineVisible (PointF pt, Pen pen, Graphics graphics)
  600. {
  601. return IsOutlineVisible (pt.X, pt.Y, pen, graphics);
  602. }
  603. [MonoTODO ("GdipIsOutlineVisiblePathPoint[I] isn't implemented in libgdiplus")]
  604. public bool IsOutlineVisible (int x, int y, Pen pen, Graphics graphics)
  605. {
  606. bool result;
  607. IntPtr g = (graphics == null) ? IntPtr.Zero : graphics.nativeObject;
  608. Status s = GDIPlus.GdipIsOutlineVisiblePathPointI (nativePath, x, y, g, out result);
  609. GDIPlus.CheckStatus (s);
  610. return result;
  611. }
  612. [MonoTODO ("GdipIsOutlineVisiblePathPoint[I] isn't implemented in libgdiplus")]
  613. public bool IsOutlineVisible (float x, float y, Pen pen, Graphics graphics)
  614. {
  615. bool result;
  616. IntPtr g = (graphics == null) ? IntPtr.Zero : graphics.nativeObject;
  617. Status s = GDIPlus.GdipIsOutlineVisiblePathPoint (nativePath, x, y, g, out result);
  618. GDIPlus.CheckStatus (s);
  619. return result;
  620. }
  621. [MonoTODO ("GdipIsVisiblePathPoint[I] isn't implemented in libgdiplus")]
  622. public bool IsVisible (Point point)
  623. {
  624. return IsVisible (point.X, point.Y, null);
  625. }
  626. [MonoTODO ("GdipIsVisiblePathPoint[I] isn't implemented in libgdiplus")]
  627. public bool IsVisible (PointF point)
  628. {
  629. return IsVisible (point.X, point.Y, null);
  630. }
  631. [MonoTODO ("GdipIsVisiblePathPoint[I] isn't implemented in libgdiplus")]
  632. public bool IsVisible (int x, int y)
  633. {
  634. return IsVisible (x, y, null);
  635. }
  636. [MonoTODO ("GdipIsVisiblePathPoint[I] isn't implemented in libgdiplus")]
  637. public bool IsVisible (float x, float y)
  638. {
  639. return IsVisible (x, y, null);
  640. }
  641. [MonoTODO ("GdipIsVisiblePathPoint[I] isn't implemented in libgdiplus")]
  642. public bool IsVisible (Point pt, Graphics graphics)
  643. {
  644. return IsVisible (pt.X, pt.Y, graphics);
  645. }
  646. [MonoTODO ("GdipIsVisiblePathPoint[I] isn't implemented in libgdiplus")]
  647. public bool IsVisible (PointF pt, Graphics graphics)
  648. {
  649. return IsVisible (pt.X, pt.Y, graphics);
  650. }
  651. [MonoTODO ("GdipIsVisiblePathPoint[I] isn't implemented in libgdiplus")]
  652. public bool IsVisible (int x, int y, Graphics graphics)
  653. {
  654. bool retval;
  655. IntPtr g = (graphics == null) ? IntPtr.Zero : graphics.nativeObject;
  656. Status s = GDIPlus.GdipIsVisiblePathPointI (nativePath, x, y, g, out retval);
  657. GDIPlus.CheckStatus (s);
  658. return retval;
  659. }
  660. [MonoTODO ("GdipIsVisiblePathPoint[I] isn't implemented in libgdiplus")]
  661. public bool IsVisible (float x, float y, Graphics graphics)
  662. {
  663. bool retval;
  664. IntPtr g = (graphics == null) ? IntPtr.Zero : graphics.nativeObject;
  665. Status s = GDIPlus.GdipIsVisiblePathPoint (nativePath, x, y, g, out retval);
  666. GDIPlus.CheckStatus (s);
  667. return retval;
  668. }
  669. public void SetMarkers ()
  670. {
  671. Status s = GDIPlus.GdipSetPathMarker (nativePath);
  672. GDIPlus.CheckStatus (s);
  673. }
  674. public void StartFigure()
  675. {
  676. Status s = GDIPlus.GdipStartPathFigure (nativePath);
  677. GDIPlus.CheckStatus (s);
  678. }
  679. [MonoTODO ("GdipWarpPath isn't implemented in libgdiplus")]
  680. public void Warp (PointF[] destPoints, RectangleF srcRect)
  681. {
  682. Warp (destPoints, srcRect, null, WarpMode.Perspective, FlatnessDefault);
  683. }
  684. [MonoTODO ("GdipWarpPath isn't implemented in libgdiplus")]
  685. public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix)
  686. {
  687. Warp (destPoints, srcRect, matrix, WarpMode.Perspective, FlatnessDefault);
  688. }
  689. [MonoTODO ("GdipWarpPath isn't implemented in libgdiplus")]
  690. public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode)
  691. {
  692. Warp (destPoints, srcRect, matrix, warpMode, FlatnessDefault);
  693. }
  694. [MonoTODO ("GdipWarpPath isn't implemented in libgdiplus")]
  695. public void Warp (PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode, float flatness)
  696. {
  697. if (destPoints == null)
  698. throw new ArgumentNullException ("destPoints");
  699. IntPtr m = (matrix == null) ? IntPtr.Zero : matrix.nativeMatrix;
  700. Status s = GDIPlus.GdipWarpPath (nativePath, m, destPoints, destPoints.Length,
  701. srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, warpMode, flatness);
  702. GDIPlus.CheckStatus (s);
  703. }
  704. [MonoTODO ("GdipWidenPath isn't implemented in libgdiplus")]
  705. public void Widen (Pen pen)
  706. {
  707. Widen (pen, null, FlatnessDefault);
  708. }
  709. [MonoTODO ("GdipWidenPath isn't implemented in libgdiplus")]
  710. public void Widen (Pen pen, Matrix matrix)
  711. {
  712. Widen (pen, matrix, FlatnessDefault);
  713. }
  714. [MonoTODO ("GdipWidenPath isn't implemented in libgdiplus")]
  715. public void Widen (Pen pen, Matrix matrix, float flatness)
  716. {
  717. IntPtr p = (pen == null) ? IntPtr.Zero : pen.nativeObject;
  718. IntPtr m = (matrix == null) ? IntPtr.Zero : matrix.nativeMatrix;
  719. Status s = GDIPlus.GdipWidenPath (nativePath, p, m, flatness);
  720. GDIPlus.CheckStatus (s);
  721. }
  722. }
  723. }