ПИбд-21 Кувшинов Тимур 1 лаба простая #1

Closed
TImourka wants to merge 1 commits from laba1 into main
20 changed files with 1326 additions and 0 deletions
Showing only changes of commit 307d615227 - Show all commits

25
Laba1Loco/Laba1Loco.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33424.131
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Laba1Loco", "Laba1Loco\Laba1Loco.csproj", "{9F9C9603-3EF7-403E-A895-04EA0CBC5586}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9F9C9603-3EF7-403E-A895-04EA0CBC5586}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9F9C9603-3EF7-403E-A895-04EA0CBC5586}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9F9C9603-3EF7-403E-A895-04EA0CBC5586}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9F9C9603-3EF7-403E-A895-04EA0CBC5586}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EF8E2621-D5D1-4E60-BC18-2388B1EB5E59}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Laba1Loco
{
public enum Direction
{
/// <summary>
/// Вверх
/// </summary>
Up = 1,
/// <summary>
/// Вниз
/// </summary>
Down = 2,
/// <summary>
/// Влево
/// </summary>
Left = 3,
/// <summary>
/// Вправо
/// </summary>
Right = 4
}
}

View File

@ -0,0 +1,393 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Laba1Loco
{
internal class DrawingLoco
{
/// <summary>
/// Класс-сущность
/// </summary>
public EntityLoco EntityLoco { get; private set; }
/// <summary>
/// Ширина окна
/// </summary>
private int _pictureWidth;
/// <summary>
/// Высота окна
/// </summary>
private int _pictureHeight;
/// <summary>
/// Левая координата прорисовки локомотива
/// </summary>
private int _startPosX;
/// <summary>
/// Верхняя кооридната прорисовки локомотива
/// </summary>
private int _startPosY;
/// <summary>
/// Ширина прорисовки локомотива
/// </summary>
private int _locoWidth => (EntityLoco?.FuelTank ?? false) ? 169 : 83;
/// <summary>
/// Высота прорисовки локомотива
/// </summary>
private readonly int _locoHeight = 41;
/// <summary>
/// Инициализация свойств
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Цвет кузова</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="tube">Признак наличия трубы</param>
/// <param name="fuelTank">Признак наличия бака</param>
/// <param name="locoLine">Признак наличия паровозной полосы</param>
/// <param name="width">Ширина картинки</param>
/// <param name="height">Высота картинки</param>
/// <returns>true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах</returns>
public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool tube, bool fuelTank, bool locoLine, int width, int height)
{
_pictureWidth = width;
_pictureHeight = height;
if (_pictureHeight < _locoHeight || _pictureWidth < _locoWidth)
Review

Сначала выполняются проверки и только потом, если они пройдены успешно, запоминаются данные

Сначала выполняются проверки и только потом, если они пройдены успешно, запоминаются данные
return false;
EntityLoco = new EntityLoco();
EntityLoco.Init(speed, weight, bodyColor, additionalColor, tube, fuelTank, locoLine);
return true;
}
/// <summary>
/// Установка позиции
/// </summary>
/// <param name="x">Координата X</param>
/// <param name="y">Координата Y</param>
public void SetPosition(int x, int y)
{
_startPosX = Math.Min(x, _pictureWidth-_locoWidth);
Review

Не учтены все условия, при которых объект может выйти за границы

Не учтены все условия, при которых объект может выйти за границы
_startPosY = Math.Min(y, _pictureHeight-_locoHeight);
}
/// <summary>
/// Изменение направления перемещения
/// </summary>
/// <param name="direction">Направление</param>
public void MoveTransport(Direction direction)
{
if (EntityLoco == null){
return;
}
switch (direction)
{
//влево
case Direction.Left:
if (_startPosX - EntityLoco.Step > 0)
{
_startPosX -= (int)EntityLoco.Step;
}
break;
//вверх
case Direction.Up:
if (_startPosY - EntityLoco.Step > 0)
{
_startPosY -= (int)EntityLoco.Step;
}
break;
// вправо
case Direction.Right:
if (_startPosX + _locoWidth + EntityLoco.Step < _pictureWidth)
{
_startPosX += (int)EntityLoco.Step;
}
break;
//вниз
case Direction.Down:
if (_startPosY + _locoHeight + EntityLoco.Step < _pictureHeight)
{
_startPosY += (int)EntityLoco.Step;
}
break;
}
}
/// <summary>
/// класс облака
/// </summary>
class cloud
Review

Встроенных классов быть не должно

Встроенных классов быть не должно
{
/// <summary>
/// просто рандом
/// </summary>
Random random;
/// <summary>
/// координаты облака
/// </summary>
int x, y;
/// <summary>
/// размер облака
/// </summary>
int size;
/// <summary>
/// прозрачность облака
/// </summary>
public int opasity;
/// <summary>
/// intialisation облака
/// </summary>
/// <param name="x_">координата облака по горизонтали</param>
/// <param name="y_">координата облака по вертикали</param>
public cloud(int x_, int y_)
{
random = new Random();
x = x_;
y = y_ - 5;
size = 10;
opasity = 255;
}
/// <summary>
/// шаг времени для облака
/// </summary>
public void timeTick()
{
y -= 3;
size += 5;
opasity -= 20;
/// добавляем случайности
y += random.Next(-1, 2);
x += random.Next(-1, 2);
size += random.Next(-1, 2);
opasity += random.Next(-1, 2);
}
/// <summary>
/// отрисовка облака
/// </summary>
/// <param name="g"></param>
public void Draw(Graphics g)
{
g.DrawEllipse(new Pen(Color.FromArgb(opasity, Pens.Gray.Color)), x - size / 2, y-size/2, size, size);
}
}
/// <summary>
/// массив облачков
/// </summary>
List<cloud> clouds = new List<cloud>();
/// <summary>
/// шаг времени для облаков
/// </summary>
public void timeTick()
{
if (EntityLoco != null)
{
if (clouds.Count < 10)
clouds.Add(new cloud(_startPosX+40, EntityLoco.Tube ? _startPosY : _startPosY + 9));
}
for (int i = 0; i < clouds.Count; i++)
{
if (i < clouds.Count)
{
clouds[i].timeTick();
if (clouds[i].opasity < 20)
{
clouds.RemoveAt(i);
}
}
}
}
/// <summary>
/// Прорисовка объекта
/// </summary>
/// <param name="g"></param>
public void DrawTransport(Graphics g)
{
if (EntityLoco == null)
{
return;
}
Pen pen = new Pen(EntityLoco.BodyColor);
Brush brush = new SolidBrush(EntityLoco.BodyColor);
Pen additionalPen = new Pen(EntityLoco.AdditionalColor);
Brush additionalBrush = new SolidBrush(EntityLoco.AdditionalColor);
//smoke
foreach(var it in clouds){
it.Draw(g);
}
// body
g.DrawLines(pen,
new Point[] {
new Point(_startPosX + 8, _startPosY+10),
new Point(_startPosX + 79, _startPosY+10),
new Point(_startPosX + 79, _startPosY+32),
new Point(_startPosX + 4, _startPosY+32),
new Point(_startPosX + 4, _startPosY+20),
new Point(_startPosX + 8, _startPosY+10),
}
);
g.DrawLines(pen,
new Point[] {
new Point(_startPosX + 4, _startPosY+21),
new Point(_startPosX + 29, _startPosY+21),
new Point(_startPosX + 29, _startPosY+14),
new Point(_startPosX + 37, _startPosY+14),
new Point(_startPosX + 37, _startPosY+21),
new Point(_startPosX + 79, _startPosY+21),
new Point(_startPosX + 37, _startPosY+21),
new Point(_startPosX + 37, _startPosY+29),
new Point(_startPosX + 29, _startPosY+29),
new Point(_startPosX + 29, _startPosY+21),
}
);
// trucks
g.FillPolygon(brush,
new Point[] {
new Point(_startPosX + 0, _startPosY+37),
new Point(_startPosX + 5, _startPosY+33),
new Point(_startPosX + 32, _startPosY+33),
new Point(_startPosX + 36, _startPosY+37),
}
);
g.FillPolygon(brush,
new Point[] {
new Point(_startPosX + 44, _startPosY+37),
new Point(_startPosX + 49, _startPosY+33),
new Point(_startPosX + 76, _startPosY+33),
new Point(_startPosX + 80, _startPosY+37),
}
);
//back
g.FillPolygon(brush,
new Point[] {
new Point(_startPosX + 79, _startPosY+12),
new Point(_startPosX + 82, _startPosY+12),
new Point(_startPosX + 82, _startPosY+30),
new Point(_startPosX + 79, _startPosY+30),
}
);
//windows
g.DrawRectangle(Pens.Blue, _startPosX + 10, _startPosY + 12, 6, 7);
g.DrawRectangle(Pens.Blue, _startPosX + 19, _startPosY + 12, 6, 7);
g.DrawRectangle(Pens.Blue, _startPosX + 72, _startPosY + 12, 6, 7);
//wheels
g.FillEllipse(brush, _startPosX + 3, _startPosY + 34, 8, 8);
g.FillEllipse(additionalBrush, _startPosX + 4, _startPosY + 35, 6, 6);
g.FillEllipse(brush, _startPosX + 26, _startPosY + 34, 8, 8);
g.FillEllipse(additionalBrush, _startPosX + 27, _startPosY + 35, 6, 6);
g.FillEllipse(brush, _startPosX + 46, _startPosY + 34, 8, 8);
g.FillEllipse(additionalBrush, _startPosX + 47, _startPosY + 35, 6, 6);
g.FillEllipse(brush, _startPosX + 72, _startPosY + 34, 8, 8);
g.FillEllipse(additionalBrush, _startPosX + 73, _startPosY + 35, 6, 6);
if (EntityLoco.Tube)
{
g.DrawLines(additionalPen,
new Point[] {
new Point(_startPosX + 40, _startPosY+9),
new Point(_startPosX + 40, _startPosY+3),
new Point(_startPosX + 45, _startPosY+3),
new Point(_startPosX + 41, _startPosY+3),
new Point(_startPosX + 41, _startPosY),
new Point(_startPosX + 44, _startPosY),
new Point(_startPosX + 44, _startPosY+3),
new Point(_startPosX + 45, _startPosY+3),
new Point(_startPosX + 45, _startPosY+9),
});
}
if (EntityLoco.LocoLine)
{
g.DrawLines(additionalPen,
new Point[] {
new Point(_startPosX + 60, _startPosY+10),
new Point(_startPosX + 38, _startPosY+32),
});
g.DrawLines(additionalPen,
new Point[] {
new Point(_startPosX + 65, _startPosY+10),
new Point(_startPosX + 43, _startPosY+32),
});
g.DrawLines(additionalPen,
new Point[] {
new Point(_startPosX + 70, _startPosY+10),
new Point(_startPosX + 48, _startPosY+32),
});
}
if (EntityLoco.FuelTank)
{
// body
g.DrawLines(pen,
new Point[] {
new Point(_startPosX + 89, _startPosY+10),
new Point(_startPosX + 164, _startPosY+10),
new Point(_startPosX + 164, _startPosY+32),
new Point(_startPosX + 89, _startPosY+32),
new Point(_startPosX + 89, _startPosY+10),
}
);
g.DrawLines(pen,
new Point[] {
new Point(_startPosX + 89, _startPosY+21),
new Point(_startPosX + 164, _startPosY+21),
}
);
// trucks
g.FillPolygon(brush,
new Point[] {
new Point(_startPosX + 0+85, _startPosY+37),
new Point(_startPosX + 5+85, _startPosY+33),
new Point(_startPosX + 32+85, _startPosY+33),
new Point(_startPosX + 36+85, _startPosY+37),
}
);
g.FillPolygon(brush,
new Point[] {
new Point(_startPosX + 44+85, _startPosY+37),
new Point(_startPosX + 49+85, _startPosY+33),
new Point(_startPosX + 76+85, _startPosY+33),
new Point(_startPosX + 80+85, _startPosY+37),
}
);
//front
g.FillPolygon(brush,
new Point[] {
new Point(_startPosX + 86, _startPosY+12),
new Point(_startPosX + 89, _startPosY+12),
new Point(_startPosX + 89, _startPosY+30),
new Point(_startPosX + 86, _startPosY+30),
}
);
//back
g.FillPolygon(brush,
new Point[] {
new Point(_startPosX + 79+85, _startPosY+12),
new Point(_startPosX + 82+85, _startPosY+12),
new Point(_startPosX + 82+85, _startPosY+30),
new Point(_startPosX + 79+85, _startPosY+30),
}
);
//wheels
g.FillEllipse(brush, _startPosX + 3 + 85, _startPosY + 34, 8, 8);
g.FillEllipse(additionalBrush, _startPosX + 4, _startPosY + 35, 6, 6);
g.FillEllipse(brush, _startPosX + 26 + 85, _startPosY + 34, 8, 8);
g.FillEllipse(additionalBrush, _startPosX + 27, _startPosY + 35, 6, 6);
g.FillEllipse(brush, _startPosX + 46 + 85, _startPosY + 34, 8, 8);
g.FillEllipse(additionalBrush, _startPosX + 47, _startPosY + 35, 6, 6);
g.FillEllipse(brush, _startPosX + 72 + 85, _startPosY + 34, 8, 8);
g.FillEllipse(additionalBrush, _startPosX + 73, _startPosY + 35, 6, 6);
}
}
}
}

View File

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Laba1Loco
{
internal class EntityLoco
{
/// <summary>
/// Скорость
/// </summary>
public int Speed { get; private set; }
/// <summary>
/// Вес
/// </summary>
public double Weight { get; private set; }
/// <summary>
/// Основной цвет
/// </summary>
public Color BodyColor { get; private set; }
/// <summary>
/// Дополнительный цвет (для опциональных элементов)
/// </summary>
public Color AdditionalColor { get; private set; }
/// <summary>
/// Признак (опция) наличия трубы
/// </summary>
public bool Tube { get; private set; }
/// <summary>
/// Признак (опция) наличия топливного бака
/// </summary>
public bool FuelTank { get; private set; }
/// <summary>
/// Признак (опция) наличия паровозной полосы
/// </summary>
public bool LocoLine { get; private set; }
/// <summary>
/// Шаг перемещения поезда
/// </summary>
public double Step => (double)Speed * 100 / Weight;
/// <summary>
/// Инициализация полей объекта-класса Локомотива
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес автомобиля</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="tube">Признак наличия трубы</param>
/// <param name="fuelTank">Признак наличия бака</param>
/// <param name="locoLine">Признак наличия паровозной полосы</param>
public void Init(int speed, double weight, Color bodyColor, Color
additionalColor, bool tube, bool fuelTank, bool locoLine)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
AdditionalColor = additionalColor;
Tube = tube;
FuelTank = fuelTank;
LocoLine = locoLine;
}
}
}

View File

@ -0,0 +1,140 @@
namespace Laba1Loco
{
partial class FormLocomotive
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором форм Windows
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.pictureBox = new System.Windows.Forms.PictureBox();
this.create = new System.Windows.Forms.Button();
this.left = new System.Windows.Forms.Button();
this.up = new System.Windows.Forms.Button();
this.down = new System.Windows.Forms.Button();
this.right = new System.Windows.Forms.Button();
this.timer1 = new System.Windows.Forms.Timer(this.components);
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
this.SuspendLayout();
//
// pictureBox
//
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox.Location = new System.Drawing.Point(0, 0);
this.pictureBox.Name = "pictureBox";
this.pictureBox.Size = new System.Drawing.Size(800, 450);
this.pictureBox.TabIndex = 0;
this.pictureBox.TabStop = false;
//
// create
//
this.create.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.create.Location = new System.Drawing.Point(12, 415);
this.create.Name = "create";
this.create.Size = new System.Drawing.Size(75, 23);
this.create.TabIndex = 1;
this.create.Text = "create";
this.create.UseVisualStyleBackColor = true;
this.create.Click += new System.EventHandler(this.create_Click);
//
// left
//
this.left.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.left.Image = global::Laba1Loco.Properties.Resources.arowL340x259;
this.left.Location = new System.Drawing.Point(632, 390);
this.left.Name = "left";
this.left.Size = new System.Drawing.Size(48, 48);
this.left.TabIndex = 3;
this.left.UseVisualStyleBackColor = true;
this.left.Click += new System.EventHandler(this.Click);
//
// up
//
this.up.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.up.Image = global::Laba1Loco.Properties.Resources.arowUp340x259;
this.up.Location = new System.Drawing.Point(686, 336);
this.up.Name = "up";
this.up.Size = new System.Drawing.Size(48, 48);
this.up.TabIndex = 4;
this.up.UseVisualStyleBackColor = true;
this.up.Click += new System.EventHandler(this.Click);
//
// down
//
this.down.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.down.Image = global::Laba1Loco.Properties.Resources.arowDown340x259;
this.down.Location = new System.Drawing.Point(686, 390);
this.down.Name = "down";
this.down.Size = new System.Drawing.Size(48, 48);
this.down.TabIndex = 5;
this.down.UseVisualStyleBackColor = true;
this.down.Click += new System.EventHandler(this.Click);
//
// right
//
this.right.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.right.Image = global::Laba1Loco.Properties.Resources.arowR340x259;
this.right.Location = new System.Drawing.Point(740, 390);
this.right.Name = "right";
this.right.Size = new System.Drawing.Size(48, 48);
this.right.TabIndex = 6;
this.right.UseVisualStyleBackColor = true;
this.right.Click += new System.EventHandler(this.Click);
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// FormLocomotive
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.right);
this.Controls.Add(this.down);
this.Controls.Add(this.up);
this.Controls.Add(this.left);
this.Controls.Add(this.create);
this.Controls.Add(this.pictureBox);
this.Name = "FormLocomotive";
this.Text = "Locomotive(moving)";
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PictureBox pictureBox;
private System.Windows.Forms.Button create;
private System.Windows.Forms.Button left;
private System.Windows.Forms.Button up;
private System.Windows.Forms.Button down;
private System.Windows.Forms.Button right;
private System.Windows.Forms.Timer timer1;
}
}

View File

@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Laba1Loco
{
public partial class FormLocomotive : Form
{
/// <summary>
/// Поле-объект для прорисовки объекта
/// </summary>
private DrawingLoco _drawingLoco;
/// <summary>
/// Инициализация формы
/// </summary>
public FormLocomotive()
{
InitializeComponent();
}
/// <summary>
/// Метод прорисовки локомотива
/// </summary>
private void Draw()
{
if (_drawingLoco == null)
{
return;
}
Bitmap bmp = new Bitmap(pictureBox.Width, pictureBox.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawingLoco.DrawTransport(gr);
pictureBox.Image = bmp;
}
/// <summary>
/// Обработка нажатия кнопки "Создать"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void create_Click(object sender, EventArgs e)
{
Random random = new Random();
_drawingLoco = new DrawingLoco();
_drawingLoco.Init(random.Next(100, 300), random.Next(2000, 4000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), pictureBox.Width, pictureBox.Height);
_drawingLoco.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
/// <summary>
/// клик движения мышки
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Click(object sender, EventArgs e)
{
if (_drawingLoco == null)
{
return;
}
string name = ((Button)sender)?.Name ?? string.Empty;
switch (name)
{
case "up":
_drawingLoco.MoveTransport(Direction.Up);
break;
case "down":
_drawingLoco.MoveTransport(Direction.Down);
break;
case "left":
_drawingLoco.MoveTransport(Direction.Left);
break;
case "right":
_drawingLoco.MoveTransport(Direction.Right);
break;
}
Draw();
}
/// <summary>
/// таймер для дымка
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void timer1_Tick(object sender, EventArgs e)
{
if (_drawingLoco != null)
_drawingLoco.timeTick();
Draw();
}
}
}

View File

@ -0,0 +1,123 @@
<?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>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9F9C9603-3EF7-403E-A895-04EA0CBC5586}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Laba1Loco</RootNamespace>
<AssemblyName>Laba1Loco</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Direction.cs" />
<Compile Include="DrawingLoco.cs" />
<Compile Include="EntityLoco.cs" />
<Compile Include="FormLocomotive.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormLocomotive.Designer.cs">
<DependentUpon>FormLocomotive.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="FormLocomotive.resx">
<DependentUpon>FormLocomotive.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<None Include="arow340x259.png" />
</ItemGroup>
<ItemGroup>
<None Include="arowDown340x259.png" />
</ItemGroup>
<ItemGroup>
<None Include="arowL340x259.png" />
</ItemGroup>
<ItemGroup>
<None Include="arowR340x259.png" />
</ItemGroup>
<ItemGroup>
<None Include="arowUp340x259.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Laba1Loco
{
internal static class Program
{
/// <summary>
/// Главная точка входа для приложения.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormLocomotive());
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
// связанных со сборкой.
[assembly: AssemblyTitle("Laba1Loco")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Laba1Loco")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// COM, следует установить атрибут ComVisible в TRUE для этого типа.
[assembly: ComVisible(false)]
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
[assembly: Guid("9f9c9603-3ef7-403e-a895-04ea0cbc5586")]
// Сведения о версии сборки состоят из указанных ниже четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Редакция
//
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,113 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Laba1Loco.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("Laba1Loco.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 arow340x259 {
get {
object obj = ResourceManager.GetObject("arow340x259", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arowDown340x259 {
get {
object obj = ResourceManager.GetObject("arowDown340x259", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arowL340x259 {
get {
object obj = ResourceManager.GetObject("arowL340x259", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arowR340x259 {
get {
object obj = ResourceManager.GetObject("arowR340x259", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arowUp340x259 {
get {
object obj = ResourceManager.GetObject("arowUp340x259", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,136 @@
<?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="arow340x259" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\arow340x259.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arowDown340x259" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\arowDown340x259.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arowL340x259" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\arowL340x259.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arowR340x259" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\arowR340x259.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="arowUp340x259" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\arowUp340x259.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Laba1Loco.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

Binary file not shown.

After

Width:  |  Height:  |  Size: 541 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 541 B