@@ -11,9 +11,9 @@ public class class1
1111 // 1948e834-e104-481c-b71d-d8aa9e4d106e
1212 // How to: Create a Path Gradient
1313
14- public void Method11 ( PaintEventArgs e )
14+ // <snippet11>
15+ public void FillEllipseWithPathGradient ( PaintEventArgs e )
1516 {
16- // <snippet11>
1717 // Create a path that consists of a single ellipse.
1818 GraphicsPath path = new GraphicsPath ( ) ;
1919 path . AddEllipse ( 0 , 0 , 140 , 70 ) ;
@@ -31,11 +31,12 @@ public void Method11(PaintEventArgs e)
3131
3232 e . Graphics . FillEllipse ( pthGrBrush , 0 , 0 , 140 , 70 ) ;
3333
34- // </snippet11>
3534 }
36- public void Method12 ( PaintEventArgs e )
35+ // </snippet11>
36+
37+ // <snippet12>
38+ public void ConstructBrushFromStarShapedPath ( PaintEventArgs e )
3739 {
38- // <snippet12>
3940 // Put the points of a polygon in an array.
4041 Point [ ] points = {
4142 new Point ( 75 , 0 ) ,
@@ -77,11 +78,12 @@ public void Method12(PaintEventArgs e)
7778 // Fill the path with the path gradient brush.
7879 e . Graphics . FillPath ( pthGrBrush , path ) ;
7980
80- // </snippet12>
8181 }
82- public void Method13 ( PaintEventArgs e )
82+ // </snippet12>
83+
84+ // <snippet13>
85+ public void DrawPathGradentWthoutGraphicsPath ( PaintEventArgs e )
8386 {
84- // <snippet13>
8587 // Construct a path gradient brush based on an array of points.
8688 PointF [ ] ptsF = {
8789 new PointF ( 0 , 0 ) ,
@@ -108,11 +110,13 @@ public void Method13(PaintEventArgs e)
108110
109111 // Use the path gradient brush to fill a rectangle.
110112 e . Graphics . FillRectangle ( pBrush , new Rectangle ( 0 , 0 , 160 , 200 ) ) ;
111- // </snippet13>
112113 }
113- public void Method14 ( PaintEventArgs e )
114+ // </snippet13>
115+
116+
117+ // <snippet14>
118+ public void CustomizePathGradientBrush ( PaintEventArgs e )
114119 {
115- // <snippet14>
116120 // Create a path that consists of a single ellipse.
117121 GraphicsPath path = new GraphicsPath ( ) ;
118122 path . AddEllipse ( 0 , 0 , 200 , 100 ) ;
@@ -137,11 +141,12 @@ public void Method14(PaintEventArgs e)
137141 // Show this filled ellipse to the right of the first filled ellipse.
138142 e . Graphics . TranslateTransform ( 220.0f , 0.0f ) ;
139143 e . Graphics . FillPath ( pthGrBrush , path ) ;
140- // </snippet14>
141144 }
142- public void Method15 ( PaintEventArgs e )
145+ // <snippet14>
146+
147+ // <snippet15>
148+ public void CustomizeWithInterpolation ( PaintEventArgs e )
143149 {
144- // <snippet15>
145150 // Vertices of the outer triangle
146151 Point [ ] points = {
147152 new Point ( 100 , 0 ) ,
@@ -172,11 +177,12 @@ public void Method15(PaintEventArgs e)
172177 // specified in the Point array. The portion of the
173178 // rectangle outside the triangle will not be painted.
174179 e . Graphics . FillRectangle ( pthGrBrush , 0 , 0 , 200 , 200 ) ;
175- // </snippet15>
176180 }
177- public void Method16 ( PaintEventArgs e )
181+ // </snippet15>
182+
183+ // <snippet16>
184+ public void SetCenterPoint ( PaintEventArgs e )
178185 {
179- // <snippet16>
180186 // Create a path that consists of a single ellipse.
181187 GraphicsPath path = new GraphicsPath ( ) ;
182188 path . AddEllipse ( 0 , 0 , 140 , 70 ) ;
@@ -197,19 +203,41 @@ public void Method16(PaintEventArgs e)
197203 pthGrBrush . SurroundColors = colors ;
198204
199205 e . Graphics . FillEllipse ( pthGrBrush , 0 , 0 , 140 , 70 ) ;
200-
201- // </snippet16>
206+ }
207+ // </snippet16>
202208
203- // <snippet17>
209+ // <snippet17>
210+ public void SetCenterPointOutsidePath ( PaintEventArgs e )
211+ {
212+ // Create a path that consists of a single ellipse.
213+ GraphicsPath path = new GraphicsPath ( ) ;
214+ path . AddEllipse ( 0 , 0 , 140 , 70 ) ;
215+
216+ // Use the path to construct a brush.
217+ PathGradientBrush pthGrBrush = new PathGradientBrush ( path ) ;
218+
219+ // Set the center point to a location that is not
220+ // the centroid of the path.
204221 pthGrBrush . CenterPoint = new PointF ( 145 , 35 ) ;
205- // </snippet17>
222+
223+ // Set the color at the center of the path to blue.
224+ pthGrBrush . CenterColor = Color . FromArgb ( 255 , 0 , 0 , 255 ) ;
225+
226+ // Set the color along the entire boundary
227+ // of the path to aqua.
228+ Color [ ] colors = { Color . FromArgb ( 255 , 0 , 255 , 255 ) } ;
229+ pthGrBrush . SurroundColors = colors ;
230+
231+ e . Graphics . FillEllipse ( pthGrBrush , 0 , 0 , 140 , 70 ) ;
206232 }
233+ // </snippet17>
234+
207235 // 6c88e1cc-1217-4399-ac12-cb37592b9f01
208236 // How to: Create a Linear Gradient
209237
210- public void Method21 ( PaintEventArgs e )
238+ // <snippet21>
239+ public void UseHorizontalLinearGradients ( PaintEventArgs e )
211240 {
212- // <snippet21>
213241 LinearGradientBrush linGrBrush = new LinearGradientBrush (
214242 new Point ( 0 , 10 ) ,
215243 new Point ( 200 , 10 ) ,
@@ -221,11 +249,12 @@ public void Method21(PaintEventArgs e)
221249 e . Graphics . DrawLine ( pen , 0 , 10 , 200 , 10 ) ;
222250 e . Graphics . FillEllipse ( linGrBrush , 0 , 30 , 200 , 100 ) ;
223251 e . Graphics . FillRectangle ( linGrBrush , 0 , 155 , 500 , 30 ) ;
224- // </snippet21>
225252 }
226- public void Method22 ( PaintEventArgs e )
253+ // </snippet21>
254+
255+ // <snippet22>
256+ public void CustomizeLinearGradients ( PaintEventArgs e )
227257 {
228- // <snippet22>
229258 LinearGradientBrush linGrBrush = new LinearGradientBrush (
230259 new Point ( 0 , 10 ) ,
231260 new Point ( 200 , 10 ) ,
@@ -243,11 +272,12 @@ public void Method22(PaintEventArgs e)
243272
244273 e . Graphics . FillEllipse ( linGrBrush , 0 , 30 , 200 , 100 ) ;
245274 e . Graphics . FillRectangle ( linGrBrush , 0 , 155 , 500 , 30 ) ;
246- // </snippet22>
247275 }
248- public void Method23 ( PaintEventArgs e )
276+ // </snippet22>
277+
278+ // <snippet23>
279+ public void CreateDiagonalLinearGradients ( PaintEventArgs e )
249280 {
250- // <snippet23>
251281 LinearGradientBrush linGrBrush = new LinearGradientBrush (
252282 new Point ( 0 , 0 ) ,
253283 new Point ( 200 , 100 ) ,
@@ -258,15 +288,17 @@ public void Method23(PaintEventArgs e)
258288
259289 e . Graphics . DrawLine ( pen , 0 , 0 , 600 , 300 ) ;
260290 e . Graphics . FillEllipse ( linGrBrush , 10 , 100 , 200 , 100 ) ;
261- // </snippet23>
262291 }
292+ // </snippet23>
293+
294+
263295 // da4690e7-5fac-4fd2-b3f0-5cb35c165b92
264296 // How to: Apply Gamma Correction to a Gradient
265297
266- public void Method31 ( PaintEventArgs e )
298+ // <snippet31>
299+ public void FillTwoRectangles ( PaintEventArgs e )
267300 {
268- // <snippet31>
269- LinearGradientBrush linGrBrush = new LinearGradientBrush (
301+ LinearGradientBrush linGrBrush = new LinearGradientBrush (
270302 new Point ( 0 , 10 ) ,
271303 new Point ( 200 , 10 ) ,
272304 Color . Red ,
@@ -275,7 +307,8 @@ public void Method31(PaintEventArgs e)
275307 e . Graphics . FillRectangle ( linGrBrush , 0 , 0 , 200 , 50 ) ;
276308 linGrBrush . GammaCorrection = true ;
277309 e . Graphics . FillRectangle ( linGrBrush , 0 , 60 , 200 , 50 ) ;
278- // </snippet31>
279310 }
280- }
311+ // </snippet31>
312+ }
313+
281314
0 commit comments