From 8b7d4a8a2bef07804ff252570a05f6008ab33619 Mon Sep 17 00:00:00 2001 From: Ron Petrusha Date: Thu, 18 Apr 2019 09:53:32 -0700 Subject: [PATCH] Renamed methods, moved snippet tags --- .../CS/Class1.cs | 103 ++++++++++++------ 1 file changed, 68 insertions(+), 35 deletions(-) diff --git a/snippets/csharp/VS_Snippets_Winforms/System.Drawing.UsingaGradientBrush/CS/Class1.cs b/snippets/csharp/VS_Snippets_Winforms/System.Drawing.UsingaGradientBrush/CS/Class1.cs index 6e93e4768a4..6d9b1970454 100644 --- a/snippets/csharp/VS_Snippets_Winforms/System.Drawing.UsingaGradientBrush/CS/Class1.cs +++ b/snippets/csharp/VS_Snippets_Winforms/System.Drawing.UsingaGradientBrush/CS/Class1.cs @@ -11,9 +11,9 @@ public class class1 // 1948e834-e104-481c-b71d-d8aa9e4d106e // How to: Create a Path Gradient - public void Method11(PaintEventArgs e) + // + public void FillEllipseWithPathGradient(PaintEventArgs e) { - // // Create a path that consists of a single ellipse. GraphicsPath path = new GraphicsPath(); path.AddEllipse(0, 0, 140, 70); @@ -31,11 +31,12 @@ public void Method11(PaintEventArgs e) e.Graphics.FillEllipse(pthGrBrush, 0, 0, 140, 70); - // } - public void Method12(PaintEventArgs e) + // + + // + public void ConstructBrushFromStarShapedPath(PaintEventArgs e) { - // // Put the points of a polygon in an array. Point[] points = { new Point(75, 0), @@ -77,11 +78,12 @@ public void Method12(PaintEventArgs e) // Fill the path with the path gradient brush. e.Graphics.FillPath(pthGrBrush, path); - // } - public void Method13(PaintEventArgs e) + // + + // + public void DrawPathGradentWthoutGraphicsPath(PaintEventArgs e) { - // // Construct a path gradient brush based on an array of points. PointF[] ptsF = { new PointF(0, 0), @@ -108,11 +110,13 @@ public void Method13(PaintEventArgs e) // Use the path gradient brush to fill a rectangle. e.Graphics.FillRectangle(pBrush, new Rectangle(0, 0, 160, 200)); - // } - public void Method14(PaintEventArgs e) + // + + + // + public void CustomizePathGradientBrush(PaintEventArgs e) { - // // Create a path that consists of a single ellipse. GraphicsPath path = new GraphicsPath(); path.AddEllipse(0, 0, 200, 100); @@ -137,11 +141,12 @@ public void Method14(PaintEventArgs e) // Show this filled ellipse to the right of the first filled ellipse. e.Graphics.TranslateTransform(220.0f, 0.0f); e.Graphics.FillPath(pthGrBrush, path); - // } - public void Method15(PaintEventArgs e) + // + + // + public void CustomizeWithInterpolation(PaintEventArgs e) { - // // Vertices of the outer triangle Point[] points = { new Point(100, 0), @@ -172,11 +177,12 @@ public void Method15(PaintEventArgs e) // specified in the Point array. The portion of the // rectangle outside the triangle will not be painted. e.Graphics.FillRectangle(pthGrBrush, 0, 0, 200, 200); - // } - public void Method16(PaintEventArgs e) + // + + // + public void SetCenterPoint(PaintEventArgs e) { - // // Create a path that consists of a single ellipse. GraphicsPath path = new GraphicsPath(); path.AddEllipse(0, 0, 140, 70); @@ -197,19 +203,41 @@ public void Method16(PaintEventArgs e) pthGrBrush.SurroundColors = colors; e.Graphics.FillEllipse(pthGrBrush, 0, 0, 140, 70); - - // + } + // - // + // + public void SetCenterPointOutsidePath(PaintEventArgs e) + { + // Create a path that consists of a single ellipse. + GraphicsPath path = new GraphicsPath(); + path.AddEllipse(0, 0, 140, 70); + + // Use the path to construct a brush. + PathGradientBrush pthGrBrush = new PathGradientBrush(path); + + // Set the center point to a location that is not + // the centroid of the path. pthGrBrush.CenterPoint = new PointF(145, 35); - // + + // Set the color at the center of the path to blue. + pthGrBrush.CenterColor = Color.FromArgb(255, 0, 0, 255); + + // Set the color along the entire boundary + // of the path to aqua. + Color[] colors = { Color.FromArgb(255, 0, 255, 255) }; + pthGrBrush.SurroundColors = colors; + + e.Graphics.FillEllipse(pthGrBrush, 0, 0, 140, 70); } + // + // 6c88e1cc-1217-4399-ac12-cb37592b9f01 // How to: Create a Linear Gradient - public void Method21(PaintEventArgs e) + // + public void UseHorizontalLinearGradients(PaintEventArgs e) { - // LinearGradientBrush linGrBrush = new LinearGradientBrush( new Point(0, 10), new Point(200, 10), @@ -221,11 +249,12 @@ public void Method21(PaintEventArgs e) e.Graphics.DrawLine(pen, 0, 10, 200, 10); e.Graphics.FillEllipse(linGrBrush, 0, 30, 200, 100); e.Graphics.FillRectangle(linGrBrush, 0, 155, 500, 30); - // } - public void Method22(PaintEventArgs e) + // + + // + public void CustomizeLinearGradients(PaintEventArgs e) { - // LinearGradientBrush linGrBrush = new LinearGradientBrush( new Point(0, 10), new Point(200, 10), @@ -243,11 +272,12 @@ public void Method22(PaintEventArgs e) e.Graphics.FillEllipse(linGrBrush, 0, 30, 200, 100); e.Graphics.FillRectangle(linGrBrush, 0, 155, 500, 30); - // } - public void Method23(PaintEventArgs e) + // + + // + public void CreateDiagonalLinearGradients(PaintEventArgs e) { - // LinearGradientBrush linGrBrush = new LinearGradientBrush( new Point(0, 0), new Point(200, 100), @@ -258,15 +288,17 @@ public void Method23(PaintEventArgs e) e.Graphics.DrawLine(pen, 0, 0, 600, 300); e.Graphics.FillEllipse(linGrBrush, 10, 100, 200, 100); - // } + // + + // da4690e7-5fac-4fd2-b3f0-5cb35c165b92 // How to: Apply Gamma Correction to a Gradient - public void Method31(PaintEventArgs e) + // + public void FillTwoRectangles(PaintEventArgs e) { - // - LinearGradientBrush linGrBrush = new LinearGradientBrush( + LinearGradientBrush linGrBrush = new LinearGradientBrush( new Point(0, 10), new Point(200, 10), Color.Red, @@ -275,7 +307,8 @@ public void Method31(PaintEventArgs e) e.Graphics.FillRectangle(linGrBrush, 0, 0, 200, 50); linGrBrush.GammaCorrection = true; e.Graphics.FillRectangle(linGrBrush, 0, 60, 200, 50); - // } -} + // +} +