g.DrawLine(OXY, centerXOY.X, 0, centerXOY.X, pnlXOY.Size.Height);
g.DrawString("0", txt, Brushes.Black, centerXOY.X - txt.Size, centerXOY.Y);
cx = local_x;
cy = local_y;
relX = cx / stepX;
relY = cy / stepY;
XY.X = centerXOY.X - relX;
XY.Y = centerXOY.Y + relY;
g.FillEllipse(Brushes.Green, XY.X - 10, XY.Y - 10, 20, 20);
for (int i = 0; i < 8; i++) //преобразование точек плоскости в экранные
{
cx = old_points[0, i];
cy = old_points[1, i];
relX = cx / stepX;
relY = cy / stepY;
XY.X = centerXOY.X - relX;
XY.Y = centerXOY.Y + relY;
old_scr_points[i].X = XY.X;
old_scr_points[i].Y = XY.Y;
}
g.DrawLine(figur1, old_scr_points[0], old_scr_points[3]); //рисование фигуры
g.DrawLine(figur1, old_scr_points[0], old_scr_points[1]);
g.DrawLine(figur1, old_scr_points[1], old_scr_points[2]);
g.DrawLine(figur1, old_scr_points[2], old_scr_points[3]);
g.DrawLine(figur1, old_scr_points[0], old_scr_points[4]);
g.DrawLine(figur1, old_scr_points[1], old_scr_points[5]);
g.DrawLine(figur1, old_scr_points[2], old_scr_points[6]);
g.DrawLine(figur1, old_scr_points[3], old_scr_points[7]);
g.DrawLine(figur1, old_scr_points[4], old_scr_points[5]);
g.DrawLine(figur1, old_scr_points[5], old_scr_points[6]);
g.DrawLine(figur1, old_scr_points[4], old_scr_points[7]);
g.DrawLine(figur1, old_scr_points[7], old_scr_points[6]);
for (int i = 0; i < 8; i++) //преобразование точек плоскости в экранные
{
cx = points[0, i];
cy = points[1, i];
relX = cx / stepX;
relY = cy / stepY;
XY.X = centerXOY.X - relX;
XY.Y = centerXOY.Y + relY;
scr_points[i].X = XY.X;
scr_points[i].Y = XY.Y;
}
g.DrawLine(figur, scr_points[0], scr_points[3]); //рисование фигуры
g.DrawLine(figur, scr_points[0], scr_points[1]);
g.DrawLine(figur, scr_points[1], scr_points[2]);
g.DrawLine(figur, scr_points[2], scr_points[3]);
g.DrawLine(figur, scr_points[0], scr_points[4]);
g.DrawLine(figur, scr_points[1], scr_points[5]);
g.DrawLine(figur, scr_points[2], scr_points[6]);
g.DrawLine(figur, scr_points[3], scr_points[7]);
g.DrawLine(figur, scr_points[4], scr_points[5]);
g.DrawLine(figur, scr_points[5], scr_points[6]);
g.DrawLine(figur, scr_points[4], scr_points[7]);
g.DrawLine(figur, scr_points[7], scr_points[6]);
}
private void pnlYOZ_Paint(object sender, PaintEventArgs e)
{
Pen OXY = new Pen(Color.Blue, 2); //перо оси XOY
Pen setka = new Pen(Color.Gray, 1); //перо масштабной сетки
Pen figur = new Pen(Color.Red, 3); //перо для рисования фигуры
Pen figur1 = new Pen(Color.Blue, 3);
Graphics g = e.Graphics;
Font txt = new Font("Arial", 14, FontStyle.Bold);
int count = 0;
float cx, cy; //текущие точки плоскости XOY
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
g.FillRectangle(Brushes.White, 0, 0, pnlYOZ.Size.Width, pnlYOZ.Size.Height);
sizeX = int.Parse(mashtab_oy.Value.ToString());
sizeY = int.Parse(mashtab_oz.Value.ToString());
stepX = 1 / sizeX;
stepY = 1 / sizeY;
//рисование масштабной сетки по x
for (XY.X = centerYOZ.X, count = 0; XY.X < pnlYOZ.Size.Width; XY.X += sizeX, count++)
{
g.DrawLine(setka, XY.X, 0, XY.X, pnlYOZ.Size.Height);
g.DrawString(count.ToString(), txt, Brushes.Black, XY.X - txt.Size, centerYOZ.Y);
}
for (XY.X = centerYOZ.X, count = 0; XY.X > 0; XY.X -= sizeX, count--)
{
g.DrawLine(setka, XY.X, 0, XY.X, pnlYOZ.Size.Height);
if (count != 0)
g.DrawString(count.ToString(), txt, Brushes.Black, XY.X - 1.5f * txt.Size, centerYOZ.Y);
}
//по y
for (XY.Y = centerYOZ.Y, count = 0; XY.Y > 0; XY.Y -= sizeY, count++)
{
g.DrawLine(setka, 0, XY.Y, pnlYOZ.Size.Width, XY.Y);
g.DrawString(count.ToString(), txt, Brushes.Black, centerYOZ.X - txt.Size, XY.Y);
}
for (XY.Y = centerYOZ.Y, count = 0; XY.Y < pnlYOZ.Size.Height; XY.Y += sizeY, count--)
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.