Исправления

This commit is contained in:
Itos 2024-10-03 00:16:11 +03:00
parent 9346511d94
commit f0605b226a
32 changed files with 843 additions and 432 deletions

View File

@ -1,163 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GasolineTanker
{
public class DrawningGasolineTanker
{
public EntityGasolineTanker? EntityGasolineTanker { get; private set; }
public int _pictureWidth;
public int _pictureHeight;
private int _startPosX = 0;
private int _startPosY = 0;
//Ширина грузовика
private readonly int _gasolineTankerWidth = 200;
//Высота грузовика
private readonly int _gasolineTankerHeight = 100;
//Инициализация свойств
public bool Init(int speed, double weight, Color bodyColor, bool tank, bool signalBeacon, Color additionalColor, int width, int height)
{
if (width <= _gasolineTankerWidth || height <= _gasolineTankerHeight)
{
return false;
}
_pictureWidth = width;
_pictureHeight = height;
EntityGasolineTanker = new EntityGasolineTanker();
EntityGasolineTanker.Init(speed, weight, bodyColor, tank, signalBeacon, additionalColor);
return true;
}
public void SetPosition(int x, int y)
{
if (EntityGasolineTanker == null)
{
return;
}
_startPosX = x;
_startPosY = y;
if(x + _gasolineTankerWidth >= _pictureWidth || y + _gasolineTankerHeight >= _pictureHeight)
{
_startPosX = 1;
_startPosY = 1;
}
}
public void MoveTransport(Direction direction)
{
if (EntityGasolineTanker == null)
{
return;
}
switch (direction)
{
case Direction.Left:
if (_startPosX - EntityGasolineTanker.Step >= 0)
{
_startPosX -= (int)EntityGasolineTanker.Step;
}
else
{
_startPosX = 0;
}
break;
case Direction.Up:
if (_startPosY - EntityGasolineTanker.Step > 0)
{
_startPosY -= (int)EntityGasolineTanker.Step;
}
else
{
_startPosY = 0;
}
break;
case Direction.Right:
if (_startPosX + EntityGasolineTanker.Step + _gasolineTankerWidth < _pictureWidth)
{
_startPosX += (int)EntityGasolineTanker.Step;
}
else
{
_startPosX = _pictureWidth - _gasolineTankerWidth;
}
break;
case Direction.Down:
if (_startPosY + EntityGasolineTanker.Step + _gasolineTankerHeight < _pictureHeight)
{
_startPosY += (int)EntityGasolineTanker.Step;
}
else
{
_startPosY = _pictureHeight - _gasolineTankerHeight;
}
break;
}
}
public void DrawTransport(Graphics g)
{
if (EntityGasolineTanker == null)
{
return;
}
Pen pen = new(Color.Black);
Brush bodyBrush = new SolidBrush(EntityGasolineTanker.BodyColor);
Brush additionalBrush = new SolidBrush(EntityGasolineTanker.AdditionalColor);
Brush wheelBrush = new SolidBrush(Color.Black);
//Дополнительные элементы
if (EntityGasolineTanker.Tank)
{
//Цистерна
g.FillEllipse(additionalBrush, _startPosX + _gasolineTankerWidth / 20 * 0, _startPosY + _gasolineTankerHeight / 10 * 1, _gasolineTankerWidth / 20 * 5, _gasolineTankerHeight / 10 * 5);
g.FillEllipse(additionalBrush, _startPosX + _gasolineTankerWidth / 20 * 7, _startPosY + _gasolineTankerHeight / 10 * 1, _gasolineTankerWidth / 20 * 5, _gasolineTankerHeight / 10 * 5);
Point[] pointsTunk =
{
new Point(_startPosX + _gasolineTankerWidth / 20 * 2, _startPosY + _gasolineTankerHeight / 10 * 1),
new Point(_startPosX + _gasolineTankerWidth / 20 * 9, _startPosY + _gasolineTankerHeight / 10 * 1),
new Point(_startPosX + _gasolineTankerWidth / 20 * 9, _startPosY + _gasolineTankerHeight / 10 * 6),
new Point(_startPosX + _gasolineTankerWidth / 20 * 2, _startPosY + _gasolineTankerHeight / 10 * 6),
};
g.FillPolygon(additionalBrush, pointsTunk);
}
if (EntityGasolineTanker.SignalBeacon)
{
//Маячок
Point[] pointsBeacon =
{
new Point(_startPosX + _gasolineTankerWidth / 20 * 13, _startPosY + _gasolineTankerHeight / 10 * 1),
new Point(_startPosX + _gasolineTankerWidth / 20 * 13, _startPosY + _gasolineTankerHeight / 10 * 0),
new Point(_startPosX + _gasolineTankerWidth / 20 * 14, _startPosY + _gasolineTankerHeight / 10 * 0),
new Point(_startPosX + _gasolineTankerWidth / 20 * 14, _startPosY + _gasolineTankerHeight / 10 * 1),
};
g.FillPolygon(additionalBrush, pointsBeacon);
//g.DrawPolygon(pen, pointsBeacon);
}
/*
//Граница отрисовки объекта(для безопасности при редактировании)
Point[] pointsBorder = { new Point(_startPosX, _startPosY),
new Point(_startPosX, _startPosY + _gasolineTankerHeight),
new Point(_startPosX + _gasolineTankerWidth, _startPosY + _gasolineTankerHeight),
new Point(_startPosX + _gasolineTankerWidth, _startPosY)};
g.DrawPolygon(pen, pointsBorder);
*/
Point[] pointsFrame = {
new Point(_startPosX + _gasolineTankerWidth / 20 * 0, _startPosY + _gasolineTankerHeight / 10 * 6),
new Point(_startPosX + _gasolineTankerWidth / 20 * 12, _startPosY + _gasolineTankerHeight / 10 * 6),
new Point(_startPosX + _gasolineTankerWidth / 20 * 12, _startPosY + _gasolineTankerHeight / 10 * 1),
new Point(_startPosX + _gasolineTankerWidth / 20 * 15, _startPosY + _gasolineTankerHeight / 10 * 1),
new Point(_startPosX + _gasolineTankerWidth / 20 * 16, _startPosY + _gasolineTankerHeight / 10 * 4),
new Point(_startPosX + _gasolineTankerWidth / 20 * 20, _startPosY + _gasolineTankerHeight / 10 * 5),
new Point(_startPosX + _gasolineTankerWidth / 20 * 20, _startPosY + _gasolineTankerHeight / 10 * 8),
new Point(_startPosX + _gasolineTankerWidth / 20 * 0, _startPosY + _gasolineTankerHeight / 10 * 8),};
g.FillPolygon(bodyBrush, pointsFrame);
g.DrawPolygon(pen, pointsFrame);
//Колёса
g.FillEllipse(wheelBrush, _startPosX + _gasolineTankerWidth / 20 * 1, _startPosY + _gasolineTankerHeight / 10 * 7, _gasolineTankerWidth / 20 * 3, _gasolineTankerHeight / 10 * 3);
g.FillEllipse(wheelBrush, _startPosX + _gasolineTankerWidth / 20 * 5, _startPosY + _gasolineTankerHeight / 10 * 7, _gasolineTankerWidth / 20 * 3, _gasolineTankerHeight / 10 * 3);
g.FillEllipse(wheelBrush, _startPosX + _gasolineTankerWidth / 20 * 16, _startPosY + _gasolineTankerHeight / 10 * 7, _gasolineTankerWidth / 20 * 3, _gasolineTankerHeight / 10 * 3);
}
}
}

View File

@ -1,35 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace GasolineTanker
{
public class EntityGasolineTanker
{
public int Speed { get; private set; }
public double Weight { get; private set; }
// Основной цвет
public Color BodyColor { get; private set; }
//Наличие цистерны
public bool Tank { get; private set; }
//Наличие сигнального маяка
public bool SignalBeacon { get; private set; }
//Дополнительный цвет
public Color AdditionalColor { get; private set; }
//Шаг перемещения
public double Step => (double)Speed * 100 / Weight;
//Инициализация полей Грузовика
public void Init(int speed, double weight, Color bodyColor, bool tank, bool signalBeacon, Color additionalColor)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
Tank = tank;
SignalBeacon = signalBeacon;
AdditionalColor = additionalColor;
}
}
}

View File

@ -1,138 +0,0 @@
namespace GasolineTanker
{
partial class GasolineTanker
{
/// <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.PictureBoxGasolineTanker = new System.Windows.Forms.PictureBox();
this.ButtonCreate = new System.Windows.Forms.Button();
this.ButtonRight = new System.Windows.Forms.Button();
this.ButtonDown = new System.Windows.Forms.Button();
this.ButtonLeft = new System.Windows.Forms.Button();
this.ButtonUp = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.PictureBoxGasolineTanker)).BeginInit();
this.SuspendLayout();
//
// PictureBoxGasolineTanker
//
this.PictureBoxGasolineTanker.Dock = System.Windows.Forms.DockStyle.Fill;
this.PictureBoxGasolineTanker.Location = new System.Drawing.Point(0, 0);
this.PictureBoxGasolineTanker.Name = "PictureBoxGasolineTanker";
this.PictureBoxGasolineTanker.Size = new System.Drawing.Size(884, 461);
this.PictureBoxGasolineTanker.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.PictureBoxGasolineTanker.TabIndex = 0;
this.PictureBoxGasolineTanker.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(12, 426);
this.ButtonCreate.Name = "ButtonCreate";
this.ButtonCreate.Size = new System.Drawing.Size(75, 23);
this.ButtonCreate.TabIndex = 1;
this.ButtonCreate.Text = "Создать";
this.ButtonCreate.UseVisualStyleBackColor = true;
this.ButtonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
//
// ButtonRight
//
this.ButtonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonRight.BackgroundImage = global::GasolineTanker.Properties.Resources.right;
this.ButtonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.ButtonRight.Location = new System.Drawing.Point(842, 419);
this.ButtonRight.Name = "ButtonRight";
this.ButtonRight.Size = new System.Drawing.Size(30, 30);
this.ButtonRight.TabIndex = 2;
this.ButtonRight.UseVisualStyleBackColor = true;
this.ButtonRight.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::GasolineTanker.Properties.Resources.down;
this.ButtonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.ButtonDown.Location = new System.Drawing.Point(806, 419);
this.ButtonDown.Name = "ButtonDown";
this.ButtonDown.Size = new System.Drawing.Size(30, 30);
this.ButtonDown.TabIndex = 3;
this.ButtonDown.UseVisualStyleBackColor = true;
this.ButtonDown.Click += new System.EventHandler(this.ButtonMove_Click);
//
// ButtonLeft
//
this.ButtonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonLeft.BackgroundImage = global::GasolineTanker.Properties.Resources.left;
this.ButtonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.ButtonLeft.Location = new System.Drawing.Point(770, 419);
this.ButtonLeft.Name = "ButtonLeft";
this.ButtonLeft.Size = new System.Drawing.Size(30, 30);
this.ButtonLeft.TabIndex = 4;
this.ButtonLeft.UseVisualStyleBackColor = true;
this.ButtonLeft.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::GasolineTanker.Properties.Resources.up;
this.ButtonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.ButtonUp.Location = new System.Drawing.Point(806, 383);
this.ButtonUp.Name = "ButtonUp";
this.ButtonUp.Size = new System.Drawing.Size(30, 30);
this.ButtonUp.TabIndex = 5;
this.ButtonUp.UseVisualStyleBackColor = true;
this.ButtonUp.Click += new System.EventHandler(this.ButtonMove_Click);
//
// GasolineTanker
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(884, 461);
this.Controls.Add(this.ButtonUp);
this.Controls.Add(this.ButtonLeft);
this.Controls.Add(this.ButtonDown);
this.Controls.Add(this.ButtonRight);
this.Controls.Add(this.ButtonCreate);
this.Controls.Add(this.PictureBoxGasolineTanker);
this.Name = "GasolineTanker";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "GasolineTanker";
((System.ComponentModel.ISupportInitialize)(this.PictureBoxGasolineTanker)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private PictureBox PictureBoxGasolineTanker;
private Button ButtonCreate;
private Button ButtonRight;
private Button ButtonDown;
private Button ButtonLeft;
private Button ButtonUp;
}
}

View File

@ -1,65 +0,0 @@
namespace GasolineTanker
{
public partial class GasolineTanker : Form
{
private DrawningGasolineTanker? _drawningGasolineTanker;
public GasolineTanker()
{
InitializeComponent();
}
private void Draw()
{
if (_drawningGasolineTanker == null)
return;
Bitmap bmp = new(PictureBoxGasolineTanker.Width, PictureBoxGasolineTanker.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawningGasolineTanker.DrawTransport(gr);
PictureBoxGasolineTanker.Image = bmp;
}
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random random = new();
_drawningGasolineTanker = new DrawningGasolineTanker();
_drawningGasolineTanker.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)),
PictureBoxGasolineTanker.Width, PictureBoxGasolineTanker.Height);
_drawningGasolineTanker.SetPosition(random.Next(10, 100),
random.Next(10, 100));
Draw();
}
private void ButtonMove_Click(object sender, EventArgs e)
{
if (_drawningGasolineTanker == null)
{
return;
}
string name = ((Button)sender)?.Name ?? string.Empty;
switch (name)
{
case "ButtonUp":
_drawningGasolineTanker.MoveTransport(Direction.Up);
break;
case "ButtonDown":
_drawningGasolineTanker.MoveTransport(Direction.Down);
break;
case "ButtonLeft":
_drawningGasolineTanker.MoveTransport(Direction.Left);
break;
case "ButtonRight":
_drawningGasolineTanker.MoveTransport(Direction.Right);
break;
}
Draw();
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -1,9 +1,9 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.3.32901.215 VisualStudioVersion = 17.7.34024.191
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GasolineTanker", "GasolineTanker\GasolineTanker.csproj", "{07CE8245-8EAE-4397-B520-52291E0FA5E3}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectGasolineTanker", "ProjectGasolineTanker\ProjectGasolineTanker.csproj", "{D0EC2C7B-1218-45A1-95F1-7697825B93CF}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -11,15 +11,15 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{07CE8245-8EAE-4397-B520-52291E0FA5E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D0EC2C7B-1218-45A1-95F1-7697825B93CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{07CE8245-8EAE-4397-B520-52291E0FA5E3}.Debug|Any CPU.Build.0 = Debug|Any CPU {D0EC2C7B-1218-45A1-95F1-7697825B93CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07CE8245-8EAE-4397-B520-52291E0FA5E3}.Release|Any CPU.ActiveCfg = Release|Any CPU {D0EC2C7B-1218-45A1-95F1-7697825B93CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07CE8245-8EAE-4397-B520-52291E0FA5E3}.Release|Any CPU.Build.0 = Release|Any CPU {D0EC2C7B-1218-45A1-95F1-7697825B93CF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2ECAEF3F-3601-44FD-BAC5-49DEF6859A6B} SolutionGuid = {7BD35329-9874-48AD-A3F4-50BA7A354CF5}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@ -0,0 +1,74 @@
using ProjectGasolineTanker.MovementStrategy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using ProjectGasolineTanker.DrawingObjects;
namespace ProjectGasolineTanker.MovementStrategy
{
public abstract class AbstractStrategy
{
private IMoveableObject? _moveableObject;
private Status _state = Status.NotInit;
protected int FieldWidth { get; private set; }
protected int FieldHeight { get; private set; }
public Status GetStatus() { return _state; }
public void SetData(IMoveableObject moveableObject, int width, int height)
{
if (moveableObject == null)
{
_state = Status.NotInit;
return;
}
_state = Status.InProgress;
_moveableObject = moveableObject;
FieldWidth = width;
FieldHeight = height;
}
public void MakeStep()
{
if (_state != Status.InProgress)
{
return;
}
if (IsTargetDestinaion())
{
_state = Status.Finish;
return;
}
MoveToTarget();
}
protected bool MoveLeft() => MoveTo(DirectionType.Left);
protected bool MoveRight() => MoveTo(DirectionType.Right);
protected bool MoveUp() => MoveTo(DirectionType.Up);
protected bool MoveDown() => MoveTo(DirectionType.Down);
protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition;
protected int? GetStep()
{
if (_state != Status.InProgress)
{
return null;
}
return _moveableObject?.GetStep;
}
protected abstract void MoveToTarget();
protected abstract bool IsTargetDestinaion();
private bool MoveTo(DirectionType directionType)
{
if (_state != Status.InProgress)
{
return false;
}
if (_moveableObject?.CheckCanMove(directionType) ?? false)
{
_moveableObject.MoveObject(directionType);
return true;
}
return false;
}
}
}

View File

@ -4,9 +4,9 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace GasolineTanker namespace ProjectGasolineTanker
{ {
public enum Direction public enum DirectionType
{ {
Up = 1, Up = 1,
Down = 2, Down = 2,

View File

@ -0,0 +1,46 @@
using ProjectGasolineTanker.DrawingObjects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ProjectGasolineTanker.Entities;
namespace ProjectGasolineTanker
{
public class DrawingGasolineTanker : DrawingTruck
{
public DrawingGasolineTanker(int speed, double weight, Color bodyColor, Color additionalColor, bool tank, bool wheel, int width, int height) : base(speed, weight, bodyColor, width, height, 130, 70)
{
if (EntityTruck != null)
{
EntityTruck = new EntityGasolineTanker(speed, weight, bodyColor, additionalColor, tank, wheel);
}
}
public override void DrawTransport(Graphics g)
{
if (EntityTruck is not EntityGasolineTanker GasolineTanker)
{
return;
}
Pen pen = new(Color.Black);
Pen additionalPen = new(GasolineTanker.Body);
Brush additionalBrush = new SolidBrush(GasolineTanker.Body);
base.DrawTransport(g);
if (GasolineTanker.Tank)
{
g.FillRectangle(additionalBrush, _startPosX + 45, _startPosY + 53, 35, 20);
g.DrawLine(pen, _startPosX + 45, _startPosY + 53, _startPosX + 80, _startPosY + 73);
g.DrawLine(pen, _startPosX + 80, _startPosY + 53, _startPosX + 45, _startPosY + 73);
}
if (GasolineTanker.Wheel)
{
Brush gr = new SolidBrush(Color.Gray);
g.FillEllipse(additionalBrush, _startPosX + 85, _startPosY + 55, 22, 22);
g.FillEllipse(gr, _startPosX + 87, _startPosY + 57, 18, 18);
g.DrawEllipse(pen, _startPosX + 85, _startPosY + 55, 22, 22);
}
}
}
}

View File

@ -0,0 +1,35 @@
using ProjectGasolineTanker.MovementStrategy;
using ProjectGasolineTanker;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using ProjectGasolineTanker.DrawingObjects;
namespace ProjectGasolineTanker.MovementStrategy
{
public class DrawingObjectTruck : IMoveableObject
{
private readonly DrawingTruck? _drawingTruck = null;
public DrawingObjectTruck(DrawingTruck drawingTruck)
{
_drawingTruck = drawingTruck;
}
public ObjectParameters? GetObjectPosition
{
get
{
if (_drawingTruck == null || _drawingTruck.EntityTruck == null)
{
return null;
}
return new ObjectParameters(_drawingTruck.GetPosX,_drawingTruck.GetPosY, _drawingTruck.GetWidth, _drawingTruck.GetHeight);
}
}
public int GetStep => (int)(_drawingTruck?.EntityTruck?.Step ?? 0);
public bool CheckCanMove(DirectionType direction) => _drawingTruck?.CanMove(direction) ?? false;
public void MoveObject(DirectionType direction) => _drawingTruck?.MoveTransport(direction);
}
}

View File

@ -0,0 +1,136 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProjectGasolineTanker.Entities;
namespace ProjectGasolineTanker.DrawingObjects
{
public class DrawingTruck
{
public EntityTruck? EntityTruck { get; protected set; }
private int _pictureWidth;
private int _pictureHeight;
protected int _startPosX;
protected int _startPosY;
protected readonly int _tankerWidth = 130;
protected readonly int _tankerHeight = 70;
public int GetPosX => _startPosX;
public int GetPosY => _startPosY;
public int GetWidth => _tankerWidth;
public int GetHeight => _tankerHeight;
public DrawingTruck(int speed, double weight, Color bodyColor, int width, int height)
{
if (width < _tankerWidth || height < _tankerHeight)
{
return;
}
_pictureWidth = width;
_pictureHeight = height;
EntityTruck = new EntityTruck(speed, weight, bodyColor);
}
protected DrawingTruck(int speed, double weight, Color bodyColor, int width, int height, int tankerWidth, int tankerHeight)
{
if (width < _tankerWidth || height < _tankerHeight)
{
return;
}
_pictureWidth = width;
_pictureHeight = height;
_tankerWidth = tankerWidth;
_tankerHeight = tankerHeight;
EntityTruck = new EntityTruck(speed, weight, bodyColor);
}
public void SetPosition(int x, int y)
{
if (x > _pictureWidth || y > _pictureHeight)
{
return;
}
_startPosX = x;
_startPosY = y;
}
public void MoveTransport(DirectionType direction)
{
if (!CanMove(direction) || EntityTruck == null)
{
return;
}
switch (direction)
{
case DirectionType.Left:
if (_startPosX - EntityTruck.Step > 0)
{
_startPosX -= (int)EntityTruck.Step;
}
break;
case DirectionType.Up:
if (_startPosY - EntityTruck.Step > 0)
{
_startPosY -= (int)EntityTruck.Step;
}
break;
case DirectionType.Right:
if (_startPosX + _tankerWidth + EntityTruck.Step < _pictureWidth)
{
_startPosX += (int)EntityTruck.Step;
}
break;
case DirectionType.Down:
if (_startPosY + _tankerHeight + EntityTruck.Step < _pictureHeight)
{
_startPosY += (int)EntityTruck.Step;
}
break;
}
}
public virtual void DrawTransport(Graphics g)
{
Pen pen = new(Color.Black);
Brush additionalBrush = new SolidBrush(EntityTruck.BodyColor);
g.FillRectangle(additionalBrush, _startPosX + 29, _startPosY + 11, 71, 28);
g.FillRectangle(additionalBrush, _startPosX + 29, _startPosY + 20, 71, 9);
g.DrawRectangle(pen, _startPosX + 29, _startPosY + 11, 71, 28);
g.DrawRectangle(pen, _startPosX + 29, _startPosY + 20, 71, 9);
Brush additionalBrush1 = new
SolidBrush(EntityTruck.BodyColor);
g.FillRectangle(additionalBrush1, _startPosX + 100, _startPosY + 10, 24, 16);
g.FillRectangle(additionalBrush1, _startPosX + 124, _startPosY + 10, 9, 16);
g.FillRectangle(additionalBrush1, _startPosX + 100, _startPosY + 10, 33, 16);
g.FillRectangle(additionalBrush1, _startPosX + 100, _startPosY + 26, 33, 13);
g.DrawLine(pen, _startPosX + 100, _startPosY + 26, _startPosX + 133, _startPosY + 39);
g.DrawRectangle(pen, _startPosX + 100, _startPosY + 10, 24, 16);
g.DrawRectangle(pen, _startPosX + 124, _startPosY + 10, 9, 16);
g.DrawRectangle(pen, _startPosX + 100, _startPosY + 10, 33, 16);
g.DrawRectangle(pen, _startPosX + 100, _startPosY + 26, 33, 13);
Brush additionalBrush2 = new
SolidBrush(EntityTruck.BodyColor);
g.FillRectangle(additionalBrush2, _startPosX + 4, _startPosY + 40, 130, 25);
g.DrawLine(pen, _startPosX + 4, _startPosY + 65, _startPosX + 25, _startPosY + 40);
Brush gr = new SolidBrush(Color.Gray);
g.FillEllipse(additionalBrush, _startPosX + 15, _startPosY + 50, 26, 26);
g.FillEllipse(additionalBrush, _startPosX + 110, _startPosY + 55, 22, 22);
g.FillEllipse(gr, _startPosX + 18, _startPosY + 53, 20, 20);
g.FillEllipse(gr, _startPosX + 112, _startPosY + 57, 18, 18);
g.DrawEllipse(pen, _startPosX + 15, _startPosY + 50, 26, 26);
g.DrawEllipse(pen, _startPosX + 110, _startPosY + 55, 22, 22);
}
public bool CanMove(DirectionType direction)
{
if (EntityTruck == null)
{
return false;
}
return direction switch
{
DirectionType.Left => _startPosX - EntityTruck.Step > 0,
DirectionType.Up => _startPosY - EntityTruck.Step > 0,
DirectionType.Right => _startPosX + _tankerWidth + EntityTruck.Step < _pictureWidth,
DirectionType.Down => _startPosY + _tankerHeight + EntityTruck.Step < _pictureHeight,
_ => false,
};
}
}
}

View File

@ -0,0 +1,22 @@
using ProjectGasolineTanker.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasolineTanker.Entities
{
public class EntityGasolineTanker : EntityTruck
{
public Color Body { get; private set; }
public bool Tank { get; private set; }
public bool Wheel { get; private set; }
public EntityGasolineTanker(int speed, double weight, Color bodyColor, Color additionalColor, bool tank, bool wheel) : base(speed, weight, bodyColor)
{
Body = additionalColor;
Tank = tank;
Wheel = wheel;
}
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasolineTanker.Entities
{
public class EntityTruck
{
public int Speed { get; private set; }
public double Weight { get; private set; }
public Color BodyColor { get; private set; }
public double Step => (double)Speed * 100 / Weight;
public EntityTruck(int speed, double weight, Color bodyColor)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
}
}
}

View File

@ -0,0 +1,190 @@
namespace ProjectGasolineTanker
{
partial class FormGasolineTanker
{
/// <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.pictureBoxGasolineTanker = new System.Windows.Forms.PictureBox();
this.buttonCreateGasolineTanker = new System.Windows.Forms.Button();
this.buttonUp = 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.comboBoxStrategy = new System.Windows.Forms.ComboBox();
this.buttonStep = new System.Windows.Forms.Button();
this.buttonCreateTruck = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxGasolineTanker)).BeginInit();
this.SuspendLayout();
//
// pictureBoxGasolineTanker
//
this.pictureBoxGasolineTanker.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxGasolineTanker.Location = new System.Drawing.Point(0, 0);
this.pictureBoxGasolineTanker.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.pictureBoxGasolineTanker.Name = "pictureBoxGasolineTanker";
this.pictureBoxGasolineTanker.Size = new System.Drawing.Size(772, 340);
this.pictureBoxGasolineTanker.TabIndex = 5;
this.pictureBoxGasolineTanker.TabStop = false;
//
// buttonCreateGasolineTanker
//
this.buttonCreateGasolineTanker.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonCreateGasolineTanker.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.buttonCreateGasolineTanker.Location = new System.Drawing.Point(10, 274);
this.buttonCreateGasolineTanker.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCreateGasolineTanker.Name = "buttonCreateGasolineTanker";
this.buttonCreateGasolineTanker.Size = new System.Drawing.Size(105, 55);
this.buttonCreateGasolineTanker.TabIndex = 6;
this.buttonCreateGasolineTanker.Text = "Создать газовоз";
this.buttonCreateGasolineTanker.UseVisualStyleBackColor = true;
this.buttonCreateGasolineTanker.Click += new System.EventHandler(this.buttonCreateGasolineTanker_Click);
//
// buttonUp
//
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUp.BackgroundImage = global::ProjectGasolineTanker.Properties.Resources.стрелка_вверх;
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.buttonUp.Location = new System.Drawing.Point(710, 283);
this.buttonUp.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonUp.Name = "buttonUp";
this.buttonUp.Size = new System.Drawing.Size(26, 22);
this.buttonUp.TabIndex = 7;
this.buttonUp.UseVisualStyleBackColor = true;
this.buttonUp.Click += new System.EventHandler(this.buttonMove_Click);
//
// buttonLeft
//
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonLeft.BackgroundImage = global::ProjectGasolineTanker.Properties.Resources.стрелка_влево;
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.buttonLeft.Location = new System.Drawing.Point(679, 310);
this.buttonLeft.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonLeft.Name = "buttonLeft";
this.buttonLeft.Size = new System.Drawing.Size(26, 22);
this.buttonLeft.TabIndex = 8;
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::ProjectGasolineTanker.Properties.Resources.стрелка_вниз;
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.buttonDown.Location = new System.Drawing.Point(710, 310);
this.buttonDown.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonDown.Name = "buttonDown";
this.buttonDown.Size = new System.Drawing.Size(26, 22);
this.buttonDown.TabIndex = 9;
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::ProjectGasolineTanker.Properties.Resources.стрелка_вправо;
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.buttonRight.Location = new System.Drawing.Point(742, 310);
this.buttonRight.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonRight.Name = "buttonRight";
this.buttonRight.Size = new System.Drawing.Size(26, 22);
this.buttonRight.TabIndex = 10;
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.buttonMove_Click);
//
// comboBoxStrategy
//
this.comboBoxStrategy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.comboBoxStrategy.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxStrategy.FormattingEnabled = true;
this.comboBoxStrategy.Items.AddRange(new object[] {
"В центр",
"В правый нижний угол"});
this.comboBoxStrategy.Location = new System.Drawing.Point(629, 9);
this.comboBoxStrategy.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.comboBoxStrategy.Name = "comboBoxStrategy";
this.comboBoxStrategy.Size = new System.Drawing.Size(133, 23);
this.comboBoxStrategy.TabIndex = 11;
//
// buttonStep
//
this.buttonStep.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonStep.Location = new System.Drawing.Point(654, 34);
this.buttonStep.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonStep.Name = "buttonStep";
this.buttonStep.Size = new System.Drawing.Size(82, 22);
this.buttonStep.TabIndex = 12;
this.buttonStep.Text = "Шаг";
this.buttonStep.UseVisualStyleBackColor = true;
this.buttonStep.Click += new System.EventHandler(this.buttonStep_Click);
//
// buttonCreateTruck
//
this.buttonCreateTruck.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonCreateTruck.Location = new System.Drawing.Point(121, 291);
this.buttonCreateTruck.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.buttonCreateTruck.Name = "buttonCreateTruck";
this.buttonCreateTruck.Size = new System.Drawing.Size(105, 38);
this.buttonCreateTruck.TabIndex = 13;
this.buttonCreateTruck.Text = "Создать грузовик";
this.buttonCreateTruck.UseVisualStyleBackColor = true;
this.buttonCreateTruck.Click += new System.EventHandler(this.buttonCreateTruck_Click);
//
// FormGasolineTanker
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(772, 340);
this.Controls.Add(this.buttonCreateTruck);
this.Controls.Add(this.buttonStep);
this.Controls.Add(this.comboBoxStrategy);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonDown);
this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.buttonCreateGasolineTanker);
this.Controls.Add(this.pictureBoxGasolineTanker);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "FormGasolineTanker";
this.Text = "GasolineTanker";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxGasolineTanker)).EndInit();
this.ResumeLayout(false);
}
#endregion
private PictureBox pictureBoxGasolineTanker;
private Button buttonCreateGasolineTanker;
private Button buttonUp;
private Button buttonLeft;
private Button buttonDown;
private Button buttonRight;
private ComboBox comboBoxStrategy;
private Button buttonStep;
private Button buttonCreateTruck;
}
}

View File

@ -0,0 +1,111 @@
using ProjectGasolineTanker.DrawingObjects;
using ProjectGasolineTanker.MovementStrategy;
namespace ProjectGasolineTanker
{
public partial class FormGasolineTanker : Form
{
private DrawingTruck? _drawingTruck;
private AbstractStrategy? _abstractStrategy;
public FormGasolineTanker()
{
InitializeComponent();
}
private void Draw()
{
if (_drawingTruck == null)
{
return;
}
Bitmap bmp = new(pictureBoxGasolineTanker.Width, pictureBoxGasolineTanker.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawingTruck.DrawTransport(gr);
pictureBoxGasolineTanker.Image = bmp;
}
private void buttonCreateGasolineTanker_Click(object sender, EventArgs e)
{
Random random = new();
_drawingTruck = new DrawingGasolineTanker(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)),
pictureBoxGasolineTanker.Width, pictureBoxGasolineTanker.Height);
_drawingTruck.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
private void buttonCreateTruck_Click(object sender, EventArgs e)
{
Random random = new();
_drawingTruck = new DrawingTruck(random.Next(100, 300),
random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256),
random.Next(0, 256)),
pictureBoxGasolineTanker.Width, pictureBoxGasolineTanker.Height);
_drawingTruck.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
private void buttonMove_Click(object sender, EventArgs e)
{
if (_drawingTruck == null)
{
return;
}
string name = ((Button)sender)?.Name ?? string.Empty;
switch (name)
{
case "buttonUp":
_drawingTruck.MoveTransport(DirectionType.Up);
break;
case "buttonDown":
_drawingTruck.MoveTransport(DirectionType.Down);
break;
case "buttonLeft":
_drawingTruck.MoveTransport(DirectionType.Left);
break;
case "buttonRight":
_drawingTruck.MoveTransport(DirectionType.Right);
break;
}
Draw();
}
private void buttonStep_Click(object sender, EventArgs e)
{
if (_drawingTruck == null)
{
return;
}
if (comboBoxStrategy.Enabled)
{
_abstractStrategy = comboBoxStrategy.SelectedIndex
switch
{
0 => new MoveToCenter(),
1 => new MoveToBorder(),
_ => null,
};
if (_abstractStrategy == null)
{
return;
}
_abstractStrategy.SetData(new DrawingObjectTruck(_drawingTruck), pictureBoxGasolineTanker.Width, pictureBoxGasolineTanker.Height);
comboBoxStrategy.Enabled = false;
}
if (_abstractStrategy == null)
{
return;
}
_abstractStrategy.MakeStep();
Draw();
if (_abstractStrategy.GetStatus() == Status.Finish)
{
comboBoxStrategy.Enabled = true;
_abstractStrategy = null;
}
}
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProjectGasolineTanker.DrawingObjects;
namespace ProjectGasolineTanker.MovementStrategy
{
public interface IMoveableObject
{
ObjectParameters? GetObjectPosition { get; }
int GetStep { get; }
bool CheckCanMove(DirectionType direction);
void MoveObject(DirectionType direction);
}
}

View File

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasolineTanker.MovementStrategy
{
internal class MoveToBorder : AbstractStrategy
{
protected override bool IsTargetDestinaion()
{
var objParams = GetObjectParameters;
if (objParams == null)
{
return false;
}
return objParams.RightBorder <= FieldWidth &&
objParams.RightBorder + GetStep() >= FieldWidth &&
objParams.DownBorder <= FieldHeight &&
objParams.DownBorder + GetStep() >= FieldHeight;
}
protected override void MoveToTarget()
{
var objParams = GetObjectParameters;
if (objParams == null)
{
return;
}
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth;
if (Math.Abs(diffX) > GetStep())
{
if (diffX > 0)
{
MoveLeft();
}
else
{
MoveRight();
}
}
var diffY = objParams.ObjectMiddleVertical - FieldHeight;
if (Math.Abs(diffY) > GetStep())
{
if (diffY > 0)
{
MoveUp();
}
else
{
MoveDown();
}
}
}
}
}

View File

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasolineTanker.MovementStrategy
{
public class MoveToCenter : AbstractStrategy
{
protected override bool IsTargetDestinaion()
{
var objParams = GetObjectParameters;
if (objParams == null)
{
return false;
}
return objParams.ObjectMiddleHorizontal <= FieldWidth / 2 &&
objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 &&
objParams.ObjectMiddleVertical <= FieldHeight / 2 &&
objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
}
protected override void MoveToTarget()
{
var objParams = GetObjectParameters;
if (objParams == null)
{
return;
}
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
if (Math.Abs(diffX) > GetStep())
{
if (diffX > 0)
{
MoveLeft();
}
else
{
MoveRight();
}
}
var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
if (Math.Abs(diffY) > GetStep())
{
if (diffY > 0)
{
MoveUp();
}
else
{
MoveDown();
}
}
}
}
}

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasolineTanker.MovementStrategy
{
public class ObjectParameters
{
private readonly int _x;
private readonly int _y;
private readonly int _width;
private readonly int _height;
public int LeftBorder => _x;
public int TopBorder => _y;
public int RightBorder => _x + _width;
public int DownBorder => _y + _height;
public int ObjectMiddleHorizontal => _x + _width / 2;
public int ObjectMiddleVertical => _y + _height / 2;
public ObjectParameters(int x, int y, int width, int height)
{
_x = x;
_y = y;
_width = width;
_height = height;
}
}
}

View File

@ -1,4 +1,4 @@
namespace GasolineTanker namespace ProjectGasolineTanker
{ {
internal static class Program internal static class Program
{ {
@ -7,11 +7,11 @@ namespace GasolineTanker
/// </summary> /// </summary>
[STAThread] [STAThread]
static void Main() static void Main()
{ {
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
Application.Run(new GasolineTanker()); Application.Run(new FormGasolineTanker());
} }
} }
} }

View File

@ -8,7 +8,7 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace GasolineTanker.Properties { namespace ProjectGasolineTanker.Properties {
using System; using System;
@ -39,7 +39,7 @@ namespace GasolineTanker.Properties {
internal static global::System.Resources.ResourceManager ResourceManager { internal static global::System.Resources.ResourceManager ResourceManager {
get { get {
if (object.ReferenceEquals(resourceMan, null)) { if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GasolineTanker.Properties.Resources", typeof(Resources).Assembly); global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectGasolineTanker.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp; resourceMan = temp;
} }
return resourceMan; return resourceMan;
@ -63,9 +63,9 @@ namespace GasolineTanker.Properties {
/// <summary> /// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap. /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary> /// </summary>
internal static System.Drawing.Bitmap down { internal static System.Drawing.Bitmap стрелка_вверх {
get { get {
object obj = ResourceManager.GetObject("down", resourceCulture); object obj = ResourceManager.GetObject("стрелка вверх", resourceCulture);
return ((System.Drawing.Bitmap)(obj)); return ((System.Drawing.Bitmap)(obj));
} }
} }
@ -73,9 +73,9 @@ namespace GasolineTanker.Properties {
/// <summary> /// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap. /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary> /// </summary>
internal static System.Drawing.Bitmap left { internal static System.Drawing.Bitmap стрелка_влево {
get { get {
object obj = ResourceManager.GetObject("left", resourceCulture); object obj = ResourceManager.GetObject("стрелка влево", resourceCulture);
return ((System.Drawing.Bitmap)(obj)); return ((System.Drawing.Bitmap)(obj));
} }
} }
@ -83,9 +83,9 @@ namespace GasolineTanker.Properties {
/// <summary> /// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap. /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary> /// </summary>
internal static System.Drawing.Bitmap right { internal static System.Drawing.Bitmap стрелка_вниз {
get { get {
object obj = ResourceManager.GetObject("right", resourceCulture); object obj = ResourceManager.GetObject("стрелка вниз", resourceCulture);
return ((System.Drawing.Bitmap)(obj)); return ((System.Drawing.Bitmap)(obj));
} }
} }
@ -93,9 +93,9 @@ namespace GasolineTanker.Properties {
/// <summary> /// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap. /// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary> /// </summary>
internal static System.Drawing.Bitmap up { internal static System.Drawing.Bitmap стрелка_вправо {
get { get {
object obj = ResourceManager.GetObject("up", resourceCulture); object obj = ResourceManager.GetObject("стрелка вправо", resourceCulture);
return ((System.Drawing.Bitmap)(obj)); return ((System.Drawing.Bitmap)(obj));
} }
} }

View File

@ -118,16 +118,16 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <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"> <data name="стрелка вверх" 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> <value>..\Resources\стрелка вверх.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="left" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="стрелка влево" 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> <value>..\Resources\стрелка влево.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="right" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="стрелка вниз" 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> <value>..\Resources\стрелка вниз.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="up" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="стрелка вправо" 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> <value>..\Resources\стрелка вправо.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
</root> </root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasolineTanker.MovementStrategy
{
public enum Status
{
NotInit,
InProgress,
Finish
}
}