Лабораторная работа 1
This commit is contained in:
parent
2fe124c6ef
commit
69b1fb0114
16
ProjectPlane/ProjectPlane/Direction.cs
Normal file
16
ProjectPlane/ProjectPlane/Direction.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectPlane
|
||||
{
|
||||
internal enum Direction
|
||||
{
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 3,
|
||||
Right = 4
|
||||
}
|
||||
}
|
229
ProjectPlane/ProjectPlane/DrawningPlane.cs
Normal file
229
ProjectPlane/ProjectPlane/DrawningPlane.cs
Normal file
@ -0,0 +1,229 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectPlane
|
||||
{
|
||||
internal class DrawingPlane
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
/// </summary>
|
||||
public EntityPlane Plane { get; private set; }
|
||||
/// <summary>
|
||||
/// Левая координата отрисовки самолета
|
||||
/// </summary>
|
||||
private float _startPosX;
|
||||
/// <summary>
|
||||
/// Верхняя кооридната отрисовки самолета
|
||||
/// </summary>
|
||||
private float _startPosY;
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
private int? _pictureWidth = null;
|
||||
/// <summary>
|
||||
/// Высота окна отрисовки
|
||||
/// </summary>
|
||||
private int? _pictureHeight = null;
|
||||
/// <summary>
|
||||
/// Ширина отрисовки самолета
|
||||
/// </summary>
|
||||
private readonly int _planeWidth = 120;
|
||||
/// <summary>
|
||||
/// Высота отрисовки самолета
|
||||
/// </summary>
|
||||
private readonly int _planeHeight = 50;
|
||||
/// <summary>
|
||||
/// Левый край
|
||||
/// </summary>
|
||||
private readonly int _minX = 5;
|
||||
/// <summary>
|
||||
/// Верхний край
|
||||
/// </summary>
|
||||
private readonly int _minY = 40;
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес самолета</param>
|
||||
/// <param name="bodyColor">Цвет корпуса</param>
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Plane = new EntityPlane();
|
||||
Plane.Init(speed, weight, bodyColor);
|
||||
}
|
||||
/// <summary>
|
||||
/// Установка позиции самолета
|
||||
/// </summary>
|
||||
/// <param name="x">Координата X</param>
|
||||
/// <param name="y">Координата Y</param>
|
||||
/// <param name="width">Ширина картинки</param>
|
||||
/// <param name="height">Высота картинки</param>
|
||||
public void SetPosition(int x, int y, int width, int height)
|
||||
{
|
||||
if (x >= _minX && x <= width && y >= _minY && y <= height)
|
||||
{
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
}
|
||||
else SetPosition(_minX, _minY, width, height);
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменение направления пермещения
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
public void MoveTransport(Direction direction)
|
||||
{
|
||||
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
// вправо
|
||||
case Direction.Right:
|
||||
if (_startPosX + _planeWidth + Plane.Step < _pictureWidth)
|
||||
{
|
||||
_startPosX += Plane.Step;
|
||||
}
|
||||
break;
|
||||
//влево
|
||||
case Direction.Left:
|
||||
if (_startPosX - Plane.Step > 0)
|
||||
{
|
||||
_startPosX -= Plane.Step;
|
||||
}
|
||||
break;
|
||||
//вверх
|
||||
case Direction.Up:
|
||||
if (_startPosY - Plane.Step > 35)
|
||||
{
|
||||
_startPosY -= Plane.Step;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
//вниз
|
||||
case Direction.Down:
|
||||
if (_startPosY + _planeHeight + Plane.Step < _pictureHeight)
|
||||
{
|
||||
_startPosY += Plane.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Отрисовка самолета
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public void DrawTransport(Graphics g)
|
||||
{
|
||||
if (_startPosX < 0 || _startPosY < 0
|
||||
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//границы самолета
|
||||
Pen pen = new(Color.Black);
|
||||
|
||||
g.DrawEllipse(pen, _startPosX, _startPosY, 20, 20);
|
||||
|
||||
g.DrawRectangle(pen, _startPosX + 8, _startPosY, 100, 20);
|
||||
|
||||
Point[] Triangle0 = new Point[3];
|
||||
Triangle0[0].X = Convert.ToInt32(_startPosX + 108); Triangle0[0].Y = Convert.ToInt32(_startPosY - 2);
|
||||
Triangle0[1].X = Convert.ToInt32(_startPosX + 125); Triangle0[1].Y = Convert.ToInt32(_startPosY + 10);
|
||||
Triangle0[2].X = Convert.ToInt32(_startPosX + 108); Triangle0[2].Y = Convert.ToInt32(_startPosY + 10);
|
||||
g.DrawPolygon(pen, Triangle0);
|
||||
|
||||
Point[] Triangle1 = new Point[3];
|
||||
Triangle1[0].X = Convert.ToInt32(_startPosX + 108); Triangle1[0].Y = Convert.ToInt32(_startPosY + 10);
|
||||
Triangle1[1].X = Convert.ToInt32(_startPosX + 125); Triangle1[1].Y = Convert.ToInt32(_startPosY + 10);
|
||||
Triangle1[2].X = Convert.ToInt32(_startPosX + 108); Triangle1[2].Y = Convert.ToInt32(_startPosY + 22);
|
||||
g.DrawPolygon(pen, Triangle1);
|
||||
|
||||
Point[] Triangle = new Point[3];
|
||||
Triangle[0].X = Convert.ToInt32(_startPosX + 5); Triangle[0].Y = Convert.ToInt32(_startPosY);
|
||||
Triangle[1].X = Convert.ToInt32(_startPosX + 5); Triangle[1].Y = Convert.ToInt32(_startPosY - 20);
|
||||
Triangle[2].X = Convert.ToInt32(_startPosX + 35); Triangle[2].Y = Convert.ToInt32(_startPosY);
|
||||
g.DrawPolygon(pen, Triangle);
|
||||
|
||||
////корпус
|
||||
|
||||
Brush br = new SolidBrush(Plane?.BodyColor ?? Color.Black);
|
||||
|
||||
g.FillEllipse(br, _startPosX, _startPosY, 20, 20);
|
||||
|
||||
g.FillRectangle(br, _startPosX + 8, _startPosY, 100, 20);
|
||||
|
||||
Point[] Triangle2 = new Point[3];
|
||||
Triangle2[0].X = Convert.ToInt32(_startPosX + 5); Triangle2[0].Y = Convert.ToInt32(_startPosY);
|
||||
Triangle2[1].X = Convert.ToInt32(_startPosX + 5); Triangle2[1].Y = Convert.ToInt32(_startPosY - 20);
|
||||
Triangle2[2].X = Convert.ToInt32(_startPosX + 35); Triangle2[2].Y = Convert.ToInt32(_startPosY);
|
||||
g.FillPolygon(br, Triangle2);
|
||||
|
||||
Point[] Triangle4 = new Point[3];
|
||||
Triangle4[0].X = Convert.ToInt32(_startPosX + 108); Triangle4[0].Y = Convert.ToInt32(_startPosY + 10);
|
||||
Triangle4[1].X = Convert.ToInt32(_startPosX + 125); Triangle4[1].Y = Convert.ToInt32(_startPosY + 10);
|
||||
Triangle4[2].X = Convert.ToInt32(_startPosX + 108); Triangle4[2].Y = Convert.ToInt32(_startPosY + 22);
|
||||
g.FillPolygon(br, Triangle4);
|
||||
|
||||
// window
|
||||
|
||||
Brush brBlue = new SolidBrush(Color.LightBlue);
|
||||
|
||||
Point[] Triangle3 = new Point[3];
|
||||
Triangle3[0].X = Convert.ToInt32(_startPosX + 108); Triangle3[0].Y = Convert.ToInt32(_startPosY - 2);
|
||||
Triangle3[1].X = Convert.ToInt32(_startPosX + 125); Triangle3[1].Y = Convert.ToInt32(_startPosY + 10);
|
||||
Triangle3[2].X = Convert.ToInt32(_startPosX + 108); Triangle3[2].Y = Convert.ToInt32(_startPosY + 10);
|
||||
g.FillPolygon(brBlue, Triangle3);
|
||||
|
||||
g.DrawLine(pen, _startPosX + 37, _startPosY + 20, _startPosX + 37, _startPosY + 25);
|
||||
g.DrawLine(pen, _startPosX + 32, _startPosY + 25, _startPosX + 40, _startPosY + 25);
|
||||
g.DrawRectangle(pen, _startPosX + 32, _startPosY + 25, 3, 3);
|
||||
g.DrawRectangle(pen, _startPosX + 39, _startPosY + 25, 3, 3);
|
||||
|
||||
g.DrawLine(pen, _startPosX + 102, _startPosY + 20, _startPosX + 102, _startPosY + 25);
|
||||
g.DrawRectangle(pen, _startPosX + 101, _startPosY + 25, 3, 3);
|
||||
|
||||
Brush brBlack = new SolidBrush(Color.Black);
|
||||
|
||||
g.FillRectangle(brBlack, _startPosX + 5, _startPosY - 2, 18, 7);
|
||||
g.FillEllipse(brBlack, _startPosX, _startPosY - 2, 7, 7);
|
||||
g.FillEllipse(brBlack, _startPosX + 20, _startPosY - 2, 7, 7);
|
||||
|
||||
g.FillRectangle(brBlack, _startPosX + 41, _startPosY + 8, 42, 4);
|
||||
g.FillEllipse(brBlack, _startPosX + 39, _startPosY + 8, 4, 4);
|
||||
g.FillEllipse(brBlack, _startPosX + 81, _startPosY + 8, 4, 4);
|
||||
}
|
||||
/// <summary>
|
||||
/// Смена границ формы отрисовки
|
||||
/// </summary>
|
||||
/// <param name="width">Ширина картинки</param>
|
||||
/// <param name="height">Высота картинки</param>
|
||||
public void ChangeBorders(int width, int height)
|
||||
{
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
if (_pictureWidth <= _planeWidth || _pictureHeight <= _planeHeight)
|
||||
{
|
||||
_pictureWidth = null;
|
||||
_pictureHeight = null;
|
||||
return;
|
||||
}
|
||||
if (_startPosX + _planeWidth > _pictureWidth)
|
||||
{
|
||||
_startPosX = _pictureWidth.Value - _planeWidth;
|
||||
}
|
||||
if (_startPosY + _planeHeight > _pictureHeight)
|
||||
{
|
||||
_startPosY = _pictureHeight.Value - _planeHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
43
ProjectPlane/ProjectPlane/EntityPlane.cs
Normal file
43
ProjectPlane/ProjectPlane/EntityPlane.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectPlane
|
||||
{
|
||||
internal class EntityPlane
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Скорость
|
||||
/// </summary>
|
||||
public int Speed { get; private set; }
|
||||
/// <summary>
|
||||
/// Вес
|
||||
/// </summary>
|
||||
public float Weight { get; private set; }
|
||||
/// <summary>
|
||||
/// Цвет корпуса
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
/// <summary>
|
||||
/// Шаг перемещения самолета
|
||||
/// </summary>
|
||||
public float Step => Speed * 100 / Weight;
|
||||
/// <summary>
|
||||
/// Инициализация полей объекта-класса самолета
|
||||
/// </summary>
|
||||
/// <param name="speed"></param>
|
||||
/// <param name="weight"></param>
|
||||
/// <param name="bodyColor"></param>
|
||||
/// <returns></returns>
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Random rnd = new();
|
||||
Speed = speed <= 0 ? rnd.Next(350, 550) : speed;
|
||||
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
}
|
||||
}
|
39
ProjectPlane/ProjectPlane/Form1.Designer.cs
generated
39
ProjectPlane/ProjectPlane/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
||||
namespace ProjectPlane
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form1";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
namespace ProjectPlane
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
171
ProjectPlane/ProjectPlane/FormPlane.Designer.cs
generated
Normal file
171
ProjectPlane/ProjectPlane/FormPlane.Designer.cs
generated
Normal file
@ -0,0 +1,171 @@
|
||||
namespace ProjectPlane
|
||||
{
|
||||
partial class FormPlane
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonCreate = new System.Windows.Forms.Button();
|
||||
this.pictureBoxPlane = new System.Windows.Forms.PictureBox();
|
||||
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
||||
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlane)).BeginInit();
|
||||
this.statusStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
this.buttonUp.BackgroundImage = global::ProjectPlane.Properties.Resources.up;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonUp.Location = new System.Drawing.Point(686, 323);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(48, 47);
|
||||
this.buttonUp.TabIndex = 8;
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
this.buttonRight.BackgroundImage = global::ProjectPlane.Properties.Resources.right;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonRight.Location = new System.Drawing.Point(740, 372);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(48, 47);
|
||||
this.buttonRight.TabIndex = 7;
|
||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
this.buttonDown.BackgroundImage = global::ProjectPlane.Properties.Resources.down;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonDown.Location = new System.Drawing.Point(686, 372);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(48, 47);
|
||||
this.buttonDown.TabIndex = 6;
|
||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
this.buttonLeft.BackgroundImage = global::ProjectPlane.Properties.Resources.left;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(632, 372);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(48, 47);
|
||||
this.buttonLeft.TabIndex = 5;
|
||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
this.buttonCreate.BackColor = System.Drawing.SystemColors.ControlLightLight;
|
||||
this.buttonCreate.Location = new System.Drawing.Point(12, 376);
|
||||
this.buttonCreate.Name = "buttonCreate";
|
||||
this.buttonCreate.Size = new System.Drawing.Size(120, 47);
|
||||
this.buttonCreate.TabIndex = 4;
|
||||
this.buttonCreate.Text = "New Plane";
|
||||
this.buttonCreate.UseVisualStyleBackColor = false;
|
||||
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
|
||||
//
|
||||
// pictureBoxPlane
|
||||
//
|
||||
this.pictureBoxPlane.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxPlane.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxPlane.Name = "pictureBoxPlane";
|
||||
this.pictureBoxPlane.Size = new System.Drawing.Size(800, 450);
|
||||
this.pictureBoxPlane.TabIndex = 5;
|
||||
this.pictureBoxPlane.TabStop = false;
|
||||
//
|
||||
// statusStrip1
|
||||
//
|
||||
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripStatusLabelSpeed,
|
||||
this.toolStripStatusLabelWeight,
|
||||
this.toolStripStatusLabelBodyColor});
|
||||
this.statusStrip1.Location = new System.Drawing.Point(0, 428);
|
||||
this.statusStrip1.Name = "statusStrip1";
|
||||
this.statusStrip1.Size = new System.Drawing.Size(800, 22);
|
||||
this.statusStrip1.TabIndex = 9;
|
||||
this.statusStrip1.Text = "statusStrip1";
|
||||
//
|
||||
// toolStripStatusLabelSpeed
|
||||
//
|
||||
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
|
||||
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(39, 17);
|
||||
this.toolStripStatusLabelSpeed.Text = "Speed";
|
||||
//
|
||||
// toolStripStatusLabelWeight
|
||||
//
|
||||
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
|
||||
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(45, 17);
|
||||
this.toolStripStatusLabelWeight.Text = "Weight";
|
||||
//
|
||||
// toolStripStatusLabelBodyColor
|
||||
//
|
||||
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
|
||||
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(36, 17);
|
||||
this.toolStripStatusLabelBodyColor.Text = "Color";
|
||||
//
|
||||
// FormPlane
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.buttonCreate);
|
||||
this.Controls.Add(this.buttonLeft);
|
||||
this.Controls.Add(this.buttonDown);
|
||||
this.Controls.Add(this.buttonRight);
|
||||
this.Controls.Add(this.buttonUp);
|
||||
this.Controls.Add(this.statusStrip1);
|
||||
this.Controls.Add(this.pictureBoxPlane);
|
||||
this.Name = "FormPlane";
|
||||
this.Text = "Plane";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlane)).EndInit();
|
||||
this.statusStrip1.ResumeLayout(false);
|
||||
this.statusStrip1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private Button buttonUp;
|
||||
private Button buttonRight;
|
||||
private Button buttonDown;
|
||||
private Button buttonLeft;
|
||||
private Button buttonCreate;
|
||||
private PictureBox pictureBoxPlane;
|
||||
private StatusStrip statusStrip1;
|
||||
private ToolStripStatusLabel toolStripStatusLabelSpeed;
|
||||
private ToolStripStatusLabel toolStripStatusLabelWeight;
|
||||
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
|
||||
}
|
||||
}
|
67
ProjectPlane/ProjectPlane/FormPlane.cs
Normal file
67
ProjectPlane/ProjectPlane/FormPlane.cs
Normal file
@ -0,0 +1,67 @@
|
||||
namespace ProjectPlane
|
||||
{
|
||||
public partial class FormPlane : Form
|
||||
{
|
||||
private DrawingPlane _plane;
|
||||
|
||||
|
||||
public FormPlane()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
/// <summary>
|
||||
/// Ìåòîä ïðîðèñîâêè ñàìîëåòà
|
||||
/// </summary>
|
||||
private void Draw()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxPlane.Width, pictureBoxPlane.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_plane?.DrawTransport(gr);
|
||||
pictureBoxPlane.Image = bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Ñîçäàòü"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
//ïîëó÷àåì èìÿ êíîïêè
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_plane?.MoveTransport(Direction.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_plane?.MoveTransport(Direction.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_plane?.MoveTransport(Direction.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_plane?.MoveTransport(Direction.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rand = new Random();
|
||||
_plane = new DrawingPlane();
|
||||
_plane.Init(rand.Next(200, 500), rand.Next(2000, 3000),
|
||||
Color.FromArgb(rand.Next(0, 256), rand.Next(0, 256), rand.Next(0, 256)));
|
||||
_plane.SetPosition(rand.Next(5, 100), rand.Next(40, 100),
|
||||
pictureBoxPlane.Width, pictureBoxPlane.Height);
|
||||
toolStripStatusLabelSpeed.Text = $"Speed: {_plane.Plane.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Weiht: {_plane.Plane.Weight}";
|
||||
toolStripStatusLabelBodyColor.Text = $"Color: {_plane.Plane.BodyColor.Name}";
|
||||
Draw();
|
||||
}
|
||||
private void PictureBoxCar_Resize(object sender, EventArgs e)
|
||||
{
|
||||
_plane?.ChangeBorders(pictureBoxPlane.Width, pictureBoxPlane.Height);
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
63
ProjectPlane/ProjectPlane/FormPlane.resx
Normal file
63
ProjectPlane/ProjectPlane/FormPlane.resx
Normal file
@ -0,0 +1,63 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -9,7 +9,7 @@ namespace ProjectPlane
|
||||
static void Main()
|
||||
{
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
Application.Run(new FormPlane());
|
||||
}
|
||||
}
|
||||
}
|
@ -8,4 +8,23 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
103
ProjectPlane/ProjectPlane/Properties/Resources.Designer.cs
generated
Normal file
103
ProjectPlane/ProjectPlane/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ProjectPlane.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||
/// </summary>
|
||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||
// с помощью такого средства, как ResGen или Visual Studio.
|
||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||
// с параметром /str или перестройте свой проект VS.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectPlane.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap down {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("down", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap left {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("left", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap right {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("right", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap up {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("up", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
ProjectPlane/ProjectPlane/Properties/Resources.resx
Normal file
133
ProjectPlane/ProjectPlane/Properties/Resources.resx
Normal file
@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="up" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\up.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="down" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\down.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="left" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\left.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="right" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\right.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
ProjectPlane/ProjectPlane/Resources/down.jpg
Normal file
BIN
ProjectPlane/ProjectPlane/Resources/down.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
BIN
ProjectPlane/ProjectPlane/Resources/left.jpg
Normal file
BIN
ProjectPlane/ProjectPlane/Resources/left.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 55 KiB |
BIN
ProjectPlane/ProjectPlane/Resources/right.jpg
Normal file
BIN
ProjectPlane/ProjectPlane/Resources/right.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 55 KiB |
BIN
ProjectPlane/ProjectPlane/Resources/up.jpg
Normal file
BIN
ProjectPlane/ProjectPlane/Resources/up.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
Loading…
Reference in New Issue
Block a user