using System using System Collections Generic using System ComponentMo

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
private int[][,] figures = new int[4][,];
public Form1()
{
InitializeComponent();
// Первая проекция
figures[0] = new int[,] {
{ 30, 60, 30, 60 }, { 0, 0, 20, 0 }, { 0, 0, 0, 40 }, { 0, 20, 70, 20 },
{ 40, 20, 70, 20 }, { 70, 0, 70, 40 }, { 20, 10, 50, 10 }, { 20, 0, 20, 10 },
{ 50, 0, 50, 10 }, { 50, 0, 70, 0 }, { 55, 0, 55, 20 }, { 0, 40, 70, 40 },
};
// Вторая проекция
figures[1] = new int[,] {
{ 130, 60, 130, 60 }, { 0, 0, 15, 0 }, { 0, 0, 0, 40 }, { 15, 0, 15, 20 },
{ 0, 40, 45, 40 }, { 15, 0, 45, 20 }, { 15, 20, 45, 20 }, { 45, 20, 45, 40 },
};
// Третья проекция
figures[2] = new int[,] {
{ 30, 130, 30, 130 }, { 0, 0, 70, 0 }, { 0, 15, 70, 15 },
{ 0, 0, 0, 45 }, { 70, 0, 70, 45 }, { 0, 45, 70, 45 },
{ 20, 0, 20, 15 }, { 50, 0, 50, 15 }, { 55, 15, 55, 45 },
};
// Аксонометрия
figures[3] = new int[,] {
{ 305, 205, 305, 205 },
{ 0, 0, 13, -7 }, { 13, -7, 24, -2 }, { 11, 4, 24, -2 }, { 0, 0, 11, 4 },
{ 11, 4, 11, 22 }, { 11, 22, 34, 31 }, { 34, 31, 34, 49 }, { 34, 49, 0, 36 },
{ 0, 36, 0, 0, }, { 34, 49, 80, 25 }, { 80, 25, 80, 7 }, { 80, 7, 34, 31 },
{ 80, 7, 70, 12 }, { 48, 4, 70, 12 }, { 48, 4, 11, 22 }, { 48, 4, 48, -14 },
{ 48, -14, 70, 12 }, { 57, -20, 80, 7 }, { 44, -13, 57, -20 }, { 44, -13, 33, -17 },
{ 33, -17, 46, -24 }, { 46, -24, 57, -20 }, { 44, -3, 44, -13 }, { 24, 7, 44, -3 },
{ 24, 7, 24, -2 }, { 33, -8, 33, -17 }, { 33, -8, 44, -3 }, { 33, -8, 23, -3 },
};
}
private void DrawFigures()
{
Graphics canvas = Graphics.FromHwnd(this.Handle);
Pen pen = new Pen(Color.Maroon, 1);
for (int i = 0; i < 4; i++)
{
int[,] f = figures[i];
for (int j = 1; j < figures[i].GetLength(0); j++ )
{
canvas.DrawLine(pen, f[0, 0] + f[j, 0], f[0, 1] + f[j, 1], f[0, 2] + f[j, 2], f[0, 3] + f[j, 3]);
}
}
Font f2 = new Font("Arial", 8);
Font f1 = new Font("Arial", 15);
Pen pen2 = new Pen(Color.IndianRed, 1);
Pen pen3 = new Pen(Color.MediumSeaGreen, 1);
SolidBrush b = new SolidBrush(Color.FromArgb(150, 0, 0, 255));
int x0 = 110; int y0 = 110;
canvas.DrawString("X", f1, b, x0 - 100, y0 + 10);
canvas.DrawString("Y", f1, b, x0 + 100, y0 + 10);
canvas.DrawString("Z", f1, b, x0 + 10, y0 - 100);
canvas.DrawString("Ортогональные проекции", f2, b, 25, 270);
canvas.DrawString("Y", f1, b, x0 + 10, y0 + 100);
canvas.DrawString("X", f1, b, 445, 172);
canvas.DrawString("Y", f1, b, 265, 180);
canvas.DrawString("Z", f1, b, 365, 45);
canvas.DrawString("Аксонометрия", f2, b, 265, 270);
canvas.DrawLine(pen3, 115, 220, 115, 20);
canvas.DrawLine(pen3, 25, 115, 220, 115);
canvas.DrawLine(pen3, 360, 160, 360, 50);
canvas.DrawLine(pen3, 360, 160, 360 - 92, 160 + 48);
canvas.DrawLine(pen3, 360, 160, 360 + 74 * 2, 160 + 58);
canvas.DrawRectangle(pen2, 10, 5, 230, 300);
canvas.DrawRectangle(pen2, 250, 5, 230, 300);
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
DrawFigures();
}
}
}