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);
- //
}
-}
+ //
+}
+
diff --git a/snippets/csharp/language-reference/operators/BitwiseAndShiftOperators.cs b/snippets/csharp/language-reference/operators/BitwiseAndShiftOperators.cs
index c04249f390e..f0d9829fed5 100644
--- a/snippets/csharp/language-reference/operators/BitwiseAndShiftOperators.cs
+++ b/snippets/csharp/language-reference/operators/BitwiseAndShiftOperators.cs
@@ -139,9 +139,13 @@ private static void ShiftCount()
int a = 0b_0001;
Console.WriteLine($"{a} << {count1} is {a << count1}; {a} << {count2} is {a << count2}");
+ // Output:
+ // 1 << 1 is 2; 1 << 225 is 2
int b = 0b_0100;
Console.WriteLine($"{b} >> {count1} is {b >> count1}; {b} >> {count2} is {b >> count2}");
+ // Output:
+ // 4 >> 1 is 2; 4 >> 225 is 2
//
}
diff --git a/snippets/csharp/language-reference/operators/BitwiseComplementExamples.cs b/snippets/csharp/language-reference/operators/BitwiseComplementExamples.cs
deleted file mode 100644
index 07ec9ab42a8..00000000000
--- a/snippets/csharp/language-reference/operators/BitwiseComplementExamples.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-
-namespace operators
-{
- public static class BitwiseComplementExamples
- {
- public static void Examples()
- {
- BitwiseComplement();
- }
-
- private static void BitwiseComplement()
- {
- //
- uint a = 0b_0000_1111_0000_1111_0000_1111_0000_1100;
- uint b = ~a;
- Console.WriteLine(Convert.ToString(b, toBase: 2));
- // Output:
- // 11110000111100001111000011110011
- //
- }
- }
-}
\ No newline at end of file
diff --git a/snippets/csharp/language-reference/operators/ShiftOperatorsExamples.cs b/snippets/csharp/language-reference/operators/ShiftOperatorsExamples.cs
deleted file mode 100644
index 7825ebdbca8..00000000000
--- a/snippets/csharp/language-reference/operators/ShiftOperatorsExamples.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-using System;
-
-namespace operators
-{
- public static class ShiftOperatorsExamples
- {
- public static void Examples()
- {
- LeftShift();
- LeftShiftByLargeCount();
- LeftShiftAssignment();
- RightShift();
- RightShiftByLargeCount();
- RightShiftAssignment();
- }
-
- private static void LeftShift()
- {
- //
- uint x = 0b_1100_1001_0000_0000_0000_0000_0001_0001;
- Console.WriteLine($"Before: {Convert.ToString(x, toBase: 2)}");
-
- uint y = x << 4;
- Console.WriteLine($"After: {Convert.ToString(y, toBase: 2)}");
- // Output:
- // Before: 11001001000000000000000000010001
- // After: 10010000000000000000000100010000
- //
- }
-
- private static void LeftShiftByLargeCount()
- {
- //
- int a = 0b_0001;
- int count1 = 0b_0000_0001;
- int count2 = 0b_1110_0001;
- Console.WriteLine($"{a} << {count1} is {a << count1}; {a} << {count2} is {a << count2}");
- // Output:
- // 1 << 1 is 2; 1 << 225 is 2
- //
- }
-
- private static void LeftShiftAssignment()
- {
- //
- uint x = 0b_1100_1001_0000_0000_0000_0000_0001_0001;
- Console.WriteLine($"Before: {Convert.ToString(x, toBase: 2)}");
-
- x <<= 4;
- Console.WriteLine($"After: {Convert.ToString(x, toBase: 2)}");
- // Output:
- // Before: 11001001000000000000000000010001
- // After: 10010000000000000000000100010000
- //
- }
-
- private static void RightShift()
- {
- //
- uint x = 0b_1001;
- Console.WriteLine($"Before: {Convert.ToString(x, toBase: 2), 4}");
-
- uint y = x >> 2;
- Console.WriteLine($"After: {Convert.ToString(y, toBase: 2), 4}");
- // Output:
- // Before: 1001
- // After: 10
-
- int a = int.MinValue;
- Console.WriteLine($"Before: {Convert.ToString(a, toBase: 2)}");
-
- int b = a >> 3;
- Console.WriteLine($"After: {Convert.ToString(b, toBase: 2)}");
- // Output:
- // Before: 10000000000000000000000000000000
- // After: 11110000000000000000000000000000
- //
- }
-
- private static void RightShiftByLargeCount()
- {
- //
- int a = 0b_0100;
- int count1 = 0b_0000_0001;
- int count2 = 0b_1110_0001;
- Console.WriteLine($"{a} >> {count1} is {a >> count1}; {a} >> {count2} is {a >> count2}");
- // Output:
- // 4 >> 1 is 2; 4 >> 225 is 2
- //
- }
-
- private static void RightShiftAssignment()
- {
- //
- uint x = 0b_1001;
- Console.WriteLine($"Before: {Convert.ToString(x, toBase: 2), 4}");
-
- x >>= 2;
- Console.WriteLine($"After: {Convert.ToString(x, toBase: 2), 4}");
- // Output:
- // Before: 1001
- // After: 10
- //
- }
- }
-}
\ No newline at end of file