Graphics.cs 79 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490
  1. //
  2. // System.Drawing.Graphics.cs
  3. //
  4. // Authors:
  5. // Gonzalo Paniagua Javier ([email protected]) (stubbed out)
  6. // Alexandre Pigolkine([email protected])
  7. // Jordi Mas i Hernandez ([email protected])
  8. // Sebastien Pouliot <[email protected]>
  9. //
  10. // Copyright (C) 2003 Ximian, Inc. (http://www.ximian.com)
  11. // Copyright (C) 2004-2006 Novell, Inc. (http://www.novell.com)
  12. //
  13. // Permission is hereby granted, free of charge, to any person obtaining
  14. // a copy of this software and associated documentation files (the
  15. // "Software"), to deal in the Software without restriction, including
  16. // without limitation the rights to use, copy, modify, merge, publish,
  17. // distribute, sublicense, and/or sell copies of the Software, and to
  18. // permit persons to whom the Software is furnished to do so, subject to
  19. // the following conditions:
  20. //
  21. // The above copyright notice and this permission notice shall be
  22. // included in all copies or substantial portions of the Software.
  23. //
  24. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  28. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  29. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  30. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  31. //
  32. using System.Drawing.Drawing2D;
  33. using System.Drawing.Imaging;
  34. using System.Drawing.Text;
  35. using System.ComponentModel;
  36. using System.Runtime.InteropServices;
  37. using System.Security.Permissions;
  38. using System.Text;
  39. namespace System.Drawing
  40. {
  41. #if !NET_2_0
  42. [ComVisible(false)]
  43. #endif
  44. public sealed class Graphics : MarshalByRefObject, IDisposable
  45. #if NET_2_0
  46. , IDeviceContext
  47. #endif
  48. {
  49. internal IntPtr nativeObject = IntPtr.Zero;
  50. private bool disposed = false;
  51. private static float defDpiX = 0;
  52. private static float defDpiY = 0;
  53. #if NET_2_0
  54. private IntPtr deviceContextHdc;
  55. #endif
  56. #if !NET_2_0
  57. [ComVisible(false)]
  58. #endif
  59. public delegate bool EnumerateMetafileProc (EmfPlusRecordType recordType,
  60. int flags,
  61. int dataSize,
  62. IntPtr data,
  63. PlayRecordCallback callbackData);
  64. #if !NET_2_0
  65. [ComVisible (false)]
  66. #endif
  67. public delegate bool DrawImageAbort (IntPtr callbackData);
  68. internal Graphics (IntPtr nativeGraphics)
  69. {
  70. nativeObject = nativeGraphics;
  71. }
  72. ~Graphics ()
  73. {
  74. Dispose ();
  75. }
  76. static internal float systemDpiX {
  77. get {
  78. if (defDpiX == 0) {
  79. Bitmap bmp = new Bitmap (1, 1);
  80. Graphics g = Graphics.FromImage (bmp);
  81. defDpiX = g.DpiX;
  82. defDpiY = g.DpiY;
  83. }
  84. return defDpiX;
  85. }
  86. }
  87. static internal float systemDpiY {
  88. get {
  89. if (defDpiY == 0) {
  90. Bitmap bmp = new Bitmap (1, 1);
  91. Graphics g = Graphics.FromImage (bmp);
  92. defDpiX = g.DpiX;
  93. defDpiY = g.DpiY;
  94. }
  95. return defDpiY;
  96. }
  97. }
  98. internal IntPtr NativeObject {
  99. get {
  100. return nativeObject;
  101. }
  102. set {
  103. nativeObject = value;
  104. }
  105. }
  106. [MonoTODO]
  107. public void AddMetafileComment (byte [] data)
  108. {
  109. throw new NotImplementedException ();
  110. }
  111. public GraphicsContainer BeginContainer ()
  112. {
  113. uint state;
  114. Status status;
  115. status = GDIPlus.GdipBeginContainer2 (nativeObject, out state);
  116. GDIPlus.CheckStatus (status);
  117. return new GraphicsContainer(state);
  118. }
  119. [MonoTODO ("rectangles and unit aren't supported in libgdiplus")]
  120. public GraphicsContainer BeginContainer (Rectangle dstrect, Rectangle srcrect, GraphicsUnit unit)
  121. {
  122. uint state;
  123. Status status;
  124. status = GDIPlus.GdipBeginContainerI (nativeObject, ref dstrect, ref srcrect, unit, out state);
  125. GDIPlus.CheckStatus (status);
  126. return new GraphicsContainer (state);
  127. }
  128. [MonoTODO ("rectangles and unit aren't supported in libgdiplus")]
  129. public GraphicsContainer BeginContainer (RectangleF dstrect, RectangleF srcrect, GraphicsUnit unit)
  130. {
  131. uint state;
  132. Status status;
  133. status = GDIPlus.GdipBeginContainer (nativeObject, ref dstrect, ref srcrect, unit, out state);
  134. GDIPlus.CheckStatus (status);
  135. return new GraphicsContainer (state);
  136. }
  137. public void Clear (Color color)
  138. {
  139. Status status;
  140. status = GDIPlus.GdipGraphicsClear (nativeObject, color.ToArgb ());
  141. GDIPlus.CheckStatus (status);
  142. }
  143. #if NET_2_0
  144. public void CopyFromScreen (Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize)
  145. {
  146. CopyFromScreen (upperLeftSource.X, upperLeftSource.Y, upperLeftDestination.X, upperLeftDestination.Y,
  147. blockRegionSize, CopyPixelOperation.SourceCopy);
  148. }
  149. public void CopyFromScreen (Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
  150. {
  151. CopyFromScreen (upperLeftSource.X, upperLeftSource.Y, upperLeftDestination.X, upperLeftDestination.Y,
  152. blockRegionSize, copyPixelOperation);
  153. }
  154. public void CopyFromScreen (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize)
  155. {
  156. CopyFromScreen (sourceX, sourceY, destinationX, destinationY, blockRegionSize,
  157. CopyPixelOperation.SourceCopy);
  158. }
  159. public void CopyFromScreen (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
  160. {
  161. IntPtr window;
  162. if (!Enum.IsDefined (typeof (CopyPixelOperation), copyPixelOperation))
  163. throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for CopyPixelOperation", copyPixelOperation));
  164. if (GDIPlus.UseCocoaDrawable || GDIPlus.UseQuartzDrawable) {
  165. throw new NotImplementedException ();
  166. }
  167. if (GDIPlus.UseX11Drawable) { // X11 implementation
  168. IntPtr image, defvisual, vPtr;
  169. int AllPlanes = ~0, nitems = 0, pixel;
  170. if (copyPixelOperation != CopyPixelOperation.SourceCopy)
  171. throw new NotImplementedException ("Operation not implemented under X11");
  172. if (GDIPlus.Display == IntPtr.Zero) {
  173. GDIPlus.Display = GDIPlus.XOpenDisplay (IntPtr.Zero);
  174. }
  175. window = GDIPlus.XRootWindow (GDIPlus.Display, 0);
  176. defvisual = GDIPlus.XDefaultVisual (GDIPlus.Display, 0);
  177. XVisualInfo visual = new XVisualInfo ();
  178. /* Get XVisualInfo for this visual */
  179. visual.visualid = GDIPlus.XVisualIDFromVisual(defvisual);
  180. vPtr = GDIPlus.XGetVisualInfo (GDIPlus.Display, 0x1 /* VisualIDMask */, ref visual, ref nitems);
  181. visual = (XVisualInfo) Marshal.PtrToStructure(vPtr, typeof (XVisualInfo));
  182. /* Sorry I do not have access to a computer with > deepth. Fell free to add more pixel formats */
  183. image = GDIPlus.XGetImage (GDIPlus.Display, window, sourceX, sourceY, blockRegionSize.Width,
  184. blockRegionSize.Height, AllPlanes, 2 /* ZPixmap*/);
  185. Bitmap bmp = new Bitmap (blockRegionSize.Width, blockRegionSize.Height);
  186. int red, blue, green;
  187. for (int y = sourceY; y < sourceY + blockRegionSize.Height; y++) {
  188. for (int x = sourceX; x < sourceX + blockRegionSize.Width; x++) {
  189. pixel = GDIPlus.XGetPixel (image, x, y);
  190. switch (visual.depth) {
  191. case 16: /* 16bbp pixel transformation */
  192. red = (int) ((pixel & visual.red_mask ) >> 8) & 0xff;
  193. green = (int) (((pixel & visual.green_mask ) >> 3 )) & 0xff;
  194. blue = (int) ((pixel & visual.blue_mask ) << 3 ) & 0xff;
  195. break;
  196. case 24:
  197. case 32:
  198. red = (int) ((pixel & visual.red_mask ) >> 16) & 0xff;
  199. green = (int) (((pixel & visual.green_mask ) >> 8 )) & 0xff;
  200. blue = (int) ((pixel & visual.blue_mask )) & 0xff;
  201. break;
  202. default:
  203. throw new NotImplementedException ("Deepth not supported right now");
  204. }
  205. bmp.SetPixel (x, y, Color.FromArgb (255, red, green, blue));
  206. }
  207. }
  208. DrawImage (bmp, 0, 0);
  209. bmp.Dispose ();
  210. GDIPlus.XDestroyImage (image);
  211. GDIPlus.XFree (vPtr);
  212. return;
  213. }
  214. // Win32 implementation
  215. window = GDIPlus.GetDesktopWindow ();
  216. IntPtr srcDC = GDIPlus.GetDC (window);
  217. IntPtr dstDC = GetHdc ();
  218. GDIPlus.BitBlt (dstDC, destinationX, destinationY, blockRegionSize.Width,
  219. blockRegionSize.Height, srcDC, sourceX, sourceY, (int) copyPixelOperation);
  220. GDIPlus.ReleaseDC (srcDC);
  221. ReleaseHdc (dstDC);
  222. }
  223. #endif
  224. public void Dispose ()
  225. {
  226. Status status;
  227. if (! disposed) {
  228. status = GDIPlus.GdipDeleteGraphics (nativeObject);
  229. nativeObject = IntPtr.Zero;
  230. GDIPlus.CheckStatus (status);
  231. disposed = true;
  232. }
  233. GC.SuppressFinalize(this);
  234. }
  235. public void DrawArc (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
  236. {
  237. DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
  238. }
  239. public void DrawArc (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
  240. {
  241. DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
  242. }
  243. public void DrawArc (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
  244. {
  245. Status status;
  246. if (pen == null)
  247. throw new ArgumentNullException ("pen");
  248. status = GDIPlus.GdipDrawArc (nativeObject, pen.nativeObject,
  249. x, y, width, height, startAngle, sweepAngle);
  250. GDIPlus.CheckStatus (status);
  251. }
  252. // Microsoft documentation states that the signature for this member should be
  253. // public void DrawArc( Pen pen, int x, int y, int width, int height, int startAngle,
  254. // int sweepAngle. However, GdipDrawArcI uses also float for the startAngle and sweepAngle params
  255. public void DrawArc (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
  256. {
  257. Status status;
  258. if (pen == null)
  259. throw new ArgumentNullException ("pen");
  260. status = GDIPlus.GdipDrawArcI (nativeObject, pen.nativeObject,
  261. x, y, width, height, startAngle, sweepAngle);
  262. GDIPlus.CheckStatus (status);
  263. }
  264. public void DrawBezier (Pen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4)
  265. {
  266. Status status;
  267. if (pen == null)
  268. throw new ArgumentNullException ("pen");
  269. status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject,
  270. pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
  271. pt3.Y, pt4.X, pt4.Y);
  272. GDIPlus.CheckStatus (status);
  273. }
  274. public void DrawBezier (Pen pen, Point pt1, Point pt2, Point pt3, Point pt4)
  275. {
  276. Status status;
  277. if (pen == null)
  278. throw new ArgumentNullException ("pen");
  279. status = GDIPlus.GdipDrawBezierI (nativeObject, pen.nativeObject,
  280. pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
  281. pt3.Y, pt4.X, pt4.Y);
  282. GDIPlus.CheckStatus (status);
  283. }
  284. public void DrawBezier (Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
  285. {
  286. Status status;
  287. if (pen == null)
  288. throw new ArgumentNullException ("pen");
  289. status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject, x1,
  290. y1, x2, y2, x3, y3, x4, y4);
  291. GDIPlus.CheckStatus (status);
  292. }
  293. public void DrawBeziers (Pen pen, Point [] points)
  294. {
  295. if (pen == null)
  296. throw new ArgumentNullException ("pen");
  297. if (points == null)
  298. throw new ArgumentNullException ("points");
  299. int length = points.Length;
  300. Status status;
  301. if (length < 4)
  302. return;
  303. for (int i = 0; i < length - 1; i += 3) {
  304. Point p1 = points [i];
  305. Point p2 = points [i + 1];
  306. Point p3 = points [i + 2];
  307. Point p4 = points [i + 3];
  308. status = GDIPlus.GdipDrawBezier (nativeObject,
  309. pen.nativeObject,
  310. p1.X, p1.Y, p2.X, p2.Y,
  311. p3.X, p3.Y, p4.X, p4.Y);
  312. GDIPlus.CheckStatus (status);
  313. }
  314. }
  315. public void DrawBeziers (Pen pen, PointF [] points)
  316. {
  317. if (pen == null)
  318. throw new ArgumentNullException ("pen");
  319. if (points == null)
  320. throw new ArgumentNullException ("points");
  321. int length = points.Length;
  322. Status status;
  323. if (length < 4)
  324. return;
  325. for (int i = 0; i < length - 1; i += 3) {
  326. PointF p1 = points [i];
  327. PointF p2 = points [i + 1];
  328. PointF p3 = points [i + 2];
  329. PointF p4 = points [i + 3];
  330. status = GDIPlus.GdipDrawBezier (nativeObject,
  331. pen.nativeObject,
  332. p1.X, p1.Y, p2.X, p2.Y,
  333. p3.X, p3.Y, p4.X, p4.Y);
  334. GDIPlus.CheckStatus (status);
  335. }
  336. }
  337. public void DrawClosedCurve (Pen pen, PointF [] points)
  338. {
  339. if (pen == null)
  340. throw new ArgumentNullException ("pen");
  341. if (points == null)
  342. throw new ArgumentNullException ("points");
  343. Status status;
  344. status = GDIPlus.GdipDrawClosedCurve (nativeObject, pen.nativeObject, points, points.Length);
  345. GDIPlus.CheckStatus (status);
  346. }
  347. public void DrawClosedCurve (Pen pen, Point [] points)
  348. {
  349. if (pen == null)
  350. throw new ArgumentNullException ("pen");
  351. if (points == null)
  352. throw new ArgumentNullException ("points");
  353. Status status;
  354. status = GDIPlus.GdipDrawClosedCurveI (nativeObject, pen.nativeObject, points, points.Length);
  355. GDIPlus.CheckStatus (status);
  356. }
  357. public void DrawClosedCurve (Pen pen, Point [] points, float tension, FillMode fillmode)
  358. {
  359. if (pen == null)
  360. throw new ArgumentNullException ("pen");
  361. if (points == null)
  362. throw new ArgumentNullException ("points");
  363. Status status;
  364. status = GDIPlus.GdipDrawClosedCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
  365. GDIPlus.CheckStatus (status);
  366. }
  367. public void DrawClosedCurve (Pen pen, PointF [] points, float tension, FillMode fillmode)
  368. {
  369. if (pen == null)
  370. throw new ArgumentNullException ("pen");
  371. if (points == null)
  372. throw new ArgumentNullException ("points");
  373. Status status;
  374. status = GDIPlus.GdipDrawClosedCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
  375. GDIPlus.CheckStatus (status);
  376. }
  377. public void DrawCurve (Pen pen, Point [] points)
  378. {
  379. if (pen == null)
  380. throw new ArgumentNullException ("pen");
  381. if (points == null)
  382. throw new ArgumentNullException ("points");
  383. Status status;
  384. status = GDIPlus.GdipDrawCurveI (nativeObject, pen.nativeObject, points, points.Length);
  385. GDIPlus.CheckStatus (status);
  386. }
  387. public void DrawCurve (Pen pen, PointF [] points)
  388. {
  389. if (pen == null)
  390. throw new ArgumentNullException ("pen");
  391. if (points == null)
  392. throw new ArgumentNullException ("points");
  393. Status status;
  394. status = GDIPlus.GdipDrawCurve (nativeObject, pen.nativeObject, points, points.Length);
  395. GDIPlus.CheckStatus (status);
  396. }
  397. public void DrawCurve (Pen pen, PointF [] points, float tension)
  398. {
  399. if (pen == null)
  400. throw new ArgumentNullException ("pen");
  401. if (points == null)
  402. throw new ArgumentNullException ("points");
  403. Status status;
  404. status = GDIPlus.GdipDrawCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
  405. GDIPlus.CheckStatus (status);
  406. }
  407. public void DrawCurve (Pen pen, Point [] points, float tension)
  408. {
  409. if (pen == null)
  410. throw new ArgumentNullException ("pen");
  411. if (points == null)
  412. throw new ArgumentNullException ("points");
  413. Status status;
  414. status = GDIPlus.GdipDrawCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
  415. GDIPlus.CheckStatus (status);
  416. }
  417. public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments)
  418. {
  419. if (pen == null)
  420. throw new ArgumentNullException ("pen");
  421. if (points == null)
  422. throw new ArgumentNullException ("points");
  423. Status status;
  424. status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
  425. points, points.Length, offset,
  426. numberOfSegments, 0.5f);
  427. GDIPlus.CheckStatus (status);
  428. }
  429. public void DrawCurve (Pen pen, Point [] points, int offset, int numberOfSegments, float tension)
  430. {
  431. if (pen == null)
  432. throw new ArgumentNullException ("pen");
  433. if (points == null)
  434. throw new ArgumentNullException ("points");
  435. Status status;
  436. status = GDIPlus.GdipDrawCurve3I (nativeObject, pen.nativeObject,
  437. points, points.Length, offset,
  438. numberOfSegments, tension);
  439. GDIPlus.CheckStatus (status);
  440. }
  441. public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments, float tension)
  442. {
  443. if (pen == null)
  444. throw new ArgumentNullException ("pen");
  445. if (points == null)
  446. throw new ArgumentNullException ("points");
  447. Status status;
  448. status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
  449. points, points.Length, offset,
  450. numberOfSegments, tension);
  451. GDIPlus.CheckStatus (status);
  452. }
  453. public void DrawEllipse (Pen pen, Rectangle rect)
  454. {
  455. if (pen == null)
  456. throw new ArgumentNullException ("pen");
  457. DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
  458. }
  459. public void DrawEllipse (Pen pen, RectangleF rect)
  460. {
  461. if (pen == null)
  462. throw new ArgumentNullException ("pen");
  463. DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
  464. }
  465. public void DrawEllipse (Pen pen, int x, int y, int width, int height)
  466. {
  467. if (pen == null)
  468. throw new ArgumentNullException ("pen");
  469. Status status;
  470. status = GDIPlus.GdipDrawEllipseI (nativeObject, pen.nativeObject, x, y, width, height);
  471. GDIPlus.CheckStatus (status);
  472. }
  473. public void DrawEllipse (Pen pen, float x, float y, float width, float height)
  474. {
  475. if (pen == null)
  476. throw new ArgumentNullException ("pen");
  477. Status status = GDIPlus.GdipDrawEllipse (nativeObject, pen.nativeObject, x, y, width, height);
  478. GDIPlus.CheckStatus (status);
  479. }
  480. public void DrawIcon (Icon icon, Rectangle targetRect)
  481. {
  482. using (Image img = icon.ToBitmap ()) {
  483. DrawImage (img, targetRect);
  484. }
  485. }
  486. public void DrawIcon (Icon icon, int x, int y)
  487. {
  488. using (Image img = icon.ToBitmap ()) {
  489. DrawImage (img, x, y);
  490. }
  491. }
  492. public void DrawIconUnstretched (Icon icon, Rectangle targetRect)
  493. {
  494. using (Image img = icon.ToBitmap ()) {
  495. DrawImageUnscaled (img, targetRect);
  496. }
  497. }
  498. public void DrawImage (Image image, RectangleF rect)
  499. {
  500. if (image == null)
  501. throw new ArgumentNullException ("image");
  502. Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, rect.X, rect.Y, rect.Width, rect.Height);
  503. GDIPlus.CheckStatus (status);
  504. }
  505. public void DrawImage (Image image, PointF point)
  506. {
  507. if (image == null)
  508. throw new ArgumentNullException ("image");
  509. Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, point.X, point.Y);
  510. GDIPlus.CheckStatus (status);
  511. }
  512. public void DrawImage (Image image, Point [] destPoints)
  513. {
  514. if (image == null)
  515. throw new ArgumentNullException ("image");
  516. if (destPoints == null)
  517. throw new ArgumentNullException ("destPoints");
  518. Status status = GDIPlus.GdipDrawImagePointsI (nativeObject, image.NativeObject, destPoints, destPoints.Length);
  519. GDIPlus.CheckStatus (status);
  520. }
  521. public void DrawImage (Image image, Point point)
  522. {
  523. if (image == null)
  524. throw new ArgumentNullException ("image");
  525. DrawImage (image, point.X, point.Y);
  526. }
  527. public void DrawImage (Image image, Rectangle rect)
  528. {
  529. if (image == null)
  530. throw new ArgumentNullException ("image");
  531. DrawImage (image, rect.X, rect.Y, rect.Width, rect.Height);
  532. }
  533. public void DrawImage (Image image, PointF [] destPoints)
  534. {
  535. if (image == null)
  536. throw new ArgumentNullException ("image");
  537. if (destPoints == null)
  538. throw new ArgumentNullException ("destPoints");
  539. Status status = GDIPlus.GdipDrawImagePoints (nativeObject, image.NativeObject, destPoints, destPoints.Length);
  540. GDIPlus.CheckStatus (status);
  541. }
  542. public void DrawImage (Image image, int x, int y)
  543. {
  544. if (image == null)
  545. throw new ArgumentNullException ("image");
  546. Status status = GDIPlus.GdipDrawImageI (nativeObject, image.NativeObject, x, y);
  547. GDIPlus.CheckStatus (status);
  548. }
  549. public void DrawImage (Image image, float x, float y)
  550. {
  551. if (image == null)
  552. throw new ArgumentNullException ("image");
  553. Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, x, y);
  554. GDIPlus.CheckStatus (status);
  555. }
  556. public void DrawImage (Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit)
  557. {
  558. if (image == null)
  559. throw new ArgumentNullException ("image");
  560. Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
  561. destRect.X, destRect.Y, destRect.Width, destRect.Height,
  562. srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
  563. srcUnit, IntPtr.Zero, null, IntPtr.Zero);
  564. GDIPlus.CheckStatus (status);
  565. }
  566. public void DrawImage (Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit)
  567. {
  568. if (image == null)
  569. throw new ArgumentNullException ("image");
  570. Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
  571. destRect.X, destRect.Y, destRect.Width, destRect.Height,
  572. srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
  573. srcUnit, IntPtr.Zero, null, IntPtr.Zero);
  574. GDIPlus.CheckStatus (status);
  575. }
  576. public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit)
  577. {
  578. if (image == null)
  579. throw new ArgumentNullException ("image");
  580. if (destPoints == null)
  581. throw new ArgumentNullException ("destPoints");
  582. Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
  583. destPoints, destPoints.Length , srcRect.X, srcRect.Y,
  584. srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero,
  585. null, IntPtr.Zero);
  586. GDIPlus.CheckStatus (status);
  587. }
  588. public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit)
  589. {
  590. if (image == null)
  591. throw new ArgumentNullException ("image");
  592. if (destPoints == null)
  593. throw new ArgumentNullException ("destPoints");
  594. Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
  595. destPoints, destPoints.Length , srcRect.X, srcRect.Y,
  596. srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero,
  597. null, IntPtr.Zero);
  598. GDIPlus.CheckStatus (status);
  599. }
  600. public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit,
  601. ImageAttributes imageAttr)
  602. {
  603. if (image == null)
  604. throw new ArgumentNullException ("image");
  605. if (destPoints == null)
  606. throw new ArgumentNullException ("destPoints");
  607. Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
  608. destPoints, destPoints.Length , srcRect.X, srcRect.Y,
  609. srcRect.Width, srcRect.Height, srcUnit,
  610. imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
  611. GDIPlus.CheckStatus (status);
  612. }
  613. public void DrawImage (Image image, float x, float y, float width, float height)
  614. {
  615. if (image == null)
  616. throw new ArgumentNullException ("image");
  617. Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, x, y,
  618. width, height);
  619. GDIPlus.CheckStatus (status);
  620. }
  621. public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit,
  622. ImageAttributes imageAttr)
  623. {
  624. if (image == null)
  625. throw new ArgumentNullException ("image");
  626. if (destPoints == null)
  627. throw new ArgumentNullException ("destPoints");
  628. Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
  629. destPoints, destPoints.Length , srcRect.X, srcRect.Y,
  630. srcRect.Width, srcRect.Height, srcUnit,
  631. imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
  632. GDIPlus.CheckStatus (status);
  633. }
  634. public void DrawImage (Image image, int x, int y, Rectangle srcRect, GraphicsUnit srcUnit)
  635. {
  636. if (image == null)
  637. throw new ArgumentNullException ("image");
  638. Status status = GDIPlus.GdipDrawImagePointRectI(nativeObject, image.NativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
  639. GDIPlus.CheckStatus (status);
  640. }
  641. public void DrawImage (Image image, int x, int y, int width, int height)
  642. {
  643. if (image == null)
  644. throw new ArgumentNullException ("image");
  645. Status status = GDIPlus.GdipDrawImageRectI (nativeObject, image.nativeObject, x, y, width, height);
  646. GDIPlus.CheckStatus (status);
  647. }
  648. public void DrawImage (Image image, float x, float y, RectangleF srcRect, GraphicsUnit srcUnit)
  649. {
  650. if (image == null)
  651. throw new ArgumentNullException ("image");
  652. Status status = GDIPlus.GdipDrawImagePointRect (nativeObject, image.nativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
  653. GDIPlus.CheckStatus (status);
  654. }
  655. public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
  656. {
  657. if (image == null)
  658. throw new ArgumentNullException ("image");
  659. if (destPoints == null)
  660. throw new ArgumentNullException ("destPoints");
  661. Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
  662. destPoints, destPoints.Length , srcRect.X, srcRect.Y,
  663. srcRect.Width, srcRect.Height, srcUnit,
  664. imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, IntPtr.Zero);
  665. GDIPlus.CheckStatus (status);
  666. }
  667. public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
  668. {
  669. if (image == null)
  670. throw new ArgumentNullException ("image");
  671. if (destPoints == null)
  672. throw new ArgumentNullException ("destPoints");
  673. Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
  674. destPoints, destPoints.Length , srcRect.X, srcRect.Y,
  675. srcRect.Width, srcRect.Height, srcUnit,
  676. imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, IntPtr.Zero);
  677. GDIPlus.CheckStatus (status);
  678. }
  679. public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
  680. {
  681. if (image == null)
  682. throw new ArgumentNullException ("image");
  683. if (destPoints == null)
  684. throw new ArgumentNullException ("destPoints");
  685. Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
  686. destPoints, destPoints.Length , srcRect.X, srcRect.Y,
  687. srcRect.Width, srcRect.Height, srcUnit,
  688. imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, (IntPtr) callbackData);
  689. GDIPlus.CheckStatus (status);
  690. }
  691. public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit)
  692. {
  693. if (image == null)
  694. throw new ArgumentNullException ("image");
  695. Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
  696. destRect.X, destRect.Y, destRect.Width, destRect.Height,
  697. srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero,
  698. null, IntPtr.Zero);
  699. GDIPlus.CheckStatus (status);
  700. }
  701. public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
  702. {
  703. Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
  704. destPoints, destPoints.Length , srcRect.X, srcRect.Y,
  705. srcRect.Width, srcRect.Height, srcUnit,
  706. imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, (IntPtr) callbackData);
  707. GDIPlus.CheckStatus (status);
  708. }
  709. public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit)
  710. {
  711. if (image == null)
  712. throw new ArgumentNullException ("image");
  713. Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
  714. destRect.X, destRect.Y, destRect.Width, destRect.Height,
  715. srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero,
  716. null, IntPtr.Zero);
  717. GDIPlus.CheckStatus (status);
  718. }
  719. public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs)
  720. {
  721. if (image == null)
  722. throw new ArgumentNullException ("image");
  723. Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
  724. destRect.X, destRect.Y, destRect.Width, destRect.Height,
  725. srcX, srcY, srcWidth, srcHeight, srcUnit,
  726. imageAttrs != null ? imageAttrs.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
  727. GDIPlus.CheckStatus (status);
  728. }
  729. public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
  730. {
  731. if (image == null)
  732. throw new ArgumentNullException ("image");
  733. Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
  734. destRect.X, destRect.Y, destRect.Width,
  735. destRect.Height, srcX, srcY, srcWidth, srcHeight,
  736. srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
  737. GDIPlus.CheckStatus (status);
  738. }
  739. public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
  740. {
  741. if (image == null)
  742. throw new ArgumentNullException ("image");
  743. Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
  744. destRect.X, destRect.Y, destRect.Width,
  745. destRect.Height, srcX, srcY, srcWidth, srcHeight,
  746. srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback,
  747. IntPtr.Zero);
  748. GDIPlus.CheckStatus (status);
  749. }
  750. public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
  751. {
  752. if (image == null)
  753. throw new ArgumentNullException ("image");
  754. Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
  755. destRect.X, destRect.Y, destRect.Width,
  756. destRect.Height, srcX, srcY, srcWidth, srcHeight,
  757. srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero,
  758. callback, IntPtr.Zero);
  759. GDIPlus.CheckStatus (status);
  760. }
  761. public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
  762. {
  763. if (image == null)
  764. throw new ArgumentNullException ("image");
  765. Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
  766. destRect.X, destRect.Y, destRect.Width, destRect.Height,
  767. srcX, srcY, srcWidth, srcHeight, srcUnit,
  768. imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, callbackData);
  769. GDIPlus.CheckStatus (status);
  770. }
  771. public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, IntPtr callbackData)
  772. {
  773. if (image == null)
  774. throw new ArgumentNullException ("image");
  775. Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
  776. destRect.X, destRect.Y, destRect.Width, destRect.Height,
  777. srcX, srcY, srcWidth, srcHeight, srcUnit,
  778. imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, callbackData);
  779. GDIPlus.CheckStatus (status);
  780. }
  781. public void DrawImageUnscaled (Image image, Point point)
  782. {
  783. if (image == null)
  784. throw new ArgumentNullException ("image");
  785. DrawImageUnscaled (image, point.X, point.Y);
  786. }
  787. public void DrawImageUnscaled (Image image, Rectangle rect)
  788. {
  789. if (image == null)
  790. throw new ArgumentNullException ("image");
  791. DrawImageUnscaled (image, rect.X, rect.Y, rect.Width, rect.Height);
  792. }
  793. public void DrawImageUnscaled (Image image, int x, int y)
  794. {
  795. if (image == null)
  796. throw new ArgumentNullException ("image");
  797. DrawImage (image, x, y, image.Width, image.Height);
  798. }
  799. public void DrawImageUnscaled (Image image, int x, int y, int width, int height)
  800. {
  801. if (image == null)
  802. throw new ArgumentNullException ("image");
  803. Image tmpImg = new Bitmap (width, height);
  804. Graphics g = FromImage (tmpImg);
  805. g.DrawImage (image, 0, 0, image.Width, image.Height);
  806. this.DrawImage (tmpImg, x, y, width, height);
  807. tmpImg.Dispose ();
  808. g.Dispose ();
  809. }
  810. #if NET_2_0
  811. public void DrawImageUnscaledAndClipped (Image image, Rectangle rect)
  812. {
  813. int height, width;
  814. width = (image.Width > rect.Width) ? rect.Width : image.Width;
  815. height = (image.Height > rect.Height) ? rect.Height : image.Height;
  816. DrawImageUnscaled (image, rect.X, rect.Y, width, height);
  817. }
  818. #endif
  819. public void DrawLine (Pen pen, PointF pt1, PointF pt2)
  820. {
  821. if (pen == null)
  822. throw new ArgumentNullException ("pen");
  823. Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject,
  824. pt1.X, pt1.Y, pt2.X, pt2.Y);
  825. GDIPlus.CheckStatus (status);
  826. }
  827. public void DrawLine (Pen pen, Point pt1, Point pt2)
  828. {
  829. if (pen == null)
  830. throw new ArgumentNullException ("pen");
  831. Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject,
  832. pt1.X, pt1.Y, pt2.X, pt2.Y);
  833. GDIPlus.CheckStatus (status);
  834. }
  835. public void DrawLine (Pen pen, int x1, int y1, int x2, int y2)
  836. {
  837. if (pen == null)
  838. throw new ArgumentNullException ("pen");
  839. Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject, x1, y1, x2, y2);
  840. GDIPlus.CheckStatus (status);
  841. }
  842. public void DrawLine (Pen pen, float x1, float y1, float x2, float y2)
  843. {
  844. if (pen == null)
  845. throw new ArgumentNullException ("pen");
  846. Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject, x1, y1, x2, y2);
  847. GDIPlus.CheckStatus (status);
  848. }
  849. public void DrawLines (Pen pen, PointF [] points)
  850. {
  851. if (pen == null)
  852. throw new ArgumentNullException ("pen");
  853. if (points == null)
  854. throw new ArgumentNullException ("points");
  855. Status status = GDIPlus.GdipDrawLines (nativeObject, pen.nativeObject, points, points.Length);
  856. GDIPlus.CheckStatus (status);
  857. }
  858. public void DrawLines (Pen pen, Point [] points)
  859. {
  860. if (pen == null)
  861. throw new ArgumentNullException ("pen");
  862. if (points == null)
  863. throw new ArgumentNullException ("points");
  864. Status status = GDIPlus.GdipDrawLinesI (nativeObject, pen.nativeObject, points, points.Length);
  865. GDIPlus.CheckStatus (status);
  866. }
  867. public void DrawPath (Pen pen, GraphicsPath path)
  868. {
  869. if (pen == null)
  870. throw new ArgumentNullException ("pen");
  871. if (path == null)
  872. throw new ArgumentNullException ("path");
  873. Status status = GDIPlus.GdipDrawPath (nativeObject, pen.nativeObject, path.nativePath);
  874. GDIPlus.CheckStatus (status);
  875. }
  876. public void DrawPie (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
  877. {
  878. if (pen == null)
  879. throw new ArgumentNullException ("pen");
  880. DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
  881. }
  882. public void DrawPie (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
  883. {
  884. if (pen == null)
  885. throw new ArgumentNullException ("pen");
  886. DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
  887. }
  888. public void DrawPie (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
  889. {
  890. if (pen == null)
  891. throw new ArgumentNullException ("pen");
  892. Status status = GDIPlus.GdipDrawPie (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
  893. GDIPlus.CheckStatus (status);
  894. }
  895. // Microsoft documentation states that the signature for this member should be
  896. // public void DrawPie(Pen pen, int x, int y, int width, int height, int startAngle
  897. // int sweepAngle. However, GdipDrawPieI uses also float for the startAngle and sweepAngle params
  898. public void DrawPie (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
  899. {
  900. if (pen == null)
  901. throw new ArgumentNullException ("pen");
  902. Status status = GDIPlus.GdipDrawPieI (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
  903. GDIPlus.CheckStatus (status);
  904. }
  905. public void DrawPolygon (Pen pen, Point [] points)
  906. {
  907. if (pen == null)
  908. throw new ArgumentNullException ("pen");
  909. if (points == null)
  910. throw new ArgumentNullException ("points");
  911. Status status = GDIPlus.GdipDrawPolygonI (nativeObject, pen.nativeObject, points, points.Length);
  912. GDIPlus.CheckStatus (status);
  913. }
  914. public void DrawPolygon (Pen pen, PointF [] points)
  915. {
  916. if (pen == null)
  917. throw new ArgumentNullException ("pen");
  918. if (points == null)
  919. throw new ArgumentNullException ("points");
  920. Status status = GDIPlus.GdipDrawPolygon (nativeObject, pen.nativeObject, points, points.Length);
  921. GDIPlus.CheckStatus (status);
  922. }
  923. internal void DrawRectangle (Pen pen, RectangleF rect)
  924. {
  925. if (pen == null)
  926. throw new ArgumentNullException ("pen");
  927. DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
  928. }
  929. public void DrawRectangle (Pen pen, Rectangle rect)
  930. {
  931. if (pen == null)
  932. throw new ArgumentNullException ("pen");
  933. DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
  934. }
  935. public void DrawRectangle (Pen pen, float x, float y, float width, float height)
  936. {
  937. if (pen == null)
  938. throw new ArgumentNullException ("pen");
  939. Status status = GDIPlus.GdipDrawRectangle (nativeObject, pen.nativeObject, x, y, width, height);
  940. GDIPlus.CheckStatus (status);
  941. }
  942. public void DrawRectangle (Pen pen, int x, int y, int width, int height)
  943. {
  944. if (pen == null)
  945. throw new ArgumentNullException ("pen");
  946. Status status = GDIPlus.GdipDrawRectangleI (nativeObject, pen.nativeObject, x, y, width, height);
  947. GDIPlus.CheckStatus (status);
  948. }
  949. public void DrawRectangles (Pen pen, RectangleF [] rects)
  950. {
  951. if (pen == null)
  952. throw new ArgumentNullException ("image");
  953. if (rects == null)
  954. throw new ArgumentNullException ("rects");
  955. Status status = GDIPlus.GdipDrawRectangles (nativeObject, pen.nativeObject, rects, rects.Length);
  956. GDIPlus.CheckStatus (status);
  957. }
  958. public void DrawRectangles (Pen pen, Rectangle [] rects)
  959. {
  960. if (pen == null)
  961. throw new ArgumentNullException ("image");
  962. if (rects == null)
  963. throw new ArgumentNullException ("rects");
  964. Status status = GDIPlus.GdipDrawRectanglesI (nativeObject, pen.nativeObject, rects, rects.Length);
  965. GDIPlus.CheckStatus (status);
  966. }
  967. public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle)
  968. {
  969. DrawString (s, font, brush, layoutRectangle, null);
  970. }
  971. public void DrawString (string s, Font font, Brush brush, PointF point)
  972. {
  973. DrawString (s, font, brush, new RectangleF (point.X, point.Y, 0, 0), null);
  974. }
  975. public void DrawString (string s, Font font, Brush brush, PointF point, StringFormat format)
  976. {
  977. DrawString(s, font, brush, new RectangleF(point.X, point.Y, 0, 0), format);
  978. }
  979. public void DrawString (string s, Font font, Brush brush, float x, float y)
  980. {
  981. DrawString (s, font, brush, new RectangleF (x, y, 0, 0), null);
  982. }
  983. public void DrawString (string s, Font font, Brush brush, float x, float y, StringFormat format)
  984. {
  985. DrawString (s, font, brush, new RectangleF(x, y, 0, 0), format);
  986. }
  987. public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
  988. {
  989. if (font == null)
  990. throw new ArgumentNullException ("font");
  991. if (brush == null)
  992. throw new ArgumentNullException ("brush");
  993. if (s == null || s.Length == 0)
  994. return;
  995. Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref layoutRectangle, format != null ? format.NativeObject : IntPtr.Zero, brush.nativeObject);
  996. GDIPlus.CheckStatus (status);
  997. }
  998. public void EndContainer (GraphicsContainer container)
  999. {
  1000. #if NET_2_0
  1001. if (container == null)
  1002. throw new ArgumentNullException ("container");
  1003. #endif
  1004. Status status = GDIPlus.GdipEndContainer(nativeObject, container.NativeObject);
  1005. GDIPlus.CheckStatus (status);
  1006. }
  1007. [MonoTODO]
  1008. public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback)
  1009. {
  1010. throw new NotImplementedException ();
  1011. }
  1012. [MonoTODO]
  1013. public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback)
  1014. {
  1015. throw new NotImplementedException ();
  1016. }
  1017. [MonoTODO]
  1018. public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback)
  1019. {
  1020. throw new NotImplementedException ();
  1021. }
  1022. [MonoTODO]
  1023. public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback)
  1024. {
  1025. throw new NotImplementedException ();
  1026. }
  1027. [MonoTODO]
  1028. public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback)
  1029. {
  1030. throw new NotImplementedException ();
  1031. }
  1032. [MonoTODO]
  1033. public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback)
  1034. {
  1035. throw new NotImplementedException ();
  1036. }
  1037. [MonoTODO]
  1038. public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
  1039. {
  1040. throw new NotImplementedException ();
  1041. }
  1042. [MonoTODO]
  1043. public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData)
  1044. {
  1045. throw new NotImplementedException ();
  1046. }
  1047. [MonoTODO]
  1048. public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
  1049. {
  1050. throw new NotImplementedException ();
  1051. }
  1052. [MonoTODO]
  1053. public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
  1054. {
  1055. throw new NotImplementedException ();
  1056. }
  1057. [MonoTODO]
  1058. public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
  1059. {
  1060. throw new NotImplementedException ();
  1061. }
  1062. [MonoTODO]
  1063. public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData)
  1064. {
  1065. throw new NotImplementedException ();
  1066. }
  1067. [MonoTODO]
  1068. public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
  1069. {
  1070. throw new NotImplementedException ();
  1071. }
  1072. [MonoTODO]
  1073. public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
  1074. {
  1075. throw new NotImplementedException ();
  1076. }
  1077. [MonoTODO]
  1078. public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
  1079. {
  1080. throw new NotImplementedException ();
  1081. }
  1082. [MonoTODO]
  1083. public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
  1084. {
  1085. throw new NotImplementedException ();
  1086. }
  1087. [MonoTODO]
  1088. public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
  1089. {
  1090. throw new NotImplementedException ();
  1091. }
  1092. [MonoTODO]
  1093. public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
  1094. {
  1095. throw new NotImplementedException ();
  1096. }
  1097. [MonoTODO]
  1098. public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
  1099. {
  1100. throw new NotImplementedException ();
  1101. }
  1102. [MonoTODO]
  1103. public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
  1104. {
  1105. throw new NotImplementedException ();
  1106. }
  1107. [MonoTODO]
  1108. public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
  1109. {
  1110. throw new NotImplementedException ();
  1111. }
  1112. [MonoTODO]
  1113. public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
  1114. {
  1115. throw new NotImplementedException ();
  1116. }
  1117. [MonoTODO]
  1118. public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
  1119. {
  1120. throw new NotImplementedException ();
  1121. }
  1122. [MonoTODO]
  1123. public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
  1124. {
  1125. throw new NotImplementedException ();
  1126. }
  1127. [MonoTODO]
  1128. public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
  1129. {
  1130. throw new NotImplementedException ();
  1131. }
  1132. [MonoTODO]
  1133. public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
  1134. {
  1135. throw new NotImplementedException ();
  1136. }
  1137. [MonoTODO]
  1138. public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
  1139. {
  1140. throw new NotImplementedException ();
  1141. }
  1142. [MonoTODO]
  1143. public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
  1144. {
  1145. throw new NotImplementedException ();
  1146. }
  1147. [MonoTODO]
  1148. public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
  1149. {
  1150. throw new NotImplementedException ();
  1151. }
  1152. [MonoTODO]
  1153. public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
  1154. {
  1155. throw new NotImplementedException ();
  1156. }
  1157. [MonoTODO]
  1158. public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
  1159. {
  1160. throw new NotImplementedException ();
  1161. }
  1162. [MonoTODO]
  1163. public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
  1164. {
  1165. throw new NotImplementedException ();
  1166. }
  1167. [MonoTODO]
  1168. public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
  1169. {
  1170. throw new NotImplementedException ();
  1171. }
  1172. [MonoTODO]
  1173. public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
  1174. {
  1175. throw new NotImplementedException ();
  1176. }
  1177. [MonoTODO]
  1178. public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
  1179. {
  1180. throw new NotImplementedException ();
  1181. }
  1182. [MonoTODO]
  1183. public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
  1184. {
  1185. throw new NotImplementedException ();
  1186. }
  1187. public void ExcludeClip (Rectangle rect)
  1188. {
  1189. Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Exclude);
  1190. GDIPlus.CheckStatus (status);
  1191. }
  1192. public void ExcludeClip (Region region)
  1193. {
  1194. if (region == null)
  1195. throw new ArgumentNullException ("region");
  1196. Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Exclude);
  1197. GDIPlus.CheckStatus (status);
  1198. }
  1199. public void FillClosedCurve (Brush brush, PointF [] points)
  1200. {
  1201. if (brush == null)
  1202. throw new ArgumentNullException ("brush");
  1203. if (points == null)
  1204. throw new ArgumentNullException ("points");
  1205. Status status = GDIPlus.GdipFillClosedCurve (nativeObject, brush.NativeObject, points, points.Length);
  1206. GDIPlus.CheckStatus (status);
  1207. }
  1208. public void FillClosedCurve (Brush brush, Point [] points)
  1209. {
  1210. if (brush == null)
  1211. throw new ArgumentNullException ("brush");
  1212. if (points == null)
  1213. throw new ArgumentNullException ("points");
  1214. Status status = GDIPlus.GdipFillClosedCurveI (nativeObject, brush.NativeObject, points, points.Length);
  1215. GDIPlus.CheckStatus (status);
  1216. }
  1217. public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode)
  1218. {
  1219. if (brush == null)
  1220. throw new ArgumentNullException ("brush");
  1221. if (points == null)
  1222. throw new ArgumentNullException ("points");
  1223. FillClosedCurve (brush, points, fillmode, 0.5f);
  1224. }
  1225. public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode)
  1226. {
  1227. if (brush == null)
  1228. throw new ArgumentNullException ("brush");
  1229. if (points == null)
  1230. throw new ArgumentNullException ("points");
  1231. FillClosedCurve (brush, points, fillmode, 0.5f);
  1232. }
  1233. public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode, float tension)
  1234. {
  1235. if (brush == null)
  1236. throw new ArgumentNullException ("brush");
  1237. if (points == null)
  1238. throw new ArgumentNullException ("points");
  1239. Status status = GDIPlus.GdipFillClosedCurve2 (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
  1240. GDIPlus.CheckStatus (status);
  1241. }
  1242. public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode, float tension)
  1243. {
  1244. if (brush == null)
  1245. throw new ArgumentNullException ("brush");
  1246. if (points == null)
  1247. throw new ArgumentNullException ("points");
  1248. Status status = GDIPlus.GdipFillClosedCurve2I (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
  1249. GDIPlus.CheckStatus (status);
  1250. }
  1251. public void FillEllipse (Brush brush, Rectangle rect)
  1252. {
  1253. if (brush == null)
  1254. throw new ArgumentNullException ("brush");
  1255. FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
  1256. }
  1257. public void FillEllipse (Brush brush, RectangleF rect)
  1258. {
  1259. if (brush == null)
  1260. throw new ArgumentNullException ("brush");
  1261. FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
  1262. }
  1263. public void FillEllipse (Brush brush, float x, float y, float width, float height)
  1264. {
  1265. if (brush == null)
  1266. throw new ArgumentNullException ("brush");
  1267. Status status = GDIPlus.GdipFillEllipse (nativeObject, brush.nativeObject, x, y, width, height);
  1268. GDIPlus.CheckStatus (status);
  1269. }
  1270. public void FillEllipse (Brush brush, int x, int y, int width, int height)
  1271. {
  1272. if (brush == null)
  1273. throw new ArgumentNullException ("brush");
  1274. Status status = GDIPlus.GdipFillEllipseI (nativeObject, brush.nativeObject, x, y, width, height);
  1275. GDIPlus.CheckStatus (status);
  1276. }
  1277. public void FillPath (Brush brush, GraphicsPath path)
  1278. {
  1279. if (brush == null)
  1280. throw new ArgumentNullException ("brush");
  1281. if (path == null)
  1282. throw new ArgumentNullException ("path");
  1283. Status status = GDIPlus.GdipFillPath (nativeObject, brush.NativeObject, path.NativeObject);
  1284. GDIPlus.CheckStatus (status);
  1285. }
  1286. public void FillPie (Brush brush, Rectangle rect, float startAngle, float sweepAngle)
  1287. {
  1288. if (brush == null)
  1289. throw new ArgumentNullException ("brush");
  1290. Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
  1291. GDIPlus.CheckStatus (status);
  1292. }
  1293. public void FillPie (Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle)
  1294. {
  1295. if (brush == null)
  1296. throw new ArgumentNullException ("brush");
  1297. Status status = GDIPlus.GdipFillPieI (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
  1298. GDIPlus.CheckStatus (status);
  1299. }
  1300. public void FillPie (Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
  1301. {
  1302. if (brush == null)
  1303. throw new ArgumentNullException ("brush");
  1304. Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
  1305. GDIPlus.CheckStatus (status);
  1306. }
  1307. public void FillPolygon (Brush brush, PointF [] points)
  1308. {
  1309. if (brush == null)
  1310. throw new ArgumentNullException ("brush");
  1311. if (points == null)
  1312. throw new ArgumentNullException ("points");
  1313. Status status = GDIPlus.GdipFillPolygon2 (nativeObject, brush.nativeObject, points, points.Length);
  1314. GDIPlus.CheckStatus (status);
  1315. }
  1316. public void FillPolygon (Brush brush, Point [] points)
  1317. {
  1318. if (brush == null)
  1319. throw new ArgumentNullException ("brush");
  1320. if (points == null)
  1321. throw new ArgumentNullException ("points");
  1322. Status status = GDIPlus.GdipFillPolygon2I (nativeObject, brush.nativeObject, points, points.Length);
  1323. GDIPlus.CheckStatus (status);
  1324. }
  1325. public void FillPolygon (Brush brush, Point [] points, FillMode fillMode)
  1326. {
  1327. if (brush == null)
  1328. throw new ArgumentNullException ("brush");
  1329. if (points == null)
  1330. throw new ArgumentNullException ("points");
  1331. Status status = GDIPlus.GdipFillPolygonI (nativeObject, brush.nativeObject, points, points.Length, fillMode);
  1332. GDIPlus.CheckStatus (status);
  1333. }
  1334. public void FillPolygon (Brush brush, PointF [] points, FillMode fillMode)
  1335. {
  1336. if (brush == null)
  1337. throw new ArgumentNullException ("brush");
  1338. if (points == null)
  1339. throw new ArgumentNullException ("points");
  1340. Status status = GDIPlus.GdipFillPolygon (nativeObject, brush.nativeObject, points, points.Length, fillMode);
  1341. GDIPlus.CheckStatus (status);
  1342. }
  1343. public void FillRectangle (Brush brush, RectangleF rect)
  1344. {
  1345. if (brush == null)
  1346. throw new ArgumentNullException ("brush");
  1347. FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
  1348. }
  1349. public void FillRectangle (Brush brush, Rectangle rect)
  1350. {
  1351. if (brush == null)
  1352. throw new ArgumentNullException ("brush");
  1353. FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
  1354. }
  1355. public void FillRectangle (Brush brush, int x, int y, int width, int height)
  1356. {
  1357. if (brush == null)
  1358. throw new ArgumentNullException ("brush");
  1359. Status status = GDIPlus.GdipFillRectangleI (nativeObject, brush.nativeObject, x, y, width, height);
  1360. GDIPlus.CheckStatus (status);
  1361. }
  1362. public void FillRectangle (Brush brush, float x, float y, float width, float height)
  1363. {
  1364. if (brush == null)
  1365. throw new ArgumentNullException ("brush");
  1366. Status status = GDIPlus.GdipFillRectangle (nativeObject, brush.nativeObject, x, y, width, height);
  1367. GDIPlus.CheckStatus (status);
  1368. }
  1369. public void FillRectangles (Brush brush, Rectangle [] rects)
  1370. {
  1371. if (brush == null)
  1372. throw new ArgumentNullException ("brush");
  1373. if (rects == null)
  1374. throw new ArgumentNullException ("rects");
  1375. Status status = GDIPlus.GdipFillRectanglesI (nativeObject, brush.nativeObject, rects, rects.Length);
  1376. GDIPlus.CheckStatus (status);
  1377. }
  1378. public void FillRectangles (Brush brush, RectangleF [] rects)
  1379. {
  1380. if (brush == null)
  1381. throw new ArgumentNullException ("brush");
  1382. if (rects == null)
  1383. throw new ArgumentNullException ("rects");
  1384. Status status = GDIPlus.GdipFillRectangles (nativeObject, brush.nativeObject, rects, rects.Length);
  1385. GDIPlus.CheckStatus (status);
  1386. }
  1387. public void FillRegion (Brush brush, Region region)
  1388. {
  1389. if (brush == null)
  1390. throw new ArgumentNullException ("brush");
  1391. if (region == null)
  1392. throw new ArgumentNullException ("region");
  1393. Status status = GDIPlus.GdipFillRegion (nativeObject, brush.NativeObject, region.NativeObject);
  1394. GDIPlus.CheckStatus(status);
  1395. }
  1396. public void Flush ()
  1397. {
  1398. Flush (FlushIntention.Flush);
  1399. }
  1400. public void Flush (FlushIntention intention)
  1401. {
  1402. if (nativeObject == IntPtr.Zero) {
  1403. return;
  1404. }
  1405. Status status = GDIPlus.GdipFlush (nativeObject, intention);
  1406. GDIPlus.CheckStatus (status);
  1407. if (GDIPlus.UseQuartzDrawable || GDIPlus.UseCocoaDrawable)
  1408. Carbon.CGContextSynchronize (GDIPlus.Display);
  1409. }
  1410. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1411. public static Graphics FromHdc (IntPtr hdc)
  1412. {
  1413. IntPtr graphics;
  1414. Status status = GDIPlus.GdipCreateFromHDC (hdc, out graphics);
  1415. GDIPlus.CheckStatus (status);
  1416. return new Graphics (graphics);
  1417. }
  1418. [MonoTODO]
  1419. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1420. public static Graphics FromHdc (IntPtr hdc, IntPtr hdevice)
  1421. {
  1422. throw new NotImplementedException ();
  1423. }
  1424. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1425. [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
  1426. public static Graphics FromHdcInternal (IntPtr hdc)
  1427. {
  1428. GDIPlus.Display = hdc;
  1429. return null;
  1430. }
  1431. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1432. public static Graphics FromHwnd (IntPtr hwnd)
  1433. {
  1434. IntPtr graphics;
  1435. if (GDIPlus.UseCocoaDrawable) {
  1436. CarbonContext cgContext = Carbon.GetCGContextForNSView (hwnd);
  1437. GDIPlus.GdipCreateFromQuartz_macosx (cgContext.ctx, cgContext.width, cgContext.height, out graphics);
  1438. GDIPlus.Display = cgContext.ctx;
  1439. return new Graphics (graphics);
  1440. }
  1441. if (GDIPlus.UseQuartzDrawable) {
  1442. CarbonContext cgContext = Carbon.GetCGContextForView (hwnd);
  1443. GDIPlus.GdipCreateFromQuartz_macosx (cgContext.ctx, cgContext.width, cgContext.height, out graphics);
  1444. GDIPlus.Display = cgContext.ctx;
  1445. return new Graphics (graphics);
  1446. }
  1447. if (GDIPlus.UseX11Drawable) {
  1448. if (GDIPlus.Display == IntPtr.Zero) {
  1449. GDIPlus.Display = GDIPlus.XOpenDisplay (IntPtr.Zero);
  1450. }
  1451. return FromXDrawable (hwnd, GDIPlus.Display);
  1452. }
  1453. Status status = GDIPlus.GdipCreateFromHWND (hwnd, out graphics);
  1454. GDIPlus.CheckStatus (status);
  1455. return new Graphics (graphics);
  1456. }
  1457. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1458. [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
  1459. public static Graphics FromHwndInternal (IntPtr hwnd)
  1460. {
  1461. return FromHwnd (hwnd);
  1462. }
  1463. public static Graphics FromImage (Image image)
  1464. {
  1465. IntPtr graphics;
  1466. if (image == null)
  1467. throw new ArgumentNullException ("image");
  1468. Status status = GDIPlus.GdipGetImageGraphicsContext (image.nativeObject, out graphics);
  1469. GDIPlus.CheckStatus (status);
  1470. Graphics result = new Graphics (graphics);
  1471. // check for Unix platforms - see FAQ for more details
  1472. // http://www.mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
  1473. int platform = (int) Environment.OSVersion.Platform;
  1474. if ((platform == 4) || (platform == 128)) {
  1475. Rectangle rect = new Rectangle (0,0, image.Width, image.Height);
  1476. GDIPlus.GdipSetVisibleClip_linux (result.NativeObject, ref rect);
  1477. }
  1478. return result;
  1479. }
  1480. internal static Graphics FromXDrawable (IntPtr drawable, IntPtr display)
  1481. {
  1482. IntPtr graphics;
  1483. Status s = GDIPlus.GdipCreateFromXDrawable_linux (drawable, display, out graphics);
  1484. GDIPlus.CheckStatus (s);
  1485. return new Graphics (graphics);
  1486. }
  1487. [MonoTODO]
  1488. public static IntPtr GetHalftonePalette ()
  1489. {
  1490. throw new NotImplementedException ();
  1491. }
  1492. #if !NET_2_0
  1493. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1494. #endif
  1495. public IntPtr GetHdc ()
  1496. {
  1497. IntPtr hdc;
  1498. GDIPlus.CheckStatus (GDIPlus.GdipGetDC (this.nativeObject, out hdc));
  1499. #if NET_2_0
  1500. deviceContextHdc = hdc;
  1501. #endif
  1502. return hdc;
  1503. }
  1504. public Color GetNearestColor (Color color)
  1505. {
  1506. int argb;
  1507. Status status = GDIPlus.GdipGetNearestColor (nativeObject, out argb);
  1508. GDIPlus.CheckStatus (status);
  1509. return Color.FromArgb (argb);
  1510. }
  1511. public void IntersectClip (Region region)
  1512. {
  1513. if (region == null)
  1514. throw new ArgumentNullException ("region");
  1515. Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Intersect);
  1516. GDIPlus.CheckStatus (status);
  1517. }
  1518. public void IntersectClip (RectangleF rect)
  1519. {
  1520. Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
  1521. GDIPlus.CheckStatus (status);
  1522. }
  1523. public void IntersectClip (Rectangle rect)
  1524. {
  1525. Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
  1526. GDIPlus.CheckStatus (status);
  1527. }
  1528. public bool IsVisible (Point point)
  1529. {
  1530. bool isVisible = false;
  1531. Status status = GDIPlus.GdipIsVisiblePointI (nativeObject, point.X, point.Y, out isVisible);
  1532. GDIPlus.CheckStatus (status);
  1533. return isVisible;
  1534. }
  1535. public bool IsVisible (RectangleF rect)
  1536. {
  1537. bool isVisible = false;
  1538. Status status = GDIPlus.GdipIsVisibleRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
  1539. GDIPlus.CheckStatus (status);
  1540. return isVisible;
  1541. }
  1542. public bool IsVisible (PointF point)
  1543. {
  1544. bool isVisible = false;
  1545. Status status = GDIPlus.GdipIsVisiblePoint (nativeObject, point.X, point.Y, out isVisible);
  1546. GDIPlus.CheckStatus (status);
  1547. return isVisible;
  1548. }
  1549. public bool IsVisible (Rectangle rect)
  1550. {
  1551. bool isVisible = false;
  1552. Status status = GDIPlus.GdipIsVisibleRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
  1553. GDIPlus.CheckStatus (status);
  1554. return isVisible;
  1555. }
  1556. public bool IsVisible (float x, float y)
  1557. {
  1558. return IsVisible (new PointF (x, y));
  1559. }
  1560. public bool IsVisible (int x, int y)
  1561. {
  1562. return IsVisible (new Point (x, y));
  1563. }
  1564. public bool IsVisible (float x, float y, float width, float height)
  1565. {
  1566. return IsVisible (new RectangleF (x, y, width, height));
  1567. }
  1568. public bool IsVisible (int x, int y, int width, int height)
  1569. {
  1570. return IsVisible (new Rectangle (x, y, width, height));
  1571. }
  1572. public Region[] MeasureCharacterRanges (string text, Font font, RectangleF layoutRect, StringFormat stringFormat)
  1573. {
  1574. if ((text == null) || (text.Length == 0))
  1575. return new Region [0];
  1576. if (font == null)
  1577. throw new ArgumentNullException ("font");
  1578. if (stringFormat == null)
  1579. throw new ArgumentException ("stringFormat");
  1580. int regcount = stringFormat.GetMeasurableCharacterRangeCount ();
  1581. if (regcount == 0)
  1582. return new Region[0];
  1583. IntPtr[] native_regions = new IntPtr [regcount];
  1584. Region[] regions = new Region [regcount];
  1585. for (int i = 0; i < regcount; i++) {
  1586. regions[i] = new Region ();
  1587. native_regions[i] = regions[i].NativeObject;
  1588. }
  1589. Status status = GDIPlus.GdipMeasureCharacterRanges (nativeObject, text, text.Length,
  1590. font.NativeObject, ref layoutRect, stringFormat.NativeObject, regcount, out native_regions[0]);
  1591. GDIPlus.CheckStatus (status);
  1592. return regions;
  1593. }
  1594. public SizeF MeasureString (string text, Font font)
  1595. {
  1596. return MeasureString (text, font, SizeF.Empty);
  1597. }
  1598. public SizeF MeasureString (string text, Font font, SizeF layoutArea)
  1599. {
  1600. if (text == null || text.Length == 0)
  1601. return SizeF.Empty;
  1602. if (font == null)
  1603. throw new ArgumentNullException ("font");
  1604. int charactersFitted, linesFilled;
  1605. RectangleF boundingBox = new RectangleF ();
  1606. RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
  1607. Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
  1608. font.NativeObject, ref rect,
  1609. IntPtr.Zero, out boundingBox,
  1610. out charactersFitted, out linesFilled);
  1611. GDIPlus.CheckStatus (status);
  1612. return new SizeF (boundingBox.Width, boundingBox.Height);
  1613. }
  1614. public SizeF MeasureString (string text, Font font, int width)
  1615. {
  1616. if (text == null || text.Length == 0)
  1617. return SizeF.Empty;
  1618. if (font == null)
  1619. throw new ArgumentNullException ("font");
  1620. RectangleF boundingBox = new RectangleF ();
  1621. RectangleF rect = new RectangleF (0, 0, width, Int32.MaxValue);
  1622. int charactersFitted, linesFilled;
  1623. Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
  1624. font.NativeObject, ref rect,
  1625. IntPtr.Zero, out boundingBox,
  1626. out charactersFitted, out linesFilled);
  1627. GDIPlus.CheckStatus (status);
  1628. return new SizeF (boundingBox.Width, boundingBox.Height);
  1629. }
  1630. public SizeF MeasureString (string text, Font font, SizeF layoutArea,
  1631. StringFormat stringFormat)
  1632. {
  1633. int charactersFitted, linesFilled;
  1634. return MeasureString (text, font, layoutArea, stringFormat,
  1635. out charactersFitted, out linesFilled);
  1636. }
  1637. public SizeF MeasureString (string text, Font font, int width, StringFormat format)
  1638. {
  1639. int charactersFitted, linesFilled;
  1640. return MeasureString (text, font, new SizeF (width, Int32.MaxValue),
  1641. format, out charactersFitted, out linesFilled);
  1642. }
  1643. public SizeF MeasureString (string text, Font font, PointF origin,
  1644. StringFormat stringFormat)
  1645. {
  1646. if (text == null || text.Length == 0)
  1647. return SizeF.Empty;
  1648. if (font == null)
  1649. throw new ArgumentNullException ("font");
  1650. RectangleF boundingBox = new RectangleF ();
  1651. RectangleF rect = new RectangleF (origin.X, origin.Y, 0, 0);
  1652. int charactersFitted, linesFilled;
  1653. IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
  1654. Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
  1655. font.NativeObject, ref rect, format,
  1656. out boundingBox,
  1657. out charactersFitted,
  1658. out linesFilled);
  1659. GDIPlus.CheckStatus (status);
  1660. return new SizeF (boundingBox.Width, boundingBox.Height);
  1661. }
  1662. public SizeF MeasureString (string text, Font font, SizeF layoutArea,
  1663. StringFormat stringFormat, out int charactersFitted,
  1664. out int linesFilled)
  1665. {
  1666. charactersFitted = 0;
  1667. linesFilled = 0;
  1668. if (text == null || text.Length == 0)
  1669. return SizeF.Empty;
  1670. if (font == null)
  1671. throw new ArgumentNullException ("font");
  1672. RectangleF boundingBox = new RectangleF ();
  1673. RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
  1674. IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
  1675. Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length,
  1676. font.NativeObject, ref rect, format,
  1677. out boundingBox,
  1678. out charactersFitted,
  1679. out linesFilled);
  1680. GDIPlus.CheckStatus (status);
  1681. return new SizeF (boundingBox.Width, boundingBox.Height);
  1682. }
  1683. public void MultiplyTransform (Matrix matrix)
  1684. {
  1685. MultiplyTransform (matrix, MatrixOrder.Prepend);
  1686. }
  1687. public void MultiplyTransform (Matrix matrix, MatrixOrder order)
  1688. {
  1689. Status status = GDIPlus.GdipMultiplyWorldTransform (nativeObject,
  1690. matrix.nativeMatrix,
  1691. order);
  1692. GDIPlus.CheckStatus (status);
  1693. }
  1694. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1695. public void ReleaseHdc (IntPtr hdc)
  1696. {
  1697. Status status = GDIPlus.GdipReleaseDC (nativeObject, hdc);
  1698. GDIPlus.CheckStatus (status);
  1699. #if NET_2_0
  1700. if (hdc == deviceContextHdc)
  1701. deviceContextHdc = IntPtr.Zero;
  1702. #endif
  1703. }
  1704. #if NET_2_0
  1705. public void ReleaseHdc ()
  1706. {
  1707. if (deviceContextHdc == IntPtr.Zero)
  1708. throw new ArgumentException ("Invalid Handle");
  1709. ReleaseHdc (deviceContextHdc);
  1710. }
  1711. #endif
  1712. [MonoTODO]
  1713. #if NET_2_0
  1714. [EditorBrowsable (EditorBrowsableState.Never)]
  1715. #else
  1716. [EditorBrowsable (EditorBrowsableState.Advanced)]
  1717. #endif
  1718. [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
  1719. public void ReleaseHdcInternal (IntPtr hdc)
  1720. {
  1721. throw new NotImplementedException ();
  1722. }
  1723. public void ResetClip ()
  1724. {
  1725. Status status = GDIPlus.GdipResetClip (nativeObject);
  1726. GDIPlus.CheckStatus (status);
  1727. }
  1728. public void ResetTransform ()
  1729. {
  1730. Status status = GDIPlus.GdipResetWorldTransform (nativeObject);
  1731. GDIPlus.CheckStatus (status);
  1732. }
  1733. public void Restore (GraphicsState gstate)
  1734. {
  1735. Status status = GDIPlus.GdipRestoreGraphics (nativeObject, gstate.nativeState);
  1736. GDIPlus.CheckStatus (status);
  1737. }
  1738. public void RotateTransform (float angle)
  1739. {
  1740. RotateTransform (angle, MatrixOrder.Prepend);
  1741. }
  1742. public void RotateTransform (float angle, MatrixOrder order)
  1743. {
  1744. Status status = GDIPlus.GdipRotateWorldTransform (nativeObject, angle, order);
  1745. GDIPlus.CheckStatus (status);
  1746. }
  1747. public GraphicsState Save ()
  1748. {
  1749. uint saveState;
  1750. Status status = GDIPlus.GdipSaveGraphics (nativeObject, out saveState);
  1751. GDIPlus.CheckStatus (status);
  1752. GraphicsState state = new GraphicsState ();
  1753. state.nativeState = saveState;
  1754. return state;
  1755. }
  1756. public void ScaleTransform (float sx, float sy)
  1757. {
  1758. ScaleTransform (sx, sy, MatrixOrder.Prepend);
  1759. }
  1760. public void ScaleTransform (float sx, float sy, MatrixOrder order)
  1761. {
  1762. Status status = GDIPlus.GdipScaleWorldTransform (nativeObject, sx, sy, order);
  1763. GDIPlus.CheckStatus (status);
  1764. }
  1765. public void SetClip (RectangleF rect)
  1766. {
  1767. SetClip (rect, CombineMode.Replace);
  1768. }
  1769. public void SetClip (GraphicsPath path)
  1770. {
  1771. SetClip (path, CombineMode.Replace);
  1772. }
  1773. public void SetClip (Rectangle rect)
  1774. {
  1775. SetClip (rect, CombineMode.Replace);
  1776. }
  1777. public void SetClip (Graphics g)
  1778. {
  1779. SetClip (g, CombineMode.Replace);
  1780. }
  1781. public void SetClip (Graphics g, CombineMode combineMode)
  1782. {
  1783. if (g == null)
  1784. throw new ArgumentNullException ("g");
  1785. Status status = GDIPlus.GdipSetClipGraphics (nativeObject, g.NativeObject, combineMode);
  1786. GDIPlus.CheckStatus (status);
  1787. }
  1788. public void SetClip (Rectangle rect, CombineMode combineMode)
  1789. {
  1790. Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
  1791. GDIPlus.CheckStatus (status);
  1792. }
  1793. public void SetClip (RectangleF rect, CombineMode combineMode)
  1794. {
  1795. Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
  1796. GDIPlus.CheckStatus (status);
  1797. }
  1798. public void SetClip (Region region, CombineMode combineMode)
  1799. {
  1800. if (region == null)
  1801. throw new ArgumentNullException ("region");
  1802. Status status = GDIPlus.GdipSetClipRegion(nativeObject, region.NativeObject, combineMode);
  1803. GDIPlus.CheckStatus (status);
  1804. }
  1805. public void SetClip (GraphicsPath path, CombineMode combineMode)
  1806. {
  1807. if (path == null)
  1808. throw new ArgumentNullException ("path");
  1809. Status status = GDIPlus.GdipSetClipPath (nativeObject, path.NativeObject, combineMode);
  1810. GDIPlus.CheckStatus (status);
  1811. }
  1812. public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF [] pts)
  1813. {
  1814. if (pts == null)
  1815. throw new ArgumentNullException ("pts");
  1816. IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemory (pts);
  1817. Status status = GDIPlus.GdipTransformPoints (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
  1818. GDIPlus.CheckStatus (status);
  1819. GDIPlus.FromUnManagedMemoryToPoint (ptrPt, pts);
  1820. }
  1821. public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, Point [] pts)
  1822. {
  1823. if (pts == null)
  1824. throw new ArgumentNullException ("pts");
  1825. IntPtr ptrPt = GDIPlus.FromPointToUnManagedMemoryI (pts);
  1826. Status status = GDIPlus.GdipTransformPointsI (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
  1827. GDIPlus.CheckStatus (status);
  1828. GDIPlus.FromUnManagedMemoryToPointI (ptrPt, pts);
  1829. }
  1830. public void TranslateClip (int dx, int dy)
  1831. {
  1832. Status status = GDIPlus.GdipTranslateClipI (nativeObject, dx, dy);
  1833. GDIPlus.CheckStatus (status);
  1834. }
  1835. public void TranslateClip (float dx, float dy)
  1836. {
  1837. Status status = GDIPlus.GdipTranslateClip (nativeObject, dx, dy);
  1838. GDIPlus.CheckStatus (status);
  1839. }
  1840. public void TranslateTransform (float dx, float dy)
  1841. {
  1842. TranslateTransform (dx, dy, MatrixOrder.Prepend);
  1843. }
  1844. public void TranslateTransform (float dx, float dy, MatrixOrder order)
  1845. {
  1846. Status status = GDIPlus.GdipTranslateWorldTransform (nativeObject, dx, dy, order);
  1847. GDIPlus.CheckStatus (status);
  1848. }
  1849. public Region Clip {
  1850. get {
  1851. Region reg = new Region();
  1852. Status status = GDIPlus.GdipGetClip (nativeObject, reg.NativeObject);
  1853. GDIPlus.CheckStatus (status);
  1854. return reg;
  1855. }
  1856. set {
  1857. SetClip (value, CombineMode.Replace);
  1858. }
  1859. }
  1860. public RectangleF ClipBounds {
  1861. get {
  1862. RectangleF rect = new RectangleF ();
  1863. Status status = GDIPlus.GdipGetClipBounds (nativeObject, out rect);
  1864. GDIPlus.CheckStatus (status);
  1865. return rect;
  1866. }
  1867. }
  1868. public CompositingMode CompositingMode {
  1869. get {
  1870. CompositingMode mode;
  1871. Status status = GDIPlus.GdipGetCompositingMode (nativeObject, out mode);
  1872. GDIPlus.CheckStatus (status);
  1873. return mode;
  1874. }
  1875. set {
  1876. Status status = GDIPlus.GdipSetCompositingMode (nativeObject, value);
  1877. GDIPlus.CheckStatus (status);
  1878. }
  1879. }
  1880. public CompositingQuality CompositingQuality {
  1881. get {
  1882. CompositingQuality quality;
  1883. Status status = GDIPlus.GdipGetCompositingQuality (nativeObject, out quality);
  1884. GDIPlus.CheckStatus (status);
  1885. return quality;
  1886. }
  1887. set {
  1888. Status status = GDIPlus.GdipSetCompositingQuality (nativeObject, value);
  1889. GDIPlus.CheckStatus (status);
  1890. }
  1891. }
  1892. public float DpiX {
  1893. get {
  1894. float x;
  1895. Status status = GDIPlus.GdipGetDpiX (nativeObject, out x);
  1896. GDIPlus.CheckStatus (status);
  1897. return x;
  1898. }
  1899. }
  1900. public float DpiY {
  1901. get {
  1902. float y;
  1903. Status status = GDIPlus.GdipGetDpiY (nativeObject, out y);
  1904. GDIPlus.CheckStatus (status);
  1905. return y;
  1906. }
  1907. }
  1908. public InterpolationMode InterpolationMode {
  1909. get {
  1910. InterpolationMode imode = InterpolationMode.Invalid;
  1911. Status status = GDIPlus.GdipGetInterpolationMode (nativeObject, out imode);
  1912. GDIPlus.CheckStatus (status);
  1913. return imode;
  1914. }
  1915. set {
  1916. Status status = GDIPlus.GdipSetInterpolationMode (nativeObject, value);
  1917. GDIPlus.CheckStatus (status);
  1918. }
  1919. }
  1920. public bool IsClipEmpty {
  1921. get {
  1922. bool isEmpty = false;
  1923. Status status = GDIPlus.GdipIsClipEmpty (nativeObject, out isEmpty);
  1924. GDIPlus.CheckStatus (status);
  1925. return isEmpty;
  1926. }
  1927. }
  1928. public bool IsVisibleClipEmpty {
  1929. get {
  1930. bool isEmpty = false;
  1931. Status status = GDIPlus.GdipIsVisibleClipEmpty (nativeObject, out isEmpty);
  1932. GDIPlus.CheckStatus (status);
  1933. return isEmpty;
  1934. }
  1935. }
  1936. public float PageScale {
  1937. get {
  1938. float scale;
  1939. Status status = GDIPlus.GdipGetPageScale (nativeObject, out scale);
  1940. GDIPlus.CheckStatus (status);
  1941. return scale;
  1942. }
  1943. set {
  1944. Status status = GDIPlus.GdipSetPageScale (nativeObject, value);
  1945. GDIPlus.CheckStatus (status);
  1946. }
  1947. }
  1948. public GraphicsUnit PageUnit {
  1949. get {
  1950. GraphicsUnit unit;
  1951. Status status = GDIPlus.GdipGetPageUnit (nativeObject, out unit);
  1952. GDIPlus.CheckStatus (status);
  1953. return unit;
  1954. }
  1955. set {
  1956. Status status = GDIPlus.GdipSetPageUnit (nativeObject, value);
  1957. GDIPlus.CheckStatus (status);
  1958. }
  1959. }
  1960. [MonoTODO ("not supported by libgdiplus")]
  1961. public PixelOffsetMode PixelOffsetMode {
  1962. get {
  1963. PixelOffsetMode pixelOffset = PixelOffsetMode.Invalid;
  1964. Status status = GDIPlus.GdipGetPixelOffsetMode (nativeObject, out pixelOffset);
  1965. GDIPlus.CheckStatus (status);
  1966. return pixelOffset;
  1967. }
  1968. set {
  1969. Status status = GDIPlus.GdipSetPixelOffsetMode (nativeObject, value);
  1970. GDIPlus.CheckStatus (status);
  1971. }
  1972. }
  1973. public Point RenderingOrigin {
  1974. get {
  1975. int x, y;
  1976. Status status = GDIPlus.GdipGetRenderingOrigin (nativeObject, out x, out y);
  1977. GDIPlus.CheckStatus (status);
  1978. return new Point (x, y);
  1979. }
  1980. set {
  1981. Status status = GDIPlus.GdipSetRenderingOrigin (nativeObject, value.X, value.Y);
  1982. GDIPlus.CheckStatus (status);
  1983. }
  1984. }
  1985. public SmoothingMode SmoothingMode {
  1986. get {
  1987. SmoothingMode mode = SmoothingMode.Invalid;
  1988. Status status = GDIPlus.GdipGetSmoothingMode (nativeObject, out mode);
  1989. GDIPlus.CheckStatus (status);
  1990. return mode;
  1991. }
  1992. set {
  1993. Status status = GDIPlus.GdipSetSmoothingMode (nativeObject, value);
  1994. GDIPlus.CheckStatus (status);
  1995. }
  1996. }
  1997. [MonoTODO ("not supported by libgdiplus")]
  1998. public int TextContrast {
  1999. get {
  2000. int contrast;
  2001. Status status = GDIPlus.GdipGetTextContrast (nativeObject, out contrast);
  2002. GDIPlus.CheckStatus (status);
  2003. return contrast;
  2004. }
  2005. set {
  2006. Status status = GDIPlus.GdipSetTextContrast (nativeObject, value);
  2007. GDIPlus.CheckStatus (status);
  2008. }
  2009. }
  2010. public TextRenderingHint TextRenderingHint {
  2011. get {
  2012. TextRenderingHint hint;
  2013. Status status = GDIPlus.GdipGetTextRenderingHint (nativeObject, out hint);
  2014. GDIPlus.CheckStatus (status);
  2015. return hint;
  2016. }
  2017. set {
  2018. Status status = GDIPlus.GdipSetTextRenderingHint (nativeObject, value);
  2019. GDIPlus.CheckStatus (status);
  2020. }
  2021. }
  2022. public Matrix Transform {
  2023. get {
  2024. Matrix matrix = new Matrix ();
  2025. Status status = GDIPlus.GdipGetWorldTransform (nativeObject, matrix.nativeMatrix);
  2026. GDIPlus.CheckStatus (status);
  2027. return matrix;
  2028. }
  2029. set {
  2030. if (value == null)
  2031. throw new ArgumentNullException ("value");
  2032. Status status = GDIPlus.GdipSetWorldTransform (nativeObject, value.nativeMatrix);
  2033. GDIPlus.CheckStatus (status);
  2034. }
  2035. }
  2036. public RectangleF VisibleClipBounds {
  2037. get {
  2038. RectangleF rect;
  2039. Status status = GDIPlus.GdipGetVisibleClipBounds (nativeObject, out rect);
  2040. GDIPlus.CheckStatus (status);
  2041. return rect;
  2042. }
  2043. }
  2044. #if NET_2_0
  2045. [MonoTODO]
  2046. [EditorBrowsable (EditorBrowsableState.Never)]
  2047. public object GetContextInfo ()
  2048. {
  2049. throw new NotImplementedException ();
  2050. }
  2051. #endif
  2052. }
  2053. }