PIbd-21. Anisin R.S. Lab work 01 #1
27
DumpTruck/Direction.cs
Normal file
27
DumpTruck/Direction.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DumpTruck
|
||||
{
|
||||
public enum Direction
|
||||
{
|
||||
/// Вверх
|
||||
/// </summary>
|
||||
Up = 1,
|
||||
/// <summary>
|
||||
/// Вниз
|
||||
/// </summary>
|
||||
Down = 2,
|
||||
/// <summary>
|
||||
/// Влево
|
||||
/// </summary>
|
||||
Left = 3,
|
||||
/// <summary>
|
||||
/// Вправо
|
||||
/// </summary>
|
||||
Right = 4
|
||||
}
|
||||
}
|
156
DumpTruck/DrawingDumpTruck.cs
Normal file
156
DumpTruck/DrawingDumpTruck.cs
Normal file
@ -0,0 +1,156 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DumpTruck
|
||||
{
|
||||
public class DrawingDumpTruck
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
/// </summary>
|
||||
public EntityDumpTruck? EntityDumpTruck { 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 readonly int _truckWidth = 160;
|
||||
/// <summary>
|
||||
/// Высота прорисовки самосвала
|
||||
/// </summary>
|
||||
private readonly int _truckHeight = 90;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет самосвала</param>
|
||||
/// <param name="tent">Признак наличия тента</param>
|
||||
/// <param name="dumpBox">Признак наличия кузова</param>
|
||||
/// <param name="dumpBoxColor">Цвет кузова</param>
|
||||
/// <param name="tentColor">Цвет тента</param>
|
||||
/// <param name="width">Ширина картинки</param>
|
||||
/// <param name="height">Высота картинки</param>
|
||||
/// <returns>true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах</returns>
|
||||
public bool Init(int speed, double weight, Color bodyColor, bool tent, bool dumpBox, Color tentColor, Color dumpBoxColor, int width, int height)
|
||||
{
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
if (_pictureHeight < _truckHeight || _pictureWidth < _truckWidth) return false;
|
||||
|
||||
EntityDumpTruck = new EntityDumpTruck();
|
||||
EntityDumpTruck.Init(speed, weight, bodyColor, tent, dumpBox, tentColor, dumpBoxColor);
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Установка позиции
|
||||
/// </summary>
|
||||
/// <param name="x">Координата X</param>
|
||||
/// <param name="y">Координата Y</param>
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (x < 0 || x + _truckWidth > _pictureWidth) { x = 0; }
|
||||
if (y < 0 || y + _truckHeight > _pictureHeight) { y = 0; }
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменение направления перемещения
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
public void MoveTransport(Direction direction)
|
||||
{
|
||||
if (EntityDumpTruck == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
//влево
|
||||
case Direction.Left:
|
||||
if (_startPosX - EntityDumpTruck.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityDumpTruck.Step;
|
||||
}
|
||||
break;
|
||||
//вверх
|
||||
case Direction.Up:
|
||||
if (_startPosY - EntityDumpTruck.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityDumpTruck.Step;
|
||||
}
|
||||
break;
|
||||
// вправо
|
||||
case Direction.Right:
|
||||
if (_startPosX + _truckWidth + EntityDumpTruck.Step < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityDumpTruck.Step;
|
||||
}
|
||||
break;
|
||||
//вниз
|
||||
case Direction.Down:
|
||||
if (_startPosY + _truckHeight + EntityDumpTruck.Step < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityDumpTruck.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Прорисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityDumpTruck == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Brush brush = new SolidBrush(EntityDumpTruck.BodyColor);
|
||||
g.FillRectangle(brush, _startPosX, _startPosY + 40, 160, 10);
|
||||
g.FillRectangle(brush, _startPosX + 120, _startPosY, 40, 40);
|
||||
g.FillEllipse(brush, _startPosX, _startPosY + 50, 40, 40);
|
||||
g.FillEllipse(brush, _startPosX + 40, _startPosY + 50, 40, 40);
|
||||
g.FillEllipse(brush, _startPosX + 120, _startPosY + 50, 40, 40);
|
||||
if (EntityDumpTruck.DumpBox)
|
||||
{
|
||||
Brush brDumpBox = new SolidBrush(EntityDumpTruck.DumpBoxColor);
|
||||
Point point1 = new Point(_startPosX + 20, _startPosY);
|
||||
Point point2 = new Point(_startPosX + 120, _startPosY);
|
||||
Point point3 = new Point(_startPosX + 100, _startPosY + 39);
|
||||
Point point4 = new Point(_startPosX, _startPosY + 39);
|
||||
Point[] dumpBoxPoints = { point1, point2, point3, point4};
|
||||
g.FillPolygon(brDumpBox, dumpBoxPoints);
|
||||
}
|
||||
if (EntityDumpTruck.DumpBox && EntityDumpTruck.Tent)
|
||||
{
|
||||
Brush brTent = new SolidBrush(EntityDumpTruck.TentColor);
|
||||
Point point1 = new Point(_startPosX + 15, _startPosY);
|
||||
Point point2 = new Point(_startPosX + 120, _startPosY);
|
||||
Point point3 = new Point(_startPosX + 115, _startPosY + 10);
|
||||
Point point4 = new Point(_startPosX + 10, _startPosY + 10);
|
||||
Point[] tentPoints = { point1, point2, point3, point4 };
|
||||
g.FillPolygon(brTent, tentPoints);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
26
DumpTruck/DumpTruck.csproj
Normal file
26
DumpTruck/DumpTruck.csproj
Normal file
@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<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>
|
@ -1,9 +1,9 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32929.385
|
||||
VisualStudioVersion = 17.5.33530.505
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DumpTruck", "DumpTruck\DumpTruck.csproj", "{26796F32-D785-418E-9A6B-E3BAC62BAFEA}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DumpTruck", "DumpTruck.csproj", "{6B4E6B76-8A8E-41F4-8152-149554710311}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -11,15 +11,15 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{26796F32-D785-418E-9A6B-E3BAC62BAFEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{26796F32-D785-418E-9A6B-E3BAC62BAFEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{26796F32-D785-418E-9A6B-E3BAC62BAFEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{26796F32-D785-418E-9A6B-E3BAC62BAFEA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6B4E6B76-8A8E-41F4-8152-149554710311}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6B4E6B76-8A8E-41F4-8152-149554710311}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6B4E6B76-8A8E-41F4-8152-149554710311}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6B4E6B76-8A8E-41F4-8152-149554710311}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {379CC8BC-ED77-4529-A5E0-2F1171582BE4}
|
||||
SolutionGuid = {E03F6674-51B1-427F-A0F7-7F63C642A734}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
@ -1,11 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
39
DumpTruck/DumpTruck/Form1.Designer.cs
generated
39
DumpTruck/DumpTruck/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
||||
namespace DumpTruck
|
||||
{
|
||||
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 DumpTruck
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
namespace DumpTruck
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[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());
|
||||
}
|
||||
}
|
||||
}
|
66
DumpTruck/EntityDumpTruck.cs
Normal file
66
DumpTruck/EntityDumpTruck.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DumpTruck
|
||||
{
|
||||
public class EntityDumpTruck
|
||||
{
|
||||
/// <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 bool Tent { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия кузова
|
||||
/// </summary>
|
||||
public bool DumpBox { get; private set; }
|
||||
/// <summary>
|
||||
/// Цвет кузова
|
||||
/// </summary>
|
||||
public Color DumpBoxColor { get; private set; }
|
||||
/// <summary>
|
||||
/// Цвет тента
|
||||
/// </summary>
|
||||
public Color TentColor { 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="tent">Признак наличия тента</param>
|
||||
/// <param name="dumpBox">Признак наличия кузова</param>
|
||||
/// <param name="dumpBoxColor">Цвет кузова</param>
|
||||
/// <param name="tentColor">Цвет тента</param>
|
||||
public void Init(int speed, double weight, Color bodyColor, bool tent, bool dumpBox, Color tentColor, Color dumpBoxColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
Tent = tent;
|
||||
DumpBox = dumpBox;
|
||||
DumpBoxColor = dumpBoxColor;
|
||||
TentColor = tentColor;
|
||||
}
|
||||
}
|
||||
}
|
134
DumpTruck/FormDumpTruck.Designer.cs
generated
Normal file
134
DumpTruck/FormDumpTruck.Designer.cs
generated
Normal file
@ -0,0 +1,134 @@
|
||||
namespace DumpTruck
|
||||
{
|
||||
partial class FormDumpTruck
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
pictureBoxDumpTruck = new PictureBox();
|
||||
Create = new Button();
|
||||
buttonLeft = new Button();
|
||||
buttonUp = new Button();
|
||||
buttonRight = new Button();
|
||||
buttonDown = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxDumpTruck).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBoxDumpTruck
|
||||
//
|
||||
pictureBoxDumpTruck.Dock = DockStyle.Fill;
|
||||
pictureBoxDumpTruck.Location = new Point(0, 0);
|
||||
pictureBoxDumpTruck.Name = "pictureBoxDumpTruck";
|
||||
pictureBoxDumpTruck.Size = new Size(800, 450);
|
||||
pictureBoxDumpTruck.TabIndex = 0;
|
||||
pictureBoxDumpTruck.TabStop = false;
|
||||
//
|
||||
// Create
|
||||
//
|
||||
Create.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
Create.Location = new Point(12, 415);
|
||||
Create.Name = "Create";
|
||||
Create.Size = new Size(75, 23);
|
||||
Create.TabIndex = 1;
|
||||
Create.Text = "Создать";
|
||||
Create.UseVisualStyleBackColor = true;
|
||||
Create.Click += Create_Click;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonLeft.BackgroundImage = Properties.Resources.left;
|
||||
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonLeft.Location = new Point(686, 408);
|
||||
buttonLeft.Name = "buttonLeft";
|
||||
buttonLeft.Size = new Size(30, 30);
|
||||
buttonLeft.TabIndex = 2;
|
||||
buttonLeft.UseVisualStyleBackColor = true;
|
||||
buttonLeft.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonUp.BackgroundImage = Properties.Resources.up;
|
||||
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonUp.Location = new Point(722, 372);
|
||||
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.right;
|
||||
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonRight.Location = new Point(758, 408);
|
||||
buttonRight.Name = "buttonRight";
|
||||
buttonRight.Size = new Size(30, 30);
|
||||
buttonRight.TabIndex = 4;
|
||||
buttonRight.UseVisualStyleBackColor = true;
|
||||
buttonRight.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonDown.BackgroundImage = Properties.Resources.down;
|
||||
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonDown.Location = new Point(722, 408);
|
||||
buttonDown.Name = "buttonDown";
|
||||
buttonDown.Size = new Size(30, 30);
|
||||
buttonDown.TabIndex = 5;
|
||||
buttonDown.UseVisualStyleBackColor = true;
|
||||
buttonDown.Click += ButtonMove_Click;
|
||||
//
|
||||
// FormDumpTruck
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(Create);
|
||||
Controls.Add(pictureBoxDumpTruck);
|
||||
Name = "FormDumpTruck";
|
||||
Text = "FormDumpTruck";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxDumpTruck).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxDumpTruck;
|
||||
private Button Create;
|
||||
private Button buttonLeft;
|
||||
private Button buttonUp;
|
||||
private Button buttonRight;
|
||||
private Button buttonDown;
|
||||
}
|
||||
}
|
65
DumpTruck/FormDumpTruck.cs
Normal file
65
DumpTruck/FormDumpTruck.cs
Normal file
@ -0,0 +1,65 @@
|
||||
namespace DumpTruck
|
||||
{
|
||||
public partial class FormDumpTruck : Form
|
||||
{
|
||||
public FormDumpTruck()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private DrawingDumpTruck? _drawingDumpTruck;
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawingDumpTruck == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureBoxDumpTruck.Width,
|
||||
pictureBoxDumpTruck.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawingDumpTruck.DrawTransport(gr);
|
||||
pictureBoxDumpTruck.Image = bmp;
|
||||
}
|
||||
|
||||
|
||||
private void Create_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
_drawingDumpTruck = new DrawingDumpTruck();
|
||||
_drawingDumpTruck.Init(random.Next(100, 300), random.Next(1000, 3000),
|
||||
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)),
|
||||
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)),
|
||||
pictureBoxDumpTruck.Width, pictureBoxDumpTruck.Height);
|
||||
_drawingDumpTruck.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawingDumpTruck == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_drawingDumpTruck.MoveTransport(Direction.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_drawingDumpTruck.MoveTransport(Direction.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_drawingDumpTruck.MoveTransport(Direction.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_drawingDumpTruck.MoveTransport(Direction.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
60
DumpTruck/FormDumpTruck.resx
Normal file
60
DumpTruck/FormDumpTruck.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>
|
17
DumpTruck/Program.cs
Normal file
17
DumpTruck/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace DumpTruck
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[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 FormDumpTruck());
|
||||
}
|
||||
}
|
||||
}
|
103
DumpTruck/Properties/Resources.Designer.cs
generated
Normal file
103
DumpTruck/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DumpTruck.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("DumpTruck.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap down {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("down", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap left {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("left", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap right {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("right", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap up {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("up", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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="down" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="left" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\left.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="right" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\right.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="up" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
DumpTruck/Resources/down.png
Normal file
BIN
DumpTruck/Resources/down.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
BIN
DumpTruck/Resources/left.png
Normal file
BIN
DumpTruck/Resources/left.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
BIN
DumpTruck/Resources/right.png
Normal file
BIN
DumpTruck/Resources/right.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
BIN
DumpTruck/Resources/up.png
Normal file
BIN
DumpTruck/Resources/up.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
Loading…
Reference in New Issue
Block a user
Сначала выполняются проверки и только потом, если они пройдены успешно, запоминаются данные