Compare commits
14 Commits
main
...
Lab8SailBo
Author | SHA1 | Date | |
---|---|---|---|
0fa9af72bf | |||
4b736d3233 | |||
a55d9450cf | |||
ff1ab7fbc9 | |||
20c1d01940 | |||
fc647fd9af | |||
4ff5aeaad7 | |||
773e1b74fb | |||
bad7f562ec | |||
bdf0062316 | |||
ae022205eb | |||
81268266be | |||
e5d7602c05 | |||
c340d7785e |
@ -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.33717.318
|
VisualStudioVersion = 17.6.33829.357
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SailBoat", "SailBoat\SailBoat.csproj", "{2DF6420E-A429-41FF-975D-9CC7F0635749}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SailBoat", "SailBoat\SailBoat.csproj", "{8BDA67FC-B991-4A0A-B505-B10C27DB53C7}"
|
||||||
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
|
||||||
{2DF6420E-A429-41FF-975D-9CC7F0635749}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{8BDA67FC-B991-4A0A-B505-B10C27DB53C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{2DF6420E-A429-41FF-975D-9CC7F0635749}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{8BDA67FC-B991-4A0A-B505-B10C27DB53C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{2DF6420E-A429-41FF-975D-9CC7F0635749}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{8BDA67FC-B991-4A0A-B505-B10C27DB53C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{2DF6420E-A429-41FF-975D-9CC7F0635749}.Release|Any CPU.Build.0 = Release|Any CPU
|
{8BDA67FC-B991-4A0A-B505-B10C27DB53C7}.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 = {3BCBDA82-2EB8-4315-9C43-B85A3FD48F29}
|
SolutionGuid = {1FD39AE3-D95F-4D22-9D86-54C16EB26DDB}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
19
SailBoat/SailBoat/Direction.cs
Normal file
19
SailBoat/SailBoat/Direction.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
113
SailBoat/SailBoat/DrawningObjects/DrawningBoat.cs
Normal file
113
SailBoat/SailBoat/DrawningObjects/DrawningBoat.cs
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
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; }
|
||||||
|
|
||||||
|
public int _pictureWidth;
|
||||||
|
|
||||||
|
public 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);
|
||||||
|
}
|
||||||
|
}
|
59
SailBoat/SailBoat/DrawningObjects/DrawningSailBoat.cs
Normal file
59
SailBoat/SailBoat/DrawningObjects/DrawningSailBoat.cs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
41
SailBoat/SailBoat/DrawningObjects/ExtentionDrawningBoat.cs
Normal file
41
SailBoat/SailBoat/DrawningObjects/ExtentionDrawningBoat.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using SailBoat.Entities;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SailBoat.DrawningObjects
|
||||||
|
{
|
||||||
|
public static class ExtentionDrawningBoat
|
||||||
|
{
|
||||||
|
public static DrawningBoat? CreateDrawningBoat(this string info, char separatorForObject, int width, int height)
|
||||||
|
{
|
||||||
|
string[] strs = info.Split(separatorForObject);
|
||||||
|
if(strs.Length == 3)
|
||||||
|
{
|
||||||
|
return new DrawningBoat(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
|
||||||
|
}
|
||||||
|
if(strs.Length == 6)
|
||||||
|
{
|
||||||
|
return new DrawningSailBoat(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]), Color.FromName(strs[3]), Convert.ToBoolean(strs[4]), Convert.ToBoolean(strs[5]), width, height);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetDataForSave(this DrawningBoat drawningBoat, char separatorForObject)
|
||||||
|
{
|
||||||
|
var boat = drawningBoat.EntityBoat;
|
||||||
|
if(boat == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
var str = $"{boat.Speed}{separatorForObject}{boat.Weight}{separatorForObject}{boat.BodyColor.Name}";
|
||||||
|
if(boat is not EntitySailBoat sailBoat)
|
||||||
|
{
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
return $"{str}{separatorForObject}{sailBoat.AdditionalColor.Name}{separatorForObject}{sailBoat.Sail}{separatorForObject}{sailBoat.RainforcedBody}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
32
SailBoat/SailBoat/Entities/EntityBoat.cs
Normal file
32
SailBoat/SailBoat/Entities/EntityBoat.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SailBoat.Entities
|
||||||
|
{
|
||||||
|
public class EntityBoat
|
||||||
|
{
|
||||||
|
|
||||||
|
public void SetBodyColor(Color color)
|
||||||
|
{
|
||||||
|
BodyColor = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
28
SailBoat/SailBoat/Entities/EntitySailBoat.cs
Normal file
28
SailBoat/SailBoat/Entities/EntitySailBoat.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SailBoat.Entities
|
||||||
|
{
|
||||||
|
public class EntitySailBoat : EntityBoat
|
||||||
|
{
|
||||||
|
public void setAdditionalColor(Color color)
|
||||||
|
{
|
||||||
|
AdditionalColor = color;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
23
SailBoat/SailBoat/Exceptions/BoatNotFoundException.cs
Normal file
23
SailBoat/SailBoat/Exceptions/BoatNotFoundException.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
|
namespace SailBoat.Exceptions
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
internal class BoatNotFoundException : ApplicationException
|
||||||
|
{
|
||||||
|
public BoatNotFoundException(int i) : base($"Не найден объект по позиции {i}") { }
|
||||||
|
|
||||||
|
public BoatNotFoundException() : base() { }
|
||||||
|
|
||||||
|
public BoatNotFoundException(string message) : base(message) { }
|
||||||
|
|
||||||
|
public BoatNotFoundException(string message, Exception exception) : base(message, exception) { }
|
||||||
|
|
||||||
|
protected BoatNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||||
|
}
|
||||||
|
}
|
23
SailBoat/SailBoat/Exceptions/StorageOverflowException.cs
Normal file
23
SailBoat/SailBoat/Exceptions/StorageOverflowException.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SailBoat.Exceptions
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
internal class StorageOverflowException : ApplicationException
|
||||||
|
{
|
||||||
|
public StorageOverflowException(int count) : base($"В наборе превышено допустимое количество: {count}") { }
|
||||||
|
|
||||||
|
public StorageOverflowException() : base() { }
|
||||||
|
|
||||||
|
public StorageOverflowException(string message) : base(message) { }
|
||||||
|
|
||||||
|
public StorageOverflowException(string message, Exception Exception) : base(message, Exception) { }
|
||||||
|
|
||||||
|
protected StorageOverflowException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||||
|
}
|
||||||
|
}
|
39
SailBoat/SailBoat/Form1.Designer.cs
generated
39
SailBoat/SailBoat/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
namespace SailBoat
|
|
||||||
{
|
|
||||||
public partial class Form1 : Form
|
|
||||||
{
|
|
||||||
public Form1()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
273
SailBoat/SailBoat/FormBoatCollection.Designer.cs
generated
Normal file
273
SailBoat/SailBoat/FormBoatCollection.Designer.cs
generated
Normal file
@ -0,0 +1,273 @@
|
|||||||
|
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();
|
||||||
|
ButtonSortByColor = new Button();
|
||||||
|
ButtonSortByType = new Button();
|
||||||
|
sets = new GroupBox();
|
||||||
|
ButtonDelObject = new Button();
|
||||||
|
listBoxStorages = new ListBox();
|
||||||
|
ButtonAddObject = new Button();
|
||||||
|
textBoxStorageName = new TextBox();
|
||||||
|
maskedTextBoxNumber = new MaskedTextBox();
|
||||||
|
buttonRefreshCollection = new Button();
|
||||||
|
buttonRemoveBoat = new Button();
|
||||||
|
buttonAddBoat = new Button();
|
||||||
|
pictureBoxCollection = new PictureBox();
|
||||||
|
menuStrip = new MenuStrip();
|
||||||
|
файлToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
SaveToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
LoadToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
openFileDialog = new OpenFileDialog();
|
||||||
|
saveFileDialog = new SaveFileDialog();
|
||||||
|
tools.SuspendLayout();
|
||||||
|
sets.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
||||||
|
menuStrip.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// tools
|
||||||
|
//
|
||||||
|
tools.Controls.Add(ButtonSortByColor);
|
||||||
|
tools.Controls.Add(ButtonSortByType);
|
||||||
|
tools.Controls.Add(sets);
|
||||||
|
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, 24);
|
||||||
|
tools.Name = "tools";
|
||||||
|
tools.Size = new Size(200, 613);
|
||||||
|
tools.TabIndex = 0;
|
||||||
|
tools.TabStop = false;
|
||||||
|
tools.Text = "Инструменты";
|
||||||
|
//
|
||||||
|
// ButtonSortByColor
|
||||||
|
//
|
||||||
|
ButtonSortByColor.Location = new Point(12, 353);
|
||||||
|
ButtonSortByColor.Name = "ButtonSortByColor";
|
||||||
|
ButtonSortByColor.Size = new Size(176, 45);
|
||||||
|
ButtonSortByColor.TabIndex = 7;
|
||||||
|
ButtonSortByColor.Text = "Сортировать по цвету";
|
||||||
|
ButtonSortByColor.UseVisualStyleBackColor = true;
|
||||||
|
ButtonSortByColor.Click += ButtonSortByColor_Click;
|
||||||
|
//
|
||||||
|
// ButtonSortByType
|
||||||
|
//
|
||||||
|
ButtonSortByType.Location = new Point(12, 305);
|
||||||
|
ButtonSortByType.Name = "ButtonSortByType";
|
||||||
|
ButtonSortByType.Size = new Size(176, 42);
|
||||||
|
ButtonSortByType.TabIndex = 6;
|
||||||
|
ButtonSortByType.Text = "Сортировать по типу";
|
||||||
|
ButtonSortByType.UseVisualStyleBackColor = true;
|
||||||
|
ButtonSortByType.Click += ButtonSortByType_Click;
|
||||||
|
//
|
||||||
|
// sets
|
||||||
|
//
|
||||||
|
sets.Controls.Add(ButtonDelObject);
|
||||||
|
sets.Controls.Add(listBoxStorages);
|
||||||
|
sets.Controls.Add(ButtonAddObject);
|
||||||
|
sets.Controls.Add(textBoxStorageName);
|
||||||
|
sets.Location = new Point(6, 22);
|
||||||
|
sets.Name = "sets";
|
||||||
|
sets.Size = new Size(188, 257);
|
||||||
|
sets.TabIndex = 5;
|
||||||
|
sets.TabStop = false;
|
||||||
|
sets.Text = "Наборы";
|
||||||
|
//
|
||||||
|
// ButtonDelObject
|
||||||
|
//
|
||||||
|
ButtonDelObject.Location = new Point(6, 208);
|
||||||
|
ButtonDelObject.Name = "ButtonDelObject";
|
||||||
|
ButtonDelObject.Size = new Size(176, 41);
|
||||||
|
ButtonDelObject.TabIndex = 3;
|
||||||
|
ButtonDelObject.Text = "Удалить набор";
|
||||||
|
ButtonDelObject.UseVisualStyleBackColor = true;
|
||||||
|
ButtonDelObject.Click += ButtonDelObject_Click;
|
||||||
|
//
|
||||||
|
// listBoxStorages
|
||||||
|
//
|
||||||
|
listBoxStorages.FormattingEnabled = true;
|
||||||
|
listBoxStorages.ItemHeight = 15;
|
||||||
|
listBoxStorages.Location = new Point(6, 93);
|
||||||
|
listBoxStorages.Name = "listBoxStorages";
|
||||||
|
listBoxStorages.Size = new Size(176, 109);
|
||||||
|
listBoxStorages.TabIndex = 2;
|
||||||
|
listBoxStorages.SelectedIndexChanged += listBoxStorages_SelectedIndexChanged;
|
||||||
|
//
|
||||||
|
// ButtonAddObject
|
||||||
|
//
|
||||||
|
ButtonAddObject.Location = new Point(6, 17);
|
||||||
|
ButtonAddObject.Name = "ButtonAddObject";
|
||||||
|
ButtonAddObject.Size = new Size(176, 41);
|
||||||
|
ButtonAddObject.TabIndex = 1;
|
||||||
|
ButtonAddObject.Text = "Добавить набор";
|
||||||
|
ButtonAddObject.UseVisualStyleBackColor = true;
|
||||||
|
ButtonAddObject.Click += ButtonAddObject_Click;
|
||||||
|
//
|
||||||
|
// textBoxStorageName
|
||||||
|
//
|
||||||
|
textBoxStorageName.Location = new Point(6, 64);
|
||||||
|
textBoxStorageName.Name = "textBoxStorageName";
|
||||||
|
textBoxStorageName.Size = new Size(176, 23);
|
||||||
|
textBoxStorageName.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// maskedTextBoxNumber
|
||||||
|
//
|
||||||
|
maskedTextBoxNumber.Location = new Point(45, 488);
|
||||||
|
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, 562);
|
||||||
|
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, 517);
|
||||||
|
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, 421);
|
||||||
|
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, 24);
|
||||||
|
pictureBoxCollection.Name = "pictureBoxCollection";
|
||||||
|
pictureBoxCollection.Size = new Size(710, 613);
|
||||||
|
pictureBoxCollection.TabIndex = 1;
|
||||||
|
pictureBoxCollection.TabStop = false;
|
||||||
|
//
|
||||||
|
// menuStrip
|
||||||
|
//
|
||||||
|
menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
|
||||||
|
menuStrip.Location = new Point(0, 0);
|
||||||
|
menuStrip.Name = "menuStrip";
|
||||||
|
menuStrip.RenderMode = ToolStripRenderMode.System;
|
||||||
|
menuStrip.Size = new Size(916, 24);
|
||||||
|
menuStrip.TabIndex = 2;
|
||||||
|
menuStrip.Text = "menuStrip";
|
||||||
|
//
|
||||||
|
// файлToolStripMenuItem
|
||||||
|
//
|
||||||
|
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SaveToolStripMenuItem, LoadToolStripMenuItem });
|
||||||
|
файлToolStripMenuItem.Name = "файлToolStripMenuItem";
|
||||||
|
файлToolStripMenuItem.Size = new Size(48, 20);
|
||||||
|
файлToolStripMenuItem.Text = "Файл";
|
||||||
|
//
|
||||||
|
// SaveToolStripMenuItem
|
||||||
|
//
|
||||||
|
SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||||
|
SaveToolStripMenuItem.Size = new Size(141, 22);
|
||||||
|
SaveToolStripMenuItem.Text = "Сохранение";
|
||||||
|
SaveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// LoadToolStripMenuItem
|
||||||
|
//
|
||||||
|
LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
|
||||||
|
LoadToolStripMenuItem.Size = new Size(141, 22);
|
||||||
|
LoadToolStripMenuItem.Text = "Загрузка";
|
||||||
|
LoadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// openFileDialog
|
||||||
|
//
|
||||||
|
openFileDialog.FileName = "openFileDialog";
|
||||||
|
openFileDialog.Filter = "txt file | *.txt";
|
||||||
|
//
|
||||||
|
// saveFileDialog
|
||||||
|
//
|
||||||
|
saveFileDialog.Filter = "txt file | *.txt";
|
||||||
|
//
|
||||||
|
// FormBoatCollection
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(916, 637);
|
||||||
|
Controls.Add(pictureBoxCollection);
|
||||||
|
Controls.Add(tools);
|
||||||
|
Controls.Add(menuStrip);
|
||||||
|
Name = "FormBoatCollection";
|
||||||
|
Text = "Набор лодок";
|
||||||
|
tools.ResumeLayout(false);
|
||||||
|
tools.PerformLayout();
|
||||||
|
sets.ResumeLayout(false);
|
||||||
|
sets.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
||||||
|
menuStrip.ResumeLayout(false);
|
||||||
|
menuStrip.PerformLayout();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private GroupBox tools;
|
||||||
|
private Button buttonAddBoat;
|
||||||
|
private Button buttonRemoveBoat;
|
||||||
|
private Button buttonRefreshCollection;
|
||||||
|
private PictureBox pictureBoxCollection;
|
||||||
|
private MaskedTextBox maskedTextBoxNumber;
|
||||||
|
private GroupBox sets;
|
||||||
|
private Button ButtonDelObject;
|
||||||
|
private ListBox listBoxStorages;
|
||||||
|
private Button ButtonAddObject;
|
||||||
|
private TextBox textBoxStorageName;
|
||||||
|
private MenuStrip menuStrip;
|
||||||
|
private ToolStripMenuItem файлToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem SaveToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||||
|
private OpenFileDialog openFileDialog;
|
||||||
|
private SaveFileDialog saveFileDialog;
|
||||||
|
private Button ButtonSortByColor;
|
||||||
|
private Button ButtonSortByType;
|
||||||
|
}
|
||||||
|
}
|
231
SailBoat/SailBoat/FormBoatCollection.cs
Normal file
231
SailBoat/SailBoat/FormBoatCollection.cs
Normal file
@ -0,0 +1,231 @@
|
|||||||
|
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;
|
||||||
|
using SailBoat.Exceptions;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace SailBoat
|
||||||
|
{
|
||||||
|
public partial class FormBoatCollection : Form
|
||||||
|
{
|
||||||
|
private readonly BoatsGenericStorage _storage;
|
||||||
|
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
public FormBoatCollection(ILogger<FormBoatCollection> logger)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_storage = new BoatsGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReloadObjects()
|
||||||
|
{
|
||||||
|
int index = listBoxStorages.SelectedIndex;
|
||||||
|
|
||||||
|
listBoxStorages.Items.Clear();
|
||||||
|
for (int i = 0; i < _storage.Keys.Count; i++)
|
||||||
|
{
|
||||||
|
listBoxStorages.Items.Add(_storage.Keys[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count))
|
||||||
|
{
|
||||||
|
listBoxStorages.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
else if (listBoxStorages.Items.Count > 0 && index > -1 && index < listBoxStorages.Items.Count)
|
||||||
|
{
|
||||||
|
listBoxStorages.SelectedIndex = index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonAddObject_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
_logger.LogWarning($"!!Ошибка!! Не все данные заполнены");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_storage.AddSet(textBoxStorageName.Text);
|
||||||
|
ReloadObjects();
|
||||||
|
_logger.LogInformation($"Добавлен набор: {textBoxStorageName.Text}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void listBoxStorages_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowBoats();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDelObject_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
_logger.LogWarning($"Удаление не выбранного набора");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string name = listBoxStorages.SelectedItem.ToString() ?? string.Empty;
|
||||||
|
if (MessageBox.Show($"Удалить объект{listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
_storage.DelSet(listBoxStorages.SelectedItem.ToString() ?? string.Empty);
|
||||||
|
ReloadObjects();
|
||||||
|
_logger.LogInformation($"Удален набор: {name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddBoat(DrawningBoat boat)
|
||||||
|
{
|
||||||
|
boat._pictureWidth = pictureBoxCollection.Width;
|
||||||
|
boat._pictureHeight = pictureBoxCollection.Height;
|
||||||
|
if (listBoxStorages.SelectedIndex == -1) return;
|
||||||
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
string name = listBoxStorages.SelectedItem.ToString() ?? string.Empty;
|
||||||
|
if (obj == null) return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
if (obj + boat)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект добавлен");
|
||||||
|
pictureBoxCollection.Image = obj.ShowBoats();
|
||||||
|
_logger.LogInformation($"В набор {name} добавлен объект");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
_logger.LogWarning("Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (StorageOverflowException ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
_logger.LogWarning($"{ex.Message}. Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
_logger.LogWarning($"{ex.Message}. Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAddBoat_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex == -1) return;
|
||||||
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
if (obj == null) return;
|
||||||
|
|
||||||
|
FormBoatConfig form = new FormBoatConfig();
|
||||||
|
form.Show();
|
||||||
|
form.AddEvent(AddBoat);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonRemoveBoat_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex == -1) return;
|
||||||
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
string name = listBoxStorages.SelectedItem.ToString() ?? string.Empty;
|
||||||
|
if (obj == null) return;
|
||||||
|
|
||||||
|
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (maskedTextBoxNumber.Text == "") { return; }
|
||||||
|
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (obj - pos != null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект удален");
|
||||||
|
pictureBoxCollection.Image = obj.ShowBoats();
|
||||||
|
_logger.LogInformation($"Из набора {name} удален объект");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось удалить объект");
|
||||||
|
_logger.LogWarning("Не удалось удалить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (BoatNotFoundException ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
_logger.LogWarning($"{ex.Message}. Не удалось удалить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonRefreshCollection_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex == -1) return;
|
||||||
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
if (obj == null) return;
|
||||||
|
pictureBoxCollection.Image = obj.ShowBoats();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_storage.SaveData(saveFileDialog.FileName);
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
_logger.LogInformation("Сохранение");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"Не сохранилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
_logger.LogWarning("Ошибка сохранения");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_storage.LoadData(openFileDialog.FileName);
|
||||||
|
ReloadObjects();
|
||||||
|
MessageBox.Show("Загрузка произошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
_logger.LogInformation("Загрузка");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"Не загрузилось: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
_logger.LogWarning("Ошибка загрузки");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSortByType_Click(object sender, EventArgs e) => CompareBoats(new BoatCompareByType());
|
||||||
|
|
||||||
|
private void CompareBoats(IComparer<DrawningBoat?> comparer)
|
||||||
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
obj.Sort(comparer);
|
||||||
|
pictureBoxCollection.Image = obj.ShowBoats();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSortByColor_Click(object sender, EventArgs e) => CompareBoats(new BoatCompareByColor());
|
||||||
|
}
|
||||||
|
}
|
129
SailBoat/SailBoat/FormBoatCollection.resx
Normal file
129
SailBoat/SailBoat/FormBoatCollection.resx
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
<?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>
|
||||||
|
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>132, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>247, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>387, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
358
SailBoat/SailBoat/FormBoatConfig.Designer.cs
generated
Normal file
358
SailBoat/SailBoat/FormBoatConfig.Designer.cs
generated
Normal file
@ -0,0 +1,358 @@
|
|||||||
|
namespace SailBoat
|
||||||
|
{
|
||||||
|
partial class FormBoatConfig
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
groupBox1 = new GroupBox();
|
||||||
|
labelModifiedObject = new Label();
|
||||||
|
labelSimpleObject = new Label();
|
||||||
|
groupBox2 = new GroupBox();
|
||||||
|
panelPink = new Panel();
|
||||||
|
panelBlack = new Panel();
|
||||||
|
panelGray = new Panel();
|
||||||
|
panelWhite = new Panel();
|
||||||
|
panelYellow = new Panel();
|
||||||
|
panelBlue = new Panel();
|
||||||
|
panelGreen = new Panel();
|
||||||
|
panelRed = new Panel();
|
||||||
|
checkBoxSail = new CheckBox();
|
||||||
|
checkBoxRainforce = new CheckBox();
|
||||||
|
numericUpDownWeight = new NumericUpDown();
|
||||||
|
numericUpDownSpeed = new NumericUpDown();
|
||||||
|
label2 = new Label();
|
||||||
|
label1 = new Label();
|
||||||
|
pictureBoxObject = new PictureBox();
|
||||||
|
panelObject = new Panel();
|
||||||
|
labelAdditionalColor = new Label();
|
||||||
|
labelColor = new Label();
|
||||||
|
buttonOk = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
groupBox1.SuspendLayout();
|
||||||
|
groupBox2.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||||
|
panelObject.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
groupBox1.Controls.Add(labelModifiedObject);
|
||||||
|
groupBox1.Controls.Add(labelSimpleObject);
|
||||||
|
groupBox1.Controls.Add(groupBox2);
|
||||||
|
groupBox1.Controls.Add(checkBoxSail);
|
||||||
|
groupBox1.Controls.Add(checkBoxRainforce);
|
||||||
|
groupBox1.Controls.Add(numericUpDownWeight);
|
||||||
|
groupBox1.Controls.Add(numericUpDownSpeed);
|
||||||
|
groupBox1.Controls.Add(label2);
|
||||||
|
groupBox1.Controls.Add(label1);
|
||||||
|
groupBox1.Location = new Point(12, 12);
|
||||||
|
groupBox1.Name = "groupBox1";
|
||||||
|
groupBox1.Size = new Size(525, 241);
|
||||||
|
groupBox1.TabIndex = 0;
|
||||||
|
groupBox1.TabStop = false;
|
||||||
|
groupBox1.Text = "Праметры";
|
||||||
|
//
|
||||||
|
// labelModifiedObject
|
||||||
|
//
|
||||||
|
labelModifiedObject.AutoEllipsis = true;
|
||||||
|
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelModifiedObject.Location = new Point(385, 185);
|
||||||
|
labelModifiedObject.Name = "labelModifiedObject";
|
||||||
|
labelModifiedObject.Size = new Size(96, 42);
|
||||||
|
labelModifiedObject.TabIndex = 8;
|
||||||
|
labelModifiedObject.Text = "Продвинутый";
|
||||||
|
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||||
|
//
|
||||||
|
// labelSimpleObject
|
||||||
|
//
|
||||||
|
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelSimpleObject.Location = new Point(263, 185);
|
||||||
|
labelSimpleObject.Name = "labelSimpleObject";
|
||||||
|
labelSimpleObject.Size = new Size(96, 42);
|
||||||
|
labelSimpleObject.TabIndex = 7;
|
||||||
|
labelSimpleObject.Text = "Простой";
|
||||||
|
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||||
|
//
|
||||||
|
// groupBox2
|
||||||
|
//
|
||||||
|
groupBox2.Controls.Add(panelPink);
|
||||||
|
groupBox2.Controls.Add(panelBlack);
|
||||||
|
groupBox2.Controls.Add(panelGray);
|
||||||
|
groupBox2.Controls.Add(panelWhite);
|
||||||
|
groupBox2.Controls.Add(panelYellow);
|
||||||
|
groupBox2.Controls.Add(panelBlue);
|
||||||
|
groupBox2.Controls.Add(panelGreen);
|
||||||
|
groupBox2.Controls.Add(panelRed);
|
||||||
|
groupBox2.Location = new Point(248, 22);
|
||||||
|
groupBox2.Name = "groupBox2";
|
||||||
|
groupBox2.Size = new Size(250, 150);
|
||||||
|
groupBox2.TabIndex = 6;
|
||||||
|
groupBox2.TabStop = false;
|
||||||
|
groupBox2.Text = "Цвета";
|
||||||
|
//
|
||||||
|
// panelPink
|
||||||
|
//
|
||||||
|
panelPink.BackColor = Color.Fuchsia;
|
||||||
|
panelPink.Location = new Point(183, 82);
|
||||||
|
panelPink.Name = "panelPink";
|
||||||
|
panelPink.Size = new Size(50, 50);
|
||||||
|
panelPink.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelBlack
|
||||||
|
//
|
||||||
|
panelBlack.BackColor = Color.Black;
|
||||||
|
panelBlack.Location = new Point(127, 82);
|
||||||
|
panelBlack.Name = "panelBlack";
|
||||||
|
panelBlack.Size = new Size(50, 50);
|
||||||
|
panelBlack.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelGray
|
||||||
|
//
|
||||||
|
panelGray.BackColor = Color.Silver;
|
||||||
|
panelGray.Location = new Point(71, 82);
|
||||||
|
panelGray.Name = "panelGray";
|
||||||
|
panelGray.Size = new Size(50, 50);
|
||||||
|
panelGray.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelWhite
|
||||||
|
//
|
||||||
|
panelWhite.BackColor = Color.White;
|
||||||
|
panelWhite.Location = new Point(15, 82);
|
||||||
|
panelWhite.Name = "panelWhite";
|
||||||
|
panelWhite.Size = new Size(50, 50);
|
||||||
|
panelWhite.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelYellow
|
||||||
|
//
|
||||||
|
panelYellow.BackColor = Color.Yellow;
|
||||||
|
panelYellow.Location = new Point(183, 22);
|
||||||
|
panelYellow.Name = "panelYellow";
|
||||||
|
panelYellow.Size = new Size(50, 50);
|
||||||
|
panelYellow.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelBlue
|
||||||
|
//
|
||||||
|
panelBlue.BackColor = Color.Blue;
|
||||||
|
panelBlue.Location = new Point(127, 22);
|
||||||
|
panelBlue.Name = "panelBlue";
|
||||||
|
panelBlue.Size = new Size(50, 50);
|
||||||
|
panelBlue.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelGreen
|
||||||
|
//
|
||||||
|
panelGreen.BackColor = Color.LimeGreen;
|
||||||
|
panelGreen.Location = new Point(71, 22);
|
||||||
|
panelGreen.Name = "panelGreen";
|
||||||
|
panelGreen.Size = new Size(50, 50);
|
||||||
|
panelGreen.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelRed
|
||||||
|
//
|
||||||
|
panelRed.BackColor = Color.Red;
|
||||||
|
panelRed.Location = new Point(15, 22);
|
||||||
|
panelRed.Name = "panelRed";
|
||||||
|
panelRed.Size = new Size(50, 50);
|
||||||
|
panelRed.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// checkBoxSail
|
||||||
|
//
|
||||||
|
checkBoxSail.AutoSize = true;
|
||||||
|
checkBoxSail.Location = new Point(6, 114);
|
||||||
|
checkBoxSail.Name = "checkBoxSail";
|
||||||
|
checkBoxSail.Size = new Size(60, 19);
|
||||||
|
checkBoxSail.TabIndex = 5;
|
||||||
|
checkBoxSail.Text = "Парус";
|
||||||
|
checkBoxSail.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxRainforce
|
||||||
|
//
|
||||||
|
checkBoxRainforce.AutoSize = true;
|
||||||
|
checkBoxRainforce.Location = new Point(6, 153);
|
||||||
|
checkBoxRainforce.Name = "checkBoxRainforce";
|
||||||
|
checkBoxRainforce.Size = new Size(239, 19);
|
||||||
|
checkBoxRainforce.TabIndex = 4;
|
||||||
|
checkBoxRainforce.Text = "Признак наличия усиленного корпуса";
|
||||||
|
checkBoxRainforce.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// numericUpDownWeight
|
||||||
|
//
|
||||||
|
numericUpDownWeight.Location = new Point(74, 71);
|
||||||
|
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||||
|
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
numericUpDownWeight.Name = "numericUpDownWeight";
|
||||||
|
numericUpDownWeight.Size = new Size(65, 23);
|
||||||
|
numericUpDownWeight.TabIndex = 3;
|
||||||
|
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// numericUpDownSpeed
|
||||||
|
//
|
||||||
|
numericUpDownSpeed.Location = new Point(74, 30);
|
||||||
|
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||||
|
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||||
|
numericUpDownSpeed.Size = new Size(65, 23);
|
||||||
|
numericUpDownSpeed.TabIndex = 2;
|
||||||
|
numericUpDownSpeed.UseWaitCursor = true;
|
||||||
|
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(6, 73);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(29, 15);
|
||||||
|
label2.TabIndex = 1;
|
||||||
|
label2.Text = "Вес:";
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(6, 32);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(62, 15);
|
||||||
|
label1.TabIndex = 0;
|
||||||
|
label1.Text = "Скорость:";
|
||||||
|
//
|
||||||
|
// pictureBoxObject
|
||||||
|
//
|
||||||
|
pictureBoxObject.Location = new Point(26, 58);
|
||||||
|
pictureBoxObject.Name = "pictureBoxObject";
|
||||||
|
pictureBoxObject.Size = new Size(345, 139);
|
||||||
|
pictureBoxObject.TabIndex = 1;
|
||||||
|
pictureBoxObject.TabStop = false;
|
||||||
|
//
|
||||||
|
// panelObject
|
||||||
|
//
|
||||||
|
panelObject.AllowDrop = true;
|
||||||
|
panelObject.Controls.Add(labelAdditionalColor);
|
||||||
|
panelObject.Controls.Add(pictureBoxObject);
|
||||||
|
panelObject.Controls.Add(labelColor);
|
||||||
|
panelObject.Location = new Point(543, 12);
|
||||||
|
panelObject.Name = "panelObject";
|
||||||
|
panelObject.Size = new Size(395, 207);
|
||||||
|
panelObject.TabIndex = 2;
|
||||||
|
panelObject.DragDrop += panelObject_DragDrop;
|
||||||
|
panelObject.DragEnter += panelObject_DragEnter;
|
||||||
|
//
|
||||||
|
// labelAdditionalColor
|
||||||
|
//
|
||||||
|
labelAdditionalColor.AllowDrop = true;
|
||||||
|
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelAdditionalColor.Location = new Point(221, 14);
|
||||||
|
labelAdditionalColor.Name = "labelAdditionalColor";
|
||||||
|
labelAdditionalColor.Size = new Size(150, 36);
|
||||||
|
labelAdditionalColor.TabIndex = 3;
|
||||||
|
labelAdditionalColor.Text = "Доп. цвет";
|
||||||
|
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelAdditionalColor.DragDrop += LabelColor_DragDrop;
|
||||||
|
labelAdditionalColor.DragEnter += LabelColor_DragEnter;
|
||||||
|
//
|
||||||
|
// labelColor
|
||||||
|
//
|
||||||
|
labelColor.AllowDrop = true;
|
||||||
|
labelColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelColor.Location = new Point(26, 14);
|
||||||
|
labelColor.Name = "labelColor";
|
||||||
|
labelColor.Size = new Size(150, 36);
|
||||||
|
labelColor.TabIndex = 2;
|
||||||
|
labelColor.Text = "Цвет";
|
||||||
|
labelColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelColor.DragDrop += LabelColor_DragDrop;
|
||||||
|
labelColor.DragEnter += LabelColor_DragEnter;
|
||||||
|
//
|
||||||
|
// buttonOk
|
||||||
|
//
|
||||||
|
buttonOk.Location = new Point(569, 225);
|
||||||
|
buttonOk.Name = "buttonOk";
|
||||||
|
buttonOk.Size = new Size(150, 28);
|
||||||
|
buttonOk.TabIndex = 3;
|
||||||
|
buttonOk.Text = "Добавить";
|
||||||
|
buttonOk.UseVisualStyleBackColor = true;
|
||||||
|
buttonOk.Click += buttonOk_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(764, 225);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(150, 28);
|
||||||
|
buttonCancel.TabIndex = 4;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// FormBoatConfig
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(950, 265);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonOk);
|
||||||
|
Controls.Add(panelObject);
|
||||||
|
Controls.Add(groupBox1);
|
||||||
|
Name = "FormBoatConfig";
|
||||||
|
Text = "FormBoatConfig";
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
groupBox1.PerformLayout();
|
||||||
|
groupBox2.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||||
|
panelObject.ResumeLayout(false);
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private NumericUpDown numericUpDownWeight;
|
||||||
|
private NumericUpDown numericUpDownSpeed;
|
||||||
|
private Label label2;
|
||||||
|
private Label label1;
|
||||||
|
private GroupBox groupBox2;
|
||||||
|
private Panel panelPink;
|
||||||
|
private Panel panelBlack;
|
||||||
|
private Panel panelGray;
|
||||||
|
private Panel panelWhite;
|
||||||
|
private Panel panelYellow;
|
||||||
|
private Panel panelBlue;
|
||||||
|
private Panel panelGreen;
|
||||||
|
private Panel panelRed;
|
||||||
|
private CheckBox checkBoxSail;
|
||||||
|
private CheckBox checkBoxRainforce;
|
||||||
|
private Label labelModifiedObject;
|
||||||
|
private Label labelSimpleObject;
|
||||||
|
private PictureBox pictureBoxObject;
|
||||||
|
private Panel panelObject;
|
||||||
|
private Label labelAdditionalColor;
|
||||||
|
private Label labelColor;
|
||||||
|
private Button buttonOk;
|
||||||
|
private Button buttonCancel;
|
||||||
|
}
|
||||||
|
}
|
129
SailBoat/SailBoat/FormBoatConfig.cs
Normal file
129
SailBoat/SailBoat/FormBoatConfig.cs
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
using SailBoat.DrawningObjects;
|
||||||
|
using SailBoat.Entities;
|
||||||
|
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 FormBoatConfig : Form
|
||||||
|
{
|
||||||
|
|
||||||
|
public DrawningBoat? _boat = null;
|
||||||
|
|
||||||
|
private event Action<DrawningBoat>? EventAddBoat;
|
||||||
|
|
||||||
|
public void AddEvent(Action<DrawningBoat> ev)
|
||||||
|
{
|
||||||
|
if (EventAddBoat == null)
|
||||||
|
{
|
||||||
|
EventAddBoat = ev;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EventAddBoat += ev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormBoatConfig()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelPink.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelGray.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelRed.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||||
|
buttonCancel.Click += (sender, e) => Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawBoat()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_boat?.SetPosition(5, 5);
|
||||||
|
_boat?.DrawTransport(gr);
|
||||||
|
pictureBoxObject.Image = bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void panelObject_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||||
|
{
|
||||||
|
case "labelSimpleObject":
|
||||||
|
_boat = new DrawningBoat((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
case "labelModifiedObject":
|
||||||
|
_boat = new DrawningSailBoat((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxSail.Checked, checkBoxRainforce.Checked, pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawBoat();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void panelObject_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void buttonOk_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
EventAddBoat?.Invoke(_boat);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LabelColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_boat == null) return;
|
||||||
|
switch (((Label)sender).Name)
|
||||||
|
{
|
||||||
|
case "labelColor":
|
||||||
|
_boat.EntityBoat.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
break;
|
||||||
|
case "labelAdditionalColor":
|
||||||
|
if (_boat == null) return;
|
||||||
|
(_boat.EntityBoat as EntitySailBoat).setAdditionalColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawBoat();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LabelColor_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
SailBoat/SailBoat/FormBoatConfig.resx
Normal file
120
SailBoat/SailBoat/FormBoatConfig.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?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
Normal file
189
SailBoat/SailBoat/FormSailBoat.Designer.cs
generated
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
120
SailBoat/SailBoat/FormSailBoat.cs
Normal file
120
SailBoat/SailBoat/FormSailBoat.cs
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
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; 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
SailBoat/SailBoat/FormSailBoat.resx
Normal file
120
SailBoat/SailBoat/FormSailBoat.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?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>
|
43
SailBoat/SailBoat/Generics/BoatCompareByColor.cs
Normal file
43
SailBoat/SailBoat/Generics/BoatCompareByColor.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using SailBoat.DrawningObjects;
|
||||||
|
using SailBoat.Entities;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SailBoat.Generics
|
||||||
|
{
|
||||||
|
internal class BoatCompareByColor : IComparer<DrawningBoat?>
|
||||||
|
{
|
||||||
|
public int Compare(DrawningBoat? x, DrawningBoat? y)
|
||||||
|
{
|
||||||
|
if (x == null || x.EntityBoat == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(x));
|
||||||
|
}
|
||||||
|
if (y == null || y.EntityBoat == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(y));
|
||||||
|
}
|
||||||
|
if (x.EntityBoat.BodyColor != y.EntityBoat.BodyColor)
|
||||||
|
{
|
||||||
|
return x.EntityBoat.BodyColor.Name.CompareTo(y.EntityBoat.BodyColor.Name);
|
||||||
|
}
|
||||||
|
if (x.EntityBoat is EntitySailBoat _SailBoatX && y.EntityBoat is EntitySailBoat _SailBoatY)
|
||||||
|
{
|
||||||
|
var ElementsColorCompare = _SailBoatX.AdditionalColor.Name.CompareTo(_SailBoatY.AdditionalColor.Name);
|
||||||
|
if (ElementsColorCompare != 0)
|
||||||
|
{
|
||||||
|
return ElementsColorCompare;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var speedCompare = x.EntityBoat.Speed.CompareTo(y.EntityBoat.Speed);
|
||||||
|
if (speedCompare != 0)
|
||||||
|
{
|
||||||
|
return speedCompare;
|
||||||
|
}
|
||||||
|
return x.EntityBoat.Weight.CompareTo(y.EntityBoat.Weight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
34
SailBoat/SailBoat/Generics/BoatCompareByType.cs
Normal file
34
SailBoat/SailBoat/Generics/BoatCompareByType.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
using SailBoat.DrawningObjects;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SailBoat.Generics
|
||||||
|
{
|
||||||
|
internal class BoatCompareByType : IComparer<DrawningBoat?>
|
||||||
|
{
|
||||||
|
public int Compare(DrawningBoat? x, DrawningBoat? y)
|
||||||
|
{
|
||||||
|
if(x==null||x.EntityBoat == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(x));
|
||||||
|
}
|
||||||
|
if(y == null || y.EntityBoat == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(y));
|
||||||
|
}
|
||||||
|
if(x.GetType().Name != y.GetType().Name)
|
||||||
|
{
|
||||||
|
return x.GetType().Name.CompareTo(y.GetType().Name);
|
||||||
|
}
|
||||||
|
var speedCompare = x.EntityBoat.Speed.CompareTo(y.EntityBoat.Speed);
|
||||||
|
if(speedCompare != 0)
|
||||||
|
{
|
||||||
|
return speedCompare;
|
||||||
|
}
|
||||||
|
return x.EntityBoat.Weight.CompareTo(y.EntityBoat.Weight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
35
SailBoat/SailBoat/Generics/BoatsCollectionInfo.cs
Normal file
35
SailBoat/SailBoat/Generics/BoatsCollectionInfo.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SailBoat.Generics
|
||||||
|
{
|
||||||
|
internal class BoatsCollectionInfo : IEquatable<BoatsCollectionInfo>
|
||||||
|
{
|
||||||
|
public string Name { get; private set; }
|
||||||
|
|
||||||
|
public string Description { get; private set; }
|
||||||
|
|
||||||
|
public BoatsCollectionInfo(string name, string description)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
Description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Equals(BoatsCollectionInfo? other)
|
||||||
|
{
|
||||||
|
return Name == other.Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return Name.GetHashCode();
|
||||||
|
}
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
96
SailBoat/SailBoat/Generics/BoatsGenericCollection.cs
Normal file
96
SailBoat/SailBoat/Generics/BoatsGenericCollection.cs
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
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 bool operator +(BoatsGenericCollection<T,U> collect, T? obj)
|
||||||
|
{
|
||||||
|
if (obj == null) return false;
|
||||||
|
return collect._collection.Insert(obj, new DrawingBoatEqutables());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T? operator -(BoatsGenericCollection<T,U> collect, int pos)
|
||||||
|
{
|
||||||
|
T? obj = collect._collection[pos];
|
||||||
|
|
||||||
|
collect._collection.Remove(pos);
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
public U? GetU(int pos)
|
||||||
|
{
|
||||||
|
return (U?)_collection[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;
|
||||||
|
int i = 0;
|
||||||
|
foreach (var boat in _collection.GetBoats())
|
||||||
|
{
|
||||||
|
if(boat != null)
|
||||||
|
{
|
||||||
|
boat.SetPosition((i % width) * _placeSizeWidth, (i / (height - 1)) * _placeSizeHeight);
|
||||||
|
boat.DrawTransport(g);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<T?> GetBoats => _collection.GetBoats();
|
||||||
|
|
||||||
|
public void Sort(IComparer<T?> comparer) => _collection.SortSet(comparer);
|
||||||
|
}
|
||||||
|
}
|
139
SailBoat/SailBoat/Generics/BoatsGenericStorage.cs
Normal file
139
SailBoat/SailBoat/Generics/BoatsGenericStorage.cs
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
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 BoatsGenericStorage
|
||||||
|
{
|
||||||
|
readonly Dictionary<BoatsCollectionInfo, BoatsGenericCollection<DrawningBoat, DrawningObjectBoat>> _boatStorages;
|
||||||
|
|
||||||
|
public List<BoatsCollectionInfo> Keys => _boatStorages.Keys.ToList();
|
||||||
|
|
||||||
|
private readonly int _pictureWidth;
|
||||||
|
|
||||||
|
private readonly int _pictureHeight;
|
||||||
|
|
||||||
|
public BoatsGenericStorage(int pictureWidth, int pictureHeight)
|
||||||
|
{
|
||||||
|
_boatStorages = new Dictionary<BoatsCollectionInfo, BoatsGenericCollection<DrawningBoat, DrawningObjectBoat>>();
|
||||||
|
_pictureWidth = pictureWidth;
|
||||||
|
_pictureHeight = pictureHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddSet(string Name)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!_boatStorages.ContainsKey(new BoatsCollectionInfo(Name, "")))
|
||||||
|
{
|
||||||
|
_boatStorages[new BoatsCollectionInfo(Name, "")] = new BoatsGenericCollection<DrawningBoat, DrawningObjectBoat>(_pictureWidth, _pictureHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DelSet(string Name)
|
||||||
|
{
|
||||||
|
if (_boatStorages.ContainsKey(new BoatsCollectionInfo(Name, "")))
|
||||||
|
{
|
||||||
|
_boatStorages.Remove(new BoatsCollectionInfo(Name, ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BoatsGenericCollection<DrawningBoat, DrawningObjectBoat>? this[string ind]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var info = new BoatsCollectionInfo(ind, "");
|
||||||
|
if (_boatStorages.ContainsKey(info)) return _boatStorages[info];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly char _separatorForKeyValue = '|';
|
||||||
|
private readonly char _separatorRecords = ';';
|
||||||
|
private static readonly char _separatorForObject = ':';
|
||||||
|
|
||||||
|
public bool SaveData(string filename)
|
||||||
|
{
|
||||||
|
if (File.Exists(filename))
|
||||||
|
{
|
||||||
|
File.Delete(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder data = new();
|
||||||
|
|
||||||
|
foreach (KeyValuePair <BoatsCollectionInfo, BoatsGenericCollection < DrawningBoat, DrawningObjectBoat>> record in _boatStorages)
|
||||||
|
{
|
||||||
|
StringBuilder records = new();
|
||||||
|
foreach (DrawningBoat? elem in record.Value.GetBoats)
|
||||||
|
{
|
||||||
|
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
||||||
|
}
|
||||||
|
data.Append($"{record.Key}{_separatorForKeyValue}{records}\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.Length == 0)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Невалиданя операция, нет данных для сохранения");
|
||||||
|
}
|
||||||
|
|
||||||
|
using StreamWriter fs = new StreamWriter(filename);
|
||||||
|
string info = $"BoatStorage{Environment.NewLine}{data}";
|
||||||
|
fs.Write(info, 0, info.Length);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool LoadData(string filename)
|
||||||
|
{
|
||||||
|
if (!File.Exists(filename))
|
||||||
|
{
|
||||||
|
throw new FileNotFoundException("Файл не найден");
|
||||||
|
}
|
||||||
|
|
||||||
|
using (StreamReader fs = new StreamReader(filename))
|
||||||
|
{
|
||||||
|
string str = fs.ReadLine();
|
||||||
|
|
||||||
|
if(str == null || str.Length == 0)
|
||||||
|
{
|
||||||
|
throw new NullReferenceException("Нет данных для загрузки");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!str.StartsWith("BoatStorage"))
|
||||||
|
{
|
||||||
|
throw new FormatException("Неверный формат данных");
|
||||||
|
}
|
||||||
|
_boatStorages.Clear();
|
||||||
|
while ((str = fs.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
string[] record = str.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (record.Length != 2)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
BoatsGenericCollection<DrawningBoat, DrawningObjectBoat> collection = new(_pictureWidth, _pictureHeight);
|
||||||
|
string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
foreach (string elem in set)
|
||||||
|
{
|
||||||
|
DrawningBoat? boat = elem?.CreateDrawningBoat(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||||
|
if (boat != null)
|
||||||
|
{
|
||||||
|
if (!(collection + boat))
|
||||||
|
{
|
||||||
|
throw new ApplicationException("Ошибка добавления в коллекцию");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_boatStorages.Add(new BoatsCollectionInfo(record[0], ""), collection);
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
SailBoat/SailBoat/Generics/DrawingBoatEqutables.cs
Normal file
60
SailBoat/SailBoat/Generics/DrawingBoatEqutables.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
using SailBoat.DrawningObjects;
|
||||||
|
using SailBoat.Entities;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SailBoat.Generics
|
||||||
|
{
|
||||||
|
internal class DrawingBoatEqutables : IEqualityComparer<DrawningBoat?>
|
||||||
|
{
|
||||||
|
public bool Equals(DrawningBoat? x, DrawningBoat? y)
|
||||||
|
{
|
||||||
|
if (x == null || x.EntityBoat == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(x));
|
||||||
|
}
|
||||||
|
if (y == null || y.EntityBoat == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(y));
|
||||||
|
}
|
||||||
|
if (x.GetType().Name != y.GetType().Name)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (x.EntityBoat.Speed != y.EntityBoat.Speed)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (x.EntityBoat.Weight != y.EntityBoat.Weight)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (x.EntityBoat.BodyColor != y.EntityBoat.BodyColor)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (x is DrawningSailBoat && y is DrawningSailBoat)
|
||||||
|
{
|
||||||
|
if ((x.EntityBoat as EntitySailBoat).Sail != (y.EntityBoat as EntitySailBoat).Sail)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if((x.EntityBoat as EntitySailBoat).RainforcedBody != (y.EntityBoat as EntitySailBoat).RainforcedBody)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetHashCode([DisallowNull] DrawningBoat obj)
|
||||||
|
{
|
||||||
|
return obj.GetHashCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
99
SailBoat/SailBoat/Generics/SetGeneric.cs
Normal file
99
SailBoat/SailBoat/Generics/SetGeneric.cs
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
using SailBoat.Exceptions;
|
||||||
|
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 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 boat, IEqualityComparer<T?>? equal = null)
|
||||||
|
{
|
||||||
|
return Insert(boat, 0, equal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Insert(T boat, int position, IEqualityComparer<T?>? equal = null)
|
||||||
|
{
|
||||||
|
if (position < 0 || position >= _maxCount)
|
||||||
|
{
|
||||||
|
throw new BoatNotFoundException(position);
|
||||||
|
}
|
||||||
|
if (Count >= _maxCount)
|
||||||
|
{
|
||||||
|
throw new StorageOverflowException(_maxCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(equal != null)
|
||||||
|
{
|
||||||
|
foreach(var i in _places)
|
||||||
|
{
|
||||||
|
if (equal.Equals(i, boat))
|
||||||
|
{
|
||||||
|
throw new ApplicationException($"Объект уже существует");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_places.Insert(position, boat);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Remove(int position)
|
||||||
|
{
|
||||||
|
if (position < 0 || position >= _maxCount)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (_places[position] == null)
|
||||||
|
{
|
||||||
|
throw new BoatNotFoundException(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
_places[position] = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T? this[int position]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (position < 0 || position >= Count) { return null; }
|
||||||
|
return _places[position];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (position < 0 || position >= Count) { return; }
|
||||||
|
_places[position] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<T?> GetBoats(int? maxBoats = null)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < _places.Count; i++)
|
||||||
|
{
|
||||||
|
yield return _places[i];
|
||||||
|
if(maxBoats.HasValue && i == maxBoats.Value)
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SortSet(IComparer<T?> comparer) => _places.Sort(comparer);
|
||||||
|
}
|
||||||
|
}
|
82
SailBoat/SailBoat/MovementStrategy/AbstractStrategy.cs
Normal file
82
SailBoat/SailBoat/MovementStrategy/AbstractStrategy.cs
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
34
SailBoat/SailBoat/MovementStrategy/DrawningObjectBoat.cs
Normal file
34
SailBoat/SailBoat/MovementStrategy/DrawningObjectBoat.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
20
SailBoat/SailBoat/MovementStrategy/IMoveableObject.cs
Normal file
20
SailBoat/SailBoat/MovementStrategy/IMoveableObject.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
40
SailBoat/SailBoat/MovementStrategy/MoveToBorder.cs
Normal file
40
SailBoat/SailBoat/MovementStrategy/MoveToBorder.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
48
SailBoat/SailBoat/MovementStrategy/MoveToCenter.cs
Normal file
48
SailBoat/SailBoat/MovementStrategy/MoveToCenter.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
39
SailBoat/SailBoat/MovementStrategy/ObjectParameters.cs
Normal file
39
SailBoat/SailBoat/MovementStrategy/ObjectParameters.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
17
SailBoat/SailBoat/MovementStrategy/Status.cs
Normal file
17
SailBoat/SailBoat/MovementStrategy/Status.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,11 @@
|
|||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Serilog;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace SailBoat
|
namespace SailBoat
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
@ -11,7 +19,29 @@ 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 Form1());
|
var services = new ServiceCollection();
|
||||||
|
ConfigureServices(services);
|
||||||
|
using (ServiceProvider serviceProvider = services.BuildServiceProvider())
|
||||||
|
{
|
||||||
|
Application.Run(serviceProvider.GetRequiredService<FormBoatCollection>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ConfigureServices(IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddSingleton<FormBoatCollection>().AddLogging(option =>
|
||||||
|
{
|
||||||
|
string[] path = Directory.GetCurrentDirectory().Split('\\');
|
||||||
|
string appPath = "";
|
||||||
|
for (int i = 0; i < path.Length - 3; i++)
|
||||||
|
{
|
||||||
|
appPath += path[i] + "\\";
|
||||||
|
}
|
||||||
|
var configuration = new ConfigurationBuilder().AddJsonFile($"{appPath}appsettings.json").Build();
|
||||||
|
var logger = new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger();
|
||||||
|
option.SetMinimumLevel(LogLevel.Information);
|
||||||
|
option.AddSerilog(logger);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
103
SailBoat/SailBoat/Properties/Resources.Designer.cs
generated
Normal file
103
SailBoat/SailBoat/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
133
SailBoat/SailBoat/Properties/Resources.resx
Normal file
133
SailBoat/SailBoat/Properties/Resources.resx
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
<?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>
|
BIN
SailBoat/SailBoat/Resources/down.png
Normal file
BIN
SailBoat/SailBoat/Resources/down.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.0 KiB |
BIN
SailBoat/SailBoat/Resources/left.png
Normal file
BIN
SailBoat/SailBoat/Resources/left.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
BIN
SailBoat/SailBoat/Resources/right.png
Normal file
BIN
SailBoat/SailBoat/Resources/right.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
BIN
SailBoat/SailBoat/Resources/up.png
Normal file
BIN
SailBoat/SailBoat/Resources/up.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.0 KiB |
@ -8,4 +8,47 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="C:\Users\shotb\.nuget\packages\nlog.config\4.7.15\contentFiles\any\any\NLog.config" />
|
||||||
|
<None Remove="C:\Users\shotb\.nuget\packages\nlog.schema\5.2.7\contentFiles\any\any\NLog.xsd" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Primitives" Version="8.0.0" />
|
||||||
|
<PackageReference Include="NLog" Version="5.2.7" />
|
||||||
|
<PackageReference Include="NLog.Config" Version="4.7.15" />
|
||||||
|
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.5" />
|
||||||
|
<PackageReference Include="NLog.Schema" Version="5.2.7" />
|
||||||
|
<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.5" />
|
||||||
|
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||||
|
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Settings.AppSettings" Version="2.2.2" />
|
||||||
|
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||||
|
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<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>
|
20
SailBoat/SailBoat/appsettings.json
Normal file
20
SailBoat/SailBoat/appsettings.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"Serilog": {
|
||||||
|
"Using": [ "Serilog.Sinks.File" ],
|
||||||
|
"MinimumLevel": "Information",
|
||||||
|
"WriteTo": [
|
||||||
|
{
|
||||||
|
"Name": "File",
|
||||||
|
"Args": {
|
||||||
|
"path": "logs/boatlog-.log",
|
||||||
|
"rollingInterval": "Day",
|
||||||
|
"outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
|
||||||
|
"Properties": {
|
||||||
|
"Application": "Loco"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user