Compare commits
No commits in common. "Lab3SailBoat" and "main" have entirely different histories.
Lab3SailBo
...
main
@ -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.6.33829.357
|
VisualStudioVersion = 17.6.33717.318
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SailBoat", "SailBoat\SailBoat.csproj", "{8BDA67FC-B991-4A0A-B505-B10C27DB53C7}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SailBoat", "SailBoat\SailBoat.csproj", "{2DF6420E-A429-41FF-975D-9CC7F0635749}"
|
||||||
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
|
||||||
{8BDA67FC-B991-4A0A-B505-B10C27DB53C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{2DF6420E-A429-41FF-975D-9CC7F0635749}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{8BDA67FC-B991-4A0A-B505-B10C27DB53C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{2DF6420E-A429-41FF-975D-9CC7F0635749}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{8BDA67FC-B991-4A0A-B505-B10C27DB53C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{2DF6420E-A429-41FF-975D-9CC7F0635749}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{8BDA67FC-B991-4A0A-B505-B10C27DB53C7}.Release|Any CPU.Build.0 = Release|Any CPU
|
{2DF6420E-A429-41FF-975D-9CC7F0635749}.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 = {1FD39AE3-D95F-4D22-9D86-54C16EB26DDB}
|
SolutionGuid = {3BCBDA82-2EB8-4315-9C43-B85A3FD48F29}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SailBoat
|
|
||||||
{
|
|
||||||
public enum DirectionType
|
|
||||||
{
|
|
||||||
Up = 1,
|
|
||||||
|
|
||||||
Down = 2,
|
|
||||||
|
|
||||||
Left = 3,
|
|
||||||
|
|
||||||
Right = 4
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,113 +0,0 @@
|
|||||||
using SailBoat.Entities;
|
|
||||||
using SailBoat.MovementStrategy;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Configuration;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SailBoat.DrawningObjects
|
|
||||||
{
|
|
||||||
public class DrawningBoat
|
|
||||||
{
|
|
||||||
public EntityBoat? EntityBoat { get; protected set; }
|
|
||||||
|
|
||||||
private int _pictureWidth;
|
|
||||||
|
|
||||||
private int _pictureHeight;
|
|
||||||
|
|
||||||
protected int _startPosX;
|
|
||||||
|
|
||||||
protected int _startPosY;
|
|
||||||
|
|
||||||
protected readonly int _boatWidth = 180;
|
|
||||||
|
|
||||||
protected readonly int _boatHeight = 125;
|
|
||||||
|
|
||||||
public int GetPosX => _startPosX;
|
|
||||||
|
|
||||||
public int GetPosY => _startPosY;
|
|
||||||
|
|
||||||
public int GetWidth => _boatWidth;
|
|
||||||
|
|
||||||
public int GetHight => _boatHeight;
|
|
||||||
|
|
||||||
public bool CanMove(DirectionType direction)
|
|
||||||
{
|
|
||||||
if (EntityBoat == null) { return false; }
|
|
||||||
return direction switch
|
|
||||||
{
|
|
||||||
DirectionType.Left => _startPosX - EntityBoat.Step > 0,
|
|
||||||
DirectionType.Up => _startPosY - EntityBoat.Step > 0,
|
|
||||||
DirectionType.Right => _startPosX + EntityBoat.Step + _boatWidth < _pictureWidth,
|
|
||||||
DirectionType.Down => _startPosY + EntityBoat.Step + _boatHeight < _pictureHeight,
|
|
||||||
_ => false
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public DrawningBoat(int speed, double weight, Color bodyColor, int width, int height)
|
|
||||||
{
|
|
||||||
if (width < 200) { width = 900; }
|
|
||||||
if (height < 200) { height = 500; }
|
|
||||||
_pictureWidth = width;
|
|
||||||
_pictureHeight = height;
|
|
||||||
EntityBoat = new EntityBoat(speed, weight, bodyColor);
|
|
||||||
}
|
|
||||||
protected DrawningBoat(int speed, double weight, Color bodyColor, int width, int height, int boatWidth, int boatHeight)
|
|
||||||
{
|
|
||||||
if (width < _boatWidth) { return; }
|
|
||||||
if (height < _boatHeight) { return; }
|
|
||||||
|
|
||||||
_pictureWidth = width;
|
|
||||||
_pictureHeight = height;
|
|
||||||
_boatWidth = boatWidth;
|
|
||||||
_boatHeight = boatHeight;
|
|
||||||
EntityBoat = new EntityBoat(speed, weight, bodyColor);
|
|
||||||
}
|
|
||||||
public void SetPosition(int x, int y)
|
|
||||||
{
|
|
||||||
if (x < 0) { x = 0; }
|
|
||||||
else if (x > _pictureWidth) { x = _pictureWidth; }
|
|
||||||
if (y < 0) { y = 0; }
|
|
||||||
else if (y > _pictureHeight) { y = _pictureHeight; }
|
|
||||||
_startPosX = x;
|
|
||||||
_startPosY = y;
|
|
||||||
}
|
|
||||||
public void MoveTransport(DirectionType direction)
|
|
||||||
{
|
|
||||||
if (!CanMove(direction) || EntityBoat == null) return;
|
|
||||||
switch (direction)
|
|
||||||
{
|
|
||||||
case DirectionType.Left:
|
|
||||||
_startPosX -= (int)EntityBoat.Step;
|
|
||||||
break;
|
|
||||||
case DirectionType.Right:
|
|
||||||
_startPosX += (int)EntityBoat.Step;
|
|
||||||
break;
|
|
||||||
case DirectionType.Up:
|
|
||||||
_startPosY -= (int)EntityBoat.Step;
|
|
||||||
break;
|
|
||||||
case DirectionType.Down:
|
|
||||||
_startPosY += (int)EntityBoat.Step;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public virtual void DrawTransport(Graphics g)
|
|
||||||
{
|
|
||||||
if (EntityBoat == null) return;
|
|
||||||
Pen pen = new(Color.Black);
|
|
||||||
Brush BodyBrush = new SolidBrush(EntityBoat.BodyColor);
|
|
||||||
|
|
||||||
g.DrawLine(pen, _startPosX + 10, _startPosY + 60, _startPosX + 110, _startPosY + 60);
|
|
||||||
g.DrawLine(pen, _startPosX + 110, _startPosY + 60, _startPosX + 180, _startPosY + 90);
|
|
||||||
g.DrawLine(pen, _startPosX + 180, _startPosY + 90, _startPosX + 110, _startPosY + 120);
|
|
||||||
g.DrawLine(pen, _startPosX + 110, _startPosY + 120, _startPosX + 10, _startPosY + 120);
|
|
||||||
g.DrawLine(pen, _startPosX + 10, _startPosY + 120, _startPosX + 10, _startPosY + 60);
|
|
||||||
g.FillEllipse(BodyBrush, _startPosX + 15, _startPosY + 65, 95, 50);
|
|
||||||
g.DrawEllipse(pen, _startPosX + 15, _startPosY + 65, 95, 50);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IMoveableObject GetMoveableObjects => new DrawningObjectBoat(this);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using SailBoat.Entities;
|
|
||||||
|
|
||||||
namespace SailBoat.DrawningObjects
|
|
||||||
{
|
|
||||||
internal class DrawningSailBoat : DrawningBoat
|
|
||||||
{
|
|
||||||
|
|
||||||
public DrawningSailBoat(int speed, double weight, Color bodyColor, Color additionalColor, bool sail, bool rainforcedBody, int width, int height) : base(speed, weight, bodyColor, width, height, 180,125)
|
|
||||||
{
|
|
||||||
if(EntityBoat != null)
|
|
||||||
{
|
|
||||||
EntityBoat = new EntitySailBoat(speed, weight, bodyColor, additionalColor, sail, rainforcedBody);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public override void DrawTransport(Graphics g)
|
|
||||||
{
|
|
||||||
if (EntityBoat is not EntitySailBoat sailBoat) { return; }
|
|
||||||
Pen pen = new(Color.Black);
|
|
||||||
Brush bodyColor = new SolidBrush(sailBoat.BodyColor);
|
|
||||||
Brush additionalBrush = new SolidBrush(sailBoat.AdditionalColor);
|
|
||||||
|
|
||||||
g.DrawLine(pen, _startPosX + 10, _startPosY + 60, _startPosX + 110, _startPosY + 60);
|
|
||||||
g.DrawLine(pen, _startPosX + 110, _startPosY + 60, _startPosX + 180, _startPosY + 90);
|
|
||||||
g.DrawLine(pen, _startPosX + 180, _startPosY + 90, _startPosX + 110, _startPosY + 120);
|
|
||||||
g.DrawLine(pen, _startPosX + 110, _startPosY + 120, _startPosX + 10, _startPosY + 120);
|
|
||||||
g.DrawLine(pen, _startPosX + 10, _startPosY + 120, _startPosX + 10, _startPosY + 60);
|
|
||||||
g.FillEllipse(bodyColor, _startPosX + 15, _startPosY + 65, 95, 50);
|
|
||||||
g.DrawEllipse(pen, _startPosX + 15, _startPosY + 65, 95, 50);
|
|
||||||
|
|
||||||
base.DrawTransport(g);
|
|
||||||
|
|
||||||
if (sailBoat.RainforcedBody)
|
|
||||||
{
|
|
||||||
g.FillRectangle(additionalBrush, _startPosX + 2, _startPosY + 65, 10, 50);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 2, _startPosY + 65, 10, 50);
|
|
||||||
g.FillRectangle(additionalBrush, _startPosX + 15, _startPosY + 53, 90, 10);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 15, _startPosY + 53, 90, 10);
|
|
||||||
g.FillRectangle(additionalBrush, _startPosX + 15, _startPosY + 118, 90, 10);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 15, _startPosY + 118, 90, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sailBoat.Sail)
|
|
||||||
{
|
|
||||||
Brush mast = new SolidBrush(Color.Brown);
|
|
||||||
g.FillRectangle(mast, _startPosX + 60, _startPosY, 4, 90);
|
|
||||||
g.DrawRectangle(pen, _startPosX + 60, _startPosY, 4, 90);
|
|
||||||
g.DrawLine(pen, _startPosX + 25, _startPosY + 20, _startPosX + 100, _startPosY);
|
|
||||||
g.DrawLine(pen, _startPosX + 100, _startPosY, _startPosX + 100, _startPosY + 50);
|
|
||||||
g.DrawLine(pen, _startPosX + 25, _startPosY + 70, _startPosX + 100, _startPosY + 50);
|
|
||||||
g.DrawLine(pen, _startPosX + 25, _startPosY + 70, _startPosX + 25, _startPosY + 20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SailBoat.Entities
|
|
||||||
{
|
|
||||||
public class EntityBoat
|
|
||||||
{
|
|
||||||
|
|
||||||
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 EntityBoat(int speed, double weight, Color bodyColor)
|
|
||||||
{
|
|
||||||
Speed = speed;
|
|
||||||
Weight = weight;
|
|
||||||
BodyColor = bodyColor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SailBoat.Entities
|
|
||||||
{
|
|
||||||
public class EntitySailBoat : EntityBoat
|
|
||||||
{
|
|
||||||
public Color AdditionalColor { get; private set; }
|
|
||||||
|
|
||||||
public bool Sail { get; private set; }
|
|
||||||
|
|
||||||
public bool RainforcedBody { get; private set; }
|
|
||||||
|
|
||||||
public EntitySailBoat(int speed, double weight, Color bodyColor, Color additionalColor, bool sail, bool rainforcedBody) : base(speed, weight, bodyColor)
|
|
||||||
{
|
|
||||||
AdditionalColor = additionalColor;
|
|
||||||
Sail = sail;
|
|
||||||
RainforcedBody = rainforcedBody;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
39
SailBoat/SailBoat/Form1.Designer.cs
generated
Normal file
39
SailBoat/SailBoat/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
namespace SailBoat
|
||||||
|
{
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
10
SailBoat/SailBoat/Form1.cs
Normal file
10
SailBoat/SailBoat/Form1.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace SailBoat
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
126
SailBoat/SailBoat/FormBoatCollection.Designer.cs
generated
126
SailBoat/SailBoat/FormBoatCollection.Designer.cs
generated
@ -1,126 +0,0 @@
|
|||||||
namespace SailBoat
|
|
||||||
{
|
|
||||||
partial class FormBoatCollection
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
tools = new GroupBox();
|
|
||||||
maskedTextBoxNumber = new MaskedTextBox();
|
|
||||||
buttonRefreshCollection = new Button();
|
|
||||||
buttonRemoveBoat = new Button();
|
|
||||||
buttonAddBoat = new Button();
|
|
||||||
pictureBoxCollection = new PictureBox();
|
|
||||||
tools.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// tools
|
|
||||||
//
|
|
||||||
tools.Controls.Add(maskedTextBoxNumber);
|
|
||||||
tools.Controls.Add(buttonRefreshCollection);
|
|
||||||
tools.Controls.Add(buttonRemoveBoat);
|
|
||||||
tools.Controls.Add(buttonAddBoat);
|
|
||||||
tools.Dock = DockStyle.Right;
|
|
||||||
tools.Location = new Point(716, 0);
|
|
||||||
tools.Name = "tools";
|
|
||||||
tools.Size = new Size(200, 608);
|
|
||||||
tools.TabIndex = 0;
|
|
||||||
tools.TabStop = false;
|
|
||||||
tools.Text = "Инструменты";
|
|
||||||
//
|
|
||||||
// maskedTextBoxNumber
|
|
||||||
//
|
|
||||||
maskedTextBoxNumber.Location = new Point(45, 104);
|
|
||||||
maskedTextBoxNumber.Mask = "00000";
|
|
||||||
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
|
||||||
maskedTextBoxNumber.Size = new Size(112, 23);
|
|
||||||
maskedTextBoxNumber.TabIndex = 4;
|
|
||||||
maskedTextBoxNumber.ValidatingType = typeof(int);
|
|
||||||
//
|
|
||||||
// buttonRefreshCollection
|
|
||||||
//
|
|
||||||
buttonRefreshCollection.Location = new Point(6, 211);
|
|
||||||
buttonRefreshCollection.Name = "buttonRefreshCollection";
|
|
||||||
buttonRefreshCollection.Size = new Size(188, 39);
|
|
||||||
buttonRefreshCollection.TabIndex = 3;
|
|
||||||
buttonRefreshCollection.Text = "Обновить коллекцию";
|
|
||||||
buttonRefreshCollection.UseVisualStyleBackColor = true;
|
|
||||||
buttonRefreshCollection.Click += buttonRefreshCollection_Click;
|
|
||||||
//
|
|
||||||
// buttonRemoveBoat
|
|
||||||
//
|
|
||||||
buttonRemoveBoat.Location = new Point(6, 133);
|
|
||||||
buttonRemoveBoat.Name = "buttonRemoveBoat";
|
|
||||||
buttonRemoveBoat.Size = new Size(188, 39);
|
|
||||||
buttonRemoveBoat.TabIndex = 1;
|
|
||||||
buttonRemoveBoat.Text = "Удалить лодку";
|
|
||||||
buttonRemoveBoat.UseVisualStyleBackColor = true;
|
|
||||||
buttonRemoveBoat.Click += buttonRemoveBoat_Click;
|
|
||||||
//
|
|
||||||
// buttonAddBoat
|
|
||||||
//
|
|
||||||
buttonAddBoat.Location = new Point(6, 22);
|
|
||||||
buttonAddBoat.Name = "buttonAddBoat";
|
|
||||||
buttonAddBoat.Size = new Size(188, 39);
|
|
||||||
buttonAddBoat.TabIndex = 0;
|
|
||||||
buttonAddBoat.Text = "Добавить лодку";
|
|
||||||
buttonAddBoat.UseVisualStyleBackColor = true;
|
|
||||||
buttonAddBoat.Click += buttonAddBoat_Click;
|
|
||||||
//
|
|
||||||
// pictureBoxCollection
|
|
||||||
//
|
|
||||||
pictureBoxCollection.Location = new Point(0, 0);
|
|
||||||
pictureBoxCollection.Name = "pictureBoxCollection";
|
|
||||||
pictureBoxCollection.Size = new Size(710, 608);
|
|
||||||
pictureBoxCollection.TabIndex = 1;
|
|
||||||
pictureBoxCollection.TabStop = false;
|
|
||||||
//
|
|
||||||
// FormBoatCollection
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(916, 608);
|
|
||||||
Controls.Add(pictureBoxCollection);
|
|
||||||
Controls.Add(tools);
|
|
||||||
Name = "FormBoatCollection";
|
|
||||||
Text = "Набор лодок";
|
|
||||||
tools.ResumeLayout(false);
|
|
||||||
tools.PerformLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private GroupBox tools;
|
|
||||||
private Button buttonAddBoat;
|
|
||||||
private Button buttonRemoveBoat;
|
|
||||||
private Button buttonRefreshCollection;
|
|
||||||
private PictureBox pictureBoxCollection;
|
|
||||||
private MaskedTextBox maskedTextBoxNumber;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
using SailBoat.DrawningObjects;
|
|
||||||
using SailBoat.MovementStrategy;
|
|
||||||
using SailBoat.Generics;
|
|
||||||
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 SailBoat
|
|
||||||
{
|
|
||||||
public partial class FormBoatCollection : Form
|
|
||||||
{
|
|
||||||
private readonly BoatsGenericCollection<DrawningBoat, DrawningObjectBoat> _boats;
|
|
||||||
|
|
||||||
public FormBoatCollection()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_boats = new BoatsGenericCollection<DrawningBoat, DrawningObjectBoat>(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonAddBoat_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
FormSailBoat form = new();
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if ((_boats + form.SelectedBoat) == 0)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект добавлен");
|
|
||||||
pictureBoxCollection.Image = _boats.ShowBoats();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonRemoveBoat_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (maskedTextBoxNumber.Text == "") { return; }
|
|
||||||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
|
||||||
if (_boats - pos)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект удален");
|
|
||||||
pictureBoxCollection.Image = _boats.ShowBoats();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось удалить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonRefreshCollection_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
pictureBoxCollection.Image = _boats.ShowBoats();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
189
SailBoat/SailBoat/FormSailBoat.Designer.cs
generated
189
SailBoat/SailBoat/FormSailBoat.Designer.cs
generated
@ -1,189 +0,0 @@
|
|||||||
namespace SailBoat
|
|
||||||
{
|
|
||||||
partial class FormSailBoat
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
pictureBoxSailBoat = new PictureBox();
|
|
||||||
buttonCreateSailBoat = new Button();
|
|
||||||
buttonDown = new Button();
|
|
||||||
buttonLeft = new Button();
|
|
||||||
buttonUp = new Button();
|
|
||||||
buttonRight = new Button();
|
|
||||||
comboBoxStrategy = new ComboBox();
|
|
||||||
buttonStep = new Button();
|
|
||||||
buttonCreateBoat = new Button();
|
|
||||||
buttonSelectBoat = new Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxSailBoat).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// pictureBoxSailBoat
|
|
||||||
//
|
|
||||||
pictureBoxSailBoat.Dock = DockStyle.Fill;
|
|
||||||
pictureBoxSailBoat.Location = new Point(0, 0);
|
|
||||||
pictureBoxSailBoat.Name = "pictureBoxSailBoat";
|
|
||||||
pictureBoxSailBoat.Size = new Size(884, 461);
|
|
||||||
pictureBoxSailBoat.SizeMode = PictureBoxSizeMode.AutoSize;
|
|
||||||
pictureBoxSailBoat.TabIndex = 0;
|
|
||||||
pictureBoxSailBoat.TabStop = false;
|
|
||||||
//
|
|
||||||
// buttonCreateSailBoat
|
|
||||||
//
|
|
||||||
buttonCreateSailBoat.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
buttonCreateSailBoat.Location = new Point(12, 407);
|
|
||||||
buttonCreateSailBoat.Name = "buttonCreateSailBoat";
|
|
||||||
buttonCreateSailBoat.Size = new Size(96, 42);
|
|
||||||
buttonCreateSailBoat.TabIndex = 3;
|
|
||||||
buttonCreateSailBoat.Text = "Создать Парусник";
|
|
||||||
buttonCreateSailBoat.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreateSailBoat.Click += buttonCreateSailBoat_Click;
|
|
||||||
//
|
|
||||||
// buttonDown
|
|
||||||
//
|
|
||||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonDown.BackgroundImage = Properties.Resources.down;
|
|
||||||
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonDown.Location = new Point(806, 419);
|
|
||||||
buttonDown.Name = "buttonDown";
|
|
||||||
buttonDown.Size = new Size(30, 30);
|
|
||||||
buttonDown.TabIndex = 10;
|
|
||||||
buttonDown.UseVisualStyleBackColor = true;
|
|
||||||
buttonDown.Click += buttonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonLeft
|
|
||||||
//
|
|
||||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonLeft.BackgroundImage = Properties.Resources.left;
|
|
||||||
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonLeft.Location = new Point(770, 419);
|
|
||||||
buttonLeft.Name = "buttonLeft";
|
|
||||||
buttonLeft.Size = new Size(30, 30);
|
|
||||||
buttonLeft.TabIndex = 9;
|
|
||||||
buttonLeft.UseVisualStyleBackColor = true;
|
|
||||||
buttonLeft.Click += buttonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonUp
|
|
||||||
//
|
|
||||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonUp.BackgroundImage = Properties.Resources.up;
|
|
||||||
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonUp.Location = new Point(806, 383);
|
|
||||||
buttonUp.Name = "buttonUp";
|
|
||||||
buttonUp.Size = new Size(30, 30);
|
|
||||||
buttonUp.TabIndex = 8;
|
|
||||||
buttonUp.UseVisualStyleBackColor = true;
|
|
||||||
buttonUp.Click += buttonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonRight
|
|
||||||
//
|
|
||||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonRight.BackgroundImage = Properties.Resources.right;
|
|
||||||
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonRight.Location = new Point(842, 419);
|
|
||||||
buttonRight.Name = "buttonRight";
|
|
||||||
buttonRight.Size = new Size(30, 30);
|
|
||||||
buttonRight.TabIndex = 7;
|
|
||||||
buttonRight.UseVisualStyleBackColor = true;
|
|
||||||
buttonRight.Click += buttonMove_Click;
|
|
||||||
//
|
|
||||||
// comboBoxStrategy
|
|
||||||
//
|
|
||||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxStrategy.FormattingEnabled = true;
|
|
||||||
comboBoxStrategy.Items.AddRange(new object[] { "Движение в центр", "Движение в правый нижний угол" });
|
|
||||||
comboBoxStrategy.Location = new Point(644, 12);
|
|
||||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
|
||||||
comboBoxStrategy.Size = new Size(228, 23);
|
|
||||||
comboBoxStrategy.TabIndex = 11;
|
|
||||||
//
|
|
||||||
// buttonStep
|
|
||||||
//
|
|
||||||
buttonStep.Location = new Point(797, 41);
|
|
||||||
buttonStep.Name = "buttonStep";
|
|
||||||
buttonStep.Size = new Size(75, 23);
|
|
||||||
buttonStep.TabIndex = 12;
|
|
||||||
buttonStep.Text = "Шаг";
|
|
||||||
buttonStep.UseVisualStyleBackColor = true;
|
|
||||||
buttonStep.Click += buttonStep_Click;
|
|
||||||
//
|
|
||||||
// buttonCreateBoat
|
|
||||||
//
|
|
||||||
buttonCreateBoat.Location = new Point(114, 407);
|
|
||||||
buttonCreateBoat.Name = "buttonCreateBoat";
|
|
||||||
buttonCreateBoat.Size = new Size(75, 42);
|
|
||||||
buttonCreateBoat.TabIndex = 13;
|
|
||||||
buttonCreateBoat.Text = "Создать лодку";
|
|
||||||
buttonCreateBoat.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreateBoat.Click += buttonCreateBoat_Click;
|
|
||||||
//
|
|
||||||
// buttonSelectBoat
|
|
||||||
//
|
|
||||||
buttonSelectBoat.Location = new Point(195, 407);
|
|
||||||
buttonSelectBoat.Name = "buttonSelectBoat";
|
|
||||||
buttonSelectBoat.Size = new Size(106, 42);
|
|
||||||
buttonSelectBoat.TabIndex = 14;
|
|
||||||
buttonSelectBoat.Text = "Выбрать";
|
|
||||||
buttonSelectBoat.UseVisualStyleBackColor = true;
|
|
||||||
buttonSelectBoat.Click += buttonSelectBoat_Click;
|
|
||||||
//
|
|
||||||
// FormSailBoat
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(884, 461);
|
|
||||||
Controls.Add(buttonSelectBoat);
|
|
||||||
Controls.Add(buttonCreateBoat);
|
|
||||||
Controls.Add(buttonStep);
|
|
||||||
Controls.Add(comboBoxStrategy);
|
|
||||||
Controls.Add(buttonDown);
|
|
||||||
Controls.Add(buttonLeft);
|
|
||||||
Controls.Add(buttonUp);
|
|
||||||
Controls.Add(buttonRight);
|
|
||||||
Controls.Add(buttonCreateSailBoat);
|
|
||||||
Controls.Add(pictureBoxSailBoat);
|
|
||||||
Name = "FormSailBoat";
|
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
|
||||||
Text = "Парусник";
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxSailBoat).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private PictureBox pictureBoxSailBoat;
|
|
||||||
private Button buttonCreateSailBoat;
|
|
||||||
private Button buttonDown;
|
|
||||||
private Button buttonLeft;
|
|
||||||
private Button buttonUp;
|
|
||||||
private Button buttonRight;
|
|
||||||
private ComboBox comboBoxStrategy;
|
|
||||||
private Button buttonStep;
|
|
||||||
private Button buttonCreateBoat;
|
|
||||||
private Button buttonSelectBoat;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
using SailBoat.DrawningObjects;
|
|
||||||
using SailBoat.MovementStrategy;
|
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace SailBoat
|
|
||||||
{
|
|
||||||
public partial class FormSailBoat : Form
|
|
||||||
{
|
|
||||||
private DrawningBoat? _drawningBoat;
|
|
||||||
|
|
||||||
private AbstractStrategy? _abstractStrategy;
|
|
||||||
|
|
||||||
public DrawningBoat? SelectedBoat { get; private set; }
|
|
||||||
|
|
||||||
public FormSailBoat()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_abstractStrategy = null;
|
|
||||||
SelectedBoat = null;
|
|
||||||
}
|
|
||||||
private void Draw()
|
|
||||||
{
|
|
||||||
if (_drawningBoat == null) return;
|
|
||||||
Bitmap bmp = new(pictureBoxSailBoat.Width, pictureBoxSailBoat.Height);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
_drawningBoat.DrawTransport(gr);
|
|
||||||
pictureBoxSailBoat.Image = bmp;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonCreateSailBoat_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random random = new();
|
|
||||||
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
|
||||||
ColorDialog dialog = new();
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
color = dialog.Color;
|
|
||||||
}
|
|
||||||
Color dopcolor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
dopcolor = dialog.Color;
|
|
||||||
}
|
|
||||||
_drawningBoat = new DrawningSailBoat(random.Next(100, 300), random.Next(1000, 3000), color, dopcolor, Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), pictureBoxSailBoat.Width, pictureBoxSailBoat.Height);
|
|
||||||
_drawningBoat.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonCreateBoat_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random random = new();
|
|
||||||
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
|
||||||
ColorDialog dialog = new();
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
color = dialog.Color;
|
|
||||||
}
|
|
||||||
|
|
||||||
_drawningBoat = new DrawningBoat(random.Next(300, 700), random.Next(2000, 4000), color, pictureBoxSailBoat.Width, pictureBoxSailBoat.Height);
|
|
||||||
_drawningBoat.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonMove_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_drawningBoat == null) { return; }
|
|
||||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
|
||||||
switch (name)
|
|
||||||
{
|
|
||||||
case "buttonUp":
|
|
||||||
_drawningBoat.MoveTransport(DirectionType.Up);
|
|
||||||
break;
|
|
||||||
case "buttonDown":
|
|
||||||
_drawningBoat.MoveTransport(DirectionType.Down);
|
|
||||||
break;
|
|
||||||
case "buttonRight":
|
|
||||||
_drawningBoat.MoveTransport(DirectionType.Right);
|
|
||||||
break;
|
|
||||||
case "buttonLeft":
|
|
||||||
_drawningBoat.MoveTransport(DirectionType.Left);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonStep_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_drawningBoat == null) return;
|
|
||||||
if (comboBoxStrategy.Enabled)
|
|
||||||
{
|
|
||||||
_abstractStrategy = comboBoxStrategy.SelectedIndex switch
|
|
||||||
{
|
|
||||||
0 => new MoveToCenter(),
|
|
||||||
1 => new MoveToBorder(),
|
|
||||||
_ => null,
|
|
||||||
|
|
||||||
};
|
|
||||||
if (_abstractStrategy == null) return;
|
|
||||||
_abstractStrategy.SetData(new DrawningObjectBoat(_drawningBoat), pictureBoxSailBoat.Width, pictureBoxSailBoat.Height);
|
|
||||||
comboBoxStrategy.Enabled = false;
|
|
||||||
}
|
|
||||||
if (_abstractStrategy == null) return;
|
|
||||||
comboBoxStrategy.Enabled = false;
|
|
||||||
_abstractStrategy.MakeStep();
|
|
||||||
Draw();
|
|
||||||
if (_abstractStrategy.GetStatus() == Status.Finish)
|
|
||||||
{
|
|
||||||
comboBoxStrategy.Enabled = true;
|
|
||||||
_abstractStrategy = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonSelectBoat_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
SelectedBoat = _drawningBoat;
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
@ -1,95 +0,0 @@
|
|||||||
using SailBoat.DrawningObjects;
|
|
||||||
using SailBoat.MovementStrategy;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SailBoat.Generics
|
|
||||||
{
|
|
||||||
internal class BoatsGenericCollection<T,U>
|
|
||||||
where T : DrawningBoat
|
|
||||||
where U : IMoveableObject
|
|
||||||
{
|
|
||||||
private readonly int _pictureWidth;
|
|
||||||
|
|
||||||
private readonly int _pictureHeight;
|
|
||||||
|
|
||||||
private readonly int _placeSizeWidth = 220;
|
|
||||||
|
|
||||||
private readonly int _placeSizeHeight = 150;
|
|
||||||
|
|
||||||
private readonly SetGeneric<T> _collection;
|
|
||||||
|
|
||||||
public BoatsGenericCollection(int picWidth, int picHeight)
|
|
||||||
{
|
|
||||||
int width = picWidth / _placeSizeWidth;
|
|
||||||
int height = picHeight / _placeSizeHeight;
|
|
||||||
_pictureWidth = picWidth;
|
|
||||||
_pictureHeight = picHeight;
|
|
||||||
|
|
||||||
_collection = new SetGeneric<T>(width * height);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int? operator +(BoatsGenericCollection<T,U> collect, T? obj)
|
|
||||||
{
|
|
||||||
if (obj == null) return -1;
|
|
||||||
return collect?._collection.Insert(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator -(BoatsGenericCollection<T,U> collect, int pos)
|
|
||||||
{
|
|
||||||
T? obj = collect._collection.Get(pos);
|
|
||||||
if(obj == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
collect._collection.Remove(pos);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public U? GetU(int pos)
|
|
||||||
{
|
|
||||||
return (U?)_collection.Get(pos)?.GetMoveableObjects;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Bitmap ShowBoats()
|
|
||||||
{
|
|
||||||
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 height = _pictureHeight / _placeSizeHeight;
|
|
||||||
int width = _pictureWidth / _placeSizeWidth;
|
|
||||||
for (int i = 0; i < _collection.Count ; i++)
|
|
||||||
{
|
|
||||||
DrawningBoat boat = _collection.Get(i);
|
|
||||||
if(boat == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
boat.SetPosition((i % width) * _placeSizeWidth, (i / (height - 1)) * _placeSizeHeight);
|
|
||||||
boat.DrawTransport(g);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SailBoat.Generics
|
|
||||||
{
|
|
||||||
internal class SetGeneric<T>
|
|
||||||
where T : class
|
|
||||||
{
|
|
||||||
private readonly T?[] _places;
|
|
||||||
|
|
||||||
public int Count => _places.Length;
|
|
||||||
|
|
||||||
public SetGeneric(int Count)
|
|
||||||
{
|
|
||||||
_places = new T[Count];
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Insert(T boat)
|
|
||||||
{
|
|
||||||
int index = 0;
|
|
||||||
while (_places[index] != null) {
|
|
||||||
index++;
|
|
||||||
if(index == Count) { return -1; }
|
|
||||||
}
|
|
||||||
|
|
||||||
while (index != 0)
|
|
||||||
{
|
|
||||||
_places[index] = _places[index - 1];
|
|
||||||
index--;
|
|
||||||
}
|
|
||||||
_places[0] = boat;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Insert(T boat, int position)
|
|
||||||
{
|
|
||||||
if (position < 0 || position >= Count)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (_places[position] == null)
|
|
||||||
{
|
|
||||||
_places[position] = boat;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
int index = position;
|
|
||||||
while (_places[index] != null) index++;
|
|
||||||
if (index == Count) return false;
|
|
||||||
for(int i = index; i > position; i--)
|
|
||||||
{
|
|
||||||
_places[i] = _places[i - 1];
|
|
||||||
}
|
|
||||||
_places[position] = boat;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Remove(int position)
|
|
||||||
{
|
|
||||||
if (position < 0 || position >= Count) return false;
|
|
||||||
_places[position] = null;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T? Get(int position)
|
|
||||||
{
|
|
||||||
if (position < 0 || position >= Count) return null;
|
|
||||||
return _places[position];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,82 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SailBoat.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 (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 ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition;
|
|
||||||
|
|
||||||
protected int? GetStep()
|
|
||||||
{
|
|
||||||
if(_state != Status.InProgress)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return _moveableObject?.GetStep;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void MoveToTarget();
|
|
||||||
|
|
||||||
protected abstract bool IsTargetDestination();
|
|
||||||
|
|
||||||
private bool MoveTo(DirectionType directionType)
|
|
||||||
{
|
|
||||||
if (_state != Status.InProgress) return false;
|
|
||||||
if(_moveableObject?.CheckCanMove(directionType)?? false)
|
|
||||||
{
|
|
||||||
_moveableObject.MoveObject(directionType);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
using SailBoat.DrawningObjects;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SailBoat.MovementStrategy
|
|
||||||
{
|
|
||||||
public class DrawningObjectBoat : IMoveableObject
|
|
||||||
{
|
|
||||||
private readonly DrawningBoat? _drawningBoat = null;
|
|
||||||
|
|
||||||
public DrawningObjectBoat(DrawningBoat drawningBoat)
|
|
||||||
{
|
|
||||||
_drawningBoat = drawningBoat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ObjectParameters? GetObjectPosition
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_drawningBoat == null || _drawningBoat.EntityBoat == null) return null;
|
|
||||||
return new ObjectParameters(_drawningBoat.GetPosX, _drawningBoat.GetPosY, _drawningBoat.GetWidth, _drawningBoat.GetHight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetStep => (int)(_drawningBoat?.EntityBoat?.Step ?? 0);
|
|
||||||
|
|
||||||
public bool CheckCanMove(DirectionType direction) => _drawningBoat?.CanMove(direction) ?? false;
|
|
||||||
|
|
||||||
public void MoveObject(DirectionType direction) => _drawningBoat?.MoveTransport(direction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Xml.Serialization;
|
|
||||||
|
|
||||||
namespace SailBoat.MovementStrategy
|
|
||||||
{
|
|
||||||
public interface IMoveableObject
|
|
||||||
{
|
|
||||||
ObjectParameters? GetObjectPosition { get; }
|
|
||||||
|
|
||||||
int GetStep { get; }
|
|
||||||
|
|
||||||
bool CheckCanMove(DirectionType direction);
|
|
||||||
|
|
||||||
void MoveObject(DirectionType direction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SailBoat.MovementStrategy
|
|
||||||
{
|
|
||||||
public class MoveToBorder : AbstractStrategy
|
|
||||||
{
|
|
||||||
protected override bool IsTargetDestination()
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
MoveRight();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var diffY = objParams.DownBorder - FieldHeight;
|
|
||||||
if(Math.Abs(diffY) > GetStep())
|
|
||||||
{
|
|
||||||
if(diffY < 0)
|
|
||||||
{
|
|
||||||
MoveDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SailBoat.MovementStrategy
|
|
||||||
{
|
|
||||||
public class MoveToCenter : AbstractStrategy
|
|
||||||
{
|
|
||||||
protected override bool IsTargetDestination()
|
|
||||||
{
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SailBoat.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,17 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SailBoat.MovementStrategy
|
|
||||||
{
|
|
||||||
public enum Status
|
|
||||||
{
|
|
||||||
NotInit,
|
|
||||||
|
|
||||||
InProgress,
|
|
||||||
|
|
||||||
Finish
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,7 +11,7 @@ namespace SailBoat
|
|||||||
// 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 FormBoatCollection());
|
Application.Run(new Form1());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
103
SailBoat/SailBoat/Properties/Resources.Designer.cs
generated
103
SailBoat/SailBoat/Properties/Resources.Designer.cs
generated
@ -1,103 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// Этот код создан программой.
|
|
||||||
// Исполняемая версия:4.0.30319.42000
|
|
||||||
//
|
|
||||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
|
||||||
// повторной генерации кода.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace SailBoat.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("SailBoat.Properties.Resources", typeof(Resources).Assembly);
|
|
||||||
resourceMan = temp;
|
|
||||||
}
|
|
||||||
return resourceMan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
|
||||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Globalization.CultureInfo Culture {
|
|
||||||
get {
|
|
||||||
return resourceCulture;
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
resourceCulture = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap down {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("down", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap left {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("left", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap right {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("right", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap up {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("up", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,133 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
|
||||||
<data name="right" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\right.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="down" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="left" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\left.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="up" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
|
Binary file not shown.
Before Width: | Height: | Size: 5.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 5.0 KiB |
@ -8,19 +8,4 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</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>
|
</Project>
|
Loading…
x
Reference in New Issue
Block a user