2 // System.Drawing.Drawing2D.GraphicsPathIterator.cs
5 // Dennis Hayes (dennish@Raytek.com)
6 // Duncan Mak (duncan@ximian.com)
7 // Ravindra (rkumar@novell.com)
9 // Copyright (C) 2002/3 Ximian, Inc (http://www.ximian.com)
11 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
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:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
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.
35 namespace System
.Drawing
.Drawing2D
37 public sealed class GraphicsPathIterator
: MarshalByRefObject
, IDisposable
39 private IntPtr nativeObject
= IntPtr
.Zero
;
42 internal GraphicsPathIterator (IntPtr native
)
44 this.nativeObject
= native
;
47 public GraphicsPathIterator (GraphicsPath path
)
49 Status status
= GDIPlus
.GdipCreatePathIter (out nativeObject
, path
.NativeObject
);
50 GDIPlus
.CheckStatus (status
);
53 internal IntPtr NativeObject
{
67 Status status
= GDIPlus
.GdipPathIterGetCount (nativeObject
, out count
);
68 GDIPlus
.CheckStatus (status
);
74 public int SubpathCount
{
77 Status status
= GDIPlus
.GdipPathIterGetSubpathCount (nativeObject
, out count
);
78 GDIPlus
.CheckStatus (status
);
84 internal void Dispose (bool disposing
)
87 if (nativeObject
!= IntPtr
.Zero
) {
88 status
= GDIPlus
.GdipDeletePathIter (nativeObject
);
89 GDIPlus
.CheckStatus (status
);
91 nativeObject
= IntPtr
.Zero
;
97 public int CopyData (ref PointF
[] points
, ref byte [] types
, int startIndex
, int endIndex
)
102 if (points
.Length
!= types
.Length
)
103 throw new ArgumentException ("Invalid arguments passed. Both arrays should have the same length.");
105 status
= GDIPlus
.GdipPathIterCopyData (nativeObject
, out resultCount
, points
, types
, startIndex
, endIndex
);
106 GDIPlus
.CheckStatus (status
);
111 public void Dispose ()
114 System
.GC
.SuppressFinalize (this);
117 ~
GraphicsPathIterator ()
122 public int Enumerate (ref PointF
[] points
, ref byte [] types
)
126 int count
= points
.Length
;
128 if (count
!= types
.Length
)
129 throw new ArgumentException ("Invalid arguments passed. Both arrays should have the same length.");
131 status
= GDIPlus
.GdipPathIterEnumerate (nativeObject
, out resultCount
, points
, types
, count
);
132 GDIPlus
.CheckStatus (status
);
137 public bool HasCurve ()
140 Status status
= GDIPlus
.GdipPathIterHasCurve (nativeObject
, out curve
);
141 GDIPlus
.CheckStatus (status
);
146 public int NextMarker (GraphicsPath path
)
150 status
= GDIPlus
.GdipPathIterNextMarkerPath (nativeObject
, out resultCount
, path
.NativeObject
);
151 GDIPlus
.CheckStatus (status
);
156 public int NextMarker (out int startIndex
, out int endIndex
)
160 status
= GDIPlus
.GdipPathIterNextMarker (nativeObject
, out resultCount
, out startIndex
, out endIndex
);
161 GDIPlus
.CheckStatus (status
);
166 public int NextPathType (out byte pathType
, out int startIndex
, out int endIndex
)
170 status
= GDIPlus
.GdipPathIterNextPathType (nativeObject
, out resultCount
, out pathType
, out startIndex
, out endIndex
);
171 GDIPlus
.CheckStatus (status
);
176 public int NextSubpath (GraphicsPath path
, out bool isClosed
)
180 status
= GDIPlus
.GdipPathIterNextSubpathPath (nativeObject
, out resultCount
, path
.NativeObject
, out isClosed
);
181 GDIPlus
.CheckStatus (status
);
186 public int NextSubpath (out int startIndex
, out int endIndex
, out bool isClosed
)
190 status
= GDIPlus
.GdipPathIterNextSubpath (nativeObject
, out resultCount
, out startIndex
, out endIndex
, out isClosed
);
191 GDIPlus
.CheckStatus (status
);
196 public void Rewind ()
198 Status status
= GDIPlus
.GdipPathIterRewind (nativeObject
);
199 GDIPlus
.CheckStatus (status
);