"Fossies" - the Fresh Open Source Software Archive

Member "mono-6.12.0.122/mcs/class/System.Drawing/System.Drawing/Graphics.cs" (22 Feb 2021, 84220 Bytes) of package /linux/misc/mono-sources/mono/mono-6.12.0.122.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C# source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "Graphics.cs": 5.20.1.34_vs_6.8.0.96.

    1 //
    2 // System.Drawing.Graphics.cs
    3 //
    4 // Authors:
    5 //  Gonzalo Paniagua Javier (gonzalo@ximian.com) (stubbed out)
    6 //      Alexandre Pigolkine(pigolkine@gmx.de)
    7 //  Jordi Mas i Hernandez (jordi@ximian.com)
    8 //  Sebastien Pouliot  <sebastien@ximian.com>
    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 
   33 using System.Drawing.Drawing2D;
   34 using System.Drawing.Imaging;
   35 using System.Drawing.Text;
   36 using System.ComponentModel;
   37 using System.Runtime.InteropServices;
   38 using System.Text;
   39 
   40 namespace System.Drawing
   41 {
   42     public sealed class Graphics : MarshalByRefObject, IDisposable
   43     , IDeviceContext
   44     {
   45         internal IntPtr nativeObject = IntPtr.Zero;
   46         internal IMacContext maccontext;
   47         private bool disposed = false;
   48         private static float defDpiX = 0;
   49         private static float defDpiY = 0;
   50         private IntPtr deviceContextHdc;
   51         private Metafile.MetafileHolder _metafileHolder;
   52 
   53         public delegate bool EnumerateMetafileProc (EmfPlusRecordType recordType,
   54                                 int flags,
   55                                 int dataSize,
   56                                 IntPtr data,
   57                                 PlayRecordCallback callbackData);
   58         
   59         public delegate bool DrawImageAbort (IntPtr callbackdata);
   60 
   61         internal Graphics (IntPtr nativeGraphics)
   62         {
   63             nativeObject = nativeGraphics;
   64         }
   65 
   66         internal Graphics(IntPtr nativeGraphics, Image image) : this(nativeGraphics)
   67         {
   68             if (image is Metafile mf) {
   69                 _metafileHolder = mf.AddMetafileHolder();
   70             }
   71         }
   72 
   73         ~Graphics ()
   74         {
   75             Dispose ();         
   76         }       
   77 
   78         static internal float systemDpiX {
   79             get {
   80                 if (defDpiX == 0) {
   81                     Bitmap bmp = new Bitmap (1, 1);
   82                     Graphics g = Graphics.FromImage (bmp);
   83                     defDpiX = g.DpiX;
   84                     defDpiY = g.DpiY;
   85                 }
   86                 return defDpiX;
   87             }
   88         }
   89 
   90         static internal float systemDpiY {
   91             get {
   92                 if (defDpiY == 0) {
   93                     Bitmap bmp = new Bitmap (1, 1);
   94                     Graphics g = Graphics.FromImage (bmp);
   95                     defDpiX = g.DpiX;
   96                     defDpiY = g.DpiY;
   97                 }
   98                 return defDpiY;
   99             }
  100         }
  101 
  102         // For CoreFX compatibility
  103         internal IntPtr NativeGraphics {
  104             get {
  105                 return nativeObject;
  106             }
  107         }
  108 
  109         internal IntPtr NativeObject {
  110             get {
  111                 return nativeObject;
  112             }
  113 
  114             set {
  115                 nativeObject = value;
  116             }
  117         }
  118         
  119         [MonoTODO ("Metafiles, both WMF and EMF formats, aren't supported.")]
  120         public void AddMetafileComment (byte [] data)
  121         {
  122             throw new NotImplementedException ();
  123         }
  124 
  125         public GraphicsContainer BeginContainer ()
  126         {
  127             uint state;
  128             Status status;
  129             status = GDIPlus.GdipBeginContainer2 (nativeObject, out state);
  130                 GDIPlus.CheckStatus (status);
  131 
  132                         return new GraphicsContainer(state);
  133         }
  134 
  135         [MonoTODO ("The rectangles and unit parameters aren't supported in libgdiplus")]        
  136         public GraphicsContainer BeginContainer (Rectangle dstrect, Rectangle srcrect, GraphicsUnit unit)
  137         {
  138             uint state;
  139             Status status;
  140             status = GDIPlus.GdipBeginContainerI (nativeObject, ref dstrect, ref srcrect, unit, out state);
  141             GDIPlus.CheckStatus (status);
  142 
  143             return new GraphicsContainer (state);
  144         }
  145 
  146         [MonoTODO ("The rectangles and unit parameters aren't supported in libgdiplus")]        
  147         public GraphicsContainer BeginContainer (RectangleF dstrect, RectangleF srcrect, GraphicsUnit unit)
  148         {
  149             uint state;
  150             Status status;
  151             status = GDIPlus.GdipBeginContainer (nativeObject, ref dstrect, ref srcrect, unit, out state);
  152             GDIPlus.CheckStatus (status);
  153 
  154             return new GraphicsContainer (state);
  155         }
  156 
  157         
  158         public void Clear (Color color)
  159         {
  160             Status status;
  161             status = GDIPlus.GdipGraphicsClear (nativeObject, color.ToArgb ());
  162             GDIPlus.CheckStatus (status);
  163         }
  164         [MonoLimitation ("Works on Win32 and on X11 (but not on Cocoa and Quartz)")]
  165         public void CopyFromScreen (Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize)
  166         {
  167             CopyFromScreen (upperLeftSource.X, upperLeftSource.Y, upperLeftDestination.X, upperLeftDestination.Y,
  168                 blockRegionSize, CopyPixelOperation.SourceCopy);                
  169         }
  170 
  171         [MonoLimitation ("Works on Win32 and (for CopyPixelOperation.SourceCopy only) on X11 but not on Cocoa and Quartz")]
  172         public void CopyFromScreen (Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
  173         {
  174             CopyFromScreen (upperLeftSource.X, upperLeftSource.Y, upperLeftDestination.X, upperLeftDestination.Y,
  175                 blockRegionSize, copyPixelOperation);
  176         }
  177         
  178         [MonoLimitation ("Works on Win32 and on X11 (but not on Cocoa and Quartz)")]
  179         public void CopyFromScreen (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize)
  180         {
  181             CopyFromScreen (sourceX, sourceY, destinationX, destinationY, blockRegionSize,
  182                 CopyPixelOperation.SourceCopy);
  183         }
  184 
  185         [MonoLimitation ("Works on Win32 and (for CopyPixelOperation.SourceCopy only) on X11 but not on Cocoa and Quartz")]
  186         public void CopyFromScreen (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
  187         {
  188             if (!Enum.IsDefined (typeof (CopyPixelOperation), copyPixelOperation))
  189                 throw new InvalidEnumArgumentException (Locale.GetText ("Enum argument value '{0}' is not valid for CopyPixelOperation", copyPixelOperation));
  190 
  191             if (GDIPlus.UseX11Drawable) {
  192                 CopyFromScreenX11 (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
  193             } else if (GDIPlus.UseCarbonDrawable) {
  194                 CopyFromScreenMac (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
  195             } else if (GDIPlus.UseCocoaDrawable) {
  196                 CopyFromScreenMac (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
  197             } else {
  198                 CopyFromScreenWin32 (sourceX, sourceY, destinationX, destinationY, blockRegionSize, copyPixelOperation);
  199             }
  200         }
  201 
  202         private void CopyFromScreenWin32 (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
  203         {
  204             IntPtr window = GDIPlus.GetDesktopWindow ();
  205             IntPtr srcDC = GDIPlus.GetDC (window);
  206             IntPtr dstDC = GetHdc ();
  207             GDIPlus.BitBlt (dstDC, destinationX, destinationY, blockRegionSize.Width,
  208                 blockRegionSize.Height, srcDC, sourceX, sourceY, (int) copyPixelOperation);
  209 
  210             GDIPlus.ReleaseDC (IntPtr.Zero, srcDC);
  211             ReleaseHdc (dstDC);         
  212         }
  213         
  214         private void CopyFromScreenMac (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
  215         {
  216             throw new NotImplementedException ();
  217         }
  218 
  219         private void CopyFromScreenX11 (int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
  220         {
  221             IntPtr window, image, defvisual, vPtr;
  222             int AllPlanes = ~0, nitems = 0, pixel;
  223 
  224             if (copyPixelOperation != CopyPixelOperation.SourceCopy)
  225                 throw new NotImplementedException ("Operation not implemented under X11");
  226         
  227             if (GDIPlus.Display == IntPtr.Zero) {
  228                 GDIPlus.Display = GDIPlus.XOpenDisplay (IntPtr.Zero);
  229             }
  230 
  231             window = GDIPlus.XRootWindow (GDIPlus.Display, 0);
  232             defvisual = GDIPlus.XDefaultVisual (GDIPlus.Display, 0);
  233             XVisualInfo visual = new XVisualInfo ();
  234 
  235             /* Get XVisualInfo for this visual */
  236             visual.visualid = GDIPlus.XVisualIDFromVisual(defvisual);
  237             vPtr = GDIPlus.XGetVisualInfo (GDIPlus.Display, 0x1 /* VisualIDMask */, ref visual, ref nitems);
  238             visual = (XVisualInfo) Marshal.PtrToStructure(vPtr, typeof (XVisualInfo));
  239 #if false
  240             Console.WriteLine ("visual\t{0}", visual.visual);
  241             Console.WriteLine ("visualid\t{0}", visual.visualid);
  242             Console.WriteLine ("screen\t{0}", visual.screen);
  243             Console.WriteLine ("depth\t{0}", visual.depth);
  244             Console.WriteLine ("klass\t{0}", visual.klass);
  245             Console.WriteLine ("red_mask\t{0:X}", visual.red_mask);
  246             Console.WriteLine ("green_mask\t{0:X}", visual.green_mask);
  247             Console.WriteLine ("blue_mask\t{0:X}", visual.blue_mask);
  248             Console.WriteLine ("colormap_size\t{0}", visual.colormap_size);
  249             Console.WriteLine ("bits_per_rgb\t{0}", visual.bits_per_rgb);
  250 #endif
  251             image = GDIPlus.XGetImage (GDIPlus.Display, window, sourceX, sourceY, blockRegionSize.Width,
  252                 blockRegionSize.Height, AllPlanes, 2 /* ZPixmap*/);
  253             if (image == IntPtr.Zero) {
  254                 string s = String.Format ("XGetImage returned NULL when asked to for a {0}x{1} region block", 
  255                     blockRegionSize.Width, blockRegionSize.Height);
  256                 throw new InvalidOperationException (s);
  257             }
  258                 
  259             Bitmap bmp = new Bitmap (blockRegionSize.Width, blockRegionSize.Height);
  260             int red, blue, green;
  261             int red_mask = (int) visual.red_mask;
  262             int blue_mask = (int) visual.blue_mask;
  263             int green_mask = (int) visual.green_mask;
  264             for (int y = 0; y < blockRegionSize.Height; y++) {
  265                 for (int x = 0; x < blockRegionSize.Width; x++) {
  266                     pixel = GDIPlus.XGetPixel (image, x, y);
  267 
  268                     switch (visual.depth) {
  269                         case 16: /* 16bbp pixel transformation */
  270                             red = (int) ((pixel & red_mask ) >> 8) & 0xff;
  271                             green = (int) (((pixel & green_mask ) >> 3 )) & 0xff;
  272                             blue = (int) ((pixel & blue_mask ) << 3 ) & 0xff;
  273                             break;
  274                         case 24:
  275                         case 32:
  276                             red = (int) ((pixel & red_mask ) >> 16) & 0xff;
  277                             green = (int) (((pixel & green_mask ) >> 8 )) & 0xff;
  278                             blue = (int) ((pixel & blue_mask )) & 0xff;
  279                             break;
  280                         default:
  281                             string text = Locale.GetText ("{0}bbp depth not supported.", visual.depth);
  282                             throw new NotImplementedException (text);
  283                     }
  284                         
  285                     bmp.SetPixel (x, y, Color.FromArgb (255, red, green, blue));                             
  286                 }
  287             }
  288 
  289             DrawImage (bmp, destinationX, destinationY);
  290             bmp.Dispose ();
  291             GDIPlus.XDestroyImage (image);
  292             GDIPlus.XFree (vPtr);
  293         }
  294 
  295         public void Dispose ()
  296         {
  297             Status status;
  298             if (! disposed) {
  299                 if (GDIPlus.UseCarbonDrawable || GDIPlus.UseCocoaDrawable) {
  300                     Flush ();
  301                     if (maccontext != null)
  302                         maccontext.Release ();
  303                 }
  304 
  305                 status = GDIPlus.GdipDeleteGraphics (nativeObject);
  306                 nativeObject = IntPtr.Zero;
  307                 GDIPlus.CheckStatus (status);
  308 
  309                 if (_metafileHolder != null)
  310                 {
  311                     var mh = _metafileHolder;
  312                     _metafileHolder = null;
  313                     mh.GraphicsDisposed();
  314                 }
  315 
  316                 disposed = true;                
  317             }
  318 
  319             GC.SuppressFinalize(this);
  320         }
  321 
  322         
  323         public void DrawArc (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
  324         {
  325             DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
  326         }
  327 
  328         
  329         public void DrawArc (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
  330         {
  331             DrawArc (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
  332         }
  333 
  334         
  335         public void DrawArc (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
  336         {
  337             Status status;
  338             if (pen == null)
  339                 throw new ArgumentNullException ("pen");
  340             
  341             status = GDIPlus.GdipDrawArc (nativeObject, pen.NativePen,
  342                                         x, y, width, height, startAngle, sweepAngle);
  343             GDIPlus.CheckStatus (status);
  344         }
  345 
  346         // Microsoft documentation states that the signature for this member should be
  347         // public void DrawArc( Pen pen,  int x,  int y,  int width,  int height,   int startAngle,
  348         // int sweepAngle. However, GdipDrawArcI uses also float for the startAngle and sweepAngle params
  349         public void DrawArc (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
  350         {
  351             Status status;
  352             if (pen == null)
  353                 throw new ArgumentNullException ("pen");
  354             status = GDIPlus.GdipDrawArcI (nativeObject, pen.NativePen,
  355                         x, y, width, height, startAngle, sweepAngle);
  356             GDIPlus.CheckStatus (status);
  357         }
  358 
  359         public void DrawBezier (Pen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4)
  360         {
  361             Status status;
  362             if (pen == null)
  363                 throw new ArgumentNullException ("pen");
  364             status = GDIPlus.GdipDrawBezier (nativeObject, pen.NativePen,
  365                             pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
  366                             pt3.Y, pt4.X, pt4.Y);
  367             GDIPlus.CheckStatus (status);
  368         }
  369 
  370         public void DrawBezier (Pen pen, Point pt1, Point pt2, Point pt3, Point pt4)
  371         {
  372             Status status;
  373             if (pen == null)
  374                 throw new ArgumentNullException ("pen");
  375             status = GDIPlus.GdipDrawBezierI (nativeObject, pen.NativePen,
  376                             pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
  377                             pt3.Y, pt4.X, pt4.Y);
  378             GDIPlus.CheckStatus (status);
  379         }
  380 
  381         public void DrawBezier (Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
  382         {
  383             Status status;
  384             if (pen == null)
  385                 throw new ArgumentNullException ("pen");
  386             status = GDIPlus.GdipDrawBezier (nativeObject, pen.NativePen, x1,
  387                             y1, x2, y2, x3, y3, x4, y4);
  388             GDIPlus.CheckStatus (status);
  389         }
  390 
  391         public void DrawBeziers (Pen pen, Point [] points)
  392         {
  393             if (pen == null)
  394                 throw new ArgumentNullException ("pen");
  395             if (points == null)
  396                 throw new ArgumentNullException ("points");
  397             
  398                         int length = points.Length;
  399             Status status;
  400 
  401                         if (length < 4)
  402                                 return;
  403 
  404             for (int i = 0; i < length - 1; i += 3) {
  405                                 Point p1 = points [i];
  406                                 Point p2 = points [i + 1];
  407                                 Point p3 = points [i + 2];
  408                                 Point p4 = points [i + 3];
  409 
  410                                 status = GDIPlus.GdipDrawBezier (nativeObject, 
  411                             pen.NativePen,
  412                                                         p1.X, p1.Y, p2.X, p2.Y, 
  413                                                         p3.X, p3.Y, p4.X, p4.Y);
  414                 GDIPlus.CheckStatus (status);
  415                         }
  416         }
  417 
  418         public void DrawBeziers (Pen pen, PointF [] points)
  419         {
  420             if (pen == null)
  421                 throw new ArgumentNullException ("pen");
  422             if (points == null)
  423                 throw new ArgumentNullException ("points");
  424             
  425             int length = points.Length;
  426             Status status;
  427 
  428                         if (length < 4)
  429                                 return;
  430 
  431             for (int i = 0; i < length - 1; i += 3) {
  432                                 PointF p1 = points [i];
  433                                 PointF p2 = points [i + 1];
  434                                 PointF p3 = points [i + 2];
  435                                 PointF p4 = points [i + 3];
  436 
  437                                 status = GDIPlus.GdipDrawBezier (nativeObject, 
  438                             pen.NativePen,
  439                                                         p1.X, p1.Y, p2.X, p2.Y, 
  440                                                         p3.X, p3.Y, p4.X, p4.Y);
  441                 GDIPlus.CheckStatus (status);
  442                         }
  443         }
  444 
  445         
  446         public void DrawClosedCurve (Pen pen, PointF [] points)
  447         {
  448             if (pen == null)
  449                 throw new ArgumentNullException ("pen");
  450             if (points == null)
  451                 throw new ArgumentNullException ("points");
  452             
  453             Status status;
  454             status = GDIPlus.GdipDrawClosedCurve (nativeObject, pen.NativePen, points, points.Length);
  455             GDIPlus.CheckStatus (status);
  456         }
  457         
  458         public void DrawClosedCurve (Pen pen, Point [] points)
  459         {
  460             if (pen == null)
  461                 throw new ArgumentNullException ("pen");
  462             if (points == null)
  463                 throw new ArgumentNullException ("points");
  464             
  465             Status status;
  466             status = GDIPlus.GdipDrawClosedCurveI (nativeObject, pen.NativePen, points, points.Length);
  467             GDIPlus.CheckStatus (status);
  468         }
  469             
  470         // according to MSDN fillmode "is required but ignored" which makes _some_ sense since the unmanaged 
  471         // GDI+ call doesn't support it (issue spotted using Gendarme's AvoidUnusedParametersRule)
  472         public void DrawClosedCurve (Pen pen, Point [] points, float tension, FillMode fillmode)
  473         {
  474             if (pen == null)
  475                 throw new ArgumentNullException ("pen");
  476             if (points == null)
  477                 throw new ArgumentNullException ("points");
  478             
  479             Status status;
  480             status = GDIPlus.GdipDrawClosedCurve2I (nativeObject, pen.NativePen, points, points.Length, tension);
  481             GDIPlus.CheckStatus (status);
  482         }
  483 
  484         // according to MSDN fillmode "is required but ignored" which makes _some_ sense since the unmanaged 
  485         // GDI+ call doesn't support it (issue spotted using Gendarme's AvoidUnusedParametersRule)
  486         public void DrawClosedCurve (Pen pen, PointF [] points, float tension, FillMode fillmode)
  487         {
  488             if (pen == null)
  489                 throw new ArgumentNullException ("pen");
  490             if (points == null)
  491                 throw new ArgumentNullException ("points");
  492             
  493             Status status;
  494             status = GDIPlus.GdipDrawClosedCurve2 (nativeObject, pen.NativePen, points, points.Length, tension);
  495             GDIPlus.CheckStatus (status);
  496         }
  497         
  498         public void DrawCurve (Pen pen, Point [] points)
  499         {
  500             if (pen == null)
  501                 throw new ArgumentNullException ("pen");
  502             if (points == null)
  503                 throw new ArgumentNullException ("points");
  504             
  505             Status status;
  506             status = GDIPlus.GdipDrawCurveI (nativeObject, pen.NativePen, points, points.Length);
  507             GDIPlus.CheckStatus (status);
  508         }
  509         
  510         public void DrawCurve (Pen pen, PointF [] points)
  511         {
  512             if (pen == null)
  513                 throw new ArgumentNullException ("pen");
  514             if (points == null)
  515                 throw new ArgumentNullException ("points");
  516             
  517             Status status;
  518             status = GDIPlus.GdipDrawCurve (nativeObject, pen.NativePen, points, points.Length);
  519             GDIPlus.CheckStatus (status);
  520         }
  521         
  522         public void DrawCurve (Pen pen, PointF [] points, float tension)
  523         {
  524             if (pen == null)
  525                 throw new ArgumentNullException ("pen");
  526             if (points == null)
  527                 throw new ArgumentNullException ("points");
  528             
  529             Status status;
  530             status = GDIPlus.GdipDrawCurve2 (nativeObject, pen.NativePen, points, points.Length, tension);
  531             GDIPlus.CheckStatus (status);
  532         }
  533         
  534         public void DrawCurve (Pen pen, Point [] points, float tension)
  535         {
  536             if (pen == null)
  537                 throw new ArgumentNullException ("pen");
  538             if (points == null)
  539                 throw new ArgumentNullException ("points");
  540             
  541             Status status;
  542             status = GDIPlus.GdipDrawCurve2I (nativeObject, pen.NativePen, points, points.Length, tension);     
  543             GDIPlus.CheckStatus (status);
  544         }
  545         
  546         public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments)
  547         {
  548             if (pen == null)
  549                 throw new ArgumentNullException ("pen");
  550             if (points == null)
  551                 throw new ArgumentNullException ("points");
  552             
  553             Status status;
  554             status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.NativePen,
  555                             points, points.Length, offset,
  556                             numberOfSegments, 0.5f);
  557             GDIPlus.CheckStatus (status);
  558         }
  559 
  560         public void DrawCurve (Pen pen, Point [] points, int offset, int numberOfSegments, float tension)
  561         {
  562             if (pen == null)
  563                 throw new ArgumentNullException ("pen");
  564             if (points == null)
  565                 throw new ArgumentNullException ("points");
  566             
  567             Status status;
  568             status = GDIPlus.GdipDrawCurve3I (nativeObject, pen.NativePen,
  569                             points, points.Length, offset,
  570                             numberOfSegments, tension);
  571             GDIPlus.CheckStatus (status);
  572         }
  573 
  574         public void DrawCurve (Pen pen, PointF [] points, int offset, int numberOfSegments, float tension)
  575         {
  576             if (pen == null)
  577                 throw new ArgumentNullException ("pen");
  578             if (points == null)
  579                 throw new ArgumentNullException ("points");
  580             
  581             Status status;
  582             status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.NativePen,
  583                             points, points.Length, offset,
  584                             numberOfSegments, tension);
  585             GDIPlus.CheckStatus (status);
  586         }
  587 
  588         public void DrawEllipse (Pen pen, Rectangle rect)
  589         {
  590             if (pen == null)
  591                 throw new ArgumentNullException ("pen");
  592             
  593             DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
  594         }
  595 
  596         public void DrawEllipse (Pen pen, RectangleF rect)
  597         {
  598             if (pen == null)
  599                 throw new ArgumentNullException ("pen");
  600             DrawEllipse (pen, rect.X, rect.Y, rect.Width, rect.Height);
  601         }
  602 
  603         public void DrawEllipse (Pen pen, int x, int y, int width, int height)
  604         {
  605             if (pen == null)
  606                 throw new ArgumentNullException ("pen");
  607             Status status;
  608             status = GDIPlus.GdipDrawEllipseI (nativeObject, pen.NativePen, x, y, width, height);
  609             GDIPlus.CheckStatus (status);
  610         }
  611 
  612         public void DrawEllipse (Pen pen, float x, float y, float width, float height)
  613         {
  614             if (pen == null)
  615                 throw new ArgumentNullException ("pen");
  616             Status status = GDIPlus.GdipDrawEllipse (nativeObject, pen.NativePen, x, y, width, height);
  617             GDIPlus.CheckStatus (status);
  618         }
  619 
  620         public void DrawIcon (Icon icon, Rectangle targetRect)
  621         {
  622             if (icon == null)
  623                 throw new ArgumentNullException ("icon");
  624 
  625             DrawImage (icon.GetInternalBitmap (), targetRect);
  626         }
  627 
  628         public void DrawIcon (Icon icon, int x, int y)
  629         {
  630             if (icon == null)
  631                 throw new ArgumentNullException ("icon");
  632 
  633             DrawImage (icon.GetInternalBitmap (), x, y);
  634         }
  635 
  636         public void DrawIconUnstretched (Icon icon, Rectangle targetRect)
  637         {
  638             if (icon == null)
  639                 throw new ArgumentNullException ("icon");
  640 
  641             DrawImageUnscaled (icon.GetInternalBitmap (), targetRect);
  642         }
  643         
  644         public void DrawImage (Image image, RectangleF rect)
  645         {
  646             if (image == null)
  647                 throw new ArgumentNullException ("image");
  648             
  649             Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, rect.X, rect.Y, rect.Width, rect.Height);
  650             GDIPlus.CheckStatus (status);
  651         }
  652 
  653         public void DrawImage (Image image, PointF point)
  654         {
  655             if (image == null)
  656                 throw new ArgumentNullException ("image");
  657             
  658             Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, point.X, point.Y);
  659             GDIPlus.CheckStatus (status);
  660         }
  661 
  662         public void DrawImage (Image image, Point [] destPoints)
  663         {
  664             if (image == null)
  665                 throw new ArgumentNullException ("image");
  666             if (destPoints == null)
  667                 throw new ArgumentNullException ("destPoints");
  668             
  669             Status status = GDIPlus.GdipDrawImagePointsI (nativeObject, image.NativeObject, destPoints, destPoints.Length);
  670             GDIPlus.CheckStatus (status);
  671         }
  672 
  673         public void DrawImage (Image image, Point point)
  674         {
  675             if (image == null)
  676                 throw new ArgumentNullException ("image");
  677             DrawImage (image, point.X, point.Y);
  678         }
  679 
  680         public void DrawImage (Image image, Rectangle rect)
  681         {
  682             if (image == null)
  683                 throw new ArgumentNullException ("image");
  684             DrawImage (image, rect.X, rect.Y, rect.Width, rect.Height);
  685         }
  686 
  687         public void DrawImage (Image image, PointF [] destPoints)
  688         {
  689             if (image == null)
  690                 throw new ArgumentNullException ("image");
  691             if (destPoints == null)
  692                 throw new ArgumentNullException ("destPoints");
  693             Status status = GDIPlus.GdipDrawImagePoints (nativeObject, image.NativeObject, destPoints, destPoints.Length);
  694             GDIPlus.CheckStatus (status);
  695         }
  696 
  697         public void DrawImage (Image image, int x, int y)
  698         {
  699             if (image == null)
  700                 throw new ArgumentNullException ("image");
  701             Status status = GDIPlus.GdipDrawImageI (nativeObject, image.NativeObject, x, y);
  702             GDIPlus.CheckStatus (status);
  703         }
  704 
  705         public void DrawImage (Image image, float x, float y)
  706         {
  707             if (image == null)
  708                 throw new ArgumentNullException ("image");
  709             Status status = GDIPlus.GdipDrawImage (nativeObject, image.NativeObject, x, y);
  710             GDIPlus.CheckStatus (status);
  711         }
  712 
  713         public void DrawImage (Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit)
  714         {
  715             if (image == null)
  716                 throw new ArgumentNullException ("image");
  717             Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
  718                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
  719                 srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
  720                 srcUnit, IntPtr.Zero, null, IntPtr.Zero);
  721             GDIPlus.CheckStatus (status);
  722         }
  723         
  724         public void DrawImage (Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit)
  725         {           
  726             if (image == null)
  727                 throw new ArgumentNullException ("image");
  728             Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
  729                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
  730                 srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
  731                 srcUnit, IntPtr.Zero, null, IntPtr.Zero);
  732             GDIPlus.CheckStatus (status);
  733         }
  734 
  735         public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit)
  736         {
  737             if (image == null)
  738                 throw new ArgumentNullException ("image");
  739             if (destPoints == null)
  740                 throw new ArgumentNullException ("destPoints");
  741             
  742             Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
  743                 destPoints, destPoints.Length , srcRect.X, srcRect.Y, 
  744                 srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero, 
  745                 null, IntPtr.Zero);
  746             GDIPlus.CheckStatus (status);
  747         }
  748 
  749         public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit)
  750         {
  751             if (image == null)
  752                 throw new ArgumentNullException ("image");
  753             if (destPoints == null)
  754                 throw new ArgumentNullException ("destPoints");
  755             
  756             Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
  757                 destPoints, destPoints.Length , srcRect.X, srcRect.Y, 
  758                 srcRect.Width, srcRect.Height, srcUnit, IntPtr.Zero, 
  759                 null, IntPtr.Zero);
  760             GDIPlus.CheckStatus (status);
  761         }
  762 
  763         public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, 
  764                                 ImageAttributes imageAttr)
  765         {
  766             if (image == null)
  767                 throw new ArgumentNullException ("image");
  768             if (destPoints == null)
  769                 throw new ArgumentNullException ("destPoints");
  770             Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
  771                 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
  772                 srcRect.Width, srcRect.Height, srcUnit,
  773                 imageAttr != null ? imageAttr.nativeImageAttributes : IntPtr.Zero, null, IntPtr.Zero);
  774             GDIPlus.CheckStatus (status);
  775         }
  776         
  777         public void DrawImage (Image image, float x, float y, float width, float height)
  778         {
  779             if (image == null)
  780                 throw new ArgumentNullException ("image");
  781             Status status = GDIPlus.GdipDrawImageRect(nativeObject, image.NativeObject, x, y,
  782                            width, height);
  783             GDIPlus.CheckStatus (status);
  784         }
  785 
  786         public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, 
  787                                 ImageAttributes imageAttr)
  788         {
  789             if (image == null)
  790                 throw new ArgumentNullException ("image");
  791             if (destPoints == null)
  792                 throw new ArgumentNullException ("destPoints");
  793             Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
  794                 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
  795                 srcRect.Width, srcRect.Height, srcUnit, 
  796                 imageAttr != null ? imageAttr.nativeImageAttributes : IntPtr.Zero, null, IntPtr.Zero);
  797             GDIPlus.CheckStatus (status);
  798         }
  799 
  800         public void DrawImage (Image image, int x, int y, Rectangle srcRect, GraphicsUnit srcUnit)
  801         {           
  802             if (image == null)
  803                 throw new ArgumentNullException ("image");
  804             Status status = GDIPlus.GdipDrawImagePointRectI(nativeObject, image.NativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
  805             GDIPlus.CheckStatus (status);
  806         }
  807         
  808         public void DrawImage (Image image, int x, int y, int width, int height)
  809         {
  810             if (image == null)
  811                 throw new ArgumentNullException ("image");
  812             Status status = GDIPlus.GdipDrawImageRectI (nativeObject, image.nativeObject, x, y, width, height);
  813             GDIPlus.CheckStatus (status);
  814         }
  815 
  816         public void DrawImage (Image image, float x, float y, RectangleF srcRect, GraphicsUnit srcUnit)
  817         {           
  818             if (image == null)
  819                 throw new ArgumentNullException ("image");
  820             Status status = GDIPlus.GdipDrawImagePointRect (nativeObject, image.nativeObject, x, y, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit);
  821             GDIPlus.CheckStatus (status);
  822         }
  823 
  824         public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
  825         {
  826             if (image == null)
  827                 throw new ArgumentNullException ("image");
  828             if (destPoints == null)
  829                 throw new ArgumentNullException ("destPoints");
  830             Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
  831                 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
  832                 srcRect.Width, srcRect.Height, srcUnit, 
  833                 imageAttr != null ? imageAttr.nativeImageAttributes : IntPtr.Zero, callback, IntPtr.Zero);
  834             GDIPlus.CheckStatus (status);
  835         }
  836 
  837         public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
  838         {
  839             if (image == null)
  840                 throw new ArgumentNullException ("image");
  841             if (destPoints == null)
  842                 throw new ArgumentNullException ("destPoints");
  843             
  844             Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
  845                 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
  846                 srcRect.Width, srcRect.Height, srcUnit, 
  847                 imageAttr != null ? imageAttr.nativeImageAttributes : IntPtr.Zero, callback, IntPtr.Zero);
  848             GDIPlus.CheckStatus (status);
  849         }
  850 
  851         public void DrawImage (Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
  852         {
  853             if (image == null)
  854                 throw new ArgumentNullException ("image");
  855             if (destPoints == null)
  856                 throw new ArgumentNullException ("destPoints");
  857 
  858             Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
  859                 destPoints, destPoints.Length , srcRect.X, srcRect.Y, 
  860                 srcRect.Width, srcRect.Height, srcUnit, 
  861                 imageAttr != null ? imageAttr.nativeImageAttributes : IntPtr.Zero, callback, (IntPtr) callbackData);
  862             GDIPlus.CheckStatus (status);
  863         }
  864 
  865         public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit)
  866         {
  867             if (image == null)
  868                 throw new ArgumentNullException ("image");
  869             Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
  870                                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
  871                             srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero, 
  872                             null, IntPtr.Zero);
  873             GDIPlus.CheckStatus (status);
  874         }
  875         
  876         public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
  877         {
  878             Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
  879                 destPoints, destPoints.Length , srcRect.X, srcRect.Y,
  880                 srcRect.Width, srcRect.Height, srcUnit, 
  881                 imageAttr != null ? imageAttr.nativeImageAttributes : IntPtr.Zero, callback, (IntPtr) callbackData);
  882             GDIPlus.CheckStatus (status);
  883         }
  884 
  885         public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit)
  886         {
  887             if (image == null)
  888                 throw new ArgumentNullException ("image");
  889             Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject,
  890                                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
  891                             srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero, 
  892                             null, IntPtr.Zero);
  893             GDIPlus.CheckStatus (status);
  894         }
  895 
  896         public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs)
  897         {
  898             if (image == null)
  899                 throw new ArgumentNullException ("image");
  900             Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
  901                                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
  902                             srcX, srcY, srcWidth, srcHeight, srcUnit,
  903                 imageAttrs != null ? imageAttrs.nativeImageAttributes : IntPtr.Zero, null, IntPtr.Zero);
  904             GDIPlus.CheckStatus (status);
  905         }
  906         
  907         public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
  908         {           
  909             if (image == null)
  910                 throw new ArgumentNullException ("image");
  911             Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject, 
  912                                         destRect.X, destRect.Y, destRect.Width, 
  913                     destRect.Height, srcX, srcY, srcWidth, srcHeight,
  914                     srcUnit, imageAttr != null ? imageAttr.nativeImageAttributes : IntPtr.Zero, null, IntPtr.Zero);
  915             GDIPlus.CheckStatus (status);
  916         }
  917         
  918         public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
  919         {
  920             if (image == null)
  921                 throw new ArgumentNullException ("image");
  922             Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject, 
  923                                         destRect.X, destRect.Y, destRect.Width, 
  924                     destRect.Height, srcX, srcY, srcWidth, srcHeight,
  925                     srcUnit, imageAttr != null ? imageAttr.nativeImageAttributes : IntPtr.Zero, callback,
  926                     IntPtr.Zero);
  927             GDIPlus.CheckStatus (status);
  928         }
  929         
  930         public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback)
  931         {
  932             if (image == null)
  933                 throw new ArgumentNullException ("image");
  934             Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject, 
  935                                         destRect.X, destRect.Y, destRect.Width, 
  936                     destRect.Height, srcX, srcY, srcWidth, srcHeight,
  937                     srcUnit, imageAttrs != null ? imageAttrs.nativeImageAttributes : IntPtr.Zero, 
  938                     callback, IntPtr.Zero);
  939             GDIPlus.CheckStatus (status);
  940         }
  941 
  942         public void DrawImage (Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData)
  943         {
  944             if (image == null)
  945                 throw new ArgumentNullException ("image");
  946             Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject, 
  947                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
  948                 srcX, srcY, srcWidth, srcHeight, srcUnit, 
  949                 imageAttrs != null ? imageAttrs.nativeImageAttributes : IntPtr.Zero, callback, callbackData);
  950             GDIPlus.CheckStatus (status);
  951         }
  952 
  953         public void DrawImage (Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData)
  954         {
  955             if (image == null)
  956                 throw new ArgumentNullException ("image");
  957             Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject, 
  958                             destRect.X, destRect.Y, destRect.Width, destRect.Height,
  959                 srcX, srcY, srcWidth, srcHeight, srcUnit,
  960                 imageAttrs != null ? imageAttrs.nativeImageAttributes : IntPtr.Zero, callback, callbackData);
  961             GDIPlus.CheckStatus (status);
  962         }       
  963         
  964         public void DrawImageUnscaled (Image image, Point point)
  965         {
  966             DrawImageUnscaled (image, point.X, point.Y);
  967         }
  968         
  969         public void DrawImageUnscaled (Image image, Rectangle rect)
  970         {
  971             DrawImageUnscaled (image, rect.X, rect.Y, rect.Width, rect.Height);
  972         }
  973         
  974         public void DrawImageUnscaled (Image image, int x, int y)
  975         {
  976             if (image == null)
  977                 throw new ArgumentNullException ("image");
  978             DrawImage (image, x, y, image.Width, image.Height);
  979         }
  980 
  981         public void DrawImageUnscaled (Image image, int x, int y, int width, int height)
  982         {
  983             if (image == null)
  984                 throw new ArgumentNullException ("image");
  985 
  986             // avoid creating an empty, or negative w/h, bitmap...
  987             if ((width <= 0) || (height <= 0))
  988                 return;
  989 
  990             using (Image tmpImg = new Bitmap (width, height)) {
  991                 using (Graphics g = FromImage (tmpImg)) {
  992                     g.DrawImage (image, 0, 0, image.Width, image.Height);
  993                     DrawImage (tmpImg, x, y, width, height);
  994                 }
  995             }
  996         }
  997 
  998         public void DrawImageUnscaledAndClipped (Image image, Rectangle rect)
  999         {
 1000             if (image == null)
 1001                 throw new ArgumentNullException ("image");
 1002 
 1003             int width = (image.Width > rect.Width) ? rect.Width : image.Width;
 1004             int height = (image.Height > rect.Height) ? rect.Height : image.Height;
 1005 
 1006             DrawImageUnscaled (image, rect.X, rect.Y, width, height);           
 1007         }
 1008 
 1009         public void DrawLine (Pen pen, PointF pt1, PointF pt2)
 1010         {
 1011             if (pen == null)
 1012                 throw new ArgumentNullException ("pen");
 1013                         Status status = GDIPlus.GdipDrawLine (nativeObject, pen.NativePen,
 1014                                         pt1.X, pt1.Y, pt2.X, pt2.Y);
 1015             GDIPlus.CheckStatus (status);
 1016         }
 1017 
 1018         public void DrawLine (Pen pen, Point pt1, Point pt2)
 1019         {
 1020             if (pen == null)
 1021                 throw new ArgumentNullException ("pen");
 1022                         Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.NativePen,
 1023                                         pt1.X, pt1.Y, pt2.X, pt2.Y);
 1024             GDIPlus.CheckStatus (status);
 1025         }
 1026 
 1027         public void DrawLine (Pen pen, int x1, int y1, int x2, int y2)
 1028         {
 1029             if (pen == null)
 1030                 throw new ArgumentNullException ("pen");
 1031             Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.NativePen, x1, y1, x2, y2);
 1032             GDIPlus.CheckStatus (status);
 1033         }
 1034 
 1035         public void DrawLine (Pen pen, float x1, float y1, float x2, float y2)
 1036         {
 1037             if (pen == null)
 1038                 throw new ArgumentNullException ("pen");
 1039             if (!float.IsNaN(x1) && !float.IsNaN(y1) &&
 1040                 !float.IsNaN(x2) && !float.IsNaN(y2)) {
 1041                 Status status = GDIPlus.GdipDrawLine (nativeObject, pen.NativePen, x1, y1, x2, y2);
 1042                 GDIPlus.CheckStatus (status);
 1043             }
 1044         }
 1045 
 1046         public void DrawLines (Pen pen, PointF [] points)
 1047         {
 1048             if (pen == null)
 1049                 throw new ArgumentNullException ("pen");
 1050             if (points == null)
 1051                 throw new ArgumentNullException ("points");
 1052             Status status = GDIPlus.GdipDrawLines (nativeObject, pen.NativePen, points, points.Length);
 1053             GDIPlus.CheckStatus (status);
 1054         }
 1055 
 1056         public void DrawLines (Pen pen, Point [] points)
 1057         {
 1058             if (pen == null)
 1059                 throw new ArgumentNullException ("pen");
 1060             if (points == null)
 1061                 throw new ArgumentNullException ("points");
 1062             Status status = GDIPlus.GdipDrawLinesI (nativeObject, pen.NativePen, points, points.Length);
 1063             GDIPlus.CheckStatus (status);
 1064         }
 1065 
 1066         public void DrawPath (Pen pen, GraphicsPath path)
 1067         {
 1068             if (pen == null)
 1069                 throw new ArgumentNullException ("pen");
 1070             if (path == null)
 1071                 throw new ArgumentNullException ("path");
 1072             Status status = GDIPlus.GdipDrawPath (nativeObject, pen.NativePen, path.nativePath);
 1073             GDIPlus.CheckStatus (status);
 1074         }
 1075         
 1076         public void DrawPie (Pen pen, Rectangle rect, float startAngle, float sweepAngle)
 1077         {
 1078             if (pen == null)
 1079                 throw new ArgumentNullException ("pen");
 1080             DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
 1081         }
 1082         
 1083         public void DrawPie (Pen pen, RectangleF rect, float startAngle, float sweepAngle)
 1084         {
 1085             if (pen == null)
 1086                 throw new ArgumentNullException ("pen");
 1087             DrawPie (pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
 1088         }
 1089         
 1090         public void DrawPie (Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
 1091         {
 1092             if (pen == null)
 1093                 throw new ArgumentNullException ("pen");
 1094             Status status = GDIPlus.GdipDrawPie (nativeObject, pen.NativePen, x, y, width, height, startAngle, sweepAngle);
 1095             GDIPlus.CheckStatus (status);
 1096         }
 1097         
 1098         // Microsoft documentation states that the signature for this member should be
 1099         // public void DrawPie(Pen pen, int x,  int y,  int width,   int height,   int startAngle
 1100         // int sweepAngle. However, GdipDrawPieI uses also float for the startAngle and sweepAngle params
 1101         public void DrawPie (Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
 1102         {
 1103             if (pen == null)
 1104                 throw new ArgumentNullException ("pen");
 1105             Status status = GDIPlus.GdipDrawPieI (nativeObject, pen.NativePen, x, y, width, height, startAngle, sweepAngle);
 1106             GDIPlus.CheckStatus (status);
 1107         }
 1108 
 1109         public void DrawPolygon (Pen pen, Point [] points)
 1110         {
 1111             if (pen == null)
 1112                 throw new ArgumentNullException ("pen");
 1113             if (points == null)
 1114                 throw new ArgumentNullException ("points");
 1115             Status status = GDIPlus.GdipDrawPolygonI (nativeObject, pen.NativePen, points, points.Length);
 1116             GDIPlus.CheckStatus (status);
 1117         }
 1118 
 1119         public void DrawPolygon (Pen pen, PointF [] points)
 1120         {
 1121             if (pen == null)
 1122                 throw new ArgumentNullException ("pen");
 1123             if (points == null)
 1124                 throw new ArgumentNullException ("points");
 1125             Status status = GDIPlus.GdipDrawPolygon (nativeObject, pen.NativePen, points, points.Length);
 1126             GDIPlus.CheckStatus (status);
 1127         }
 1128 
 1129         public void DrawRectangle (Pen pen, Rectangle rect)
 1130         {
 1131             if (pen == null)
 1132                 throw new ArgumentNullException ("pen");
 1133             DrawRectangle (pen, rect.Left, rect.Top, rect.Width, rect.Height);
 1134         }
 1135 
 1136         public void DrawRectangle (Pen pen, float x, float y, float width, float height)
 1137         {
 1138             if (pen == null)
 1139                 throw new ArgumentNullException ("pen");
 1140             Status status = GDIPlus.GdipDrawRectangle (nativeObject, pen.NativePen, x, y, width, height);
 1141             GDIPlus.CheckStatus (status);
 1142         }
 1143 
 1144         public void DrawRectangle (Pen pen, int x, int y, int width, int height)
 1145         {
 1146             if (pen == null)
 1147                 throw new ArgumentNullException ("pen");
 1148             Status status = GDIPlus.GdipDrawRectangleI (nativeObject, pen.NativePen, x, y, width, height);
 1149             GDIPlus.CheckStatus (status);
 1150         }
 1151 
 1152         public void DrawRectangles (Pen pen, RectangleF [] rects)
 1153         {
 1154             if (pen == null)
 1155                 throw new ArgumentNullException ("image");
 1156             if (rects == null)
 1157                 throw new ArgumentNullException ("rects");
 1158             Status status = GDIPlus.GdipDrawRectangles (nativeObject, pen.NativePen, rects, rects.Length);
 1159             GDIPlus.CheckStatus (status);
 1160         }
 1161 
 1162         public void DrawRectangles (Pen pen, Rectangle [] rects)
 1163         {
 1164             if (pen == null)
 1165                 throw new ArgumentNullException ("image");
 1166             if (rects == null)
 1167                 throw new ArgumentNullException ("rects");
 1168             Status status = GDIPlus.GdipDrawRectanglesI (nativeObject, pen.NativePen, rects, rects.Length);
 1169             GDIPlus.CheckStatus (status);
 1170         }
 1171 
 1172         public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle)
 1173         {
 1174             DrawString (s, font, brush, layoutRectangle, null);
 1175         }
 1176 
 1177         public void DrawString (string s, Font font, Brush brush, PointF point)
 1178         {
 1179             DrawString (s, font, brush, new RectangleF (point.X, point.Y, 0, 0), null);
 1180         }
 1181 
 1182         public void DrawString (string s, Font font, Brush brush, PointF point, StringFormat format)
 1183         {
 1184             DrawString(s, font, brush, new RectangleF(point.X, point.Y, 0, 0), format);
 1185         }
 1186 
 1187         public void DrawString (string s, Font font, Brush brush, float x, float y)
 1188         {
 1189             DrawString (s, font, brush, new RectangleF (x, y, 0, 0), null);
 1190         }
 1191 
 1192         public void DrawString (string s, Font font, Brush brush, float x, float y, StringFormat format)
 1193         {
 1194             DrawString (s, font, brush, new RectangleF(x, y, 0, 0), format);
 1195         }
 1196 
 1197         public void DrawString (string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
 1198         {
 1199             if (font == null)
 1200                 throw new ArgumentNullException ("font");
 1201             if (brush == null)
 1202                 throw new ArgumentNullException ("brush");
 1203             if (s == null || s.Length == 0)
 1204                 return;
 1205 
 1206             Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref layoutRectangle, format != null ? format.NativeObject : IntPtr.Zero, brush.NativeBrush);
 1207             GDIPlus.CheckStatus (status);
 1208         }
 1209 
 1210         public void EndContainer (GraphicsContainer container)
 1211         {
 1212             if (container == null)
 1213                 throw new ArgumentNullException ("container");
 1214             Status status = GDIPlus.GdipEndContainer(nativeObject, container.NativeObject);
 1215             GDIPlus.CheckStatus (status);
 1216         }
 1217 
 1218         private const string MetafileEnumeration = "Metafiles enumeration, for both WMF and EMF formats, isn't supported.";
 1219 
 1220         [MonoTODO (MetafileEnumeration)]
 1221         public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback)
 1222         {
 1223             throw new NotImplementedException ();
 1224         }
 1225 
 1226         [MonoTODO (MetafileEnumeration)]
 1227         public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback)
 1228         {
 1229             throw new NotImplementedException ();
 1230         }
 1231 
 1232         [MonoTODO (MetafileEnumeration)]
 1233         public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback)
 1234         {
 1235             throw new NotImplementedException ();
 1236         }
 1237 
 1238         [MonoTODO (MetafileEnumeration)]
 1239         public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback)
 1240         {
 1241             throw new NotImplementedException ();
 1242         }
 1243 
 1244         [MonoTODO (MetafileEnumeration)]
 1245         public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback)
 1246         {
 1247             throw new NotImplementedException ();
 1248         }
 1249 
 1250         [MonoTODO (MetafileEnumeration)]
 1251         public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback)
 1252         {
 1253             throw new NotImplementedException ();
 1254         }
 1255 
 1256         [MonoTODO (MetafileEnumeration)]
 1257         public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
 1258         {
 1259             throw new NotImplementedException ();
 1260         }
 1261 
 1262         [MonoTODO (MetafileEnumeration)]
 1263         public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData)
 1264         {
 1265             throw new NotImplementedException ();
 1266         }
 1267 
 1268         [MonoTODO (MetafileEnumeration)]
 1269         public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
 1270         {
 1271             throw new NotImplementedException ();
 1272         }
 1273 
 1274         [MonoTODO (MetafileEnumeration)]
 1275         public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
 1276         {
 1277             throw new NotImplementedException ();
 1278         }
 1279 
 1280         [MonoTODO (MetafileEnumeration)]
 1281         public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
 1282         {
 1283             throw new NotImplementedException ();
 1284         }
 1285 
 1286         [MonoTODO (MetafileEnumeration)]
 1287         public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData)
 1288         {
 1289             throw new NotImplementedException ();
 1290         }
 1291 
 1292         [MonoTODO (MetafileEnumeration)]
 1293         public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
 1294         {
 1295             throw new NotImplementedException ();
 1296         }
 1297 
 1298         [MonoTODO (MetafileEnumeration)]
 1299         public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
 1300         {
 1301             throw new NotImplementedException ();
 1302         }
 1303 
 1304         [MonoTODO (MetafileEnumeration)]
 1305         public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
 1306         {
 1307             throw new NotImplementedException ();
 1308         }
 1309 
 1310         [MonoTODO (MetafileEnumeration)]
 1311         public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
 1312         {
 1313             throw new NotImplementedException ();
 1314         }
 1315 
 1316         [MonoTODO (MetafileEnumeration)]
 1317         public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
 1318         {
 1319             throw new NotImplementedException ();
 1320         }
 1321 
 1322         [MonoTODO (MetafileEnumeration)]
 1323         public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback)
 1324         {
 1325             throw new NotImplementedException ();
 1326         }
 1327 
 1328         [MonoTODO (MetafileEnumeration)]
 1329         public void EnumerateMetafile (Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
 1330         {
 1331             throw new NotImplementedException ();
 1332         }
 1333 
 1334         [MonoTODO (MetafileEnumeration)]
 1335         public void EnumerateMetafile (Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
 1336         {
 1337             throw new NotImplementedException ();
 1338         }
 1339 
 1340         [MonoTODO (MetafileEnumeration)]
 1341         public void EnumerateMetafile (Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
 1342         {
 1343             throw new NotImplementedException ();
 1344         }
 1345 
 1346         [MonoTODO (MetafileEnumeration)]
 1347         public void EnumerateMetafile (Metafile metafile, Point [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
 1348         {
 1349             throw new NotImplementedException ();
 1350         }
 1351 
 1352         [MonoTODO (MetafileEnumeration)]
 1353         public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
 1354         {
 1355             throw new NotImplementedException ();
 1356         }
 1357 
 1358         [MonoTODO (MetafileEnumeration)]
 1359         public void EnumerateMetafile (Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
 1360         {
 1361             throw new NotImplementedException ();
 1362         }
 1363 
 1364         [MonoTODO (MetafileEnumeration)]
 1365         public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
 1366         {
 1367             throw new NotImplementedException ();
 1368         }
 1369 
 1370         [MonoTODO (MetafileEnumeration)]
 1371         public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
 1372         {
 1373             throw new NotImplementedException ();
 1374         }
 1375 
 1376         [MonoTODO (MetafileEnumeration)]
 1377         public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
 1378         {
 1379             throw new NotImplementedException ();
 1380         }
 1381 
 1382         [MonoTODO (MetafileEnumeration)]
 1383         public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
 1384         {
 1385             throw new NotImplementedException ();
 1386         }
 1387 
 1388         [MonoTODO (MetafileEnumeration)]
 1389         public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
 1390         {
 1391             throw new NotImplementedException ();
 1392         }
 1393 
 1394         [MonoTODO (MetafileEnumeration)]
 1395         public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, EnumerateMetafileProc callback, IntPtr callbackData)
 1396         {
 1397             throw new NotImplementedException ();
 1398         }
 1399 
 1400         [MonoTODO (MetafileEnumeration)]
 1401         public void EnumerateMetafile (Metafile metafile, Point [] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
 1402         {
 1403             throw new NotImplementedException ();
 1404         }
 1405 
 1406         [MonoTODO (MetafileEnumeration)]
 1407         public void EnumerateMetafile (Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
 1408         {
 1409             throw new NotImplementedException ();
 1410         }
 1411 
 1412         [MonoTODO (MetafileEnumeration)]
 1413         public void EnumerateMetafile (Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
 1414         {
 1415             throw new NotImplementedException ();
 1416         }
 1417 
 1418         [MonoTODO (MetafileEnumeration)]
 1419         public void EnumerateMetafile (Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
 1420         {
 1421             throw new NotImplementedException ();
 1422         }
 1423 
 1424         [MonoTODO (MetafileEnumeration)]
 1425         public void EnumerateMetafile (Metafile metafile, PointF [] destPoints, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
 1426         {
 1427             throw new NotImplementedException ();
 1428         }
 1429 
 1430         [MonoTODO (MetafileEnumeration)]
 1431         public void EnumerateMetafile (Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
 1432         {
 1433             throw new NotImplementedException ();
 1434         }
 1435     
 1436         public void ExcludeClip (Rectangle rect)
 1437         {
 1438             Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Exclude);
 1439             GDIPlus.CheckStatus (status);
 1440         }
 1441 
 1442         public void ExcludeClip (Region region)
 1443         {
 1444             if (region == null)
 1445                 throw new ArgumentNullException ("region");
 1446             Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Exclude);
 1447             GDIPlus.CheckStatus (status);
 1448         }
 1449 
 1450         
 1451         public void FillClosedCurve (Brush brush, PointF [] points)
 1452         {
 1453             if (brush == null)
 1454                 throw new ArgumentNullException ("brush");
 1455             if (points == null)
 1456                 throw new ArgumentNullException ("points");
 1457             Status status = GDIPlus.GdipFillClosedCurve (nativeObject, brush.NativeBrush, points, points.Length);
 1458             GDIPlus.CheckStatus (status);
 1459         }
 1460         
 1461         public void FillClosedCurve (Brush brush, Point [] points)
 1462         {
 1463             if (brush == null)
 1464                 throw new ArgumentNullException ("brush");
 1465             if (points == null)
 1466                 throw new ArgumentNullException ("points");
 1467             Status status = GDIPlus.GdipFillClosedCurveI (nativeObject, brush.NativeBrush, points, points.Length);
 1468             GDIPlus.CheckStatus (status);
 1469         }
 1470 
 1471         
 1472         public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode)
 1473         {
 1474             if (brush == null)
 1475                 throw new ArgumentNullException ("brush");
 1476             if (points == null)
 1477                 throw new ArgumentNullException ("points");
 1478             FillClosedCurve (brush, points, fillmode, 0.5f);
 1479         }
 1480         
 1481         public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode)
 1482         {
 1483             if (brush == null)
 1484                 throw new ArgumentNullException ("brush");
 1485             if (points == null)
 1486                 throw new ArgumentNullException ("points");
 1487             FillClosedCurve (brush, points, fillmode, 0.5f);
 1488         }
 1489 
 1490         public void FillClosedCurve (Brush brush, PointF [] points, FillMode fillmode, float tension)
 1491         {
 1492             if (brush == null)
 1493                 throw new ArgumentNullException ("brush");
 1494             if (points == null)
 1495                 throw new ArgumentNullException ("points");
 1496             Status status = GDIPlus.GdipFillClosedCurve2 (nativeObject, brush.NativeBrush, points, points.Length, tension, fillmode);
 1497             GDIPlus.CheckStatus (status);
 1498         }
 1499 
 1500         public void FillClosedCurve (Brush brush, Point [] points, FillMode fillmode, float tension)
 1501         {
 1502             if (brush == null)
 1503                 throw new ArgumentNullException ("brush");
 1504             if (points == null)
 1505                 throw new ArgumentNullException ("points");
 1506             Status status = GDIPlus.GdipFillClosedCurve2I (nativeObject, brush.NativeBrush, points, points.Length, tension, fillmode);
 1507             GDIPlus.CheckStatus (status);
 1508         }
 1509 
 1510         public void FillEllipse (Brush brush, Rectangle rect)
 1511         {
 1512             if (brush == null)
 1513                 throw new ArgumentNullException ("brush");
 1514             FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
 1515         }
 1516 
 1517         public void FillEllipse (Brush brush, RectangleF rect)
 1518         {
 1519             if (brush == null)
 1520                 throw new ArgumentNullException ("brush");
 1521             FillEllipse (brush, rect.X, rect.Y, rect.Width, rect.Height);
 1522         }
 1523 
 1524         public void FillEllipse (Brush brush, float x, float y, float width, float height)
 1525         {
 1526             if (brush == null)
 1527                 throw new ArgumentNullException ("brush");
 1528                         Status status = GDIPlus.GdipFillEllipse (nativeObject, brush.NativeBrush, x, y, width, height);
 1529             GDIPlus.CheckStatus (status);
 1530         }
 1531 
 1532         public void FillEllipse (Brush brush, int x, int y, int width, int height)
 1533         {
 1534             if (brush == null)
 1535                 throw new ArgumentNullException ("brush");
 1536             Status status = GDIPlus.GdipFillEllipseI (nativeObject, brush.NativeBrush, x, y, width, height);
 1537             GDIPlus.CheckStatus (status);
 1538         }
 1539 
 1540         public void FillPath (Brush brush, GraphicsPath path)
 1541         {
 1542             if (brush == null)
 1543                 throw new ArgumentNullException ("brush");
 1544             if (path == null)
 1545                 throw new ArgumentNullException ("path");
 1546             Status status = GDIPlus.GdipFillPath (nativeObject, brush.NativeBrush,  path.nativePath);
 1547             GDIPlus.CheckStatus (status);
 1548         }
 1549 
 1550         public void FillPie (Brush brush, Rectangle rect, float startAngle, float sweepAngle)
 1551         {
 1552             if (brush == null)
 1553                 throw new ArgumentNullException ("brush");
 1554             Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeBrush, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
 1555             GDIPlus.CheckStatus (status);
 1556         }
 1557 
 1558         public void FillPie (Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle)
 1559         {
 1560             if (brush == null)
 1561                 throw new ArgumentNullException ("brush");
 1562             Status status = GDIPlus.GdipFillPieI (nativeObject, brush.NativeBrush, x, y, width, height, startAngle, sweepAngle);
 1563             GDIPlus.CheckStatus (status);
 1564         }
 1565 
 1566         public void FillPie (Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
 1567         {
 1568             if (brush == null)
 1569                 throw new ArgumentNullException ("brush");
 1570             Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeBrush, x, y, width, height, startAngle, sweepAngle);
 1571             GDIPlus.CheckStatus (status);
 1572         }
 1573 
 1574         public void FillPolygon (Brush brush, PointF [] points)
 1575         {
 1576             if (brush == null)
 1577                 throw new ArgumentNullException ("brush");
 1578             if (points == null)
 1579                 throw new ArgumentNullException ("points");
 1580             Status status = GDIPlus.GdipFillPolygon2 (nativeObject, brush.NativeBrush, points, points.Length);
 1581             GDIPlus.CheckStatus (status);
 1582         }
 1583 
 1584         public void FillPolygon (Brush brush, Point [] points)
 1585         {
 1586             if (brush == null)
 1587                 throw new ArgumentNullException ("brush");
 1588             if (points == null)
 1589                 throw new ArgumentNullException ("points");
 1590             Status status = GDIPlus.GdipFillPolygon2I (nativeObject, brush.NativeBrush, points, points.Length);
 1591             GDIPlus.CheckStatus (status);
 1592         }
 1593 
 1594         public void FillPolygon (Brush brush, Point [] points, FillMode fillMode)
 1595         {
 1596             if (brush == null)
 1597                 throw new ArgumentNullException ("brush");
 1598             if (points == null)
 1599                 throw new ArgumentNullException ("points");
 1600             Status status = GDIPlus.GdipFillPolygonI (nativeObject, brush.NativeBrush, points, points.Length, fillMode);
 1601             GDIPlus.CheckStatus (status);
 1602         }
 1603 
 1604         public void FillPolygon (Brush brush, PointF [] points, FillMode fillMode)
 1605         {
 1606             if (brush == null)
 1607                 throw new ArgumentNullException ("brush");
 1608             if (points == null)
 1609                 throw new ArgumentNullException ("points");
 1610             Status status = GDIPlus.GdipFillPolygon (nativeObject, brush.NativeBrush, points, points.Length, fillMode);
 1611             GDIPlus.CheckStatus (status);
 1612         }
 1613 
 1614         public void FillRectangle (Brush brush, RectangleF rect)
 1615         {
 1616             if (brush == null)
 1617                 throw new ArgumentNullException ("brush");
 1618                         FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
 1619         }
 1620 
 1621         public void FillRectangle (Brush brush, Rectangle rect)
 1622         {
 1623             if (brush == null)
 1624                 throw new ArgumentNullException ("brush");
 1625             if (rect == null)
 1626                 throw new ArgumentNullException ("rect");
 1627                 
 1628                         FillRectangle (brush, rect.Left, rect.Top, rect.Width, rect.Height);
 1629         }
 1630 
 1631         public void FillRectangle (Brush brush, int x, int y, int width, int height)
 1632         {
 1633             if (brush == null)
 1634                 throw new ArgumentNullException ("brush");
 1635             
 1636             Status status = GDIPlus.GdipFillRectangleI (nativeObject, brush.NativeBrush, x, y, width, height);
 1637             GDIPlus.CheckStatus (status);
 1638         }
 1639 
 1640         public void FillRectangle (Brush brush, float x, float y, float width, float height)
 1641         {
 1642             if (brush == null)
 1643                 throw new ArgumentNullException ("brush");
 1644             
 1645             Status status = GDIPlus.GdipFillRectangle (nativeObject, brush.NativeBrush, x, y, width, height);
 1646             GDIPlus.CheckStatus (status);
 1647         }
 1648 
 1649         public void FillRectangles (Brush brush, Rectangle [] rects)
 1650         {
 1651             if (brush == null)
 1652                 throw new ArgumentNullException ("brush");
 1653             if (rects == null)
 1654                 throw new ArgumentNullException ("rects");
 1655 
 1656             Status status = GDIPlus.GdipFillRectanglesI (nativeObject, brush.NativeBrush, rects, rects.Length);
 1657             GDIPlus.CheckStatus (status);
 1658         }
 1659 
 1660         public void FillRectangles (Brush brush, RectangleF [] rects)
 1661         {
 1662             if (brush == null)
 1663                 throw new ArgumentNullException ("brush");
 1664             if (rects == null)
 1665                 throw new ArgumentNullException ("rects");
 1666 
 1667             Status status = GDIPlus.GdipFillRectangles (nativeObject, brush.NativeBrush, rects, rects.Length);
 1668             GDIPlus.CheckStatus (status);
 1669         }
 1670 
 1671         
 1672         public void FillRegion (Brush brush, Region region)
 1673         {
 1674             if (brush == null)
 1675                 throw new ArgumentNullException ("brush");
 1676             if (region == null)
 1677                 throw new ArgumentNullException ("region");
 1678             
 1679             Status status = GDIPlus.GdipFillRegion (nativeObject, brush.NativeBrush, region.NativeObject);                  
 1680                         GDIPlus.CheckStatus(status);
 1681         }
 1682 
 1683         
 1684         public void Flush ()
 1685         {
 1686             Flush (FlushIntention.Flush);
 1687         }
 1688 
 1689         
 1690         public void Flush (FlushIntention intention)
 1691         {
 1692             if (nativeObject == IntPtr.Zero) {
 1693                 return;
 1694             }
 1695 
 1696             Status status = GDIPlus.GdipFlush (nativeObject, intention);
 1697                         GDIPlus.CheckStatus (status);                    
 1698 
 1699             if (maccontext != null)
 1700                 maccontext.Synchronize ();
 1701         }
 1702 
 1703         [EditorBrowsable (EditorBrowsableState.Advanced)]       
 1704         public static Graphics FromHdc (IntPtr hdc)
 1705         {
 1706             IntPtr graphics;
 1707             Status status = GDIPlus.GdipCreateFromHDC (hdc, out graphics);
 1708             GDIPlus.CheckStatus (status);
 1709             return new Graphics (graphics);
 1710         }
 1711 
 1712         [MonoTODO]
 1713         [EditorBrowsable (EditorBrowsableState.Advanced)]
 1714         public static Graphics FromHdc (IntPtr hdc, IntPtr hdevice)
 1715         {
 1716             throw new NotImplementedException ();
 1717         }
 1718 
 1719         [EditorBrowsable (EditorBrowsableState.Advanced)]
 1720         public static Graphics FromHdcInternal (IntPtr hdc)
 1721         {
 1722             GDIPlus.Display = hdc;
 1723             return null;
 1724         }
 1725 
 1726         [EditorBrowsable (EditorBrowsableState.Advanced)]       
 1727         public static Graphics FromHwnd (IntPtr hwnd)
 1728         {
 1729             IntPtr graphics;
 1730 
 1731             if (GDIPlus.UseCocoaDrawable) {
 1732                 if (hwnd == IntPtr.Zero) {
 1733                     throw new NotSupportedException ("Opening display graphics is not supported");
 1734                 }
 1735 
 1736                 CocoaContext context = MacSupport.GetCGContextForNSView (hwnd);
 1737                 GDIPlus.GdipCreateFromContext_macosx (context.ctx, context.width, context.height, out graphics);
 1738 
 1739                 Graphics g = new Graphics (graphics);
 1740                 g.maccontext = context;
 1741 
 1742                 return g;
 1743             }
 1744 
 1745             if (GDIPlus.UseCarbonDrawable) {
 1746                 CarbonContext context = MacSupport.GetCGContextForView (hwnd);
 1747                 GDIPlus.GdipCreateFromContext_macosx (context.ctx, context.width, context.height, out graphics);
 1748                 
 1749                 Graphics g = new Graphics (graphics);
 1750                 g.maccontext = context;
 1751                 
 1752                 return g;
 1753             }
 1754             if (GDIPlus.UseX11Drawable) {
 1755                 if (GDIPlus.Display == IntPtr.Zero) {
 1756                     GDIPlus.Display = GDIPlus.XOpenDisplay (IntPtr.Zero);
 1757                     if (GDIPlus.Display == IntPtr.Zero)
 1758                         throw new NotSupportedException ("Could not open display (X-Server required. Check your DISPLAY environment variable)");
 1759                 }
 1760                 if (hwnd == IntPtr.Zero) {
 1761                     hwnd = GDIPlus.XRootWindow (GDIPlus.Display, GDIPlus.XDefaultScreen (GDIPlus.Display));
 1762                 }
 1763 
 1764                 return FromXDrawable (hwnd, GDIPlus.Display);
 1765 
 1766             }
 1767 
 1768             Status status = GDIPlus.GdipCreateFromHWND (hwnd, out graphics);
 1769             GDIPlus.CheckStatus (status);
 1770 
 1771             return new Graphics (graphics);
 1772         }
 1773         
 1774         [EditorBrowsable (EditorBrowsableState.Advanced)]
 1775         public static Graphics FromHwndInternal (IntPtr hwnd)
 1776         {
 1777             return FromHwnd (hwnd);
 1778         }
 1779 
 1780         public static Graphics FromImage (Image image)
 1781         {
 1782             IntPtr graphics;
 1783 
 1784             if (image == null) 
 1785                 throw new ArgumentNullException ("image");
 1786 
 1787             if ((image.PixelFormat & PixelFormat.Indexed) != 0)
 1788                 throw new Exception (Locale.GetText ("Cannot create Graphics from an indexed bitmap."));
 1789 
 1790             Status status = GDIPlus.GdipGetImageGraphicsContext (image.nativeObject, out graphics);
 1791             GDIPlus.CheckStatus (status);
 1792             Graphics result = new Graphics (graphics, image);
 1793             if (GDIPlus.RunningOnUnix ()) {
 1794                 Rectangle rect  = new Rectangle (0,0, image.Width, image.Height);
 1795                 GDIPlus.GdipSetVisibleClip_linux (result.NativeObject, ref rect);
 1796             }
 1797                 
 1798             return result;
 1799         }
 1800 
 1801         internal static Graphics FromXDrawable (IntPtr drawable, IntPtr display)
 1802         {
 1803             IntPtr graphics;
 1804 
 1805             Status s = GDIPlus.GdipCreateFromXDrawable_linux (drawable, display, out graphics);
 1806             GDIPlus.CheckStatus (s);
 1807             return new Graphics (graphics);
 1808         }
 1809 
 1810         [MonoTODO]
 1811         public static IntPtr GetHalftonePalette ()
 1812         {
 1813             throw new NotImplementedException ();
 1814         }
 1815 
 1816         public IntPtr GetHdc ()
 1817         {
 1818             GDIPlus.CheckStatus (GDIPlus.GdipGetDC (this.nativeObject, out deviceContextHdc));
 1819             return deviceContextHdc;
 1820         }
 1821         
 1822         public Color GetNearestColor (Color color)
 1823         {
 1824             int argb;
 1825             
 1826             Status status = GDIPlus.GdipGetNearestColor (nativeObject, out argb);
 1827             GDIPlus.CheckStatus (status);
 1828 
 1829             return Color.FromArgb (argb);
 1830         }
 1831 
 1832         
 1833         public void IntersectClip (Region region)
 1834         {
 1835             if (region == null)
 1836                 throw new ArgumentNullException ("region");
 1837             Status status = GDIPlus.GdipSetClipRegion (nativeObject, region.NativeObject, CombineMode.Intersect);
 1838             GDIPlus.CheckStatus (status);
 1839         }
 1840         
 1841         public void IntersectClip (RectangleF rect)
 1842         {
 1843             Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
 1844             GDIPlus.CheckStatus (status);
 1845         }
 1846 
 1847         public void IntersectClip (Rectangle rect)
 1848         {           
 1849             Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, CombineMode.Intersect);
 1850             GDIPlus.CheckStatus (status);
 1851         }
 1852 
 1853         public bool IsVisible (Point point)
 1854         {
 1855             bool isVisible = false;
 1856 
 1857             Status status = GDIPlus.GdipIsVisiblePointI (nativeObject, point.X, point.Y, out isVisible);
 1858             GDIPlus.CheckStatus (status);
 1859 
 1860                         return isVisible;
 1861         }
 1862 
 1863         
 1864         public bool IsVisible (RectangleF rect)
 1865         {
 1866             bool isVisible = false;
 1867 
 1868             Status status = GDIPlus.GdipIsVisibleRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
 1869             GDIPlus.CheckStatus (status);
 1870 
 1871                         return isVisible;
 1872         }
 1873 
 1874         public bool IsVisible (PointF point)
 1875         {
 1876             bool isVisible = false;
 1877 
 1878             Status status = GDIPlus.GdipIsVisiblePoint (nativeObject, point.X, point.Y, out isVisible);
 1879             GDIPlus.CheckStatus (status);
 1880 
 1881                         return isVisible;
 1882         }
 1883         
 1884         public bool IsVisible (Rectangle rect)
 1885         {
 1886             bool isVisible = false;
 1887 
 1888             Status status = GDIPlus.GdipIsVisibleRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, out isVisible);
 1889             GDIPlus.CheckStatus (status);
 1890 
 1891                         return isVisible;
 1892         }
 1893         
 1894         public bool IsVisible (float x, float y)
 1895         {
 1896             return IsVisible (new PointF (x, y));
 1897         }
 1898         
 1899         public bool IsVisible (int x, int y)
 1900         {
 1901             return IsVisible (new Point (x, y));
 1902         }
 1903         
 1904         public bool IsVisible (float x, float y, float width, float height)
 1905         {
 1906             return IsVisible (new RectangleF (x, y, width, height));
 1907         }
 1908 
 1909         
 1910         public bool IsVisible (int x, int y, int width, int height)
 1911         {
 1912             return IsVisible (new Rectangle (x, y, width, height));
 1913         }
 1914 
 1915         
 1916         public Region[] MeasureCharacterRanges (string text, Font font, RectangleF layoutRect, StringFormat stringFormat)
 1917         {
 1918             if ((text == null) || (text.Length == 0))
 1919                 return new Region [0];
 1920 
 1921             if (font == null)
 1922                 throw new ArgumentNullException ("font");
 1923 
 1924             if (stringFormat == null)
 1925                 throw new ArgumentException ("stringFormat");
 1926 
 1927             int regcount = stringFormat.GetMeasurableCharacterRangeCount ();
 1928             if (regcount == 0)
 1929                 return new Region[0];
 1930 
 1931             IntPtr[] native_regions = new IntPtr [regcount];
 1932             Region[] regions = new Region [regcount];
 1933             
 1934             for (int i = 0; i < regcount; i++) {
 1935                 regions[i] = new Region ();
 1936                 native_regions[i] = regions[i].NativeObject;
 1937             }
 1938             
 1939             Status status = GDIPlus.GdipMeasureCharacterRanges (nativeObject, text, text.Length,
 1940                 font.NativeObject, ref layoutRect, stringFormat.NativeObject, regcount, out native_regions[0]); 
 1941             GDIPlus.CheckStatus (status);               
 1942 
 1943             return regions;                         
 1944         }
 1945 
 1946         private unsafe SizeF GdipMeasureString (IntPtr graphics, string text, Font font, ref RectangleF layoutRect,
 1947             IntPtr stringFormat)
 1948         {
 1949             if ((text == null) || (text.Length == 0))
 1950                 return SizeF.Empty;
 1951 
 1952             if (font == null)
 1953                 throw new ArgumentNullException ("font");
 1954 
 1955             RectangleF boundingBox = new RectangleF ();
 1956 
 1957             Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length, font.NativeObject, 
 1958                 ref layoutRect, stringFormat, out boundingBox, null, null);
 1959             GDIPlus.CheckStatus (status);
 1960 
 1961             return new SizeF (boundingBox.Width, boundingBox.Height);
 1962         }
 1963 
 1964         public SizeF MeasureString (string text, Font font)
 1965         {
 1966             return MeasureString (text, font, SizeF.Empty);
 1967         }
 1968 
 1969         public SizeF MeasureString (string text, Font font, SizeF layoutArea)
 1970         {
 1971             RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
 1972             return GdipMeasureString (nativeObject, text, font, ref rect, IntPtr.Zero);
 1973         }
 1974 
 1975         public SizeF MeasureString (string text, Font font, int width)
 1976         {               
 1977             RectangleF rect = new RectangleF (0, 0, width, Int32.MaxValue);
 1978             return GdipMeasureString (nativeObject, text, font, ref rect, IntPtr.Zero);
 1979         }
 1980 
 1981         public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat stringFormat)
 1982         {
 1983             RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
 1984             IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
 1985             return GdipMeasureString (nativeObject, text, font, ref rect, format);
 1986         }
 1987 
 1988         public SizeF MeasureString (string text, Font font, int width, StringFormat format)
 1989         {
 1990             RectangleF rect = new RectangleF (0, 0, width, Int32.MaxValue);
 1991             IntPtr stringFormat = (format == null) ? IntPtr.Zero : format.NativeObject;
 1992             return GdipMeasureString (nativeObject, text, font, ref rect, stringFormat);
 1993         }
 1994 
 1995         public SizeF MeasureString (string text, Font font, PointF origin, StringFormat stringFormat)
 1996         {
 1997             RectangleF rect = new RectangleF (origin.X, origin.Y, 0, 0);
 1998             IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
 1999             return GdipMeasureString (nativeObject, text, font, ref rect, format);
 2000         }
 2001 
 2002         public SizeF MeasureString (string text, Font font, SizeF layoutArea, StringFormat stringFormat, 
 2003             out int charactersFitted, out int linesFilled)
 2004         {   
 2005             charactersFitted = 0;
 2006             linesFilled = 0;
 2007 
 2008             if ((text == null) || (text.Length == 0))
 2009                 return SizeF.Empty;
 2010 
 2011             if (font == null)
 2012                 throw new ArgumentNullException ("font");
 2013 
 2014             RectangleF boundingBox = new RectangleF ();
 2015             RectangleF rect = new RectangleF (0, 0, layoutArea.Width, layoutArea.Height);
 2016 
 2017             IntPtr format = (stringFormat == null) ? IntPtr.Zero : stringFormat.NativeObject;
 2018 
 2019             unsafe {
 2020                 fixed (int* pc = &charactersFitted, pl = &linesFilled) {
 2021                     Status status = GDIPlus.GdipMeasureString (nativeObject, text, text.Length, 
 2022                     font.NativeObject, ref rect, format, out boundingBox, pc, pl);
 2023                     GDIPlus.CheckStatus (status);
 2024                 }
 2025             }
 2026             return new SizeF (boundingBox.Width, boundingBox.Height);
 2027         }
 2028 
 2029         public void MultiplyTransform (Matrix matrix)
 2030         {
 2031             MultiplyTransform (matrix, MatrixOrder.Prepend);
 2032         }
 2033 
 2034         public void MultiplyTransform (Matrix matrix, MatrixOrder order)
 2035         {
 2036             if (matrix == null)
 2037                 throw new ArgumentNullException ("matrix");
 2038 
 2039             Status status = GDIPlus.GdipMultiplyWorldTransform (nativeObject, matrix.nativeMatrix, order);
 2040             GDIPlus.CheckStatus (status);
 2041         }
 2042 
 2043         [EditorBrowsable (EditorBrowsableState.Advanced)]
 2044         public void ReleaseHdc (IntPtr hdc)
 2045         {
 2046             ReleaseHdcInternal (hdc);
 2047         }
 2048 
 2049         public void ReleaseHdc ()
 2050         {
 2051             ReleaseHdcInternal (deviceContextHdc);
 2052         }
 2053 
 2054         [MonoLimitation ("Can only be used when hdc was provided by Graphics.GetHdc() method")]
 2055         [EditorBrowsable (EditorBrowsableState.Never)]
 2056         public void ReleaseHdcInternal (IntPtr hdc)
 2057         {
 2058             Status status = Status.InvalidParameter;
 2059             if (hdc == deviceContextHdc) {
 2060                 status = GDIPlus.GdipReleaseDC (nativeObject, deviceContextHdc);
 2061                 deviceContextHdc = IntPtr.Zero;
 2062             }
 2063             GDIPlus.CheckStatus (status);
 2064         }
 2065         
 2066         public void ResetClip ()
 2067         {
 2068             Status status = GDIPlus.GdipResetClip (nativeObject);
 2069             GDIPlus.CheckStatus (status);
 2070         }
 2071 
 2072         public void ResetTransform ()
 2073         {
 2074             Status status = GDIPlus.GdipResetWorldTransform (nativeObject);
 2075             GDIPlus.CheckStatus (status);
 2076         }
 2077 
 2078         public void Restore (GraphicsState gstate)
 2079         {           
 2080             // the possible NRE thrown by gstate.nativeState match MS behaviour
 2081             Status status = GDIPlus.GdipRestoreGraphics (nativeObject, (uint)gstate.nativeState);
 2082             GDIPlus.CheckStatus (status);
 2083         }
 2084 
 2085         public void RotateTransform (float angle)
 2086         {
 2087             RotateTransform (angle, MatrixOrder.Prepend);
 2088         }
 2089 
 2090         public void RotateTransform (float angle, MatrixOrder order)
 2091         {
 2092             Status status = GDIPlus.GdipRotateWorldTransform (nativeObject, angle, order);
 2093             GDIPlus.CheckStatus (status);
 2094         }
 2095 
 2096         public GraphicsState Save ()
 2097         {                       
 2098             uint saveState;
 2099             Status status = GDIPlus.GdipSaveGraphics (nativeObject, out saveState);
 2100             GDIPlus.CheckStatus (status);
 2101 
 2102             GraphicsState state = new GraphicsState ((int)saveState);
 2103             return state;
 2104         }
 2105 
 2106         public void ScaleTransform (float sx, float sy)
 2107         {
 2108             ScaleTransform (sx, sy, MatrixOrder.Prepend);
 2109         }
 2110 
 2111         public void ScaleTransform (float sx, float sy, MatrixOrder order)
 2112         {
 2113                         Status status = GDIPlus.GdipScaleWorldTransform (nativeObject, sx, sy, order);
 2114             GDIPlus.CheckStatus (status);
 2115         }
 2116 
 2117         
 2118         public void SetClip (RectangleF rect)
 2119         {
 2120                         SetClip (rect, CombineMode.Replace);
 2121         }
 2122 
 2123         
 2124         public void SetClip (GraphicsPath path)
 2125         {
 2126             SetClip (path, CombineMode.Replace);
 2127         }
 2128 
 2129         
 2130         public void SetClip (Rectangle rect)
 2131         {
 2132             SetClip (rect, CombineMode.Replace);
 2133         }
 2134 
 2135         
 2136         public void SetClip (Graphics g)
 2137         {
 2138             SetClip (g, CombineMode.Replace);
 2139         }
 2140 
 2141         
 2142         public void SetClip (Graphics g, CombineMode combineMode)
 2143         {
 2144             if (g == null)
 2145                 throw new ArgumentNullException ("g");
 2146             
 2147             Status status = GDIPlus.GdipSetClipGraphics (nativeObject, g.NativeObject, combineMode);
 2148             GDIPlus.CheckStatus (status);
 2149         }
 2150 
 2151         
 2152         public void SetClip (Rectangle rect, CombineMode combineMode)
 2153         {
 2154             Status status = GDIPlus.GdipSetClipRectI (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
 2155             GDIPlus.CheckStatus (status);
 2156         }
 2157 
 2158         
 2159         public void SetClip (RectangleF rect, CombineMode combineMode)
 2160         {
 2161             Status status = GDIPlus.GdipSetClipRect (nativeObject, rect.X, rect.Y, rect.Width, rect.Height, combineMode);
 2162             GDIPlus.CheckStatus (status);
 2163         }
 2164 
 2165         
 2166         public void SetClip (Region region, CombineMode combineMode)
 2167         {
 2168             if (region == null)
 2169                 throw new ArgumentNullException ("region");
 2170             Status status =   GDIPlus.GdipSetClipRegion(nativeObject,  region.NativeObject, combineMode); 
 2171             GDIPlus.CheckStatus (status);
 2172         }
 2173 
 2174         
 2175         public void SetClip (GraphicsPath path, CombineMode combineMode)
 2176         {
 2177             if (path == null)
 2178                 throw new ArgumentNullException ("path");
 2179             Status status = GDIPlus.GdipSetClipPath (nativeObject, path.nativePath, combineMode);
 2180             GDIPlus.CheckStatus (status);
 2181         }
 2182 
 2183         
 2184         public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF [] pts)
 2185         {
 2186             if (pts == null)
 2187                 throw new ArgumentNullException ("pts");
 2188 
 2189             IntPtr ptrPt =  GDIPlus.FromPointToUnManagedMemory (pts);
 2190             
 2191                         Status status = GDIPlus.GdipTransformPoints (nativeObject, destSpace, srcSpace,  ptrPt, pts.Length);
 2192             GDIPlus.CheckStatus (status);
 2193             
 2194             GDIPlus.FromUnManagedMemoryToPoint (ptrPt, pts);
 2195         }
 2196 
 2197 
 2198         public void TransformPoints (CoordinateSpace destSpace, CoordinateSpace srcSpace, Point [] pts)
 2199         {                       
 2200             if (pts == null)
 2201                 throw new ArgumentNullException ("pts");
 2202                         IntPtr ptrPt =  GDIPlus.FromPointToUnManagedMemoryI (pts);
 2203             
 2204                         Status status = GDIPlus.GdipTransformPointsI (nativeObject, destSpace, srcSpace, ptrPt, pts.Length);
 2205             GDIPlus.CheckStatus (status);
 2206             
 2207             GDIPlus.FromUnManagedMemoryToPointI (ptrPt, pts);
 2208         }
 2209 
 2210         
 2211         public void TranslateClip (int dx, int dy)
 2212         {
 2213             Status status = GDIPlus.GdipTranslateClipI (nativeObject, dx, dy);
 2214             GDIPlus.CheckStatus (status);
 2215         }
 2216 
 2217         
 2218         public void TranslateClip (float dx, float dy)
 2219         {
 2220             Status status = GDIPlus.GdipTranslateClip (nativeObject, dx, dy);
 2221             GDIPlus.CheckStatus (status);
 2222         }
 2223 
 2224         public void TranslateTransform (float dx, float dy)
 2225         {
 2226             TranslateTransform (dx, dy, MatrixOrder.Prepend);
 2227         }
 2228 
 2229         
 2230         public void TranslateTransform (float dx, float dy, MatrixOrder order)
 2231         {           
 2232             Status status = GDIPlus.GdipTranslateWorldTransform (nativeObject, dx, dy, order);
 2233             GDIPlus.CheckStatus (status);
 2234         }
 2235 
 2236         public Region Clip {
 2237             get {
 2238                 Region reg = new Region();
 2239                 Status status = GDIPlus.GdipGetClip (nativeObject, reg.NativeObject);
 2240                 GDIPlus.CheckStatus (status);
 2241                 return reg;             
 2242             }
 2243             set {
 2244                 SetClip (value, CombineMode.Replace);
 2245             }
 2246         }
 2247 
 2248         public RectangleF ClipBounds {
 2249             get {
 2250                                 RectangleF rect = new RectangleF ();
 2251                                 Status status = GDIPlus.GdipGetClipBounds (nativeObject, out rect);
 2252                 GDIPlus.CheckStatus (status);
 2253                 return rect;
 2254             }
 2255         }
 2256 
 2257         public CompositingMode CompositingMode {
 2258             get {
 2259                                 CompositingMode mode;
 2260                                 Status status = GDIPlus.GdipGetCompositingMode (nativeObject, out mode);
 2261                 GDIPlus.CheckStatus (status);
 2262 
 2263                 return mode;
 2264             }
 2265             set {
 2266                                 Status status = GDIPlus.GdipSetCompositingMode (nativeObject, value);
 2267                 GDIPlus.CheckStatus (status);
 2268             }
 2269 
 2270         }
 2271 
 2272         public CompositingQuality CompositingQuality {
 2273             get {
 2274                                 CompositingQuality quality;
 2275 
 2276                                 Status status = GDIPlus.GdipGetCompositingQuality (nativeObject, out quality);
 2277                 GDIPlus.CheckStatus (status);
 2278                     return quality;
 2279             }
 2280             set {
 2281                                 Status status = GDIPlus.GdipSetCompositingQuality (nativeObject, value);
 2282                 GDIPlus.CheckStatus (status);
 2283             }
 2284         }
 2285 
 2286         public float DpiX {
 2287             get {
 2288                                 float x;
 2289 
 2290                     Status status = GDIPlus.GdipGetDpiX (nativeObject, out x);
 2291                 GDIPlus.CheckStatus (status);
 2292                     return x;
 2293             }
 2294         }
 2295 
 2296         public float DpiY {
 2297             get {
 2298                                 float y;
 2299 
 2300                     Status status = GDIPlus.GdipGetDpiY (nativeObject, out y);
 2301                 GDIPlus.CheckStatus (status);
 2302                     return y;
 2303             }
 2304         }
 2305 
 2306         public InterpolationMode InterpolationMode {
 2307             get {               
 2308                                 InterpolationMode imode = InterpolationMode.Invalid;
 2309                     Status status = GDIPlus.GdipGetInterpolationMode (nativeObject, out imode);
 2310                 GDIPlus.CheckStatus (status);
 2311                     return imode;
 2312             }
 2313             set {
 2314                                 Status status = GDIPlus.GdipSetInterpolationMode (nativeObject, value);
 2315                 GDIPlus.CheckStatus (status);
 2316             }
 2317         }
 2318 
 2319         public bool IsClipEmpty {
 2320             get {
 2321                                 bool isEmpty = false;
 2322 
 2323                     Status status = GDIPlus.GdipIsClipEmpty (nativeObject, out isEmpty);
 2324                 GDIPlus.CheckStatus (status);
 2325                     return isEmpty;
 2326             }
 2327         }
 2328 
 2329         public bool IsVisibleClipEmpty {
 2330             get {
 2331                                 bool isEmpty = false;
 2332 
 2333                     Status status = GDIPlus.GdipIsVisibleClipEmpty (nativeObject, out isEmpty);
 2334                 GDIPlus.CheckStatus (status);
 2335                     return isEmpty;
 2336             }
 2337         }
 2338 
 2339         public float PageScale {
 2340             get {
 2341                                 float scale;
 2342 
 2343                     Status status = GDIPlus.GdipGetPageScale (nativeObject, out scale);
 2344                 GDIPlus.CheckStatus (status);
 2345                     return scale;
 2346             }
 2347             set {
 2348                                 Status status = GDIPlus.GdipSetPageScale (nativeObject, value);
 2349                 GDIPlus.CheckStatus (status);
 2350             }
 2351         }
 2352 
 2353         public GraphicsUnit PageUnit {
 2354             get {
 2355                                 GraphicsUnit unit;
 2356                                 
 2357                                 Status status = GDIPlus.GdipGetPageUnit (nativeObject, out unit);
 2358                 GDIPlus.CheckStatus (status);
 2359                     return unit;
 2360             }
 2361             set {
 2362                                 Status status = GDIPlus.GdipSetPageUnit (nativeObject, value);
 2363                 GDIPlus.CheckStatus (status);
 2364             }
 2365         }
 2366 
 2367         [MonoTODO ("This property does not do anything when used with libgdiplus.")]
 2368         public PixelOffsetMode PixelOffsetMode {
 2369             get {
 2370                     PixelOffsetMode pixelOffset = PixelOffsetMode.Invalid;
 2371                                 
 2372                                 Status status = GDIPlus.GdipGetPixelOffsetMode (nativeObject, out pixelOffset);
 2373                 GDIPlus.CheckStatus (status);
 2374                     return pixelOffset;
 2375             }
 2376             set {
 2377                                 Status status = GDIPlus.GdipSetPixelOffsetMode (nativeObject, value); 
 2378                 GDIPlus.CheckStatus (status);
 2379             }
 2380         }
 2381 
 2382         public Point RenderingOrigin {
 2383             get {
 2384                                 int x, y;
 2385                 Status status = GDIPlus.GdipGetRenderingOrigin (nativeObject, out x, out y);
 2386                 GDIPlus.CheckStatus (status);
 2387                                 return new Point (x, y);
 2388             }
 2389 
 2390             set {
 2391                                 Status status = GDIPlus.GdipSetRenderingOrigin (nativeObject, value.X, value.Y);
 2392                 GDIPlus.CheckStatus (status);
 2393             }
 2394         }
 2395 
 2396         public SmoothingMode SmoothingMode {
 2397             get {
 2398                                 SmoothingMode mode = SmoothingMode.Invalid;
 2399 
 2400                 Status status = GDIPlus.GdipGetSmoothingMode (nativeObject, out mode);
 2401                 GDIPlus.CheckStatus (status);
 2402                                 return mode;
 2403             }
 2404 
 2405             set {
 2406                                 Status status = GDIPlus.GdipSetSmoothingMode (nativeObject, value);
 2407                 GDIPlus.CheckStatus (status);
 2408             }
 2409         }
 2410 
 2411         [MonoTODO ("This property does not do anything when used with libgdiplus.")]
 2412         public int TextContrast {
 2413             get {   
 2414                                 int contrast;
 2415                     
 2416                                 Status status = GDIPlus.GdipGetTextContrast (nativeObject, out contrast);
 2417                 GDIPlus.CheckStatus (status);
 2418                                 return contrast;
 2419             }
 2420 
 2421                         set {
 2422                                 Status status = GDIPlus.GdipSetTextContrast (nativeObject, value);
 2423                 GDIPlus.CheckStatus (status);
 2424             }
 2425         }
 2426 
 2427         public TextRenderingHint TextRenderingHint {
 2428             get {
 2429                                 TextRenderingHint hint;
 2430 
 2431                                 Status status = GDIPlus.GdipGetTextRenderingHint (nativeObject, out hint);
 2432                 GDIPlus.CheckStatus (status);
 2433                                 return hint;        
 2434             }
 2435 
 2436             set {
 2437                                 Status status = GDIPlus.GdipSetTextRenderingHint (nativeObject, value);
 2438                 GDIPlus.CheckStatus (status);
 2439             }
 2440         }
 2441 
 2442         public Matrix Transform {
 2443             get {
 2444                                 Matrix matrix = new Matrix ();
 2445                                 Status status = GDIPlus.GdipGetWorldTransform (nativeObject, matrix.nativeMatrix);
 2446                 GDIPlus.CheckStatus (status);
 2447                                 return matrix;
 2448             }
 2449             set {
 2450                 if (value == null)
 2451                     throw new ArgumentNullException ("value");
 2452                 
 2453                                 Status status = GDIPlus.GdipSetWorldTransform (nativeObject, value.nativeMatrix);
 2454                 GDIPlus.CheckStatus (status);
 2455             }
 2456         }
 2457 
 2458         public RectangleF VisibleClipBounds {
 2459             get {
 2460                                 RectangleF rect;
 2461                     
 2462                                 Status status = GDIPlus.GdipGetVisibleClipBounds (nativeObject, out rect);
 2463                 GDIPlus.CheckStatus (status);
 2464                                 return rect;
 2465             }
 2466         }
 2467 
 2468         [MonoTODO]
 2469         [EditorBrowsable (EditorBrowsableState.Never)]
 2470         public object GetContextInfo ()
 2471         {
 2472             // only known source of information @ http://blogs.wdevs.com/jdunlap/Default.aspx
 2473             throw new NotImplementedException ();
 2474         }
 2475     }
 2476 }