Не меняет параметров у Points[], а также не отрисовует первую фигуру.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace training10
{
public partial class Form1 : Form
{
Random rand = new Random();
int i = 0;
Graphics g;
Pen pen;
Point point1;
Point point2;
Point point3;
Point point4;
Point point5;
Point point6;
Point point7;
public Form1()
{
InitializeComponent();
g = this.CreateGraphics();
}
private void Form1_Click(object sender, EventArgs e)
{
g.Clear(SystemColors.Control);
pen = new Pen(Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)));
point1 = new Point(rand.Next(0, this.ClientSize.Width), rand.Next(0, this.ClientSize.Height));
point2 = new Point(rand.Next(0, this.ClientSize.Width), rand.Next(0, this.ClientSize.Height));
point3 = new Point(rand.Next(0, this.ClientSize.Width), rand.Next(0, this.ClientSize.Height));
point4 = new Point(rand.Next(0, this.ClientSize.Width), rand.Next(0, this.ClientSize.Height));
point5 = new Point(rand.Next(0, this.ClientSize.Width), rand.Next(0, this.ClientSize.Height));
point6 = new Point(rand.Next(0, this.ClientSize.Width), rand.Next(0, this.ClientSize.Height));
point7 = new Point(rand.Next(0, this.ClientSize.Width), rand.Next(0, this.ClientSize.Height));
Point[] points = { point1, point2, point3, point4, point5, point6, point7 };
pen = new Pen(Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)));
i++;
System.Drawing.Drawing2D.HatchBrush hatchBrush1 = new HatchBrush(HatchStyle.Sphere, Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)), Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)));
System.Drawing.Drawing2D.HatchBrush hatchBrush2 = new HatchBrush(HatchStyle.Cross, Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)), Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)));
System.Drawing.Drawing2D.HatchBrush hatchBrush3 = new HatchBrush(HatchStyle.Divot, Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)), Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)));
System.Drawing.Drawing2D.HatchBrush hatchBrush4 = new HatchBrush(HatchStyle.DottedDiamond, Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)), Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)));
System.Drawing.Drawing2D.HatchBrush hatchBrush5 = new HatchBrush(HatchStyle.HorizontalBrick, Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)), Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)));
System.Drawing.Drawing2D.HatchBrush hatchBrush6 = new HatchBrush(HatchStyle.LargeGrid, Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)), Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)));
System.Drawing.Drawing2D.HatchBrush hatchBrush7 = new HatchBrush(HatchStyle.LightHorizontal, Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)), Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)));
System.Drawing.Drawing2D.HatchBrush hatchBrush8 = new HatchBrush(HatchStyle.LightVertical, Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)), Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)));
System.Drawing.Drawing2D.HatchBrush hatchBrush9 = new HatchBrush(HatchStyle.NarrowHorizontal, Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)), Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)));
System.Drawing.Drawing2D.HatchBrush hatchBrush10 = new HatchBrush(HatchStyle.NarrowVertical, Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)), Color.FromArgb(rand.Next(150, 255), rand.Next(150, 255), rand.Next(150, 255)));
switch (i)
{
case 1:
g.FillClosedCurve(hatchBrush1, points);
label1.Text = "Sphere";
break;
case 2:
g.FillClosedCurve(hatchBrush2, points);
label1.Text = "Cross";
break;
case 3:
g.FillClosedCurve(hatchBrush3, points);
label1.Text = "Divot";
break;
case 4:
g.FillClosedCurve(hatchBrush4, points);
label1.Text = "DottedDiamond";
break;
case 5:
g.FillClosedCurve(hatchBrush5, points);
label1.Text = "HorizontalBrick";
break;
case 6:
g.FillClosedCurve(hatchBrush6, points);
label1.Text = "LargeGrid";
break;
case 7:
g.FillClosedCurve(hatchBrush7, points);
label1.Text = "LightHorizontal";
break;
case 8:
g.FillClosedCurve(hatchBrush8, points);
label1.Text = "LightVertical";
break;
case 9:
g.FillClosedCurve(hatchBrush9, points);
label1.Text = "NarrowHorizontal";
break;
case 10:
g.FillClosedCurve(hatchBrush10, points);
label1.Text = "NarrowVertical";
i = 0;
break;
}
}
}
}