(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.Drawing / System.Drawing.Drawing2D / GraphicsPathIterator.cs
blobdbd2f4341dc4fe54ee265bc78659fe7a5572a077
1 //
2 // System.Drawing.Drawing2D.GraphicsPathIterator.cs
3 //
4 // Author:
5 // Dennis Hayes (dennish@Raytek.com)
6 // Duncan Mak (duncan@ximian.com)
7 // Ravindra (rkumar@novell.com)
8 //
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:
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.
32 using System;
33 using System.Drawing;
35 namespace System.Drawing.Drawing2D
37 public sealed class GraphicsPathIterator : MarshalByRefObject, IDisposable
39 private IntPtr nativeObject = IntPtr.Zero;
41 // Constructors
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 {
54 get {
55 return nativeObject;
57 set {
58 nativeObject = value;
62 // Public Properites
64 public int Count {
65 get {
66 int count;
67 Status status = GDIPlus.GdipPathIterGetCount (nativeObject, out count);
68 GDIPlus.CheckStatus (status);
70 return count;
74 public int SubpathCount {
75 get {
76 int count;
77 Status status = GDIPlus.GdipPathIterGetSubpathCount (nativeObject, out count);
78 GDIPlus.CheckStatus (status);
80 return count;
84 internal void Dispose (bool disposing)
86 Status status;
87 if (nativeObject != IntPtr.Zero) {
88 status = GDIPlus.GdipDeletePathIter (nativeObject);
89 GDIPlus.CheckStatus (status);
91 nativeObject = IntPtr.Zero;
95 // Public Methods.
97 public int CopyData (ref PointF [] points, ref byte [] types, int startIndex, int endIndex)
99 Status status;
100 int resultCount;
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);
108 return resultCount;
111 public void Dispose ()
113 Dispose (true);
114 System.GC.SuppressFinalize (this);
117 ~GraphicsPathIterator ()
119 Dispose (false);
122 public int Enumerate (ref PointF [] points, ref byte [] types)
124 Status status;
125 int resultCount;
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);
134 return resultCount;
137 public bool HasCurve ()
139 bool curve;
140 Status status = GDIPlus.GdipPathIterHasCurve (nativeObject, out curve);
141 GDIPlus.CheckStatus (status);
143 return curve;
146 public int NextMarker (GraphicsPath path)
148 Status status;
149 int resultCount;
150 status = GDIPlus.GdipPathIterNextMarkerPath (nativeObject, out resultCount, path.NativeObject);
151 GDIPlus.CheckStatus (status);
153 return resultCount;
156 public int NextMarker (out int startIndex, out int endIndex)
158 Status status;
159 int resultCount;
160 status = GDIPlus.GdipPathIterNextMarker (nativeObject, out resultCount, out startIndex, out endIndex);
161 GDIPlus.CheckStatus (status);
163 return resultCount;
166 public int NextPathType (out byte pathType, out int startIndex, out int endIndex)
168 Status status;
169 int resultCount;
170 status = GDIPlus.GdipPathIterNextPathType (nativeObject, out resultCount, out pathType, out startIndex, out endIndex);
171 GDIPlus.CheckStatus (status);
173 return resultCount;
176 public int NextSubpath (GraphicsPath path, out bool isClosed)
178 Status status;
179 int resultCount;
180 status = GDIPlus.GdipPathIterNextSubpathPath (nativeObject, out resultCount, path.NativeObject, out isClosed);
181 GDIPlus.CheckStatus (status);
183 return resultCount;
186 public int NextSubpath (out int startIndex, out int endIndex, out bool isClosed)
188 Status status;
189 int resultCount;
190 status = GDIPlus.GdipPathIterNextSubpath (nativeObject, out resultCount, out startIndex, out endIndex, out isClosed);
191 GDIPlus.CheckStatus (status);
193 return resultCount;
196 public void Rewind ()
198 Status status = GDIPlus.GdipPathIterRewind (nativeObject);
199 GDIPlus.CheckStatus (status);