ПИбд-23 Волков Никита Андреевич Лабораторная работа №1 #1
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32825.248
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bulldozer", "Bulldozer\Bulldozer.csproj", "{5971A7E3-6CB0-41D7-A8C9-F2E29DBC4C68}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bulldozer", "Bulldozer\Bulldozer.csproj", "{054C01C3-1210-4465-84BB-9B559909C149}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -11,15 +11,15 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5971A7E3-6CB0-41D7-A8C9-F2E29DBC4C68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5971A7E3-6CB0-41D7-A8C9-F2E29DBC4C68}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5971A7E3-6CB0-41D7-A8C9-F2E29DBC4C68}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5971A7E3-6CB0-41D7-A8C9-F2E29DBC4C68}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{054C01C3-1210-4465-84BB-9B559909C149}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{054C01C3-1210-4465-84BB-9B559909C149}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{054C01C3-1210-4465-84BB-9B559909C149}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{054C01C3-1210-4465-84BB-9B559909C149}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {59528A8E-08B2-4D91-8AD1-D237F3B6C1B5}
|
||||
SolutionGuid = {F8B8E9BD-8990-494B-B3F6-8CBB63A85858}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
57
Bulldozer/Bulldozer/Bulldozer.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bulldozer
|
||||
{
|
||||
public class EntityBulldozer
|
||||
{
|
||||
/// <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 Blade { get; private set; }
|
||||
/// <summary>
|
||||
/// Рыхлитель бульдозера
|
||||
/// </summary>
|
||||
public bool Ripper { get; private set; }
|
||||
/// <summary>
|
||||
/// Шаг перемещения бульдозера
|
||||
/// </summary>
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес бульдозера</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="blade">Отвал бульдозера</param>
|
||||
/// <param name="ripper">Рыхлитель бульдозера</param>
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool blade, bool ripper)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
AdditionalColor = additionalColor;
|
||||
Blade = blade;
|
||||
Ripper = ripper;
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
32
Bulldozer/Bulldozer/Direction.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bulldozer
|
||||
{
|
||||
/// <summary>
|
||||
/// Направления движения
|
||||
/// </summary>
|
||||
public enum DirectionType
|
||||
|
||||
{
|
||||
/// <summary>
|
||||
/// Вверх
|
||||
/// </summary>
|
||||
Up = 1,
|
||||
/// <summary>
|
||||
/// Вниз
|
||||
/// </summary>
|
||||
Down = 2,
|
||||
/// <summary>
|
||||
/// Влево
|
||||
/// </summary>
|
||||
Left = 3,
|
||||
/// <summary>
|
||||
/// Вправо
|
||||
/// </summary>
|
||||
Right = 4,
|
||||
|
||||
}
|
||||
}
|
224
Bulldozer/Bulldozer/DrawingBulldozer.cs
Normal file
@ -0,0 +1,224 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Windows.Forms.AxHost;
|
||||
|
||||
namespace Bulldozer
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс отрисовки и перемещения объекта-сущности
|
||||
/// </summary>
|
||||
public class DrawingBulldozer
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
/// </summary>
|
||||
public EntityBulldozer? EntityBulldozer { get; private set; }
|
||||
/// <summary>
|
||||
/// Ширина окна
|
||||
/// </summary>
|
||||
private int _pictureWidth;
|
||||
/// <summary>
|
||||
/// Высота окна
|
||||
/// </summary>
|
||||
private int _pictureHeight;
|
||||
/// <summary>
|
||||
/// Координата прорисовки по оси X
|
||||
/// </summary>
|
||||
private int _startPosX;
|
||||
/// <summary>
|
||||
/// Координата прорисовки по оси Y
|
||||
/// </summary>
|
||||
private int _startPosY;
|
||||
/// <summary>
|
||||
/// Ширина бульдозера
|
||||
/// </summary>
|
||||
private readonly int _bulldozerWidth = 150;
|
||||
/// <summary>
|
||||
/// Высота бульдозера
|
||||
/// </summary>
|
||||
private readonly int _bulldozerHeight = 60;
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес бульдозера</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="blade">Отвал бульдозера</param>
|
||||
/// <param name="ripper">Рыхлитель бульдозера</param>
|
||||
/// <param name="width">Ширина изображения</param>
|
||||
/// <param name="height">Высота изображения</param>
|
||||
|
||||
public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool blade, bool ripper, int width, int height)
|
||||
{
|
||||
if ((height < _bulldozerHeight) || (width < _bulldozerWidth))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
EntityBulldozer = new EntityBulldozer();
|
||||
EntityBulldozer.Init(speed, weight, bodyColor, additionalColor, blade, ripper);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (x < 0)
|
||||
{
|
||||
x = 0;
|
||||
}
|
||||
else if (x > _pictureWidth - _bulldozerWidth)
|
||||
{
|
||||
x = _pictureWidth - _bulldozerWidth;
|
||||
}
|
||||
|
||||
if (y < 0)
|
||||
{
|
||||
y = 0;
|
||||
}
|
||||
else if (y > _pictureHeight - _bulldozerHeight)
|
||||
{
|
||||
y = _pictureHeight - _bulldozerHeight;
|
||||
}
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
|
||||
public void MoveBulldozer(DirectionType direction)
|
||||
{
|
||||
if (EntityBulldozer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
case DirectionType.Left:
|
||||
if (_startPosX - EntityBulldozer.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityBulldozer.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Up:
|
||||
if (_startPosY - EntityBulldozer.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityBulldozer.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Right:
|
||||
if (_startPosX + _bulldozerWidth + EntityBulldozer.Step < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityBulldozer.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Down:
|
||||
if (_startPosY + _bulldozerHeight + EntityBulldozer.Step < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityBulldozer.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Прорисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityBulldozer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new SolidBrush(EntityBulldozer.AdditionalColor);
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Отрисовка отвала бульдозера
|
||||
/// </summary>
|
||||
if (EntityBulldozer.Blade)
|
||||
{
|
||||
Point point1 = new Point(_startPosX + 8, _startPosY + 29);
|
||||
Point point2 = new Point(_startPosX + 8, _startPosY + 50);
|
||||
Point point3 = new Point(_startPosX, _startPosY + 50);
|
||||
Point[] triangle = { point1, point2, point3 };
|
||||
|
||||
g.FillRectangle(additionalBrush, _startPosX + 8, _startPosY + 29, 8, 8); // заливка основания отвала
|
||||
g.FillPolygon(additionalBrush, triangle); // заливка отвала
|
||||
|
||||
g.DrawRectangle(pen, _startPosX+8, _startPosY + 29, 8, 8); // обводка основания отвала
|
||||
g.DrawPolygon(pen, triangle); // обводка отвала
|
||||
}
|
||||
/// <summary>
|
||||
/// Отрисовка рыхлителя бульдозера
|
||||
/// </summary>
|
||||
if (EntityBulldozer.Ripper)
|
||||
{
|
||||
Point ripperPoint1 = new Point(_startPosX + 140, _startPosY + 37);
|
||||
Point ripperPoint2 = new Point(_startPosX + 151, _startPosY + 37);
|
||||
Point ripperPoint3 = new Point(_startPosX + 140, _startPosY + 60);
|
||||
Point[] ripper = { ripperPoint1, ripperPoint2, ripperPoint3 };
|
||||
|
||||
g.FillRectangle(additionalBrush, _startPosX + 136, _startPosY + 29, 15, 8); // заливка основания рыхлителя
|
||||
g.FillPolygon(additionalBrush, ripper); // заливка отвала
|
||||
|
||||
g.DrawRectangle(pen, _startPosX + 136, _startPosY + 29, 15, 8); // обводка основания рыхлителя
|
||||
g.DrawPolygon(pen, ripper);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Заливка гусеницы бульдозера
|
||||
/// </summary>
|
||||
Brush brGray = new SolidBrush(Color.Gray);
|
||||
|
||||
g.FillEllipse(brGray, _startPosX + 17, _startPosY + 24, 119, 40); //Гусеница
|
||||
|
||||
Brush brGrayDk = new SolidBrush(Color.DarkGray);
|
||||
|
||||
g.FillEllipse(brGrayDk, _startPosX + 20, _startPosY + 35, 20, 20); // Левое колесо гусеницы
|
||||
g.FillEllipse(brGrayDk, _startPosX + 115, _startPosY + 35, 20, 20); // Правое колесо гусеницы
|
||||
g.FillEllipse(brGrayDk, _startPosX + 50, _startPosY + 45, 10, 10); // 1 центральное колесо гусеницы
|
||||
g.FillEllipse(brGrayDk, _startPosX + 70, _startPosY + 45, 10, 10); // 2 центральное колесо гусеницы
|
||||
g.FillEllipse(brGrayDk, _startPosX + 90, _startPosY + 45, 10, 10); // 3 центральное колесо гусеницы
|
||||
|
||||
/// <summary>
|
||||
/// Отрисовка границ бульдозера
|
||||
/// </summary>
|
||||
|
||||
g.DrawEllipse(pen, _startPosX + 20, _startPosY + 35, 20, 20); // Левое колесо гусеницы
|
||||
g.DrawEllipse(pen, _startPosX + 115, _startPosY + 35, 20, 20); // Правое колесо гусеницы
|
||||
g.DrawEllipse(pen, _startPosX + 50, _startPosY + 45, 10, 10); // 1 центральное колесо гусеницы
|
||||
g.DrawEllipse(pen, _startPosX + 70, _startPosY + 45, 10, 10); // 2 центральное колесо гусеницы
|
||||
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 45, 10, 10); // 3 центральное колесо гусеницы
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Кузов бульдозера
|
||||
/// </summary>
|
||||
Brush brBlue = new SolidBrush(Color.Blue);
|
||||
g.FillRectangle(brBlue, _startPosX + 102, _startPosY , 28, 24); //кабина
|
||||
g.FillRectangle(brBlue, _startPosX + 17, _startPosY + 24, 119, 18); // основная часть
|
||||
g.FillRectangle(brBlue, _startPosX + 30, _startPosY, 10, 24); // выхлопная труба
|
||||
|
||||
/// <summary>
|
||||
/// Корпус
|
||||
/// </summary>
|
||||
g.DrawRectangle(pen, _startPosX + 102, _startPosY, 28, 24); //кабина
|
||||
g.DrawRectangle(pen, _startPosX + 17, _startPosY + 24, 119, 18); // основная часть
|
||||
g.DrawRectangle(pen, _startPosX + 30, _startPosY, 10, 24); // выхлопная труба
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
39
Bulldozer/Bulldozer/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
||||
namespace Bulldozer
|
||||
{
|
||||
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 Bulldozer
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
148
Bulldozer/Bulldozer/FormBulldozer.Designer.cs
generated
Normal file
@ -0,0 +1,148 @@
|
||||
namespace Bulldozer
|
||||
{
|
||||
partial class FormBulldozer
|
||||
{
|
||||
/// <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.pictureBoxBulldozer = new System.Windows.Forms.PictureBox();
|
||||
this.buttonCreate = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxBulldozer)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBox
|
||||
//
|
||||
this.pictureBoxBulldozer.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxBulldozer.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxBulldozer.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.pictureBoxBulldozer.Name = "pictureBoxBulldozer";
|
||||
this.pictureBoxBulldozer.Size = new System.Drawing.Size(1010, 615);
|
||||
this.pictureBoxBulldozer.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBoxBulldozer.TabIndex = 0;
|
||||
this.pictureBoxBulldozer.TabStop = false;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonCreate.Location = new System.Drawing.Point(14, 568);
|
||||
this.buttonCreate.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonCreate.Name = "buttonCreate";
|
||||
this.buttonCreate.Size = new System.Drawing.Size(86, 31);
|
||||
this.buttonCreate.TabIndex = 1;
|
||||
this.buttonCreate.Text = "Создать";
|
||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||
this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::Bulldozer.Properties.Resources.arrowLeft;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonLeft.Image = global::Bulldozer.Properties.Resources.arrowLeft;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(867, 563);
|
||||
this.buttonLeft.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(34, 40);
|
||||
this.buttonLeft.TabIndex = 2;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::Bulldozer.Properties.Resources.arrowDown;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonDown.Location = new System.Drawing.Point(909, 563);
|
||||
this.buttonDown.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(34, 40);
|
||||
this.buttonDown.TabIndex = 3;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::Bulldozer.Properties.Resources.arrowRight;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonRight.Image = global::Bulldozer.Properties.Resources.arrowRight;
|
||||
this.buttonRight.Location = new System.Drawing.Point(950, 563);
|
||||
this.buttonRight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(34, 40);
|
||||
this.buttonRight.TabIndex = 4;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImage = global::Bulldozer.Properties.Resources.arrowUp;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonUp.Image = global::Bulldozer.Properties.Resources.arrowUp;
|
||||
this.buttonUp.Location = new System.Drawing.Point(909, 515);
|
||||
this.buttonUp.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(34, 40);
|
||||
this.buttonUp.TabIndex = 5;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// FormBulldozer
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1010, 615);
|
||||
this.Controls.Add(this.buttonUp);
|
||||
this.Controls.Add(this.buttonRight);
|
||||
this.Controls.Add(this.buttonDown);
|
||||
this.Controls.Add(this.buttonLeft);
|
||||
this.Controls.Add(this.buttonCreate);
|
||||
this.Controls.Add(this.pictureBoxBulldozer);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormBulldozer";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Bulldozer";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxBulldozer)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxBulldozer;
|
||||
private Button buttonCreate;
|
||||
private Button buttonLeft;
|
||||
private Button buttonDown;
|
||||
private Button buttonRight;
|
||||
private Button buttonUp;
|
||||
}
|
||||
}
|
71
Bulldozer/Bulldozer/FormBulldozer.cs
Normal file
@ -0,0 +1,71 @@
|
||||
namespace Bulldozer
|
||||
{
|
||||
public partial class FormBulldozer : Form
|
||||
{
|
||||
|
||||
private DrawingBulldozer? _drawingBulldozer;
|
||||
|
||||
public FormBulldozer()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawingBulldozer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureBoxBulldozer.Width, pictureBoxBulldozer.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawingBulldozer.DrawTransport(gr);
|
||||
pictureBoxBulldozer.Image = bmp;
|
||||
}
|
||||
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawingBulldozer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_drawingBulldozer.MoveBulldozer(DirectionType.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_drawingBulldozer.MoveBulldozer(DirectionType.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_drawingBulldozer.MoveBulldozer(DirectionType.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_drawingBulldozer.MoveBulldozer(DirectionType.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
_drawingBulldozer = new DrawingBulldozer();
|
||||
_drawingBulldozer.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)),
|
||||
pictureBoxBulldozer.Width,
|
||||
pictureBoxBulldozer.Height);
|
||||
_drawingBulldozer.SetPosition(random.Next(10, 100),random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
60
Bulldozer/Bulldozer/FormBulldozer.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<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>
|
||||
</root>
|
@ -8,10 +8,9 @@ namespace Bulldozer
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// 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 FormBulldozer());
|
||||
}
|
||||
}
|
||||
}
|
103
Bulldozer/Bulldozer/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Bulldozer.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("Bulldozer.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 arrowDown {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowDown", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowLeft {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowLeft", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowRight {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowRight", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowUp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowUp", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -117,4 +117,17 @@
|
||||
<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="arrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
Bulldozer/Bulldozer/Resources/arrowDown.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
Bulldozer/Bulldozer/Resources/arrowLeft.png
Normal file
After Width: | Height: | Size: 104 KiB |
BIN
Bulldozer/Bulldozer/Resources/arrowRight.png
Normal file
After Width: | Height: | Size: 104 KiB |
BIN
Bulldozer/Bulldozer/Resources/arrowUp.png
Normal file
After Width: | Height: | Size: 5.0 KiB |
BIN
Bulldozer/arrowDown.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
Bulldozer/arrowLeft.png
Normal file
After Width: | Height: | Size: 104 KiB |
BIN
Bulldozer/arrowRight.png
Normal file
After Width: | Height: | Size: 104 KiB |
BIN
Bulldozer/arrowUp.png
Normal file
After Width: | Height: | Size: 5.0 KiB |
Имя файла не соответствует имени элемента проекта