Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
853473e882 | |||
d4bfe1ad10 | |||
a575319b6c | |||
|
eeb472e8b0 | ||
|
dfb7f4306e |
29
ProjectCleaningCar/ProjectCleaningCar/DirectionType.cs
Normal file
29
ProjectCleaningCar/ProjectCleaningCar/DirectionType.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectCleaningCar;
|
||||
/// <summary>
|
||||
/// Направление перемещения
|
||||
/// </summary>
|
||||
public enum DirectionType
|
||||
{
|
||||
/// <summary>
|
||||
/// Вверх
|
||||
/// </summary>
|
||||
Up = 1,
|
||||
/// <summary>
|
||||
/// Вниз
|
||||
/// </summary>
|
||||
Down = 2,
|
||||
/// <summary>
|
||||
/// Влево
|
||||
/// </summary>
|
||||
Left = 3,
|
||||
/// <summary>
|
||||
/// Вправо
|
||||
/// </summary>
|
||||
Right = 4
|
||||
}
|
208
ProjectCleaningCar/ProjectCleaningCar/DrawningCleaningCar.cs
Normal file
208
ProjectCleaningCar/ProjectCleaningCar/DrawningCleaningCar.cs
Normal file
@ -0,0 +1,208 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectCleaningCar;
|
||||
/// <summary>
|
||||
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
||||
/// </summary>
|
||||
public class DrawningCleaningCar
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
/// </summary>
|
||||
public EntityCleaningCar? EntityCleaningCar { get; private set; }
|
||||
/// <summary>
|
||||
/// Ширина окна
|
||||
/// </summary>
|
||||
private int? _pictureWidth = null;
|
||||
/// <summary>
|
||||
/// Высота окна
|
||||
/// </summary>
|
||||
private int? _pictureHeight = null;
|
||||
/// <summary>
|
||||
/// Левая координата прорисовки автомобиля
|
||||
/// </summary>
|
||||
private int? _startPosX;
|
||||
/// <summary>
|
||||
/// Верхняя координата прорисовки автомобиля
|
||||
/// </summary>
|
||||
private int? _startPosY;
|
||||
/// <summary>
|
||||
/// Ширина прорисовки автомобиля
|
||||
/// </summary>
|
||||
private readonly int _drawningCleaningCarWidth = 150;
|
||||
/// <summary>
|
||||
/// Высота прорисовки автомобиля
|
||||
/// </summary>
|
||||
private readonly int _drawningCleaningCarHeight = 80;
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="waterTank">Признак наличия бака под воду</param>
|
||||
/// <param name="sweepingBrush">Признак наличия </param>
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor,
|
||||
bool waterTank, bool sweepingBrush)
|
||||
{
|
||||
EntityCleaningCar = new EntityCleaningCar();
|
||||
EntityCleaningCar.Init(speed, weight, bodyColor, additionalColor, waterTank, sweepingBrush);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Установка границ поля
|
||||
/// </summary>
|
||||
/// <param name="width">Ширина поля</param>
|
||||
/// <param name="height">Высота поля</param>
|
||||
/// <returns>true - границы заданы, false - проверка не найдена, нельзя разместить
|
||||
/// объект в этих размерах</returns>
|
||||
public Boolean SetPictureSize(int width, int height)
|
||||
{
|
||||
if (width <= _drawningCleaningCarWidth || height <= _drawningCleaningCarHeight) return false;
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
if (_startPosX.HasValue && _startPosY.HasValue)
|
||||
{
|
||||
if (_startPosX + _drawningCleaningCarWidth > _pictureWidth)
|
||||
{
|
||||
_startPosX = _pictureWidth.Value - _drawningCleaningCarWidth;
|
||||
}
|
||||
if (_startPosY + _drawningCleaningCarHeight > _pictureHeight)
|
||||
{
|
||||
_startPosY = _pictureHeight.Value - _drawningCleaningCarHeight;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Установка позиция
|
||||
/// </summary>
|
||||
/// <param name="x">Координата Х</param>
|
||||
/// <param name="y">Координата Y</param>
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
|
||||
if (_drawningCleaningCarHeight + y > _pictureHeight || y < 0)
|
||||
{
|
||||
_startPosY = 0;
|
||||
}
|
||||
if (_drawningCleaningCarWidth + x > _pictureWidth || x < 0)
|
||||
{
|
||||
_startPosX = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменение направления перемещения
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
/// <returns>true - перемещение выполнено, false - перемещение невозможно</returns>
|
||||
public bool MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (EntityCleaningCar == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
// Влево
|
||||
case DirectionType.Left:
|
||||
if (_startPosX.Value - EntityCleaningCar.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityCleaningCar.Step;
|
||||
}
|
||||
return true;
|
||||
// Вверх
|
||||
case DirectionType.Up:
|
||||
if (_startPosY.Value - EntityCleaningCar.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityCleaningCar.Step;
|
||||
}
|
||||
return true;
|
||||
// Вправо
|
||||
case DirectionType.Right:
|
||||
if (_startPosX.Value + _drawningCleaningCarWidth + EntityCleaningCar.Step < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityCleaningCar.Step;
|
||||
}
|
||||
return true;
|
||||
// Вниз
|
||||
case DirectionType.Down:
|
||||
if (_startPosY.Value + _drawningCleaningCarHeight + EntityCleaningCar.Step < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityCleaningCar.Step;
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Прорисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityCleaningCar == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue) return;
|
||||
Pen pen = new Pen(Color.Black);
|
||||
Brush additionalBrush = new SolidBrush(EntityCleaningCar.AdditionalColor);
|
||||
|
||||
// Границы подметально-уборочной машины
|
||||
Brush br = new SolidBrush(EntityCleaningCar.BodyColor);
|
||||
// Платформа
|
||||
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 40, 100, 20);
|
||||
g.FillRectangle(br, _startPosX.Value, _startPosY.Value + 40, 100, 20);
|
||||
// Кабина
|
||||
g.DrawRectangle(pen, _startPosX.Value + 80, _startPosY.Value, 20, 40);
|
||||
g.FillRectangle(br, _startPosX.Value + 80, _startPosY.Value, 20, 40);
|
||||
// Колёса
|
||||
Brush brBlack = new SolidBrush(Color.Black);
|
||||
g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 60, 20, 20);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 25, _startPosY.Value + 60, 20, 20);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 80, _startPosY.Value + 60, 20, 20);
|
||||
g.FillEllipse(brBlack, _startPosX.Value, _startPosY.Value + 60, 20, 20);
|
||||
g.FillEllipse(brBlack, _startPosX.Value + 25, _startPosY.Value + 60, 20, 20);
|
||||
g.FillEllipse(brBlack, _startPosX.Value + 80, _startPosY.Value + 60, 20, 20);
|
||||
// Окно
|
||||
Brush brBlue = new SolidBrush(Color.LightBlue);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 85, _startPosY.Value + 5, 10, 15);
|
||||
g.FillRectangle(brBlue, _startPosX.Value + 85, _startPosY.Value + 5, 10, 15);
|
||||
//Бак под воду
|
||||
if (EntityCleaningCar.WaterTank)
|
||||
{
|
||||
g.FillEllipse(additionalBrush, _startPosX.Value, _startPosY.Value, 80, 40);
|
||||
g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value, 80, 40);
|
||||
}
|
||||
// Щётка
|
||||
if (EntityCleaningCar.SweepingBrush)
|
||||
{
|
||||
g.DrawRectangle(pen, _startPosX.Value + 100, _startPosY.Value + 50, 30, 5);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 100, _startPosY.Value + 50, 30, 5);
|
||||
Point[] sweepingBrush =
|
||||
{
|
||||
new Point(_startPosX.Value + 130, _startPosY.Value + 50),
|
||||
new Point(_startPosX.Value + 150, _startPosY.Value + 80),
|
||||
new Point(_startPosX.Value + 110, _startPosY.Value + 80),
|
||||
};
|
||||
g.FillPolygon(additionalBrush, sweepingBrush);
|
||||
g.DrawPolygon(pen, sweepingBrush);
|
||||
}
|
||||
}
|
||||
}
|
60
ProjectCleaningCar/ProjectCleaningCar/EntityCleaningCar.cs
Normal file
60
ProjectCleaningCar/ProjectCleaningCar/EntityCleaningCar.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectCleaningCar;
|
||||
/// <summary>
|
||||
/// Класс-сущность "Подметально-уборочная машина"
|
||||
/// </summary>
|
||||
public class EntityCleaningCar
|
||||
{
|
||||
/// <summary>
|
||||
/// Скорость
|
||||
/// </summary>
|
||||
public int Speed { get; set; }
|
||||
/// <summary>
|
||||
/// Вес
|
||||
/// </summary>
|
||||
public double Weight { get; set; }
|
||||
/// <summary>
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
/// <summary>
|
||||
/// Дополнительный цвет (для опциональных элементов)
|
||||
/// </summary>
|
||||
public Color AdditionalColor { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия бака под воду
|
||||
/// </summary>
|
||||
public bool WaterTank { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия подметательной щётки
|
||||
/// </summary>
|
||||
public bool SweepingBrush { get; private set; }
|
||||
/// <summary>
|
||||
/// Шаг перемещения подметательно-уборочной машины
|
||||
/// </summary>
|
||||
public double Step => Speed * 200 / Weight;
|
||||
/// <summary>
|
||||
/// Инициализация полей объекта-класса подметально-уборочной машины
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес автомобиля</param>
|
||||
/// <param name="bodeColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="waterTank">Признак наличия бака под воду</param>
|
||||
/// <param name="sweepingBrush">Признак наличия подметательной щётки</param>
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor,
|
||||
bool waterTank, bool sweepingBrush)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
AdditionalColor = additionalColor;
|
||||
WaterTank = waterTank;
|
||||
SweepingBrush = sweepingBrush;
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
namespace ProjectCleaningCar
|
||||
{
|
||||
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 ProjectCleaningCar
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
139
ProjectCleaningCar/ProjectCleaningCar/FormCleaningCar.Designer.cs
generated
Normal file
139
ProjectCleaningCar/ProjectCleaningCar/FormCleaningCar.Designer.cs
generated
Normal file
@ -0,0 +1,139 @@
|
||||
namespace ProjectCleaningCar
|
||||
{
|
||||
partial class FormCleaningCar
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
pictureBoxCleaningCar = new PictureBox();
|
||||
buttonCreate = new Button();
|
||||
ButtonUp = new Button();
|
||||
ButtonRight = new Button();
|
||||
ButtonLeft = new Button();
|
||||
ButtonDown = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCleaningCar).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBoxCleaningCar
|
||||
//
|
||||
pictureBoxCleaningCar.Dock = DockStyle.Fill;
|
||||
pictureBoxCleaningCar.Location = new Point(0, 0);
|
||||
pictureBoxCleaningCar.Name = "pictureBoxCleaningCar";
|
||||
pictureBoxCleaningCar.Size = new Size(884, 461);
|
||||
pictureBoxCleaningCar.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||
pictureBoxCleaningCar.TabIndex = 1;
|
||||
pictureBoxCleaningCar.TabStop = false;
|
||||
pictureBoxCleaningCar.Click += buttonMove_Click;
|
||||
pictureBoxCleaningCar.Resize += new System.EventHandler(this.PictureBox_Resize);
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreate.Location = new Point(23, 382);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(124, 42);
|
||||
buttonCreate.TabIndex = 2;
|
||||
buttonCreate.Text = "Создать";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreateCleaningCar;
|
||||
//
|
||||
// ButtonUp
|
||||
//
|
||||
ButtonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
ButtonUp.BackgroundImage = Properties.Resources._1614525823_30_p_strelka_na_belom_fone_33__Up_;
|
||||
ButtonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
ButtonUp.Location = new Point(761, 373);
|
||||
ButtonUp.Name = "ButtonUp";
|
||||
ButtonUp.Size = new Size(30, 30);
|
||||
ButtonUp.TabIndex = 3;
|
||||
ButtonUp.UseVisualStyleBackColor = true;
|
||||
ButtonUp.Click += buttonMove_Click;
|
||||
//
|
||||
// ButtonRight
|
||||
//
|
||||
ButtonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
ButtonRight.BackgroundImage = Properties.Resources._1614525823_30_p_strelka_na_belom_fone__Right_;
|
||||
ButtonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
ButtonRight.Location = new Point(797, 409);
|
||||
ButtonRight.Name = "ButtonRight";
|
||||
ButtonRight.Size = new Size(30, 30);
|
||||
ButtonRight.TabIndex = 4;
|
||||
ButtonRight.UseVisualStyleBackColor = true;
|
||||
ButtonRight.Click += buttonMove_Click;
|
||||
//
|
||||
// ButtonLeft
|
||||
//
|
||||
ButtonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
ButtonLeft.BackgroundImage = Properties.Resources._1614525823_30_p_strelka_na_belom_fone_33__Left_;
|
||||
ButtonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
ButtonLeft.Location = new Point(725, 409);
|
||||
ButtonLeft.Name = "ButtonLeft";
|
||||
ButtonLeft.Size = new Size(30, 30);
|
||||
ButtonLeft.TabIndex = 5;
|
||||
ButtonLeft.UseVisualStyleBackColor = true;
|
||||
ButtonLeft.Click += buttonMove_Click;
|
||||
//
|
||||
// ButtonDown
|
||||
//
|
||||
ButtonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
ButtonDown.BackgroundImage = Properties.Resources._1614525823_30_p_strelka_na_belom_fone_33__Down_;
|
||||
ButtonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
ButtonDown.Location = new Point(761, 409);
|
||||
ButtonDown.Name = "ButtonDown";
|
||||
ButtonDown.Size = new Size(30, 30);
|
||||
ButtonDown.TabIndex = 6;
|
||||
ButtonDown.UseVisualStyleBackColor = true;
|
||||
ButtonDown.Click += buttonMove_Click;
|
||||
//
|
||||
// FormCleaningCar
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(884, 461);
|
||||
Controls.Add(ButtonDown);
|
||||
Controls.Add(ButtonLeft);
|
||||
Controls.Add(ButtonRight);
|
||||
Controls.Add(ButtonUp);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(pictureBoxCleaningCar);
|
||||
Name = "FormCleaningCar";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Подметально-уборочная машина";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCleaningCar).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxCleaningCar;
|
||||
private Button buttonCreate;
|
||||
private Button ButtonUp;
|
||||
private Button ButtonRight;
|
||||
private Button ButtonLeft;
|
||||
private Button ButtonDown;
|
||||
}
|
||||
}
|
102
ProjectCleaningCar/ProjectCleaningCar/FormCleaningCar.cs
Normal file
102
ProjectCleaningCar/ProjectCleaningCar/FormCleaningCar.cs
Normal file
@ -0,0 +1,102 @@
|
||||
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 ProjectCleaningCar
|
||||
{
|
||||
/// <summary>
|
||||
/// Форма работы с объектом "Подметально-уборочная машина"
|
||||
/// </summary>
|
||||
public partial class FormCleaningCar : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Поле-объект для прорисовки объекта
|
||||
/// </summary>
|
||||
private DrawningCleaningCar? _drawningCleaningCar;
|
||||
/// <summary>
|
||||
/// Конструктор формы
|
||||
/// </summary>
|
||||
public FormCleaningCar()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningCleaningCar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (pictureBoxCleaningCar.Width == 0 || pictureBoxCleaningCar.Height == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureBoxCleaningCar.Width, pictureBoxCleaningCar.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningCleaningCar.DrawTransport(gr);
|
||||
pictureBoxCleaningCar.Image = bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Создать".
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonCreateCleaningCar(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
_drawningCleaningCar = new DrawningCleaningCar();
|
||||
_drawningCleaningCar.Init(random.Next(100, 300), random.Next(1000, 3000),
|
||||
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)));
|
||||
_drawningCleaningCar.SetPictureSize(pictureBoxCleaningCar.Width, pictureBoxCleaningCar.Height);
|
||||
_drawningCleaningCar.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
/// <summary>
|
||||
/// Перемещение объекта по форме (нажатие кнопок навигации)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningCleaningCar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (pictureBoxCleaningCar.Width == 0 || pictureBoxCleaningCar.Height == 0) return;
|
||||
string name = (sender as Control)?.Name ?? string.Empty;
|
||||
bool result = false;
|
||||
switch (name)
|
||||
{
|
||||
case "ButtonUp":
|
||||
result = _drawningCleaningCar.MoveTransport(DirectionType.Up);
|
||||
break;
|
||||
case "ButtonDown":
|
||||
result = _drawningCleaningCar.MoveTransport(DirectionType.Down);
|
||||
break;
|
||||
case "ButtonLeft":
|
||||
result = _drawningCleaningCar.MoveTransport(DirectionType.Left);
|
||||
break;
|
||||
case "ButtonRight":
|
||||
result = _drawningCleaningCar.MoveTransport(DirectionType.Right);
|
||||
break;
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
private void PictureBox_Resize(object sender, EventArgs e)
|
||||
{
|
||||
_drawningCleaningCar?.SetPictureSize(pictureBoxCleaningCar.Width, pictureBoxCleaningCar.Height);
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
<?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
|
||||
|
||||
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>
|
||||
@ -26,36 +26,36 @@
|
||||
<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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
@ -11,7 +11,7 @@ namespace ProjectCleaningCar
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
Application.Run(new FormCleaningCar());
|
||||
}
|
||||
}
|
||||
}
|
@ -8,4 +8,19 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<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
ProjectCleaningCar/ProjectCleaningCar/Properties/Resources.Designer.cs
generated
Normal file
103
ProjectCleaningCar/ProjectCleaningCar/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ProjectCleaningCar.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("ProjectCleaningCar.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 _1614525823_30_p_strelka_na_belom_fone__Right_ {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("1614525823_30-p-strelka-na-belom-fone (Right)", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap _1614525823_30_p_strelka_na_belom_fone_33__Down_ {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("1614525823_30-p-strelka-na-belom-fone-33 (Down)", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap _1614525823_30_p_strelka_na_belom_fone_33__Left_ {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("1614525823_30-p-strelka-na-belom-fone-33 (Left)", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap _1614525823_30_p_strelka_na_belom_fone_33__Up_ {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("1614525823_30-p-strelka-na-belom-fone-33 (Up)", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
ProjectCleaningCar/ProjectCleaningCar/Properties/Resources.resx
Normal file
133
ProjectCleaningCar/ProjectCleaningCar/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="1614525823_30-p-strelka-na-belom-fone-33 (Up)" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\1614525823_30-p-strelka-na-belom-fone-33 (Up).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="1614525823_30-p-strelka-na-belom-fone-33 (Left)" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\1614525823_30-p-strelka-na-belom-fone-33 (Left).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="1614525823_30-p-strelka-na-belom-fone-33 (Down)" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\1614525823_30-p-strelka-na-belom-fone-33 (Down).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="1614525823_30-p-strelka-na-belom-fone (Right)" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\1614525823_30-p-strelka-na-belom-fone (Right).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
Loading…
Reference in New Issue
Block a user