5 // Sebastien Pouliot <sebastien@ximian.com>
7 // Copyright (C) 2006 Novell, Inc (http://www.novell.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System.Drawing.Drawing2D;
33 namespace Samples.Common {
37 static public object[] GetList ()
57 static public GraphicsPath GetShape (int index)
67 return ClosedCurve ();
94 static private GraphicsPath Arc ()
96 GraphicsPath path = new GraphicsPath ();
97 path.AddArc (20, 20, 200, 200, 60, 120);
101 static private GraphicsPath Bezier ()
103 GraphicsPath path = new GraphicsPath ();
105 new Point (20, 100), new Point (70, 10),
106 new Point (130, 200), new Point (180, 100)
111 static private GraphicsPath Beziers ()
113 GraphicsPath path = new GraphicsPath ();
114 path.AddBeziers (new Point[7] {
115 new Point (20, 100), new Point (70, 10),
116 new Point (130, 200), new Point (180, 100),
117 new Point (200, 100), new Point (240, 240),
123 static private GraphicsPath ClosedCurve ()
125 GraphicsPath path = new GraphicsPath ();
126 path.AddClosedCurve (new Point[4] {
127 new Point (20, 100), new Point (70, 10),
128 new Point (130, 200), new Point (180, 100)
133 static private GraphicsPath Curve ()
135 GraphicsPath path = new GraphicsPath ();
136 path.AddCurve (new Point[4] {
137 new Point (20, 100), new Point (70, 10),
138 new Point (130, 200), new Point (180, 100)
143 static private GraphicsPath Ellipse ()
145 GraphicsPath path = new GraphicsPath ();
146 path.AddEllipse (20, 20, 200, 100);
150 static private GraphicsPath Line ()
152 GraphicsPath path = new GraphicsPath ();
153 path.AddLine (20, 20, 200, 100);
157 static private GraphicsPath Lines ()
159 GraphicsPath path = new GraphicsPath ();
160 path.AddLines (new Point[4] {
161 new Point (20, 100), new Point (70, 10),
162 new Point (130, 200), new Point (180, 100)
167 static private GraphicsPath Pie ()
169 GraphicsPath path = new GraphicsPath ();
170 path.AddPie (20, 20, 200, 200, 60, 120);
174 static private GraphicsPath Polygon ()
176 GraphicsPath path = new GraphicsPath ();
177 path.AddPolygon (new Point[4] {
178 new Point (20, 100), new Point (70, 10),
179 new Point (130, 200), new Point (180, 100)
184 static private GraphicsPath Rectangle ()
186 GraphicsPath path = new GraphicsPath ();
187 path.AddRectangle (new Rectangle (20, 20, 200, 200));
191 static private GraphicsPath Rectangles ()
193 GraphicsPath path = new GraphicsPath ();
194 path.AddRectangles (new Rectangle[2] {
195 new Rectangle (20, 20, 100, 100),
196 new Rectangle (100, 100, 20, 20)
201 static private GraphicsPath String ()
203 GraphicsPath path = new GraphicsPath ();
205 path.AddString ("Mono", FontFamily.GenericMonospace, 0, 10f, new Point (20, 20), StringFormat.GenericDefault);
207 catch (NotImplementedException) {
208 // not implemented in libgdiplus
213 static private GraphicsPath Complex ()
215 GraphicsPath path = new GraphicsPath ();
216 path.AddPath (Pie (), false);
217 path.AddPath (Rectangle (), true);
218 path.AddPath (Polygon (), false);