Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
61099f558b | |||
bb1b96f3ff | |||
2b478161f0 | |||
ce9b9e2d60 | |||
5eb0454b66 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
MotorShip/.vs/WarmlyShip/v17/.suo
Normal file
BIN
MotorShip/.vs/WarmlyShip/v17/.suo
Normal file
Binary file not shown.
109
MotorShip/MotorShip/AbstractStrategy.cs
Normal file
109
MotorShip/MotorShip/AbstractStrategy.cs
Normal file
@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WarmlyShip.DrawingObjects;
|
||||
|
||||
|
||||
namespace WarmlyShip.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();
|
||||
}
|
||||
/// <summary>
|
||||
/// Перемещение влево
|
||||
/// </summary>
|
||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
||||
protected bool MoveLeft() => MoveTo(DirectionType.Left);
|
||||
/// <summary>
|
||||
/// Перемещение вправо
|
||||
/// </summary>
|
||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
||||
protected bool MoveRight() => MoveTo(DirectionType.Right);
|
||||
/// <summary>
|
||||
/// Перемещение вверх
|
||||
/// </summary>
|
||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
||||
protected bool MoveUp() => MoveTo(DirectionType.Up);
|
||||
/// <summary>
|
||||
/// Перемещение вниз
|
||||
/// </summary>
|
||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
||||
protected bool MoveDown() => MoveTo(DirectionType.Down);
|
||||
/// <summary>
|
||||
/// Параметры объекта
|
||||
/// </summary>
|
||||
protected ObjectParameters? GetObjectParameters =>
|
||||
_moveableObject?.GetObjectPosition;
|
||||
/// <summary>
|
||||
/// Шаг объекта
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected int? GetStep()
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _moveableObject?.GetStep;
|
||||
}
|
||||
/// <summary>
|
||||
/// Перемещение к цели
|
||||
/// </summary>
|
||||
protected abstract void MoveToTarget();
|
||||
/// <summary>
|
||||
/// Достигнута ли цель
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected abstract bool IsTargetDestinaion();
|
||||
/// <summary>
|
||||
/// Попытка перемещения в требуемом направлении
|
||||
/// </summary>
|
||||
/// <param name="directionType">Направление</param>
|
||||
/// <returns>Результат попытки (true - удалось переместиться, false - неудача)</returns>
|
||||
private bool MoveTo(DirectionType directionType)
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_moveableObject?.CheckCanMove(directionType) ?? false)
|
||||
{
|
||||
_moveableObject.MoveObject(directionType);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
32
MotorShip/MotorShip/Direction.cs
Normal file
32
MotorShip/MotorShip/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 WarmlyShip
|
||||
{
|
||||
/// <summary>
|
||||
/// Направление перемещения
|
||||
/// </summary>
|
||||
public enum DirectionType
|
||||
{
|
||||
/// <summary>
|
||||
/// Вверх
|
||||
/// </summary>
|
||||
Up = 1,
|
||||
/// <summary>
|
||||
/// Вниз
|
||||
/// </summary>
|
||||
Down = 2,
|
||||
/// <summary>
|
||||
/// Влево
|
||||
/// </summary>
|
||||
Left = 3,
|
||||
/// <summary>
|
||||
/// Вправо
|
||||
/// </summary>
|
||||
Right = 4
|
||||
|
||||
}
|
||||
}
|
35
MotorShip/MotorShip/DrawingObjectShip.cs
Normal file
35
MotorShip/MotorShip/DrawingObjectShip.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WarmlyShip.DrawingObjects;
|
||||
|
||||
namespace WarmlyShip.MovementStrategy
|
||||
{
|
||||
public class DrawingObjectShip : IMoveableObject
|
||||
{
|
||||
private readonly DrawingWarmlyShip? _drawingWarmlyShip = null;
|
||||
public DrawingObjectShip(DrawingWarmlyShip drawingWarmlyShip)
|
||||
{
|
||||
_drawingWarmlyShip = drawingWarmlyShip;
|
||||
}
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_drawingWarmlyShip == null || _drawingWarmlyShip.EntityWarmlyShip == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ObjectParameters(_drawingWarmlyShip.GetPosX,
|
||||
_drawingWarmlyShip.GetPosY, _drawingWarmlyShip.GetWidth, _drawingWarmlyShip.GetHeight);
|
||||
}
|
||||
}
|
||||
public int GetStep => (int)(_drawingWarmlyShip?.EntityWarmlyShip?.Step ?? 0);
|
||||
public bool CheckCanMove(DirectionType direction) =>
|
||||
_drawingWarmlyShip?.CanMove(direction) ?? false;
|
||||
public void MoveObject(DirectionType direction) =>
|
||||
_drawingWarmlyShip?.MoveTransport(direction);
|
||||
}
|
||||
}
|
133
MotorShip/MotorShip/DrawingWarmlyShip.cs
Normal file
133
MotorShip/MotorShip/DrawingWarmlyShip.cs
Normal file
@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WarmlyShip.Entities;
|
||||
using WarmlyShip.MovementStrategy;
|
||||
|
||||
namespace WarmlyShip.DrawingObjects
|
||||
{
|
||||
public class DrawingWarmlyShip
|
||||
{
|
||||
public EntityWarmlyShip? EntityWarmlyShip { get; protected set; }
|
||||
private int _pictureWidth;
|
||||
private int _pictureHeight;
|
||||
protected int _startPosX;
|
||||
protected int _startPosY;
|
||||
protected readonly int _WarmlyShipWidth = 185;
|
||||
protected readonly int _WarmlyShipHeight = 180;
|
||||
public DrawingWarmlyShip(int speed, double weight, Color bodyColor, int width, int height)
|
||||
{
|
||||
if (width < _WarmlyShipWidth || height < _WarmlyShipHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
EntityWarmlyShip = new EntityWarmlyShip(speed, weight, bodyColor);
|
||||
|
||||
}
|
||||
protected DrawingWarmlyShip(int speed, double weight, Color bodyColor, int
|
||||
width, int height, int warmlyShipWidth, int warmlyShipHeight)
|
||||
{
|
||||
if (width <= _WarmlyShipWidth || height <= _WarmlyShipHeight)
|
||||
return;
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
_WarmlyShipWidth = warmlyShipWidth;
|
||||
_WarmlyShipHeight = warmlyShipHeight;
|
||||
EntityWarmlyShip = new EntityWarmlyShip(speed, weight, bodyColor);
|
||||
}
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (x >= 0 && x + _WarmlyShipWidth <= _pictureWidth && y >= 0 && y + _WarmlyShipHeight <= _pictureHeight)
|
||||
{
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
}
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityWarmlyShip == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black, 2);
|
||||
Pen anchor = new(Color.Black, 4);
|
||||
Brush bodyBrush = new SolidBrush(EntityWarmlyShip.BodyColor);
|
||||
//корпус теплохода
|
||||
Point[] hull = new Point[]
|
||||
{
|
||||
new Point(_startPosX, _startPosY + 110),
|
||||
new Point(_startPosX + 180, _startPosY + 110),
|
||||
new Point(_startPosX + 140, _startPosY + 185),
|
||||
new Point(_startPosX + 40, _startPosY + 185),
|
||||
};
|
||||
g.FillPolygon(bodyBrush, hull);
|
||||
g.DrawPolygon(pen, hull);
|
||||
//палуба
|
||||
g.FillRectangle(bodyBrush, _startPosX + 25, _startPosY + 80, 130, 30);
|
||||
g.DrawRectangle(pen, _startPosX + 25, _startPosY + 80, 130, 30);
|
||||
|
||||
//якорь
|
||||
g.DrawLine(anchor, new Point(_startPosX + 50, _startPosY + 130), new Point(_startPosX + 50, _startPosY + 150));
|
||||
g.DrawLine(anchor, new Point(_startPosX + 40, _startPosY + 140), new Point(_startPosX + 60, _startPosY + 140));
|
||||
g.DrawLine(anchor, new Point(_startPosX + 45, _startPosY + 150), new Point(_startPosX + 55, _startPosY + 150));
|
||||
}
|
||||
public int GetPosX => _startPosX;
|
||||
public int GetPosY => _startPosY;
|
||||
public int GetWidth => _WarmlyShipWidth;
|
||||
public int GetHeight => _WarmlyShipHeight;
|
||||
public bool CanMove(DirectionType direction)
|
||||
{
|
||||
if (EntityWarmlyShip == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return direction switch
|
||||
{
|
||||
//влево
|
||||
DirectionType.Left => _startPosX - EntityWarmlyShip.Step > 0,
|
||||
//вверх
|
||||
DirectionType.Up => _startPosY - EntityWarmlyShip.Step > 0,
|
||||
//вправо
|
||||
DirectionType.Right => _startPosX + EntityWarmlyShip.Step + _WarmlyShipWidth < _pictureWidth,
|
||||
//вниз
|
||||
DirectionType.Down => _startPosY + EntityWarmlyShip.Step + _WarmlyShipHeight < _pictureHeight,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
public void MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (!CanMove(direction) || EntityWarmlyShip == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
//влево
|
||||
case DirectionType.Left:
|
||||
_startPosX -= (int)EntityWarmlyShip.Step;
|
||||
break;
|
||||
//вверх
|
||||
case DirectionType.Up:
|
||||
_startPosY -= (int)EntityWarmlyShip.Step;
|
||||
break;
|
||||
// вправо
|
||||
case DirectionType.Right:
|
||||
_startPosX += (int)EntityWarmlyShip.Step;
|
||||
break;
|
||||
//вниз
|
||||
case DirectionType.Down:
|
||||
_startPosY += (int)EntityWarmlyShip.Step;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение объекта IMoveableObject из объекта DrawingCar
|
||||
/// </summary>
|
||||
public IMoveableObject GetMoveableObject => new DrawingObjectShip(this);
|
||||
}
|
||||
}
|
||||
|
48
MotorShip/MotorShip/DrawingWarmlyShipWithPipes.cs
Normal file
48
MotorShip/MotorShip/DrawingWarmlyShipWithPipes.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WarmlyShip.Entities;
|
||||
|
||||
namespace WarmlyShip.DrawingObjects
|
||||
{
|
||||
public class DrawingWarmlyShipWithPipes : DrawingWarmlyShip
|
||||
{
|
||||
public DrawingWarmlyShipWithPipes(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, bool pipes, bool section, int width, int height)
|
||||
: base(speed, weight, bodyColor, width, height, 185, 180)
|
||||
{
|
||||
if (EntityWarmlyShip != null)
|
||||
{
|
||||
EntityWarmlyShip = new EntityWarmlyShipWithPipes(speed, weight, bodyColor, additionalColor, pipes, section);
|
||||
}
|
||||
}
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityWarmlyShip is not EntityWarmlyShipWithPipes warmlyShip)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black, 2);
|
||||
Brush additionalBrush = new SolidBrush(warmlyShip.AdditionalColor);
|
||||
base.DrawTransport(g);
|
||||
//отсек для топлива
|
||||
Brush brGray = new SolidBrush(Color.Gray);
|
||||
if (warmlyShip.Section)
|
||||
{
|
||||
g.FillEllipse(brGray, _startPosX + 130, _startPosY + 130, 20, 20);
|
||||
g.DrawEllipse(pen, _startPosX + 130, _startPosY + 130, 20, 20);
|
||||
}
|
||||
//трубы
|
||||
if (warmlyShip.Pipes)
|
||||
{
|
||||
g.FillRectangle(additionalBrush, _startPosX + 55, _startPosY, 25, 80);
|
||||
g.DrawRectangle(pen, _startPosX + 55, _startPosY, 25, 80);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 90, _startPosY + 20, 25, 60);
|
||||
g.DrawRectangle(pen, _startPosX + 90, _startPosY + 20, 25, 60);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
22
MotorShip/MotorShip/EntityWarmlyShip.cs
Normal file
22
MotorShip/MotorShip/EntityWarmlyShip.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WarmlyShip.Entities
|
||||
{
|
||||
public class EntityWarmlyShip
|
||||
{
|
||||
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 EntityWarmlyShip(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
}
|
||||
}
|
23
MotorShip/MotorShip/EntityWarmlyShipWithPipes.cs
Normal file
23
MotorShip/MotorShip/EntityWarmlyShipWithPipes.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WarmlyShip.Entities
|
||||
{
|
||||
public class EntityWarmlyShipWithPipes : EntityWarmlyShip
|
||||
{
|
||||
public Color AdditionalColor { get; private set; }
|
||||
public bool Pipes { get; private set; }
|
||||
public bool Section { get; private set; }
|
||||
public EntityWarmlyShipWithPipes(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, bool pipes, bool section)
|
||||
: base(speed, weight, bodyColor)
|
||||
{
|
||||
AdditionalColor = additionalColor;
|
||||
Pipes = pipes;
|
||||
Section = section;
|
||||
}
|
||||
}
|
||||
}
|
39
MotorShip/MotorShip/Form1.Designer.cs
generated
39
MotorShip/MotorShip/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
||||
namespace MotorShip
|
||||
{
|
||||
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 MotorShip
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
192
MotorShip/MotorShip/FormShipCollection.Designer.cs
generated
Normal file
192
MotorShip/MotorShip/FormShipCollection.Designer.cs
generated
Normal file
@ -0,0 +1,192 @@
|
||||
namespace WarmlyShip
|
||||
{
|
||||
partial class FormShipCollection
|
||||
{
|
||||
/// <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.pictureBoxCollection = new System.Windows.Forms.PictureBox();
|
||||
this.panelCollection = new System.Windows.Forms.Panel();
|
||||
this.buttonRefreshCollection = new System.Windows.Forms.Button();
|
||||
this.buttonRemoveShip = new System.Windows.Forms.Button();
|
||||
this.maskedTextBoxNumber = new System.Windows.Forms.MaskedTextBox();
|
||||
this.buttonAddShip = new System.Windows.Forms.Button();
|
||||
this.labelCollection = new System.Windows.Forms.Label();
|
||||
this.groupBoxSets = new System.Windows.Forms.GroupBox();
|
||||
this.textBoxStorageName = new System.Windows.Forms.TextBox();
|
||||
this.buttonnAddObject = new System.Windows.Forms.Button();
|
||||
this.listBoxStorages = new System.Windows.Forms.ListBox();
|
||||
this.buttonDelObject = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
|
||||
this.panelCollection.SuspendLayout();
|
||||
this.groupBoxSets.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxCollection
|
||||
//
|
||||
this.pictureBoxCollection.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxCollection.Name = "pictureBoxCollection";
|
||||
this.pictureBoxCollection.Size = new System.Drawing.Size(864, 536);
|
||||
this.pictureBoxCollection.TabIndex = 0;
|
||||
this.pictureBoxCollection.TabStop = false;
|
||||
//
|
||||
// panelCollection
|
||||
//
|
||||
this.panelCollection.Controls.Add(this.groupBoxSets);
|
||||
this.panelCollection.Controls.Add(this.buttonRefreshCollection);
|
||||
this.panelCollection.Controls.Add(this.buttonRemoveShip);
|
||||
this.panelCollection.Controls.Add(this.maskedTextBoxNumber);
|
||||
this.panelCollection.Controls.Add(this.buttonAddShip);
|
||||
this.panelCollection.Controls.Add(this.labelCollection);
|
||||
this.panelCollection.Location = new System.Drawing.Point(870, 0);
|
||||
this.panelCollection.Name = "panelCollection";
|
||||
this.panelCollection.Size = new System.Drawing.Size(218, 536);
|
||||
this.panelCollection.TabIndex = 1;
|
||||
//
|
||||
// buttonRefreshCollection
|
||||
//
|
||||
this.buttonRefreshCollection.Location = new System.Drawing.Point(16, 482);
|
||||
this.buttonRefreshCollection.Name = "buttonRefreshCollection";
|
||||
this.buttonRefreshCollection.Size = new System.Drawing.Size(171, 40);
|
||||
this.buttonRefreshCollection.TabIndex = 4;
|
||||
this.buttonRefreshCollection.Text = "Обновить коллекцию";
|
||||
this.buttonRefreshCollection.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonRemoveShip
|
||||
//
|
||||
this.buttonRemoveShip.Location = new System.Drawing.Point(16, 424);
|
||||
this.buttonRemoveShip.Name = "buttonRemoveShip";
|
||||
this.buttonRemoveShip.Size = new System.Drawing.Size(171, 40);
|
||||
this.buttonRemoveShip.TabIndex = 3;
|
||||
this.buttonRemoveShip.Text = "Удалить теплоход";
|
||||
this.buttonRemoveShip.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// maskedTextBoxNumber
|
||||
//
|
||||
this.maskedTextBoxNumber.Location = new System.Drawing.Point(16, 375);
|
||||
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||
this.maskedTextBoxNumber.Size = new System.Drawing.Size(171, 27);
|
||||
this.maskedTextBoxNumber.TabIndex = 2;
|
||||
//
|
||||
// buttonAddShip
|
||||
//
|
||||
this.buttonAddShip.Location = new System.Drawing.Point(16, 309);
|
||||
this.buttonAddShip.Name = "buttonAddShip";
|
||||
this.buttonAddShip.Size = new System.Drawing.Size(171, 40);
|
||||
this.buttonAddShip.TabIndex = 1;
|
||||
this.buttonAddShip.Text = "Добавить теплоход";
|
||||
this.buttonAddShip.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// labelCollection
|
||||
//
|
||||
this.labelCollection.AutoSize = true;
|
||||
this.labelCollection.Location = new System.Drawing.Point(3, 9);
|
||||
this.labelCollection.Name = "labelCollection";
|
||||
this.labelCollection.Size = new System.Drawing.Size(103, 20);
|
||||
this.labelCollection.TabIndex = 0;
|
||||
this.labelCollection.Text = "Инструменты";
|
||||
//
|
||||
// groupBoxSets
|
||||
//
|
||||
this.groupBoxSets.Controls.Add(this.buttonDelObject);
|
||||
this.groupBoxSets.Controls.Add(this.listBoxStorages);
|
||||
this.groupBoxSets.Controls.Add(this.buttonnAddObject);
|
||||
this.groupBoxSets.Controls.Add(this.textBoxStorageName);
|
||||
this.groupBoxSets.Location = new System.Drawing.Point(12, 42);
|
||||
this.groupBoxSets.Name = "groupBoxSets";
|
||||
this.groupBoxSets.Size = new System.Drawing.Size(199, 242);
|
||||
this.groupBoxSets.TabIndex = 5;
|
||||
this.groupBoxSets.TabStop = false;
|
||||
this.groupBoxSets.Text = "Наборы";
|
||||
//
|
||||
// textBoxStorageName
|
||||
//
|
||||
this.textBoxStorageName.Location = new System.Drawing.Point(0, 26);
|
||||
this.textBoxStorageName.Name = "textBoxStorageName";
|
||||
this.textBoxStorageName.Size = new System.Drawing.Size(193, 27);
|
||||
this.textBoxStorageName.TabIndex = 0;
|
||||
//
|
||||
// buttonnAddObject
|
||||
//
|
||||
this.buttonnAddObject.Location = new System.Drawing.Point(4, 71);
|
||||
this.buttonnAddObject.Name = "buttonnAddObject";
|
||||
this.buttonnAddObject.Size = new System.Drawing.Size(189, 29);
|
||||
this.buttonnAddObject.TabIndex = 1;
|
||||
this.buttonnAddObject.Text = "Добавить набор";
|
||||
this.buttonnAddObject.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// listBoxStorages
|
||||
//
|
||||
this.listBoxStorages.FormattingEnabled = true;
|
||||
this.listBoxStorages.ItemHeight = 20;
|
||||
this.listBoxStorages.Location = new System.Drawing.Point(6, 117);
|
||||
this.listBoxStorages.Name = "listBoxStorages";
|
||||
this.listBoxStorages.Size = new System.Drawing.Size(187, 84);
|
||||
this.listBoxStorages.TabIndex = 2;
|
||||
//
|
||||
// buttonDelObject
|
||||
//
|
||||
this.buttonDelObject.Location = new System.Drawing.Point(6, 207);
|
||||
this.buttonDelObject.Name = "buttonDelObject";
|
||||
this.buttonDelObject.Size = new System.Drawing.Size(187, 29);
|
||||
this.buttonDelObject.TabIndex = 3;
|
||||
this.buttonDelObject.Text = "Удалить набор";
|
||||
this.buttonDelObject.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormShipCollection
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1093, 534);
|
||||
this.Controls.Add(this.panelCollection);
|
||||
this.Controls.Add(this.pictureBoxCollection);
|
||||
this.Name = "FormShipCollection";
|
||||
this.Text = "FormShipCollection";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
|
||||
this.panelCollection.ResumeLayout(false);
|
||||
this.panelCollection.PerformLayout();
|
||||
this.groupBoxSets.ResumeLayout(false);
|
||||
this.groupBoxSets.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxCollection;
|
||||
private Panel panelCollection;
|
||||
private Button buttonRefreshCollection;
|
||||
private Button buttonRemoveShip;
|
||||
private MaskedTextBox maskedTextBoxNumber;
|
||||
private Button buttonAddShip;
|
||||
private Label labelCollection;
|
||||
private GroupBox groupBoxSets;
|
||||
private Button buttonDelObject;
|
||||
private ListBox listBoxStorages;
|
||||
private Button buttonnAddObject;
|
||||
private TextBox textBoxStorageName;
|
||||
}
|
||||
}
|
20
MotorShip/MotorShip/FormShipCollection.cs
Normal file
20
MotorShip/MotorShip/FormShipCollection.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WarmlyShip
|
||||
{
|
||||
public partial class FormShipCollection : Form
|
||||
{
|
||||
public FormShipCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
60
MotorShip/MotorShip/FormShipCollection.resx
Normal file
60
MotorShip/MotorShip/FormShipCollection.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>
|
179
MotorShip/MotorShip/FormWarmlyShip.Designer.cs
generated
Normal file
179
MotorShip/MotorShip/FormWarmlyShip.Designer.cs
generated
Normal file
@ -0,0 +1,179 @@
|
||||
namespace MotorShip
|
||||
{
|
||||
partial class FormWarmlyShip
|
||||
{
|
||||
/// <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.pictureBoxWarmlyShip = new System.Windows.Forms.PictureBox();
|
||||
this.buttonCreateWarmlyShip = new System.Windows.Forms.Button();
|
||||
this.buttonCreate = new System.Windows.Forms.Button();
|
||||
this.buttonStep = new System.Windows.Forms.Button();
|
||||
this.comboBoxStrategy = new System.Windows.Forms.ComboBox();
|
||||
this.buttonSelectShip = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxWarmlyShip)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxWarmlyShip
|
||||
//
|
||||
this.pictureBoxWarmlyShip.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxWarmlyShip.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxWarmlyShip.Name = "pictureBoxWarmlyShip";
|
||||
this.pictureBoxWarmlyShip.Size = new System.Drawing.Size(882, 453);
|
||||
this.pictureBoxWarmlyShip.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBoxWarmlyShip.TabIndex = 0;
|
||||
this.pictureBoxWarmlyShip.TabStop = false;
|
||||
this.pictureBoxWarmlyShip.Click += new System.EventHandler(this.pictureBoxWarmlyShip_Click);
|
||||
//
|
||||
// buttonCreateWarmlyShip
|
||||
//
|
||||
this.buttonCreateWarmlyShip.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonCreateWarmlyShip.Location = new System.Drawing.Point(12, 389);
|
||||
this.buttonCreateWarmlyShip.Name = "buttonCreateWarmlyShip";
|
||||
this.buttonCreateWarmlyShip.Size = new System.Drawing.Size(163, 50);
|
||||
this.buttonCreateWarmlyShip.TabIndex = 1;
|
||||
this.buttonCreateWarmlyShip.Text = "Создать теплоход с трубами";
|
||||
this.buttonCreateWarmlyShip.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// 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(197, 389);
|
||||
this.buttonCreate.Name = "buttonCreate";
|
||||
this.buttonCreate.Size = new System.Drawing.Size(122, 50);
|
||||
this.buttonCreate.TabIndex = 2;
|
||||
this.buttonCreate.Text = "Создать теплоход";
|
||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonStep
|
||||
//
|
||||
this.buttonStep.Location = new System.Drawing.Point(720, 56);
|
||||
this.buttonStep.Name = "buttonStep";
|
||||
this.buttonStep.Size = new System.Drawing.Size(150, 29);
|
||||
this.buttonStep.TabIndex = 8;
|
||||
this.buttonStep.Text = "Шаг";
|
||||
this.buttonStep.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// comboBoxStrategy
|
||||
//
|
||||
this.comboBoxStrategy.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxStrategy.FormattingEnabled = true;
|
||||
this.comboBoxStrategy.Location = new System.Drawing.Point(720, 13);
|
||||
this.comboBoxStrategy.Name = "comboBoxStrategy";
|
||||
this.comboBoxStrategy.Size = new System.Drawing.Size(151, 28);
|
||||
this.comboBoxStrategy.TabIndex = 7;
|
||||
//
|
||||
// buttonSelectShip
|
||||
//
|
||||
this.buttonSelectShip.Location = new System.Drawing.Point(720, 107);
|
||||
this.buttonSelectShip.Name = "buttonSelectShip";
|
||||
this.buttonSelectShip.Size = new System.Drawing.Size(150, 29);
|
||||
this.buttonSelectShip.TabIndex = 9;
|
||||
this.buttonSelectShip.Text = "Выбрать теплоход";
|
||||
this.buttonSelectShip.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(720, 411);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonLeft.TabIndex = 3;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonUp.Location = new System.Drawing.Point(756, 375);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonUp.TabIndex = 4;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonDown.Location = new System.Drawing.Point(756, 411);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonDown.TabIndex = 5;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonRight.Location = new System.Drawing.Point(792, 411);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonRight.TabIndex = 6;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormWarmlyShip
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.ClientSize = new System.Drawing.Size(882, 453);
|
||||
this.Controls.Add(this.buttonRight);
|
||||
this.Controls.Add(this.buttonDown);
|
||||
this.Controls.Add(this.buttonUp);
|
||||
this.Controls.Add(this.buttonLeft);
|
||||
this.Controls.Add(this.buttonSelectShip);
|
||||
this.Controls.Add(this.comboBoxStrategy);
|
||||
this.Controls.Add(this.buttonStep);
|
||||
this.Controls.Add(this.buttonCreate);
|
||||
this.Controls.Add(this.buttonCreateWarmlyShip);
|
||||
this.Controls.Add(this.pictureBoxWarmlyShip);
|
||||
this.Name = "FormWarmlyShip";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Теплоход";
|
||||
this.Load += new System.EventHandler(this.FormWarmlyShip_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxWarmlyShip)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxWarmlyShip;
|
||||
private Button buttonCreateWarmlyShip;
|
||||
private Button buttonCreate;
|
||||
private Button buttonStep;
|
||||
private ComboBox comboBoxStrategy;
|
||||
private Button buttonSelectShip;
|
||||
private Button buttonLeft;
|
||||
private Button buttonUp;
|
||||
private Button buttonDown;
|
||||
private Button buttonRight;
|
||||
}
|
||||
}
|
20
MotorShip/MotorShip/FormWarmlyShip.cs
Normal file
20
MotorShip/MotorShip/FormWarmlyShip.cs
Normal file
@ -0,0 +1,20 @@
|
||||
namespace MotorShip
|
||||
{
|
||||
public partial class FormWarmlyShip : Form
|
||||
{
|
||||
public FormWarmlyShip()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void FormWarmlyShip_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void pictureBoxWarmlyShip_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
60
MotorShip/MotorShip/FormWarmlyShip.resx
Normal file
60
MotorShip/MotorShip/FormWarmlyShip.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>
|
18
MotorShip/MotorShip/IMoveableObject.cs
Normal file
18
MotorShip/MotorShip/IMoveableObject.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WarmlyShip.DrawingObjects;
|
||||
|
||||
|
||||
namespace WarmlyShip.MovementStrategy
|
||||
{
|
||||
public interface IMoveableObject
|
||||
{
|
||||
ObjectParameters? GetObjectPosition { get; }
|
||||
int GetStep { get; }
|
||||
bool CheckCanMove(DirectionType direction);
|
||||
void MoveObject(DirectionType direction);
|
||||
}
|
||||
}
|
@ -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>
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Compile Update="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
</Project>
|
57
MotorShip/MotorShip/MoveToBorder.cs
Normal file
57
MotorShip/MotorShip/MoveToBorder.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WarmlyShip.MovementStrategy
|
||||
{
|
||||
public 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.RightBorder - FieldWidth;
|
||||
if (Math.Abs(diffX) > GetStep())
|
||||
{
|
||||
if (diffX > 0)
|
||||
{
|
||||
MoveLeft();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveRight();
|
||||
}
|
||||
}
|
||||
var diffY = objParams.DownBorder - FieldHeight;
|
||||
if (Math.Abs(diffY) > GetStep())
|
||||
{
|
||||
if (diffY > 0)
|
||||
{
|
||||
MoveUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
56
MotorShip/MotorShip/MoveToCenter.cs
Normal file
56
MotorShip/MotorShip/MoveToCenter.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WarmlyShip.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
29
MotorShip/MotorShip/ObjectParameters.cs
Normal file
29
MotorShip/MotorShip/ObjectParameters.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WarmlyShip.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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
namespace MotorShip
|
||||
namespace WarmlyShip
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
@ -11,7 +11,7 @@ namespace MotorShip
|
||||
// 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 FormShipCollection());
|
||||
}
|
||||
}
|
||||
}
|
63
MotorShip/MotorShip/Properties/Resources.Designer.cs
generated
Normal file
63
MotorShip/MotorShip/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace WarmlyShip.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("WarmlyShip.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
83
MotorShip/MotorShip/SetGeneric.cs
Normal file
83
MotorShip/MotorShip/SetGeneric.cs
Normal file
@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WarmlyShip.Generics
|
||||
{
|
||||
internal class SetGeneric<T>
|
||||
where T : class
|
||||
{
|
||||
private readonly List<T?> _places;
|
||||
public int Count => _places.Count;
|
||||
private readonly int _maxCount;
|
||||
public SetGeneric(int count)
|
||||
{
|
||||
_maxCount = count;
|
||||
_places = new List<T?>(count);
|
||||
}
|
||||
public bool Insert(T warmlyship)
|
||||
{
|
||||
if (_places.Count == _maxCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Insert(warmlyship, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Insert(T warmlyship, int position)
|
||||
{
|
||||
if (!(position >= 0 && position <= Count && _places.Count < _maxCount))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_places.Insert(position, warmlyship);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Remove(int position)
|
||||
{
|
||||
if (position < 0 || position >= Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_places.RemoveAt(position);
|
||||
return true;
|
||||
}
|
||||
|
||||
public T? this[int position]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (position < 0 || position >= Count)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _places[position];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!(position >= 0 && position < Count && _places.Count < _maxCount))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_places.Insert(position, value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
public IEnumerable<T> GetShips(int? maxShips = null)
|
||||
{
|
||||
for (int i = 0; i < _places.Count; ++i)
|
||||
{
|
||||
yield return _places[i];
|
||||
if (maxShips.HasValue && i == maxShips.Value)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
91
MotorShip/MotorShip/ShipsGenericCollection.cs
Normal file
91
MotorShip/MotorShip/ShipsGenericCollection.cs
Normal file
@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using WarmlyShip.DrawingObjects;
|
||||
using WarmlyShip.MovementStrategy;
|
||||
|
||||
namespace WarmlyShip.Generics
|
||||
{
|
||||
internal class ShipsGenericCollection<T, U>
|
||||
where T : DrawingWarmlyShip
|
||||
where U : IMoveableObject
|
||||
{
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
private readonly int _placeSizeWidth = 185;
|
||||
private readonly int _placeSizeHeight = 185;
|
||||
private readonly SetGeneric<T> _collection;
|
||||
public ShipsGenericCollection(int picWidth, int picHeight)
|
||||
{
|
||||
int width = picWidth / _placeSizeWidth;
|
||||
int height = picHeight / _placeSizeHeight;
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
_collection = new SetGeneric<T>(width * height);
|
||||
}
|
||||
public static bool operator +(ShipsGenericCollection<T, U> collect, T?
|
||||
obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return (bool)collect?._collection.Insert(obj);
|
||||
}
|
||||
public static T? operator -(ShipsGenericCollection<T, U> collect, int
|
||||
pos)
|
||||
{
|
||||
T? obj = collect._collection[pos];
|
||||
if (obj != null)
|
||||
{
|
||||
collect._collection.Remove(pos);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
public U? GetU(int pos)
|
||||
{
|
||||
return (U?)_collection[pos]?.GetMoveableObject;
|
||||
}
|
||||
public Bitmap ShowShips()
|
||||
{
|
||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
DrawBackground(gr);
|
||||
DrawObjects(gr);
|
||||
return bmp;
|
||||
}
|
||||
private void DrawBackground(Graphics g)
|
||||
{
|
||||
Pen pen = new(Color.Black, 3);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||
{
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight +
|
||||
1; ++j)
|
||||
{
|
||||
g.DrawLine(pen, i * _placeSizeWidth, j *
|
||||
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
|
||||
_placeSizeHeight);
|
||||
}
|
||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
|
||||
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
||||
}
|
||||
}
|
||||
private void DrawObjects(Graphics g)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var ship in _collection.GetShips())
|
||||
{
|
||||
if (ship != null)
|
||||
{
|
||||
int width = _pictureWidth / _placeSizeWidth;
|
||||
ship.SetPosition((width - 1 - (i % width)) * _placeSizeWidth, i / width * _placeSizeHeight);
|
||||
ship.DrawTransport(g);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
50
MotorShip/MotorShip/ShipsGenericStorage.cs
Normal file
50
MotorShip/MotorShip/ShipsGenericStorage.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WarmlyShip.DrawingObjects;
|
||||
using WarmlyShip.MovementStrategy;
|
||||
|
||||
namespace WarmlyShip.Generics
|
||||
{
|
||||
internal class ShipsGenericStorage
|
||||
{
|
||||
readonly Dictionary<string, ShipsGenericCollection<DrawingWarmlyShip, DrawingObjectShip>> _shipStorages;
|
||||
public List<string> Keys => _shipStorages.Keys.ToList();
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
public ShipsGenericStorage(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_shipStorages = new Dictionary<string,
|
||||
ShipsGenericCollection<DrawingWarmlyShip, DrawingObjectShip>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
public void AddSet(string name)
|
||||
{
|
||||
if (_shipStorages.ContainsKey(name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
_shipStorages[name] = new ShipsGenericCollection<DrawingWarmlyShip, DrawingObjectShip>(_pictureWidth, _pictureHeight);
|
||||
}
|
||||
public void DelSet(string name)
|
||||
{
|
||||
if (!_shipStorages.ContainsKey(name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_shipStorages.Remove(name);
|
||||
}
|
||||
public ShipsGenericCollection<DrawingWarmlyShip, DrawingObjectShip>? this[string ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_shipStorages.ContainsKey(ind))
|
||||
{
|
||||
return _shipStorages[ind];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
15
MotorShip/MotorShip/Status.cs
Normal file
15
MotorShip/MotorShip/Status.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WarmlyShip.MovementStrategy
|
||||
{
|
||||
public enum Status
|
||||
{
|
||||
NotInit,
|
||||
InProgress,
|
||||
Finish
|
||||
}
|
||||
}
|
26
MotorShip/MotorShip/WarmlyShip.csproj
Normal file
26
MotorShip/MotorShip/WarmlyShip.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>
|
11
MotorShip/MotorShip/WarmlyShip.csproj.user
Normal file
11
MotorShip/MotorShip/WarmlyShip.csproj.user
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Compile Update="FormShipCollection.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Update="FormWarmlyShip.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -0,0 +1,23 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v6.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v6.0": {
|
||||
"WarmlyShip/1.0.0": {
|
||||
"runtime": {
|
||||
"WarmlyShip.dll": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"WarmlyShip/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
}
|
||||
}
|
||||
}
|
BIN
MotorShip/MotorShip/bin/Debug/net6.0-windows/WarmlyShip.dll
Normal file
BIN
MotorShip/MotorShip/bin/Debug/net6.0-windows/WarmlyShip.dll
Normal file
Binary file not shown.
BIN
MotorShip/MotorShip/bin/Debug/net6.0-windows/WarmlyShip.exe
Normal file
BIN
MotorShip/MotorShip/bin/Debug/net6.0-windows/WarmlyShip.exe
Normal file
Binary file not shown.
BIN
MotorShip/MotorShip/bin/Debug/net6.0-windows/WarmlyShip.pdb
Normal file
BIN
MotorShip/MotorShip/bin/Debug/net6.0-windows/WarmlyShip.pdb
Normal file
Binary file not shown.
@ -0,0 +1,15 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net6.0",
|
||||
"frameworks": [
|
||||
{
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "6.0.0"
|
||||
},
|
||||
{
|
||||
"name": "Microsoft.WindowsDesktop.App",
|
||||
"version": "6.0.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,25 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("WarmlyShip")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("WarmlyShip")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("WarmlyShip")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Runtime.Versioning.TargetPlatformAttribute("Windows7.0")]
|
||||
[assembly: System.Runtime.Versioning.SupportedOSPlatformAttribute("Windows7.0")]
|
||||
|
||||
// Создано классом WriteCodeFragment MSBuild.
|
||||
|
@ -0,0 +1 @@
|
||||
9e4fa9fd1ecdd07181264594cdb4ea30b2f8e7a9
|
Binary file not shown.
@ -0,0 +1,16 @@
|
||||
is_global = true
|
||||
build_property.ApplicationManifest =
|
||||
build_property.StartupObject =
|
||||
build_property.ApplicationDefaultFont =
|
||||
build_property.ApplicationHighDpiMode =
|
||||
build_property.ApplicationUseCompatibleTextRendering =
|
||||
build_property.ApplicationVisualStyles =
|
||||
build_property.TargetFramework = net6.0-windows
|
||||
build_property.TargetPlatformMinVersion = 7.0
|
||||
build_property.UsingMicrosoftNETSdkWeb =
|
||||
build_property.ProjectTypeGuids =
|
||||
build_property.InvariantGlobalization =
|
||||
build_property.PlatformNeutralAssembly =
|
||||
build_property._SupportedPlatformList = Linux,macOS,Windows
|
||||
build_property.RootNamespace = WarmlyShip
|
||||
build_property.ProjectDir = C:\Users\Екатерина\OneDrive\Desktop\РПП\MotorShip\MotorShip\
|
@ -0,0 +1,10 @@
|
||||
// <auto-generated/>
|
||||
global using global::System;
|
||||
global using global::System.Collections.Generic;
|
||||
global using global::System.Drawing;
|
||||
global using global::System.IO;
|
||||
global using global::System.Linq;
|
||||
global using global::System.Net.Http;
|
||||
global using global::System.Threading;
|
||||
global using global::System.Threading.Tasks;
|
||||
global using global::System.Windows.Forms;
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
621cbda5ca6541382078a80e2a7b1378f7a5c582
|
@ -0,0 +1,19 @@
|
||||
C:\Users\Екатерина\OneDrive\Desktop\РПП\MotorShip\MotorShip\bin\Debug\net6.0-windows\WarmlyShip.exe
|
||||
C:\Users\Екатерина\OneDrive\Desktop\РПП\MotorShip\MotorShip\bin\Debug\net6.0-windows\WarmlyShip.deps.json
|
||||
C:\Users\Екатерина\OneDrive\Desktop\РПП\MotorShip\MotorShip\bin\Debug\net6.0-windows\WarmlyShip.runtimeconfig.json
|
||||
C:\Users\Екатерина\OneDrive\Desktop\РПП\MotorShip\MotorShip\bin\Debug\net6.0-windows\WarmlyShip.dll
|
||||
C:\Users\Екатерина\OneDrive\Desktop\РПП\MotorShip\MotorShip\bin\Debug\net6.0-windows\WarmlyShip.pdb
|
||||
C:\Users\Екатерина\OneDrive\Desktop\РПП\MotorShip\MotorShip\obj\Debug\net6.0-windows\WarmlyShip.csproj.AssemblyReference.cache
|
||||
C:\Users\Екатерина\OneDrive\Desktop\РПП\MotorShip\MotorShip\obj\Debug\net6.0-windows\WarmlyShip.FormShipCollection.resources
|
||||
C:\Users\Екатерина\OneDrive\Desktop\РПП\MotorShip\MotorShip\obj\Debug\net6.0-windows\MotorShip.FormWarmlyShip.resources
|
||||
C:\Users\Екатерина\OneDrive\Desktop\РПП\MotorShip\MotorShip\obj\Debug\net6.0-windows\WarmlyShip.Properties.Resources.resources
|
||||
C:\Users\Екатерина\OneDrive\Desktop\РПП\MotorShip\MotorShip\obj\Debug\net6.0-windows\WarmlyShip.csproj.GenerateResource.cache
|
||||
C:\Users\Екатерина\OneDrive\Desktop\РПП\MotorShip\MotorShip\obj\Debug\net6.0-windows\WarmlyShip.GeneratedMSBuildEditorConfig.editorconfig
|
||||
C:\Users\Екатерина\OneDrive\Desktop\РПП\MotorShip\MotorShip\obj\Debug\net6.0-windows\WarmlyShip.AssemblyInfoInputs.cache
|
||||
C:\Users\Екатерина\OneDrive\Desktop\РПП\MotorShip\MotorShip\obj\Debug\net6.0-windows\WarmlyShip.AssemblyInfo.cs
|
||||
C:\Users\Екатерина\OneDrive\Desktop\РПП\MotorShip\MotorShip\obj\Debug\net6.0-windows\WarmlyShip.csproj.CoreCompileInputs.cache
|
||||
C:\Users\Екатерина\OneDrive\Desktop\РПП\MotorShip\MotorShip\obj\Debug\net6.0-windows\WarmlyShip.dll
|
||||
C:\Users\Екатерина\OneDrive\Desktop\РПП\MotorShip\MotorShip\obj\Debug\net6.0-windows\refint\WarmlyShip.dll
|
||||
C:\Users\Екатерина\OneDrive\Desktop\РПП\MotorShip\MotorShip\obj\Debug\net6.0-windows\WarmlyShip.pdb
|
||||
C:\Users\Екатерина\OneDrive\Desktop\РПП\MotorShip\MotorShip\obj\Debug\net6.0-windows\WarmlyShip.genruntimeconfig.cache
|
||||
C:\Users\Екатерина\OneDrive\Desktop\РПП\MotorShip\MotorShip\obj\Debug\net6.0-windows\ref\WarmlyShip.dll
|
Binary file not shown.
@ -0,0 +1,11 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v6.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v6.0": {}
|
||||
},
|
||||
"libraries": {}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net6.0",
|
||||
"frameworks": [
|
||||
{
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "6.0.0"
|
||||
},
|
||||
{
|
||||
"name": "Microsoft.WindowsDesktop.App",
|
||||
"version": "6.0.0"
|
||||
}
|
||||
],
|
||||
"additionalProbingPaths": [
|
||||
"C:\\Users\\Екатерина\\.dotnet\\store\\|arch|\\|tfm|",
|
||||
"C:\\Users\\Екатерина\\.nuget\\packages",
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
|
||||
],
|
||||
"configProperties": {
|
||||
"Microsoft.NETCore.DotNetHostPolicy.SetAppPaths": true
|
||||
}
|
||||
}
|
||||
}
|
BIN
MotorShip/MotorShip/obj/Debug/net6.0-windows/WarmlyShip.dll
Normal file
BIN
MotorShip/MotorShip/obj/Debug/net6.0-windows/WarmlyShip.dll
Normal file
Binary file not shown.
@ -0,0 +1 @@
|
||||
b5ff27391765f54d26fb3871c8501fdc7aeba875
|
BIN
MotorShip/MotorShip/obj/Debug/net6.0-windows/WarmlyShip.pdb
Normal file
BIN
MotorShip/MotorShip/obj/Debug/net6.0-windows/WarmlyShip.pdb
Normal file
Binary file not shown.
@ -0,0 +1 @@
|
||||
obj\Debug\net6.0-windows\\_IsIncrementalBuild
|
BIN
MotorShip/MotorShip/obj/Debug/net6.0-windows/apphost.exe
Normal file
BIN
MotorShip/MotorShip/obj/Debug/net6.0-windows/apphost.exe
Normal file
Binary file not shown.
BIN
MotorShip/MotorShip/obj/Debug/net6.0-windows/ref/WarmlyShip.dll
Normal file
BIN
MotorShip/MotorShip/obj/Debug/net6.0-windows/ref/WarmlyShip.dll
Normal file
Binary file not shown.
Binary file not shown.
71
MotorShip/MotorShip/obj/WarmlyShip.csproj.nuget.dgspec.json
Normal file
71
MotorShip/MotorShip/obj/WarmlyShip.csproj.nuget.dgspec.json
Normal file
@ -0,0 +1,71 @@
|
||||
{
|
||||
"format": 1,
|
||||
"restore": {
|
||||
"C:\\Users\\Екатерина\\OneDrive\\Desktop\\РПП\\MotorShip\\MotorShip\\WarmlyShip.csproj": {}
|
||||
},
|
||||
"projects": {
|
||||
"C:\\Users\\Екатерина\\OneDrive\\Desktop\\РПП\\MotorShip\\MotorShip\\WarmlyShip.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "C:\\Users\\Екатерина\\OneDrive\\Desktop\\РПП\\MotorShip\\MotorShip\\WarmlyShip.csproj",
|
||||
"projectName": "WarmlyShip",
|
||||
"projectPath": "C:\\Users\\Екатерина\\OneDrive\\Desktop\\РПП\\MotorShip\\MotorShip\\WarmlyShip.csproj",
|
||||
"packagesPath": "C:\\Users\\Екатерина\\.nuget\\packages\\",
|
||||
"outputPath": "C:\\Users\\Екатерина\\OneDrive\\Desktop\\РПП\\MotorShip\\MotorShip\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\Users\\Екатерина\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
|
||||
],
|
||||
"originalTargetFrameworks": [
|
||||
"net6.0-windows"
|
||||
],
|
||||
"sources": {
|
||||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||
"C:\\Program Files\\dotnet\\library-packs": {},
|
||||
"https://api.nuget.org/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
"net6.0-windows7.0": {
|
||||
"targetAlias": "net6.0-windows",
|
||||
"projectReferences": {}
|
||||
}
|
||||
},
|
||||
"warningProperties": {
|
||||
"warnAsError": [
|
||||
"NU1605"
|
||||
]
|
||||
}
|
||||
},
|
||||
"frameworks": {
|
||||
"net6.0-windows7.0": {
|
||||
"targetAlias": "net6.0-windows",
|
||||
"imports": [
|
||||
"net461",
|
||||
"net462",
|
||||
"net47",
|
||||
"net471",
|
||||
"net472",
|
||||
"net48",
|
||||
"net481"
|
||||
],
|
||||
"assetTargetFallback": true,
|
||||
"warn": true,
|
||||
"frameworkReferences": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"privateAssets": "all"
|
||||
},
|
||||
"Microsoft.WindowsDesktop.App.WindowsForms": {
|
||||
"privateAssets": "none"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.401\\RuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
16
MotorShip/MotorShip/obj/WarmlyShip.csproj.nuget.g.props
Normal file
16
MotorShip/MotorShip/obj/WarmlyShip.csproj.nuget.g.props
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
|
||||
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
||||
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
||||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Екатерина\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
|
||||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.3.0</NuGetToolVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<SourceRoot Include="C:\Users\Екатерина\.nuget\packages\" />
|
||||
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
|
@ -14,9 +14,9 @@
|
||||
"project": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "C:\\Users\\Екатерина\\OneDrive\\Desktop\\РПП\\MotorShip\\MotorShip\\MotorShip.csproj",
|
||||
"projectName": "MotorShip",
|
||||
"projectPath": "C:\\Users\\Екатерина\\OneDrive\\Desktop\\РПП\\MotorShip\\MotorShip\\MotorShip.csproj",
|
||||
"projectUniqueName": "C:\\Users\\Екатерина\\OneDrive\\Desktop\\РПП\\MotorShip\\MotorShip\\WarmlyShip.csproj",
|
||||
"projectName": "WarmlyShip",
|
||||
"projectPath": "C:\\Users\\Екатерина\\OneDrive\\Desktop\\РПП\\MotorShip\\MotorShip\\WarmlyShip.csproj",
|
||||
"packagesPath": "C:\\Users\\Екатерина\\.nuget\\packages\\",
|
||||
"outputPath": "C:\\Users\\Екатерина\\OneDrive\\Desktop\\РПП\\MotorShip\\MotorShip\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "bnUESf/Rv6V72tUo+jhmSGhXmC6Pqj7O2CTNWB9EejNBsTYuPhenT/pJ78ztAR8PVDXUh5QMU+FThm53y2XUQg==",
|
||||
"dgSpecHash": "aDampGwy73k7qtg/YN7p9IeoOxrz4wCzs0qYdTQADvRaI/+G2V69SclPzeFFbFSm7K1+pDPW7S+T49iijnW1Xg==",
|
||||
"success": true,
|
||||
"projectFilePath": "C:\\Users\\Екатерина\\OneDrive\\Desktop\\РПП\\MotorShip\\MotorShip\\MotorShip.csproj",
|
||||
"projectFilePath": "C:\\Users\\Екатерина\\OneDrive\\Desktop\\РПП\\MotorShip\\MotorShip\\WarmlyShip.csproj",
|
||||
"expectedPackageFiles": [],
|
||||
"logs": []
|
||||
}
|
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32922.545
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MotorShip", "MotorShip\MotorShip.csproj", "{93B18DF4-AAEC-4934-9DA3-99513CAABB98}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WarmlyShip", "MotorShip\WarmlyShip.csproj", "{93B18DF4-AAEC-4934-9DA3-99513CAABB98}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ProjectMotorShip/.vs/ProjectMotorShip/v17/.futdcache.v2
Normal file
BIN
ProjectMotorShip/.vs/ProjectMotorShip/v17/.futdcache.v2
Normal file
Binary file not shown.
Binary file not shown.
75
ProjectMotorShip/ProjectMotorShip/AbstractStrategy.cs
Normal file
75
ProjectMotorShip/ProjectMotorShip/AbstractStrategy.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
using ProjectMotorShip.DrawingObjects;
|
||||
|
||||
namespace ProjectMotorShip.MovementStrategy
|
||||
{
|
||||
public abstract class AbstractStrategy
|
||||
{
|
||||
private IMoveableObject? _movebleObject;
|
||||
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;
|
||||
_movebleObject = moveableObject;
|
||||
FieldWidth = width;
|
||||
FieldHeight = height;
|
||||
}
|
||||
|
||||
public void MakeStep()
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (IsTargetDestination())
|
||||
{
|
||||
_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 ObjectParametrs? GetObjectParametrs => _movebleObject?.GetObjectPosition;
|
||||
|
||||
protected int? GetStep()
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _movebleObject?.GetStep;
|
||||
}
|
||||
protected abstract void MoveToTarget();
|
||||
protected abstract bool IsTargetDestination();
|
||||
private bool MoveTo(DirectionType directionType)
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_movebleObject?.CheckCanMove(directionType) ?? false)
|
||||
{
|
||||
_movebleObject.MoveObject(directionType);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
28
ProjectMotorShip/ProjectMotorShip/DirectionType.cs
Normal file
28
ProjectMotorShip/ProjectMotorShip/DirectionType.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectMotorShip
|
||||
{
|
||||
public enum DirectionType
|
||||
{
|
||||
/// <summary>
|
||||
/// Вверх
|
||||
/// </summary>
|
||||
Up = 1,
|
||||
/// <summary>
|
||||
/// Вниз
|
||||
/// </summary>
|
||||
Down = 2,
|
||||
/// <summary>
|
||||
/// Влево
|
||||
/// </summary>
|
||||
Left = 3,
|
||||
/// <summary>
|
||||
/// Вправо
|
||||
/// </summary>
|
||||
Right = 4
|
||||
}
|
||||
}
|
52
ProjectMotorShip/ProjectMotorShip/DrawningMotorShip.cs
Normal file
52
ProjectMotorShip/ProjectMotorShip/DrawningMotorShip.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectMotorShip.Entities;
|
||||
|
||||
namespace ProjectMotorShip.DrawingObjects
|
||||
{
|
||||
public class DrawningMotorShip : DrawningShip
|
||||
{
|
||||
public DrawningMotorShip(int speed, double weight,
|
||||
Color mainColor, Color optionalColor, bool pipes,
|
||||
bool fuelCompartment, int width, int height) :
|
||||
base(speed, weight, mainColor, width, height, 100, 60)
|
||||
{
|
||||
if (EntityShip != null)
|
||||
{
|
||||
EntityShip = new EntityMotorShip(speed, weight, mainColor,
|
||||
optionalColor, pipes, fuelCompartment);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void DrawTrasport(Graphics g)
|
||||
{
|
||||
if (EntityShip is not EntityMotorShip motorShip)
|
||||
{
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
Brush optionalBrush = new SolidBrush(motorShip.OptionalColor);
|
||||
if (motorShip.Pipes)
|
||||
{
|
||||
g.FillRectangle(optionalBrush, _startPosX + 70, _startPosY, 10, 30);
|
||||
g.FillRectangle(optionalBrush, _startPosX + 50, _startPosY + 10, 10, 20);
|
||||
g.DrawRectangle(pen, _startPosX + 50, _startPosY + 10, 10, 20);
|
||||
g.DrawRectangle(pen, _startPosX + 70, _startPosY, 10, 30);
|
||||
}
|
||||
if (motorShip.FuelCompartment)
|
||||
{
|
||||
g.FillRectangle(optionalBrush, _startPosX + 10, _startPosY + 30, 10, 10);
|
||||
g.DrawRectangle(pen, _startPosX + 10, _startPosY + 30, 10, 10);
|
||||
}
|
||||
_startPosY += 30;
|
||||
base.DrawTrasport(g);
|
||||
_startPosY -= 30;
|
||||
}
|
||||
}
|
||||
}
|
37
ProjectMotorShip/ProjectMotorShip/DrawningObjectShip.cs
Normal file
37
ProjectMotorShip/ProjectMotorShip/DrawningObjectShip.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectMotorShip.DrawingObjects;
|
||||
|
||||
|
||||
namespace ProjectMotorShip.MovementStrategy
|
||||
{
|
||||
public class DrawningObjectShip : IMoveableObject
|
||||
{
|
||||
private readonly DrawningShip? _drawningShip = null;
|
||||
public DrawningObjectShip(DrawningShip drawningShip)
|
||||
{
|
||||
_drawningShip = drawningShip;
|
||||
}
|
||||
public ObjectParametrs? GetObjectPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_drawningShip == null || _drawningShip.EntityShip == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ObjectParametrs(_drawningShip.GetPosX,
|
||||
_drawningShip.GetPosY, _drawningShip.GetWidth,
|
||||
_drawningShip.GetHeight);
|
||||
}
|
||||
}
|
||||
public int GetStep => (int)(_drawningShip?.EntityShip?.Step ?? 0);
|
||||
public bool CheckCanMove(DirectionType direction) =>
|
||||
_drawningShip?.CanMove(direction) ?? false;
|
||||
public void MoveObject(DirectionType direction) =>
|
||||
_drawningShip?.MoveTransport(direction);
|
||||
}
|
||||
}
|
132
ProjectMotorShip/ProjectMotorShip/DrawningShip.cs
Normal file
132
ProjectMotorShip/ProjectMotorShip/DrawningShip.cs
Normal file
@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectMotorShip.Entities;
|
||||
|
||||
namespace ProjectMotorShip.DrawingObjects
|
||||
{
|
||||
public class DrawningShip
|
||||
{
|
||||
public EntityShip? EntityShip { get; protected set; }
|
||||
private int _pictureWidth;
|
||||
private int _pictureHeight;
|
||||
protected int _startPosX;
|
||||
protected int _startPosY;
|
||||
protected readonly int _shipWidth = 100;
|
||||
protected readonly int _shipHeight = 30;
|
||||
|
||||
public DrawningShip(int speed, double weight, Color mainColor, int width, int heigth)
|
||||
{
|
||||
if (width <= _shipWidth || heigth <= _shipHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = heigth;
|
||||
EntityShip = new EntityShip(speed, weight, mainColor);
|
||||
}
|
||||
protected DrawningShip(int speed, double weight,
|
||||
Color mainColor, int width, int heigth,
|
||||
int shipWidth, int shipHeight)
|
||||
{
|
||||
if (width <= shipWidth || heigth <= shipHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_pictureHeight = heigth;
|
||||
_pictureWidth = width;
|
||||
_shipHeight = shipHeight;
|
||||
_shipWidth = shipWidth;
|
||||
EntityShip = new EntityShip(speed, weight, mainColor);
|
||||
}
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (x < 0 || y < 0 || x + _shipWidth > _pictureWidth || y + _shipHeight > _pictureHeight)
|
||||
{
|
||||
x = 10;
|
||||
y = 10;
|
||||
}
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
public int GetPosX => _startPosX;
|
||||
public int GetPosY => _startPosY;
|
||||
public int GetWidth => _shipWidth;
|
||||
public int GetHeight => _shipHeight;
|
||||
public bool CanMove(DirectionType direction)
|
||||
{
|
||||
if (EntityShip == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return direction switch
|
||||
{
|
||||
DirectionType.Left => _startPosX - EntityShip.Step > 0,
|
||||
DirectionType.Up => _startPosY - EntityShip.Step > 0,
|
||||
DirectionType.Right => _startPosX + EntityShip.Step + _shipWidth <= _pictureWidth,
|
||||
DirectionType.Down => _startPosY + EntityShip.Step + _shipHeight <= _pictureHeight,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
public void MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (!CanMove(direction) || EntityShip == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
case DirectionType.Left:
|
||||
_startPosX -= (int)EntityShip.Step;
|
||||
break;
|
||||
case DirectionType.Up:
|
||||
_startPosY -= (int)EntityShip.Step;
|
||||
break;
|
||||
case DirectionType.Right:
|
||||
_startPosX += (int)EntityShip.Step;
|
||||
break;
|
||||
case DirectionType.Down:
|
||||
_startPosY += (int)EntityShip.Step;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public virtual void DrawTrasport(Graphics g)
|
||||
{
|
||||
if (EntityShip == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
Brush mainBrush = new SolidBrush(EntityShip.MainColor);
|
||||
//палуба
|
||||
g.FillRectangle(mainBrush, _startPosX + 30, _startPosY, 60, 10);
|
||||
g.DrawRectangle(pen, _startPosX + 30, _startPosY, 60, 10);
|
||||
//корпус
|
||||
g.FillPolygon(mainBrush, new Point[]
|
||||
{
|
||||
new Point(_startPosX, _startPosY + 10),
|
||||
new Point(_startPosX + 100, _startPosY + 10),
|
||||
new Point(_startPosX + 90, _startPosY + 30),
|
||||
new Point(_startPosX + 20, _startPosY + 30),
|
||||
new Point(_startPosX, _startPosY + 10),
|
||||
}
|
||||
);
|
||||
g.DrawPolygon(pen, new Point[]
|
||||
{
|
||||
new Point(_startPosX, _startPosY + 10),
|
||||
new Point(_startPosX + 100, _startPosY + 10),
|
||||
new Point(_startPosX + 90, _startPosY + 30),
|
||||
new Point(_startPosX + 20, _startPosY + 30),
|
||||
new Point(_startPosX, _startPosY + 10),
|
||||
}
|
||||
);
|
||||
//якорь
|
||||
g.DrawLine(pen, _startPosX + 25, _startPosY + 15, _startPosX + 25, _startPosY + 25);
|
||||
g.DrawLine(pen, _startPosX + 20, _startPosY + 20, _startPosX + 30, _startPosY + 20);
|
||||
g.DrawLine(pen, _startPosX + 23, _startPosY + 25, _startPosX + 27, _startPosY + 25);
|
||||
}
|
||||
}
|
||||
}
|
24
ProjectMotorShip/ProjectMotorShip/EntityMotorShip.cs
Normal file
24
ProjectMotorShip/ProjectMotorShip/EntityMotorShip.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Collections.Specialized.BitVector32;
|
||||
|
||||
namespace ProjectMotorShip.Entities
|
||||
{
|
||||
public class EntityMotorShip : EntityShip
|
||||
{
|
||||
public Color OptionalColor { get; private set; }
|
||||
public bool Pipes { get; private set; }
|
||||
public bool FuelCompartment { get; private set; }
|
||||
public EntityMotorShip(int speed, double weight,
|
||||
Color mainColor, Color optionalColor,
|
||||
bool pipes, bool fuelCompartment) : base(speed, weight, mainColor)
|
||||
{
|
||||
OptionalColor = optionalColor;
|
||||
Pipes = pipes;
|
||||
FuelCompartment = fuelCompartment;
|
||||
}
|
||||
}
|
||||
}
|
22
ProjectMotorShip/ProjectMotorShip/EntityShip.cs
Normal file
22
ProjectMotorShip/ProjectMotorShip/EntityShip.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectMotorShip.Entities
|
||||
{
|
||||
public class EntityShip
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
public double Weight { get; private set; }
|
||||
public Color MainColor { get; private set; }
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
public EntityShip(int speed, double weight, Color mainColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
MainColor = mainColor;
|
||||
}
|
||||
}
|
||||
}
|
39
ProjectMotorShip/ProjectMotorShip/Form1.Designer.cs
generated
39
ProjectMotorShip/ProjectMotorShip/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
||||
namespace ProjectMotorShip
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user