Compare commits
No commits in common. "lab7" and "main" have entirely different histories.
@ -8,31 +8,4 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.7.34024.191
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cruiser", "Cruiser.csproj", "{4B55C43E-7DDF-4DA6-A186-7244085169A8}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cruiser", "Cruiser.csproj", "{756E194C-4DC4-4A91-A93C-3E903FABED76}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -11,15 +11,15 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4B55C43E-7DDF-4DA6-A186-7244085169A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4B55C43E-7DDF-4DA6-A186-7244085169A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4B55C43E-7DDF-4DA6-A186-7244085169A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4B55C43E-7DDF-4DA6-A186-7244085169A8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{756E194C-4DC4-4A91-A93C-3E903FABED76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{756E194C-4DC4-4A91-A93C-3E903FABED76}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{756E194C-4DC4-4A91-A93C-3E903FABED76}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{756E194C-4DC4-4A91-A93C-3E903FABED76}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {45C16C6A-A71C-4A65-8704-F821496C7C82}
|
||||
SolutionGuid = {034E99D7-3DC1-49BB-86DA-3314CC18DE34}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cruiser
|
||||
{
|
||||
public enum Direction
|
||||
{
|
||||
/// <summary>
|
||||
/// Вверх
|
||||
/// </summary>
|
||||
Up = 1,
|
||||
/// <summary>
|
||||
/// Вниз
|
||||
/// </summary>
|
||||
Down = 2,
|
||||
/// <summary>
|
||||
/// Влево
|
||||
/// </summary>
|
||||
Left = 3,
|
||||
/// <summary>
|
||||
/// Вправо
|
||||
/// </summary>
|
||||
Right = 4
|
||||
}
|
||||
}
|
@ -1,221 +0,0 @@
|
||||
using Cruiser.Entities;
|
||||
using Cruiser.MovementStrategy;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cruiser.Drawing
|
||||
{
|
||||
public class DrawingCruiser
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
/// </summary>
|
||||
public EntityCruiser? EntityCruiser { get; set; }
|
||||
/// <summary>
|
||||
/// Ширина окна
|
||||
/// </summary>
|
||||
public int _pictureWidth;// изменил уровень доступа для починки отрисовки на форме коллекций
|
||||
/// <summary>
|
||||
/// Высота окна
|
||||
/// </summary>
|
||||
public int _pictureHeight;// изменил уровень доступа для починки отрисовки на форме коллекций
|
||||
/// <summary>
|
||||
/// Левая координата прорисовки Крейсера
|
||||
/// </summary>
|
||||
protected static int _startPosX;
|
||||
/// <summary>
|
||||
/// Верхняя кооридната прорисовки Крейсера
|
||||
/// </summary>
|
||||
protected static int _startPosY;
|
||||
/// <summary>
|
||||
/// Ширина прорисовки Крейсера
|
||||
/// </summary>
|
||||
private readonly int _cruiserWidth = 150;
|
||||
/// <summary>
|
||||
/// Высота прорисовки Крейсера
|
||||
/// </summary>
|
||||
private readonly int _cruiserHeight = 60;
|
||||
/// <summary>
|
||||
/// Координата X объекта
|
||||
/// </summary>
|
||||
public int GetPosX => _startPosX;
|
||||
/// <summary>
|
||||
/// Координата Y объекта
|
||||
/// </summary>
|
||||
public int GetPosY => _startPosY;
|
||||
/// <summary>
|
||||
/// Ширина объекта
|
||||
/// </summary>
|
||||
public int GetWidth => _cruiserWidth;
|
||||
/// <summary>
|
||||
/// Высота объекта
|
||||
/// </summary>
|
||||
public int GetHeight => _cruiserHeight;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес автомобиля</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="secColor">Элементов цвет</param>
|
||||
/// <param name="width">Ширина картинки</param>
|
||||
/// <param name="height">Высота картинки</param>
|
||||
public DrawingCruiser(int speed, double weight, Color bodyColor, int width, int height)
|
||||
{
|
||||
if (width < _cruiserWidth || height < _cruiserHeight)
|
||||
{
|
||||
_pictureHeight = _cruiserHeight + 100;
|
||||
_pictureWidth = _cruiserWidth + 100;
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
EntityCruiser = new EntityCruiser(speed, weight, bodyColor);//переделал конструктор, т.к. secColor не использовался в конечном результате для отрисовки
|
||||
}
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес автомобиля</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="width">Ширина картинки</param>
|
||||
/// <param name="height">Высота картинки</param>
|
||||
/// <param name="cruiserWidth">Ширина прорисовки крейсера</param>
|
||||
/// <param name="cruiserHeight">Высота прорисовки крейсера</param>
|
||||
public DrawingCruiser(int speed, double weight, Color bodyColor, int width, int height, int cruiserWidth, int cruiserHeight)
|
||||
{
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
_cruiserHeight = cruiserHeight;
|
||||
_cruiserWidth = cruiserWidth;
|
||||
EntityCruiser = new EntityCruiser(speed, weight, bodyColor); //переделал конструктор, т.к. secColor не использовался в конечном результате для отрисовки
|
||||
}
|
||||
/// <summary>
|
||||
/// Установка позиции
|
||||
/// </summary>
|
||||
/// <param name="x">Координата X</param>
|
||||
/// <param name="y">Координата Y</param>
|
||||
|
||||
/// <summary>
|
||||
/// Получение объекта IMoveableObject из объекта DrawningCar
|
||||
/// </summary>
|
||||
public IMoveableObject GetMoveableObject => new
|
||||
DrawningObjectCar(this);
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (x < 0 || y < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (x > _pictureWidth || y > _pictureHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
/// <summary>
|
||||
/// Установка цвета
|
||||
/// </summary>
|
||||
public void setBodyColor(Color color)
|
||||
{
|
||||
EntityCruiser.BodyColor = color;
|
||||
}
|
||||
/// <summary>
|
||||
/// Проверка, что объект может переместится по указанному направлению
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
/// <returns>true - можно переместится по указанному направлению</returns>
|
||||
public bool CanMove(Direction direction)
|
||||
{
|
||||
if (EntityCruiser == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return direction switch
|
||||
{
|
||||
//влево
|
||||
Direction.Left => _startPosX - EntityCruiser.Step > 0,
|
||||
//вверх
|
||||
Direction.Up => _startPosY - EntityCruiser.Step > 0,
|
||||
// вправо
|
||||
Direction.Right => _startPosX + EntityCruiser.Step + _cruiserWidth < _pictureWidth,
|
||||
//вниз
|
||||
Direction.Down => _startPosY + EntityCruiser.Step + _cruiserHeight < _pictureHeight,
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменение направления перемещения
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
public void MoveTransport(Direction direction)
|
||||
{
|
||||
if (!CanMove(direction) || EntityCruiser == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
//влево
|
||||
case Direction.Left:
|
||||
_startPosX -= (int)EntityCruiser.Step;
|
||||
break;
|
||||
//вверх
|
||||
case Direction.Up:
|
||||
_startPosY -= (int)EntityCruiser.Step;
|
||||
break;
|
||||
// вправо
|
||||
case Direction.Right:
|
||||
_startPosX += (int)EntityCruiser.Step;
|
||||
break;
|
||||
//вниз
|
||||
case Direction.Down:
|
||||
_startPosY += (int)EntityCruiser.Step;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Прорисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityCruiser == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// палуба
|
||||
Point[] Paluba = new Point[5]
|
||||
{
|
||||
new Point(_startPosX + 10,_startPosY),
|
||||
new Point(_startPosX + 110,_startPosY),
|
||||
new Point(_startPosX + 160,_startPosY + 30),
|
||||
new Point(_startPosX + 110,_startPosY + 60),
|
||||
new Point(_startPosX + 10,_startPosY + 60)
|
||||
};
|
||||
Brush brush = new SolidBrush(EntityCruiser.BodyColor);
|
||||
g.FillPolygon(brush, Paluba);
|
||||
// элементы
|
||||
Brush colForElem = new SolidBrush(Color.Black); //поменял цвет для элементов(ОСНОВНЫХ) на чёрный, т.к. secColor не использовался
|
||||
Point[] Elements = new Point[8]
|
||||
{
|
||||
new Point(_startPosX + 50,_startPosY + 20),
|
||||
new Point(_startPosX + 70,_startPosY + 20),
|
||||
new Point(_startPosX + 70,_startPosY + 10),
|
||||
new Point(_startPosX + 90,_startPosY + 10),
|
||||
new Point(_startPosX + 90,_startPosY + 50),
|
||||
new Point(_startPosX + 70,_startPosY + 50),
|
||||
new Point(_startPosX + 70,_startPosY + 40),
|
||||
new Point(_startPosX + 50,_startPosY + 40),
|
||||
};
|
||||
// шар на корабле
|
||||
g.FillPolygon(colForElem, Elements);
|
||||
g.FillEllipse(colForElem, _startPosX + 100, _startPosY + 20, 20, 20);
|
||||
// турбины
|
||||
g.FillRectangle(colForElem, _startPosX, _startPosY + 10, 10, 20);
|
||||
g.FillRectangle(colForElem, _startPosX, _startPosY + 35, 10, 20);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Cruiser.Entities;
|
||||
|
||||
namespace Cruiser.Drawing
|
||||
{
|
||||
public class DrawingProCruiser : DrawingCruiser
|
||||
{
|
||||
/// <summary>
|
||||
/// установка цвета про лайнера
|
||||
/// </summary>
|
||||
public void setElementColor(Color color)
|
||||
{
|
||||
(EntityCruiser as EntityProCruiser).ElementsColor = color;
|
||||
}
|
||||
public DrawingProCruiser(int speed, double weight, Color bodyColor, Color elemColor, bool rocketMines, bool helipad, int width, int height) :
|
||||
base (speed, weight, bodyColor, width, height, 150, 60)
|
||||
{
|
||||
if (EntityCruiser != null)
|
||||
{
|
||||
EntityCruiser = new EntityProCruiser(speed, weight, bodyColor, elemColor, rocketMines, helipad);
|
||||
// по тем же причинам, что и для обычного, фиксим конструктор класса отрисовки для улучшенного
|
||||
}
|
||||
}
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityCruiser is not EntityProCruiser cruiser)
|
||||
{
|
||||
return;
|
||||
}
|
||||
base.DrawTransport(g);
|
||||
Brush DopBrush = new SolidBrush(cruiser.ElementsColor);
|
||||
// шахты
|
||||
if (cruiser.RocketMines)
|
||||
{
|
||||
g.FillRectangle(DopBrush, _startPosX + 15, _startPosY + 10, 10, 15);
|
||||
g.FillRectangle(DopBrush, _startPosX + 30, _startPosY + 10, 10, 15);
|
||||
}
|
||||
// верт площадка
|
||||
if (cruiser.Helipad)
|
||||
{
|
||||
g.FillEllipse(DopBrush, _startPosX + 15, _startPosY + 25, 25, 25);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Cruiser.Drawing;
|
||||
using Cruiser.Entities;
|
||||
namespace Cruiser.Drawing
|
||||
{
|
||||
/// <summary>
|
||||
/// Расширение для класса EntityCruiser
|
||||
/// </summary>
|
||||
public static class ExtentionDrawningCruiser
|
||||
{
|
||||
/// <summary>
|
||||
/// Создание объекта из строки
|
||||
/// </summary>
|
||||
/// <param name="info">Строка с данными для создания объекта</param>
|
||||
/// <param name="separatorForObject">Разделитель даннных</param>
|
||||
/// <param name="width">Ширина</param>
|
||||
/// <param name="height">Высота</param>
|
||||
/// <returns>Объект</returns>
|
||||
public static DrawingCruiser? CreateDrawingCruiser(this string info, char separatorForObject, int width, int height)
|
||||
{
|
||||
string[] strs = info.Split(separatorForObject);
|
||||
if (strs.Length == 3)
|
||||
{
|
||||
return new DrawingCruiser(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
|
||||
}
|
||||
if (strs.Length == 6)
|
||||
{
|
||||
return new DrawingProCruiser(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;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение данных для сохранения в файл
|
||||
/// </summary>
|
||||
/// <param name="drawingCruiser">Сохраняемый объект</param>
|
||||
/// <param name="separatorForObject">Разделитель даннных</param>
|
||||
/// <returns>Строка с данными по объекту</returns>
|
||||
public static string GetDataForSave(this DrawingCruiser drawingCruiser, char separatorForObject)
|
||||
{
|
||||
var cruiser = drawingCruiser.EntityCruiser;
|
||||
if (cruiser == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
var str = $"{cruiser.Speed}{separatorForObject}{cruiser.Weight}{separatorForObject}{cruiser.BodyColor.Name}";
|
||||
if (cruiser is not EntityProCruiser proCruiser)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
return $"{str}{separatorForObject}{proCruiser.ElementsColor.Name}{separatorForObject}{proCruiser.RocketMines}{separatorForObject}{proCruiser.Helipad}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,42 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cruiser.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность "Крейсер"
|
||||
/// </summary>
|
||||
public class EntityCruiser
|
||||
{
|
||||
/// <summary>
|
||||
/// Скорость
|
||||
/// </summary>
|
||||
public int Speed { get; private set; }
|
||||
/// <summary>
|
||||
/// Вес
|
||||
/// </summary>
|
||||
public double Weight { get; private set; }
|
||||
/// <summary>
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; set; }
|
||||
/// <summary>
|
||||
/// Шаг перемещения Крейсера
|
||||
/// </summary>
|
||||
// убрал secColor т.к. у обычного крейсера должен быть один цвет + не использовался для отрисовки
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес Крейсера</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="secColor">Второстепенный цвет</param>
|
||||
public EntityCruiser(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor; // переделал конструктор и убрал secondColor, т.к. у обычного крейсера должен быть один цвет + не использовался для отрисовки
|
||||
}
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cruiser.Entities
|
||||
{
|
||||
public class EntityProCruiser : EntityCruiser
|
||||
{
|
||||
/// <summary>
|
||||
/// Элементов цвет
|
||||
/// </summary>
|
||||
public Color ElementsColor { get; set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия ракетных шахт
|
||||
/// </summary>
|
||||
public bool RocketMines { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия вертолётной площадки
|
||||
/// </summary>
|
||||
public bool Helipad { get; private set; }
|
||||
/// <summary>
|
||||
/// Инициализация полей объекта-класса спортивного крейсера
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес Крейсера</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="elemColor">Элементов цвет</param>
|
||||
/// <param name="rocketMines">Признак наличия ракетных шахт</param>
|
||||
/// <param name="helipad">Признак наличия вертолётной площадки</param>
|
||||
public EntityProCruiser(int speed, double weight, Color bodyColor, Color elemColor, bool rocketMines, bool helipad) :
|
||||
base(speed, weight, bodyColor)
|
||||
{
|
||||
RocketMines = rocketMines;
|
||||
Helipad = helipad;
|
||||
ElementsColor = elemColor; // по тем же причинам, что и для обычного, фиксим конструктор класса для улучшенного
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cruiser.Exceptions
|
||||
{
|
||||
internal class CruiserNotFoundException : ApplicationException
|
||||
{
|
||||
public CruiserNotFoundException(int i) : base($"Не найден объект по позиции { i}") { }
|
||||
public CruiserNotFoundException() : base() { }
|
||||
public CruiserNotFoundException(string message) : base(message) { }
|
||||
public CruiserNotFoundException(string message, Exception exception) : base(message, exception) { }
|
||||
protected CruiserNotFoundException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
|
||||
}
|
||||
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cruiser.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 contex) : base(info, contex) { }
|
||||
}
|
||||
|
||||
}
|
39
Cruiser/Form1.Designer.cs
generated
Normal file
39
Cruiser/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
||||
namespace Cruiser
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form1";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
10
Cruiser/Form1.cs
Normal file
10
Cruiser/Form1.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace Cruiser
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
182
Cruiser/FormCruiser.Designer.cs
generated
182
Cruiser/FormCruiser.Designer.cs
generated
@ -1,182 +0,0 @@
|
||||
namespace Cruiser
|
||||
{
|
||||
partial class FormCruiser
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
pictureBoxCruiser = new PictureBox();
|
||||
buttonCreateLiner = new Button();
|
||||
buttonRight = new Button();
|
||||
buttonDown = new Button();
|
||||
buttonLeft = new Button();
|
||||
buttonUp = new Button();
|
||||
buttonCreateProLiner = new Button();
|
||||
comboBoxStrategy = new ComboBox();
|
||||
ButtonStep = new Button();
|
||||
buttonSelectCruiser = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCruiser).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBoxCruiser
|
||||
//
|
||||
pictureBoxCruiser.Dock = DockStyle.Fill;
|
||||
pictureBoxCruiser.Location = new Point(0, 0);
|
||||
pictureBoxCruiser.Name = "pictureBoxCruiser";
|
||||
pictureBoxCruiser.Size = new Size(800, 450);
|
||||
pictureBoxCruiser.TabIndex = 0;
|
||||
pictureBoxCruiser.TabStop = false;
|
||||
//
|
||||
// buttonCreateLiner
|
||||
//
|
||||
buttonCreateLiner.Location = new Point(12, 396);
|
||||
buttonCreateLiner.Name = "buttonCreateLiner";
|
||||
buttonCreateLiner.Size = new Size(125, 48);
|
||||
buttonCreateLiner.TabIndex = 1;
|
||||
buttonCreateLiner.Text = "Создать Лайнер";
|
||||
buttonCreateLiner.UseVisualStyleBackColor = true;
|
||||
buttonCreateLiner.Click += buttonCreateLiner_Click;
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
buttonRight.BackgroundImage = Properties.Resources.Right;
|
||||
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonRight.Location = new Point(758, 408);
|
||||
buttonRight.Name = "buttonRight";
|
||||
buttonRight.Size = new Size(30, 30);
|
||||
buttonRight.TabIndex = 2;
|
||||
buttonRight.UseVisualStyleBackColor = true;
|
||||
buttonRight.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
buttonDown.BackgroundImage = Properties.Resources.Down;
|
||||
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonDown.Location = new Point(722, 408);
|
||||
buttonDown.Name = "buttonDown";
|
||||
buttonDown.Size = new Size(30, 30);
|
||||
buttonDown.TabIndex = 3;
|
||||
buttonDown.UseVisualStyleBackColor = true;
|
||||
buttonDown.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
buttonLeft.BackgroundImage = Properties.Resources.Left;
|
||||
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonLeft.Location = new Point(686, 408);
|
||||
buttonLeft.Name = "buttonLeft";
|
||||
buttonLeft.Size = new Size(30, 30);
|
||||
buttonLeft.TabIndex = 4;
|
||||
buttonLeft.UseVisualStyleBackColor = true;
|
||||
buttonLeft.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
buttonUp.BackgroundImage = Properties.Resources.Up;
|
||||
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonUp.Location = new Point(722, 372);
|
||||
buttonUp.Name = "buttonUp";
|
||||
buttonUp.Size = new Size(30, 30);
|
||||
buttonUp.TabIndex = 5;
|
||||
buttonUp.UseVisualStyleBackColor = true;
|
||||
buttonUp.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonCreateProLiner
|
||||
//
|
||||
buttonCreateProLiner.Location = new Point(143, 396);
|
||||
buttonCreateProLiner.Name = "buttonCreateProLiner";
|
||||
buttonCreateProLiner.Size = new Size(125, 48);
|
||||
buttonCreateProLiner.TabIndex = 6;
|
||||
buttonCreateProLiner.Text = "Создать Лютый Лайнер";
|
||||
buttonCreateProLiner.UseVisualStyleBackColor = true;
|
||||
buttonCreateProLiner.Click += buttonCreateProLiner_Click;
|
||||
//
|
||||
// comboBoxStrategy
|
||||
//
|
||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxStrategy.FormattingEnabled = true;
|
||||
comboBoxStrategy.Items.AddRange(new object[] { "MoveToCenter", "MoveToBorder" });
|
||||
comboBoxStrategy.Location = new Point(667, 12);
|
||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
||||
comboBoxStrategy.Size = new Size(121, 23);
|
||||
comboBoxStrategy.TabIndex = 7;
|
||||
//
|
||||
// ButtonStep
|
||||
//
|
||||
ButtonStep.Location = new Point(713, 41);
|
||||
ButtonStep.Name = "ButtonStep";
|
||||
ButtonStep.Size = new Size(75, 23);
|
||||
ButtonStep.TabIndex = 8;
|
||||
ButtonStep.Text = "Шаг";
|
||||
ButtonStep.UseVisualStyleBackColor = true;
|
||||
ButtonStep.Click += ButtonStep_Click;
|
||||
//
|
||||
// buttonSelectCruiser
|
||||
//
|
||||
buttonSelectCruiser.Location = new Point(274, 396);
|
||||
buttonSelectCruiser.Name = "buttonSelectCruiser";
|
||||
buttonSelectCruiser.Size = new Size(127, 48);
|
||||
buttonSelectCruiser.TabIndex = 9;
|
||||
buttonSelectCruiser.Text = "Выбрать этот лайнер";
|
||||
buttonSelectCruiser.UseVisualStyleBackColor = true;
|
||||
buttonSelectCruiser.Click += ButtonSelectCruiser_Click;
|
||||
//
|
||||
// FormCruiser
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(buttonSelectCruiser);
|
||||
Controls.Add(ButtonStep);
|
||||
Controls.Add(comboBoxStrategy);
|
||||
Controls.Add(buttonCreateProLiner);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonCreateLiner);
|
||||
Controls.Add(pictureBoxCruiser);
|
||||
Name = "FormCruiser";
|
||||
Text = "Cruiser";
|
||||
Load += FormCruiser_Load;
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCruiser).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxCruiser;
|
||||
private Button buttonCreateLiner;
|
||||
private Button buttonRight;
|
||||
private Button buttonDown;
|
||||
private Button buttonLeft;
|
||||
private Button buttonUp;
|
||||
private Button buttonCreateProLiner;
|
||||
private ComboBox comboBoxStrategy;
|
||||
private Button ButtonStep;
|
||||
private Button buttonSelectCruiser;
|
||||
}
|
||||
}
|
@ -1,183 +0,0 @@
|
||||
using System;
|
||||
using Cruiser.Drawing;
|
||||
using Cruiser.Entities;
|
||||
using Cruiser.MovementStrategy;
|
||||
|
||||
namespace Cruiser
|
||||
{
|
||||
public partial class FormCruiser : Form
|
||||
{
|
||||
Bitmap bmp;
|
||||
/// <summary>
|
||||
/// Ïîëå-îáúåêò äëÿ ïðîðèñîâêè îáúåêòà
|
||||
/// </summary>
|
||||
private DrawingCruiser? _drawningCruiser;
|
||||
/// <summary>
|
||||
/// Ñòðàòåãèÿ ïåðåìåùåíèÿ
|
||||
/// </summary>
|
||||
private AbstractStrategy? _abstractStrategy;
|
||||
/// <summary>
|
||||
/// Âûáðàííûé ëàéíåð
|
||||
/// </summary>
|
||||
public DrawingCruiser? SelectedCruiser { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Èíèöèàëèçàöèÿ ôîðìû
|
||||
/// </summary>
|
||||
public FormCruiser()
|
||||
{
|
||||
InitializeComponent();
|
||||
bmp = new(pictureBoxCruiser.Width, pictureBoxCruiser.Width);
|
||||
_abstractStrategy = null;
|
||||
SelectedCruiser = null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Ìåòîä ïðîðèñîâêè êðåéñåðà
|
||||
/// </summary>
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningCruiser == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
gr.Clear(Color.White);
|
||||
_drawningCruiser.DrawTransport(gr);
|
||||
pictureBoxCruiser.Image = bmp;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Èçìåíåíèå ïîëîæåíèÿ àâòîìîáèëÿ
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningCruiser == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_drawningCruiser.MoveTransport(Direction.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_drawningCruiser.MoveTransport(Direction.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_drawningCruiser.MoveTransport(Direction.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_drawningCruiser.MoveTransport(Direction.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
/// <summary>
|
||||
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Øàã"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonStep_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningCruiser == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (comboBoxStrategy.Enabled)
|
||||
{
|
||||
_abstractStrategy = comboBoxStrategy.SelectedIndex
|
||||
switch
|
||||
{
|
||||
0 => new MoveToCenter(),
|
||||
1 => new MoveToBorder(),
|
||||
_ => null,
|
||||
};
|
||||
if (_abstractStrategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_abstractStrategy.SetData(new
|
||||
DrawningObjectCar(_drawningCruiser), pictureBoxCruiser.Width,
|
||||
pictureBoxCruiser.Height);
|
||||
comboBoxStrategy.Enabled = false;
|
||||
}
|
||||
if (_abstractStrategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_abstractStrategy.MakeStep();
|
||||
Draw();
|
||||
if (_abstractStrategy.GetStatus() == Status.Finish)
|
||||
{
|
||||
comboBoxStrategy.Enabled = true;
|
||||
_abstractStrategy = null;
|
||||
}
|
||||
}
|
||||
private void buttonCreateLiner_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
Color colorFirst = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
colorFirst = dialog.Color;
|
||||
}
|
||||
|
||||
_drawningCruiser = new DrawingCruiser(random.Next(100, 300),
|
||||
random.Next(1000, 3000),
|
||||
colorFirst, // âñ¸ åù¸ ôèêñ êîíñòðóêòîðîâ
|
||||
pictureBoxCruiser.Width,
|
||||
pictureBoxCruiser.Height);
|
||||
_drawningCruiser.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void buttonCreateProLiner_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
Color colorFirst = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
colorFirst = dialog.Color;
|
||||
}
|
||||
Color colorSecond = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
colorSecond = dialog.Color;
|
||||
}
|
||||
_drawningCruiser = new DrawingProCruiser(random.Next(100, 300),
|
||||
random.Next(1000, 3000),
|
||||
colorFirst,
|
||||
colorSecond, // âñ¸ åù¸ ôèêñ êîíñòðóêòîðîâ
|
||||
Convert.ToBoolean(random.Next(1, 2)),
|
||||
Convert.ToBoolean(random.Next(1, 2)),
|
||||
pictureBoxCruiser.Width,
|
||||
pictureBoxCruiser.Height);
|
||||
_drawningCruiser.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
/// <summary>
|
||||
/// Âûáîð ëàéíåð
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonSelectCruiser_Click(object sender, EventArgs e)
|
||||
{
|
||||
SelectedCruiser = _drawningCruiser;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
private void FormCruiser_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
245
Cruiser/FormCruiserCollection.Designer.cs
generated
245
Cruiser/FormCruiserCollection.Designer.cs
generated
@ -1,245 +0,0 @@
|
||||
namespace Cruiser
|
||||
{
|
||||
partial class FormCruiserCollection
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
groupBoxTools = new GroupBox();
|
||||
buttonDeleteCruiser = new Button();
|
||||
textBoxNumber = new TextBox();
|
||||
buttonAddCruiser = new Button();
|
||||
buttonRefreshCollection = new Button();
|
||||
pictureBoxCollection = new PictureBox();
|
||||
groupBoxStorage = new GroupBox();
|
||||
listBoxStorages = new ListBox();
|
||||
buttonDelObject = new Button();
|
||||
textBoxStorageName = new TextBox();
|
||||
buttonAddObject = new Button();
|
||||
menuStripCruiser = new MenuStrip();
|
||||
FileToolStripMenuItem = new ToolStripMenuItem();
|
||||
SaveToolStripMenuItem = new ToolStripMenuItem();
|
||||
UploadToolStripMenuItem = new ToolStripMenuItem();
|
||||
openFileDialog = new OpenFileDialog();
|
||||
saveFileDialog = new SaveFileDialog();
|
||||
groupBoxTools.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
||||
groupBoxStorage.SuspendLayout();
|
||||
menuStripCruiser.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxTools
|
||||
//
|
||||
groupBoxTools.Controls.Add(buttonDeleteCruiser);
|
||||
groupBoxTools.Controls.Add(textBoxNumber);
|
||||
groupBoxTools.Controls.Add(buttonAddCruiser);
|
||||
groupBoxTools.Location = new Point(653, 1);
|
||||
groupBoxTools.Name = "groupBoxTools";
|
||||
groupBoxTools.Size = new Size(148, 140);
|
||||
groupBoxTools.TabIndex = 0;
|
||||
groupBoxTools.TabStop = false;
|
||||
groupBoxTools.Text = "Инструменты";
|
||||
//
|
||||
// buttonDeleteCruiser
|
||||
//
|
||||
buttonDeleteCruiser.Location = new Point(15, 95);
|
||||
buttonDeleteCruiser.Name = "buttonDeleteCruiser";
|
||||
buttonDeleteCruiser.Size = new Size(122, 37);
|
||||
buttonDeleteCruiser.TabIndex = 2;
|
||||
buttonDeleteCruiser.Text = "Удалить лайнер";
|
||||
buttonDeleteCruiser.UseVisualStyleBackColor = true;
|
||||
buttonDeleteCruiser.Click += ButtonRemoveCar_Click;
|
||||
//
|
||||
// textBoxNumber
|
||||
//
|
||||
textBoxNumber.Location = new Point(15, 66);
|
||||
textBoxNumber.Name = "textBoxNumber";
|
||||
textBoxNumber.Size = new Size(122, 23);
|
||||
textBoxNumber.TabIndex = 1;
|
||||
//
|
||||
// buttonAddCruiser
|
||||
//
|
||||
buttonAddCruiser.Location = new Point(15, 26);
|
||||
buttonAddCruiser.Name = "buttonAddCruiser";
|
||||
buttonAddCruiser.Size = new Size(122, 38);
|
||||
buttonAddCruiser.TabIndex = 0;
|
||||
buttonAddCruiser.Text = "Добавить лайнер";
|
||||
buttonAddCruiser.UseVisualStyleBackColor = true;
|
||||
buttonAddCruiser.Click += ButtonAddCruiser_Click;
|
||||
//
|
||||
// buttonRefreshCollection
|
||||
//
|
||||
buttonRefreshCollection.Location = new Point(662, 397);
|
||||
buttonRefreshCollection.Name = "buttonRefreshCollection";
|
||||
buttonRefreshCollection.Size = new Size(131, 41);
|
||||
buttonRefreshCollection.TabIndex = 3;
|
||||
buttonRefreshCollection.Text = "Обновить коллекцию";
|
||||
buttonRefreshCollection.UseVisualStyleBackColor = true;
|
||||
buttonRefreshCollection.Click += ButtonRefreshCollection_Click;
|
||||
//
|
||||
// pictureBoxCollection
|
||||
//
|
||||
pictureBoxCollection.Location = new Point(14, 27);
|
||||
pictureBoxCollection.Name = "pictureBoxCollection";
|
||||
pictureBoxCollection.Size = new Size(642, 422);
|
||||
pictureBoxCollection.TabIndex = 1;
|
||||
pictureBoxCollection.TabStop = false;
|
||||
//
|
||||
// groupBoxStorage
|
||||
//
|
||||
groupBoxStorage.Controls.Add(listBoxStorages);
|
||||
groupBoxStorage.Controls.Add(buttonDelObject);
|
||||
groupBoxStorage.Controls.Add(textBoxStorageName);
|
||||
groupBoxStorage.Controls.Add(buttonAddObject);
|
||||
groupBoxStorage.Location = new Point(662, 139);
|
||||
groupBoxStorage.Name = "groupBoxStorage";
|
||||
groupBoxStorage.Size = new Size(136, 252);
|
||||
groupBoxStorage.TabIndex = 2;
|
||||
groupBoxStorage.TabStop = false;
|
||||
groupBoxStorage.Text = "Наборы";
|
||||
//
|
||||
// listBoxStorages
|
||||
//
|
||||
listBoxStorages.FormattingEnabled = true;
|
||||
listBoxStorages.ItemHeight = 15;
|
||||
listBoxStorages.Location = new Point(10, 117);
|
||||
listBoxStorages.Name = "listBoxStorages";
|
||||
listBoxStorages.Size = new Size(120, 124);
|
||||
listBoxStorages.TabIndex = 7;
|
||||
listBoxStorages.SelectedIndexChanged += ListBoxObjects_SelectedIndexChanged;
|
||||
//
|
||||
// buttonDelObject
|
||||
//
|
||||
buttonDelObject.Location = new Point(8, 86);
|
||||
buttonDelObject.Name = "buttonDelObject";
|
||||
buttonDelObject.Size = new Size(122, 25);
|
||||
buttonDelObject.TabIndex = 2;
|
||||
buttonDelObject.Text = "Удалить набор";
|
||||
buttonDelObject.UseVisualStyleBackColor = true;
|
||||
buttonDelObject.Click += ButtonDelObject_Click;
|
||||
//
|
||||
// textBoxStorageName
|
||||
//
|
||||
textBoxStorageName.Location = new Point(8, 22);
|
||||
textBoxStorageName.Name = "textBoxStorageName";
|
||||
textBoxStorageName.Size = new Size(122, 23);
|
||||
textBoxStorageName.TabIndex = 1;
|
||||
//
|
||||
// buttonAddObject
|
||||
//
|
||||
buttonAddObject.Location = new Point(8, 52);
|
||||
buttonAddObject.Name = "buttonAddObject";
|
||||
buttonAddObject.Size = new Size(122, 28);
|
||||
buttonAddObject.TabIndex = 0;
|
||||
buttonAddObject.Text = "Добавить набор";
|
||||
buttonAddObject.UseVisualStyleBackColor = true;
|
||||
buttonAddObject.Click += ButtonAddObject_Click;
|
||||
//
|
||||
// menuStripCruiser
|
||||
//
|
||||
menuStripCruiser.Items.AddRange(new ToolStripItem[] { FileToolStripMenuItem });
|
||||
menuStripCruiser.Location = new Point(0, 0);
|
||||
menuStripCruiser.Name = "menuStripCruiser";
|
||||
menuStripCruiser.Size = new Size(800, 24);
|
||||
menuStripCruiser.TabIndex = 4;
|
||||
menuStripCruiser.Text = "menuStrip1";
|
||||
//
|
||||
// FileToolStripMenuItem
|
||||
//
|
||||
FileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SaveToolStripMenuItem, UploadToolStripMenuItem });
|
||||
FileToolStripMenuItem.Name = "FileToolStripMenuItem";
|
||||
FileToolStripMenuItem.Size = new Size(48, 20);
|
||||
FileToolStripMenuItem.Text = "Файл";
|
||||
//
|
||||
// SaveToolStripMenuItem
|
||||
//
|
||||
SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||
SaveToolStripMenuItem.Size = new Size(133, 22);
|
||||
SaveToolStripMenuItem.Text = "Сохранить";
|
||||
SaveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
||||
//
|
||||
// UploadToolStripMenuItem
|
||||
//
|
||||
UploadToolStripMenuItem.Name = "UploadToolStripMenuItem";
|
||||
UploadToolStripMenuItem.Size = new Size(133, 22);
|
||||
UploadToolStripMenuItem.Text = "Загрузить";
|
||||
UploadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
openFileDialog.FileName = "openFileDialog";
|
||||
openFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
saveFileDialog.FileName = "saveFileDialog";
|
||||
saveFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// FormCruiserCollection
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(menuStripCruiser);
|
||||
Controls.Add(buttonRefreshCollection);
|
||||
Controls.Add(groupBoxStorage);
|
||||
Controls.Add(pictureBoxCollection);
|
||||
Controls.Add(groupBoxTools);
|
||||
MainMenuStrip = menuStripCruiser;
|
||||
Name = "FormCruiserCollection";
|
||||
Text = "Набор Крейсеров";
|
||||
groupBoxTools.ResumeLayout(false);
|
||||
groupBoxTools.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
||||
groupBoxStorage.ResumeLayout(false);
|
||||
groupBoxStorage.PerformLayout();
|
||||
menuStripCruiser.ResumeLayout(false);
|
||||
menuStripCruiser.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxTools;
|
||||
private TextBox textBoxNumber;
|
||||
private Button buttonAddCruiser;
|
||||
private Button buttonRefreshCollection;
|
||||
private Button buttonDeleteCruiser;
|
||||
private PictureBox pictureBoxCollection;
|
||||
private GroupBox groupBoxStorage;
|
||||
private Button buttonDelObject;
|
||||
private TextBox textBoxStorageName;
|
||||
private Button buttonAddObject;
|
||||
private ListBox listBoxStorages;
|
||||
private MenuStrip menuStripCruiser;
|
||||
private ToolStripMenuItem FileToolStripMenuItem;
|
||||
private ToolStripMenuItem SaveToolStripMenuItem;
|
||||
private ToolStripMenuItem UploadToolStripMenuItem;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
}
|
||||
}
|
@ -1,271 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Cruiser.Drawing;
|
||||
using Cruiser.Generics;
|
||||
using Cruiser.MovementStrategy;
|
||||
using Cruiser.Exceptions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Cruiser
|
||||
{
|
||||
/// <summary>
|
||||
/// Форма для работы с набором объектов класса DrawingCruiser
|
||||
/// </summary>
|
||||
public partial class FormCruiserCollection : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Набор объектов
|
||||
/// </summary>
|
||||
private readonly CruisersGenericStorage _storage;
|
||||
/// <summary>
|
||||
/// Логер
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormCruiserCollection(ILogger<FormCruiserCollection> logger)
|
||||
{
|
||||
InitializeComponent();
|
||||
_storage = new CruisersGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
_logger = logger;
|
||||
}
|
||||
/// <summary>
|
||||
/// Заполнение listBoxObjects
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление набора в коллекцию
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
||||
{
|
||||
_logger.LogWarning($"Обновление набора не удалось (не все данные заполнены)");
|
||||
MessageBox.Show("Придумайте имя набору", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_storage.AddSet(textBoxStorageName.Text);
|
||||
ReloadObjects();
|
||||
_logger.LogInformation($"Добавлен набор:{textBoxStorageName.Text}");
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление набора
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonDelObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
_logger.LogWarning($"Удаление набора не удалось (индекс вне границ)");
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show($"Удалить объект{listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
string name = listBoxStorages.SelectedItem.ToString() ?? string.Empty; //добавил для удаления повторяющегося кода
|
||||
_storage.DelSet(name);
|
||||
ReloadObjects();
|
||||
_logger.LogInformation($"Удален набор: {name}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Выбор набора
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ListBoxObjects_SelectedIndexChanged(object sender,
|
||||
EventArgs e)
|
||||
{
|
||||
pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowCruiser();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void AddCruiser(DrawingCruiser cruiser)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
_logger.LogWarning($"Добавление круизера не удалось (индекс вне границ)");
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
_logger.LogWarning($"Добавление круизера не удалось (нет хранилища)");
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
if ((obj + cruiser))
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
_logger.LogInformation($"Добавление круизера успешно {listBoxStorages.SelectedItem.ToString()}");
|
||||
pictureBoxCollection.Image = obj.ShowCruiser();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
catch (ApplicationException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRemoveCar_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
_logger.LogWarning($"Удаление круизера не удалось (индекс вне границ)");
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
_logger.LogWarning($"Удаление круизера не удалось (нет хранилища)");
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
_logger.LogWarning($"Удаление круизера не удалось (выбран вариант 'Нет')");
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(textBoxNumber.Text);
|
||||
try
|
||||
{
|
||||
if (obj - pos != null)
|
||||
{
|
||||
_logger.LogInformation($"Удаление круизера успешно {listBoxStorages.SelectedItem.ToString()} {pos}");
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxCollection.Image = obj.ShowCruiser();
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogWarning($"Удаление круизера не удалось(обьект не найден)");
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
catch (CruiserNotFoundException ex)
|
||||
{
|
||||
_logger.LogWarning($"Удаление круизера не удалось {ex.Message}");
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Обновление рисунка по набору
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
_logger.LogWarning($"Обновление объектов не удалось (индекс вне границ)");
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
||||
string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
_logger.LogWarning($"Обновление объектов не удалось (нет хранилища)");
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation($"Обновление объектов успешно");
|
||||
pictureBoxCollection.Image = obj.ShowCruiser();
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddCruiser_Click(object sender, EventArgs e)
|
||||
{
|
||||
var formCruiserConfig = new FormCruiserConfig();
|
||||
formCruiserConfig.Show();
|
||||
formCruiserConfig.AddEvent(AddCruiser);
|
||||
}
|
||||
/// <summary>
|
||||
/// Обработка нажатия "Сохранение"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_storage.SaveData(saveFileDialog.FileName);
|
||||
_logger.LogInformation($"Cохранение в файл успешно");
|
||||
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
} catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning($"Сохранение не удалось {ex.Message}");
|
||||
MessageBox.Show("Не сохранилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Обработка нажатия "Загрузка"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_storage.LoadData(openFileDialog.FileName);
|
||||
_logger.LogInformation($"Загрузка из файла успешна");
|
||||
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
ReloadObjects();
|
||||
} catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Не загрузилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_logger.LogWarning($"Загрузка не удалась {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,129 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStripCruiser.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>163, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>296, 17</value>
|
||||
</metadata>
|
||||
</root>
|
379
Cruiser/FormCruiserConfig.Designer.cs
generated
379
Cruiser/FormCruiserConfig.Designer.cs
generated
@ -1,379 +0,0 @@
|
||||
namespace Cruiser
|
||||
{
|
||||
partial class FormCruiserConfig
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
groupBoxForTools = new GroupBox();
|
||||
buttonCancel = new Button();
|
||||
buttonAddCruiser = new Button();
|
||||
labelDopColor = new Label();
|
||||
labelColor = new Label();
|
||||
panelToCruiser = new Panel();
|
||||
pictureBoxToCruiser = new PictureBox();
|
||||
labelProCruiser = new Label();
|
||||
labelCruiser = new Label();
|
||||
groupBoxColors = new GroupBox();
|
||||
panelColorGold = new Panel();
|
||||
panelColorCrimson = new Panel();
|
||||
panelColorPlum = new Panel();
|
||||
panelColorDodgerBlue = new Panel();
|
||||
panelColorAquamarine = new Panel();
|
||||
panelColorForestGreen = new Panel();
|
||||
panelColorSienna = new Panel();
|
||||
panelColorRed = new Panel();
|
||||
checkBoxHelipad = new CheckBox();
|
||||
checkBoxRockMines = new CheckBox();
|
||||
numericUpDownWeight = new NumericUpDown();
|
||||
numericUpDownSpeed = new NumericUpDown();
|
||||
labelWeight = new Label();
|
||||
labelSpeed = new Label();
|
||||
groupBoxForTools.SuspendLayout();
|
||||
panelToCruiser.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxToCruiser).BeginInit();
|
||||
groupBoxColors.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxForTools
|
||||
//
|
||||
groupBoxForTools.Controls.Add(buttonCancel);
|
||||
groupBoxForTools.Controls.Add(buttonAddCruiser);
|
||||
groupBoxForTools.Controls.Add(labelDopColor);
|
||||
groupBoxForTools.Controls.Add(labelColor);
|
||||
groupBoxForTools.Controls.Add(panelToCruiser);
|
||||
groupBoxForTools.Controls.Add(labelProCruiser);
|
||||
groupBoxForTools.Controls.Add(labelCruiser);
|
||||
groupBoxForTools.Controls.Add(groupBoxColors);
|
||||
groupBoxForTools.Controls.Add(checkBoxHelipad);
|
||||
groupBoxForTools.Controls.Add(checkBoxRockMines);
|
||||
groupBoxForTools.Controls.Add(numericUpDownWeight);
|
||||
groupBoxForTools.Controls.Add(numericUpDownSpeed);
|
||||
groupBoxForTools.Controls.Add(labelWeight);
|
||||
groupBoxForTools.Controls.Add(labelSpeed);
|
||||
groupBoxForTools.Location = new Point(15, 8);
|
||||
groupBoxForTools.Name = "groupBoxForTools";
|
||||
groupBoxForTools.Size = new Size(641, 250);
|
||||
groupBoxForTools.TabIndex = 0;
|
||||
groupBoxForTools.TabStop = false;
|
||||
groupBoxForTools.Text = "Tools";
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(403, 208);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(206, 26);
|
||||
buttonCancel.TabIndex = 14;
|
||||
buttonCancel.Text = "Cancel";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonAddCruiser
|
||||
//
|
||||
buttonAddCruiser.Location = new Point(403, 176);
|
||||
buttonAddCruiser.Name = "buttonAddCruiser";
|
||||
buttonAddCruiser.Size = new Size(206, 26);
|
||||
buttonAddCruiser.TabIndex = 13;
|
||||
buttonAddCruiser.Text = "AddCruiser";
|
||||
buttonAddCruiser.UseVisualStyleBackColor = true;
|
||||
buttonAddCruiser.Click += buttonAdd_Click;
|
||||
//
|
||||
// labelDopColor
|
||||
//
|
||||
labelDopColor.AllowDrop = true;
|
||||
labelDopColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelDopColor.Location = new Point(509, 19);
|
||||
labelDopColor.Name = "labelDopColor";
|
||||
labelDopColor.Size = new Size(100, 30);
|
||||
labelDopColor.TabIndex = 12;
|
||||
labelDopColor.Text = "DopColor";
|
||||
labelDopColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelDopColor.DragDrop += labelColor_DragDrop;
|
||||
labelDopColor.DragEnter += labelColor_DragEnter;
|
||||
labelDopColor.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// labelColor
|
||||
//
|
||||
labelColor.AllowDrop = true;
|
||||
labelColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelColor.Location = new Point(403, 19);
|
||||
labelColor.Name = "labelColor";
|
||||
labelColor.Size = new Size(100, 30);
|
||||
labelColor.TabIndex = 11;
|
||||
labelColor.Text = "Color";
|
||||
labelColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelColor.DragDrop += labelColor_DragDrop;
|
||||
labelColor.DragEnter += labelColor_DragEnter;
|
||||
labelColor.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// panelToCruiser
|
||||
//
|
||||
panelToCruiser.AllowDrop = true;
|
||||
panelToCruiser.Controls.Add(pictureBoxToCruiser);
|
||||
panelToCruiser.Location = new Point(403, 52);
|
||||
panelToCruiser.Name = "panelToCruiser";
|
||||
panelToCruiser.Size = new Size(206, 118);
|
||||
panelToCruiser.TabIndex = 10;
|
||||
panelToCruiser.DragDrop += PanelObject_DragDrop;
|
||||
panelToCruiser.DragEnter += PanelObject_DragEnter;
|
||||
panelToCruiser.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// pictureBoxToCruiser
|
||||
//
|
||||
pictureBoxToCruiser.Location = new Point(3, 3);
|
||||
pictureBoxToCruiser.Name = "pictureBoxToCruiser";
|
||||
pictureBoxToCruiser.Size = new Size(200, 112);
|
||||
pictureBoxToCruiser.TabIndex = 9;
|
||||
pictureBoxToCruiser.TabStop = false;
|
||||
//
|
||||
// labelProCruiser
|
||||
//
|
||||
labelProCruiser.AllowDrop = true;
|
||||
labelProCruiser.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelProCruiser.Location = new Point(270, 155);
|
||||
labelProCruiser.Name = "labelProCruiser";
|
||||
labelProCruiser.Size = new Size(100, 30);
|
||||
labelProCruiser.TabIndex = 8;
|
||||
labelProCruiser.Text = "ProCruiser";
|
||||
labelProCruiser.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelProCruiser.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// labelCruiser
|
||||
//
|
||||
labelCruiser.AllowDrop = true;
|
||||
labelCruiser.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelCruiser.Location = new Point(155, 155);
|
||||
labelCruiser.Name = "labelCruiser";
|
||||
labelCruiser.Size = new Size(100, 30);
|
||||
labelCruiser.TabIndex = 7;
|
||||
labelCruiser.Text = "Cruiser";
|
||||
labelCruiser.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelCruiser.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// groupBoxColors
|
||||
//
|
||||
groupBoxColors.Controls.Add(panelColorGold);
|
||||
groupBoxColors.Controls.Add(panelColorCrimson);
|
||||
groupBoxColors.Controls.Add(panelColorPlum);
|
||||
groupBoxColors.Controls.Add(panelColorDodgerBlue);
|
||||
groupBoxColors.Controls.Add(panelColorAquamarine);
|
||||
groupBoxColors.Controls.Add(panelColorForestGreen);
|
||||
groupBoxColors.Controls.Add(panelColorSienna);
|
||||
groupBoxColors.Controls.Add(panelColorRed);
|
||||
groupBoxColors.Location = new Point(152, 19);
|
||||
groupBoxColors.Name = "groupBoxColors";
|
||||
groupBoxColors.Size = new Size(224, 126);
|
||||
groupBoxColors.TabIndex = 6;
|
||||
groupBoxColors.TabStop = false;
|
||||
groupBoxColors.Text = "Colors";
|
||||
//
|
||||
// panelColorGold
|
||||
//
|
||||
panelColorGold.AllowDrop = true;
|
||||
panelColorGold.BackColor = Color.Gold;
|
||||
panelColorGold.Location = new Point(173, 76);
|
||||
panelColorGold.Name = "panelColorGold";
|
||||
panelColorGold.Size = new Size(37, 35);
|
||||
panelColorGold.TabIndex = 6;
|
||||
panelColorGold.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelColorCrimson
|
||||
//
|
||||
panelColorCrimson.AllowDrop = true;
|
||||
panelColorCrimson.BackColor = Color.Crimson;
|
||||
panelColorCrimson.Location = new Point(118, 76);
|
||||
panelColorCrimson.Name = "panelColorCrimson";
|
||||
panelColorCrimson.Size = new Size(37, 35);
|
||||
panelColorCrimson.TabIndex = 4;
|
||||
panelColorCrimson.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelColorPlum
|
||||
//
|
||||
panelColorPlum.AllowDrop = true;
|
||||
panelColorPlum.BackColor = Color.Plum;
|
||||
panelColorPlum.Location = new Point(66, 76);
|
||||
panelColorPlum.Name = "panelColorPlum";
|
||||
panelColorPlum.Size = new Size(37, 35);
|
||||
panelColorPlum.TabIndex = 5;
|
||||
panelColorPlum.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelColorDodgerBlue
|
||||
//
|
||||
panelColorDodgerBlue.AllowDrop = true;
|
||||
panelColorDodgerBlue.BackColor = Color.DodgerBlue;
|
||||
panelColorDodgerBlue.Location = new Point(12, 76);
|
||||
panelColorDodgerBlue.Name = "panelColorDodgerBlue";
|
||||
panelColorDodgerBlue.Size = new Size(37, 35);
|
||||
panelColorDodgerBlue.TabIndex = 3;
|
||||
panelColorDodgerBlue.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelColorAquamarine
|
||||
//
|
||||
panelColorAquamarine.AllowDrop = true;
|
||||
panelColorAquamarine.BackColor = Color.Aquamarine;
|
||||
panelColorAquamarine.Location = new Point(173, 23);
|
||||
panelColorAquamarine.Name = "panelColorAquamarine";
|
||||
panelColorAquamarine.Size = new Size(37, 35);
|
||||
panelColorAquamarine.TabIndex = 2;
|
||||
panelColorAquamarine.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelColorForestGreen
|
||||
//
|
||||
panelColorForestGreen.AllowDrop = true;
|
||||
panelColorForestGreen.BackColor = Color.ForestGreen;
|
||||
panelColorForestGreen.Location = new Point(118, 23);
|
||||
panelColorForestGreen.Name = "panelColorForestGreen";
|
||||
panelColorForestGreen.Size = new Size(37, 35);
|
||||
panelColorForestGreen.TabIndex = 1;
|
||||
panelColorForestGreen.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelColorSienna
|
||||
//
|
||||
panelColorSienna.AllowDrop = true;
|
||||
panelColorSienna.BackColor = Color.Sienna;
|
||||
panelColorSienna.Location = new Point(66, 23);
|
||||
panelColorSienna.Name = "panelColorSienna";
|
||||
panelColorSienna.Size = new Size(37, 35);
|
||||
panelColorSienna.TabIndex = 1;
|
||||
panelColorSienna.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelColorRed
|
||||
//
|
||||
panelColorRed.AllowDrop = true;
|
||||
panelColorRed.BackColor = Color.Red;
|
||||
panelColorRed.Location = new Point(12, 23);
|
||||
panelColorRed.Name = "panelColorRed";
|
||||
panelColorRed.Size = new Size(37, 35);
|
||||
panelColorRed.TabIndex = 0;
|
||||
panelColorRed.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// checkBoxHelipad
|
||||
//
|
||||
checkBoxHelipad.AutoSize = true;
|
||||
checkBoxHelipad.Location = new Point(6, 161);
|
||||
checkBoxHelipad.Name = "checkBoxHelipad";
|
||||
checkBoxHelipad.Size = new Size(67, 19);
|
||||
checkBoxHelipad.TabIndex = 5;
|
||||
checkBoxHelipad.Text = "Helipad";
|
||||
checkBoxHelipad.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxRockMines
|
||||
//
|
||||
checkBoxRockMines.AutoSize = true;
|
||||
checkBoxRockMines.Location = new Point(6, 136);
|
||||
checkBoxRockMines.Name = "checkBoxRockMines";
|
||||
checkBoxRockMines.Size = new Size(94, 19);
|
||||
checkBoxRockMines.TabIndex = 4;
|
||||
checkBoxRockMines.Text = "RocketMines";
|
||||
checkBoxRockMines.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
numericUpDownWeight.Location = new Point(6, 95);
|
||||
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(120, 23);
|
||||
numericUpDownWeight.TabIndex = 3;
|
||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
numericUpDownSpeed.Location = new Point(6, 37);
|
||||
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(120, 23);
|
||||
numericUpDownSpeed.TabIndex = 2;
|
||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// labelWeight
|
||||
//
|
||||
labelWeight.AutoSize = true;
|
||||
labelWeight.Location = new Point(6, 77);
|
||||
labelWeight.Name = "labelWeight";
|
||||
labelWeight.Size = new Size(45, 15);
|
||||
labelWeight.TabIndex = 1;
|
||||
labelWeight.Text = "Weight";
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
labelSpeed.AutoSize = true;
|
||||
labelSpeed.Location = new Point(6, 19);
|
||||
labelSpeed.Name = "labelSpeed";
|
||||
labelSpeed.Size = new Size(39, 15);
|
||||
labelSpeed.TabIndex = 0;
|
||||
labelSpeed.Text = "Speed";
|
||||
//
|
||||
// FormCruiserConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(684, 261);
|
||||
Controls.Add(groupBoxForTools);
|
||||
Name = "FormCruiserConfig";
|
||||
Text = "FormCruiserConfig";
|
||||
groupBoxForTools.ResumeLayout(false);
|
||||
groupBoxForTools.PerformLayout();
|
||||
panelToCruiser.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxToCruiser).EndInit();
|
||||
groupBoxColors.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxForTools;
|
||||
private Label labelWeight;
|
||||
private Label labelSpeed;
|
||||
private CheckBox checkBox3;
|
||||
private CheckBox checkBox2;
|
||||
private CheckBox checkBoxRockMines;
|
||||
private CheckBox checkBoxHelipad;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private GroupBox groupBoxColors;
|
||||
private Panel panelColorGold;
|
||||
private Panel panelColorCrimson;
|
||||
private Panel panelColorPlum;
|
||||
private Panel panelColorDodgerBlue;
|
||||
private Panel panelColorAquamarine;
|
||||
private Panel panelColorForestGreen;
|
||||
private Panel panelColorSienna;
|
||||
private Panel panelColorRed;
|
||||
private PictureBox pictureBoxToCruiser;
|
||||
private Label labelProCruiser;
|
||||
private Label labelCruiser;
|
||||
private Panel panelToCruiser;
|
||||
private Button buttonCancel;
|
||||
private Button buttonAddCruiser;
|
||||
private Label labelDopColor;
|
||||
private Label labelColor;
|
||||
}
|
||||
}
|
@ -1,160 +0,0 @@
|
||||
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 Cruiser.Drawing;
|
||||
|
||||
namespace Cruiser
|
||||
{
|
||||
public partial class FormCruiserConfig : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Переменная-выбранная лайнера
|
||||
/// </summary>
|
||||
DrawingCruiser? _cruiser = null;
|
||||
/// <summary>
|
||||
/// Событие
|
||||
/// </summary>
|
||||
private event Action<DrawingCruiser>? EventAddCruiser;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormCruiserConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelColorRed.MouseDown += panelColor_MouseDown;
|
||||
panelColorSienna.MouseDown += panelColor_MouseDown;
|
||||
panelColorForestGreen.MouseDown += panelColor_MouseDown;
|
||||
panelColorAquamarine.MouseDown += panelColor_MouseDown;
|
||||
panelColorCrimson.MouseDown += panelColor_MouseDown;
|
||||
panelColorDodgerBlue.MouseDown += panelColor_MouseDown;
|
||||
panelColorGold.MouseDown += panelColor_MouseDown;
|
||||
panelColorPlum.MouseDown += panelColor_MouseDown;
|
||||
buttonCancel.Click += (s, e) => Close();
|
||||
}
|
||||
/// <summary>
|
||||
/// Отрисовать лайнер
|
||||
/// </summary>
|
||||
private void DrawCruiser()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxToCruiser.Width, pictureBoxToCruiser.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_cruiser?.SetPosition(15, 15);
|
||||
_cruiser?.DrawTransport(gr);
|
||||
pictureBoxToCruiser.Image = bmp;
|
||||
}
|
||||
/// Добавление события
|
||||
/// </summary>
|
||||
/// <param name="ev">Привязанный метод</param>
|
||||
public void AddEvent(Action<DrawingCruiser> ev)
|
||||
{
|
||||
if (EventAddCruiser == null)
|
||||
{
|
||||
EventAddCruiser = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddCruiser += ev;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление лайнера
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddCruiser?.Invoke(_cruiser);
|
||||
Close();
|
||||
}
|
||||
/// <summary>
|
||||
/// Передаем информацию при нажатии на Label
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
/// <summary>
|
||||
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Действия при приеме перетаскиваемой информации
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "labelCruiser": //переделал из за изменения конструкторов (см. комментарии там)
|
||||
_cruiser = new DrawingCruiser((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value,
|
||||
Color.Orchid,
|
||||
pictureBoxToCruiser.Width,
|
||||
pictureBoxToCruiser.Height);
|
||||
break;
|
||||
case "labelProCruiser": //переделал из за изменения конструкторов (см. комментарии там)
|
||||
_cruiser = new DrawingProCruiser((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value,
|
||||
Color.Orchid, Color.Aquamarine,
|
||||
checkBoxRockMines.Checked, checkBoxHelipad.Checked,
|
||||
pictureBoxToCruiser.Width,
|
||||
pictureBoxToCruiser.Height);
|
||||
break;
|
||||
}
|
||||
DrawCruiser();
|
||||
}
|
||||
private void panelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
private void labelColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void labelColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_cruiser == null)
|
||||
return;
|
||||
switch (((Label)sender).Name)
|
||||
{
|
||||
case "labelColor":
|
||||
_cruiser.setBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||
break;
|
||||
case "labelDopColor":
|
||||
if (!(_cruiser is DrawingProCruiser))
|
||||
return;
|
||||
(_cruiser as DrawingProCruiser).setElementColor((Color)e.Data.GetData(typeof(Color)));
|
||||
break;
|
||||
}
|
||||
DrawCruiser();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
@ -1,145 +0,0 @@
|
||||
using Cruiser.MovementStrategy;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Cruiser.Drawing;
|
||||
|
||||
namespace Cruiser.Generics
|
||||
{
|
||||
/// <summary>
|
||||
/// Параметризованный класс для набора объектов DrawingCruiser
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="U"></typeparam>
|
||||
internal class CarsGenericCollection<T, U>
|
||||
where T : DrawingCruiser
|
||||
where U : IMoveableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Получение объектов коллекции
|
||||
/// </summary>
|
||||
public IEnumerable<T?> GetCruisers => _collection.GetCruisers();
|
||||
/// <summary>
|
||||
/// Ширина окна прорисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureWidth;
|
||||
/// <summary>
|
||||
/// Высота окна прорисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureHeight;
|
||||
/// <summary>
|
||||
/// Размер занимаемого объектом места (ширина)
|
||||
/// </summary>
|
||||
private readonly int _placeSizeWidth = 160;
|
||||
/// <summary>
|
||||
/// Размер занимаемого объектом места (высота)
|
||||
/// </summary>
|
||||
private readonly int _placeSizeHeight = 60;
|
||||
/// <summary>
|
||||
/// Набор объектов
|
||||
/// </summary>
|
||||
private readonly SetGeneric<T> _collection;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="picWidth"></param>
|
||||
/// <param name="picHeight"></param>
|
||||
public CarsGenericCollection(int picWidth, int picHeight)
|
||||
{
|
||||
int width = picWidth / _placeSizeWidth;
|
||||
int height = picHeight / _placeSizeHeight;
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
_collection = new SetGeneric<T>(width * height);
|
||||
}
|
||||
/// <summary>
|
||||
/// Перегрузка оператора сложения
|
||||
/// </summary>
|
||||
/// <param name="collect"></param>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static bool operator +(CarsGenericCollection<T, U> collect, T? obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return collect._collection.Insert(obj);
|
||||
}
|
||||
/// <summary>
|
||||
/// Перегрузка оператора вычитания
|
||||
/// </summary>
|
||||
/// <param name="collect"></param>
|
||||
/// <param name="pos"></param>
|
||||
/// <returns></returns>
|
||||
public static T? operator -(CarsGenericCollection<T, U> collect, int pos)
|
||||
{
|
||||
T? obj = collect._collection[pos];
|
||||
if (obj != null)
|
||||
{
|
||||
collect._collection.Remove(pos);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение объекта IMoveableObject
|
||||
/// </summary>
|
||||
/// <param name="pos"></param>
|
||||
/// <returns></returns>
|
||||
public U? GetU(int pos)
|
||||
{
|
||||
return (U?)_collection[pos]?.GetMoveableObject;
|
||||
}
|
||||
/// <summary>
|
||||
/// Вывод всего набора объектов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Bitmap ShowCruiser()
|
||||
{
|
||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
DrawObjects(gr);
|
||||
DrawBackground(gr);
|
||||
return bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод отрисовки фона
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
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; j++)
|
||||
{
|
||||
g.DrawRectangle(pen, i * _placeSizeWidth, j * _placeSizeHeight, _placeSizeWidth, _placeSizeHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// /// Метод прорисовки объектов
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
private void DrawObjects(Graphics g)
|
||||
{
|
||||
int Ix = 0;
|
||||
int Iy = 0;
|
||||
foreach (var cruiser in _collection.GetCruisers())
|
||||
{
|
||||
cruiser?.SetPosition(Ix, Iy); // починил, для починки удаления
|
||||
cruiser?.DrawTransport(g);
|
||||
Ix += _placeSizeWidth;
|
||||
if (Ix + _placeSizeHeight > _pictureWidth)
|
||||
{
|
||||
Ix = 0;
|
||||
Iy += _placeSizeHeight; // починил, т.к. отрисовывалось максимум 8 кораблей
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,178 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Cruiser.Drawing;
|
||||
using Cruiser.MovementStrategy;
|
||||
using System.IO;
|
||||
|
||||
namespace Cruiser.Generics
|
||||
{
|
||||
internal class CruisersGenericStorage
|
||||
{
|
||||
/// <summary>
|
||||
/// Разделитель для записи ключа и значения элемента словаря
|
||||
/// </summary>
|
||||
private static readonly char _separatorForKeyValue = '|';
|
||||
/// <summary>
|
||||
/// Разделитель для записей коллекции данных в файл
|
||||
/// </summary>
|
||||
private readonly char _separatorRecords = ';';
|
||||
/// <summary>
|
||||
/// Разделитель для записи информации по объекту в файл
|
||||
/// </summary>
|
||||
private static readonly char _separatorForObject = ':';
|
||||
|
||||
/// <summary>
|
||||
/// Словарь (хранилище)
|
||||
/// </summary>
|
||||
readonly Dictionary<string, CarsGenericCollection<DrawingCruiser, DrawningObjectCar>> _cruiserStorages;
|
||||
/// <summary>
|
||||
/// Возвращение списка названий наборов
|
||||
/// </summary>
|
||||
public List<string> Keys => _cruiserStorages.Keys.ToList();
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureWidth;
|
||||
/// <summary>
|
||||
/// Высота окна отрисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureHeight;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="pictureWidth"></param>
|
||||
/// <param name="pictureHeight"></param>
|
||||
public CruisersGenericStorage(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_cruiserStorages = new Dictionary<string, CarsGenericCollection<DrawingCruiser, DrawningObjectCar>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление набора
|
||||
/// </summary>
|
||||
/// <param name="name">Название набора</param>
|
||||
public void AddSet(string name)
|
||||
{
|
||||
if (_cruiserStorages.ContainsKey(name)) return;
|
||||
_cruiserStorages[name] = new CarsGenericCollection<DrawingCruiser, DrawningObjectCar>(_pictureWidth, _pictureHeight);
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление набора
|
||||
/// </summary>
|
||||
/// <param name="name">Название набора</param>
|
||||
public void DelSet(string name)
|
||||
{
|
||||
if (!_cruiserStorages.ContainsKey(name)) return;
|
||||
_cruiserStorages.Remove(name);
|
||||
}
|
||||
/// <summary>
|
||||
/// Доступ к набору
|
||||
/// </summary>
|
||||
/// <param name="ind"></param>
|
||||
/// <returns></returns>
|
||||
public CarsGenericCollection<DrawingCruiser, DrawningObjectCar>?
|
||||
this[string ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_cruiserStorages.ContainsKey(ind)) return _cruiserStorages[ind];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Сохранение информации по автомобилям в хранилище в файл
|
||||
/// </summary>
|
||||
/// <param name="filename">Путь и имя файла</param>
|
||||
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
|
||||
public bool SaveData(string filename)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
File.Delete(filename);
|
||||
}
|
||||
StringBuilder data = new();
|
||||
foreach (KeyValuePair<string, CarsGenericCollection<DrawingCruiser, DrawningObjectCar>> record in _cruiserStorages)
|
||||
{
|
||||
StringBuilder records = new();
|
||||
foreach (DrawingCruiser? elem in record.Value.GetCruisers)
|
||||
{
|
||||
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
||||
}
|
||||
data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}");
|
||||
}
|
||||
if (data.Length == 0)
|
||||
{
|
||||
throw new Exception("Невалиданя операция, нет данных для сохранения");
|
||||
}
|
||||
string dataStr = data.ToString();
|
||||
using (StreamWriter writer = new StreamWriter(filename))
|
||||
{
|
||||
writer.WriteLine("CruiserStorage");
|
||||
writer.WriteLine(dataStr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Загрузка информации по крейсеру в хранилище из файла
|
||||
/// </summary>
|
||||
/// <param name="filename">Путь и имя файла</param>
|
||||
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
||||
public bool LoadData(string filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
throw new FileNotFoundException("Файл не найден");
|
||||
}
|
||||
using (StreamReader reader = new StreamReader(filename))
|
||||
{
|
||||
string checker = reader.ReadLine();
|
||||
if (checker == null)
|
||||
{
|
||||
throw new NullReferenceException("Нет данных для загрузки");
|
||||
}
|
||||
if (!checker.StartsWith("CruiserStorage"))
|
||||
{
|
||||
throw new FormatException("Неверный формат данных");
|
||||
}
|
||||
_cruiserStorages.Clear();
|
||||
string strs;
|
||||
bool firstinit = true;
|
||||
while ((strs = reader.ReadLine()) != null)
|
||||
{
|
||||
if (strs == null && firstinit)
|
||||
return false;
|
||||
if (strs == null)
|
||||
break;
|
||||
if (strs == string.Empty)
|
||||
break;
|
||||
firstinit = false;
|
||||
string name = strs.Split('|')[0];
|
||||
CarsGenericCollection<DrawingCruiser, DrawningObjectCar> collection = new(_pictureWidth, _pictureHeight);
|
||||
foreach (string data in strs.Split('|')[1].Split(';').Reverse())
|
||||
{
|
||||
DrawingCruiser? cruiser = data?.CreateDrawingCruiser(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||
if (cruiser != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool? tmp = collection + cruiser;
|
||||
}
|
||||
catch (ApplicationException ex)
|
||||
{
|
||||
throw new ApplicationException($"Ошибка добавления в коллекцию: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
_cruiserStorages.Add(name, collection);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
using Cruiser.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Eventing.Reader;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cruiser.Generics
|
||||
{
|
||||
/// <summary>
|
||||
/// Параметризованный набор объектов
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
internal class SetGeneric<T>
|
||||
where T : class
|
||||
{
|
||||
/// <summary>
|
||||
/// Список объектов, которые храним
|
||||
/// </summary>
|
||||
private readonly List<T?> _places;
|
||||
/// <summary>
|
||||
/// Количество объектов в списке
|
||||
/// </summary>
|
||||
public int Count => _places.Count;
|
||||
/// <summary>
|
||||
/// Максимальное количество объектов в списке
|
||||
/// </summary>
|
||||
private readonly int _maxCount;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
public SetGeneric(int count)
|
||||
{
|
||||
_maxCount = count;
|
||||
_places = new List<T?>(count);
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор
|
||||
/// </summary>
|
||||
/// <param name="cruiser">Добавляемый лайнер</param>
|
||||
/// <returns></returns>
|
||||
public bool Insert(T cruiser) //починил код, работал неправильно
|
||||
{
|
||||
if (_places.Count >= _maxCount)
|
||||
{
|
||||
throw new StorageOverflowException(_places.Count);
|
||||
}
|
||||
_places.Insert(0, cruiser);
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора с конкретной позиции
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public bool Remove(int position)
|
||||
{
|
||||
if (position < 0 || position > _places.Count)
|
||||
{
|
||||
throw new CruiserNotFoundException(position);
|
||||
}
|
||||
_places[position] = null;
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор на конкретную позицию
|
||||
/// </summary>
|
||||
/// <param name="cruiser">Добавляемый автомобиль</param>
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns></returns>
|
||||
public bool Insert(T cruiser, int position) //починил код, работал неправильно
|
||||
{
|
||||
if (_places.Count >= _maxCount)
|
||||
{
|
||||
throw new StorageOverflowException(_places.Count);
|
||||
}
|
||||
if (position < 0 || position > _places.Count)
|
||||
{
|
||||
throw new CruiserNotFoundException(position);
|
||||
}
|
||||
_places.Insert(position, cruiser);
|
||||
return true;
|
||||
}
|
||||
public T? this[int position]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (position < 0 || position > _maxCount)
|
||||
{ return null; }
|
||||
return _places[position];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (position < 0 || position > _maxCount)
|
||||
return;
|
||||
_places[position] = value;
|
||||
}
|
||||
}
|
||||
public IEnumerable<T?> GetCruisers(int? maxCruisers = null)
|
||||
{
|
||||
for (int i = 0; i < _places.Count; ++i)
|
||||
{
|
||||
yield return _places[i];
|
||||
if (maxCruisers.HasValue && i == maxCruisers.Value)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,138 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Cruiser.Drawing;
|
||||
|
||||
namespace Cruiser.MovementStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-стратегия перемещения объекта
|
||||
/// </summary>
|
||||
public abstract class AbstractStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Перемещаемый объект
|
||||
/// </summary>
|
||||
private IMoveableObject? _moveableObject;
|
||||
/// <summary>
|
||||
/// Статус перемещения
|
||||
/// </summary>
|
||||
private Status _state = Status.NotInit;
|
||||
/// <summary>
|
||||
/// Ширина поля
|
||||
/// </summary>
|
||||
protected int FieldWidth { get; private set; }
|
||||
/// <summary>
|
||||
/// Высота поля
|
||||
/// </summary>
|
||||
protected int FieldHeight { get; private set; }
|
||||
/// <summary>
|
||||
/// Статус перемещения
|
||||
/// </summary>
|
||||
public Status GetStatus() { return _state; }
|
||||
/// <summary>
|
||||
/// Установка данных
|
||||
/// </summary>
|
||||
/// <param name="moveableObject">Перемещаемый объект</param>
|
||||
/// <param name="width">Ширина поля</param>
|
||||
/// <param name="height">Высота поля</param>
|
||||
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;
|
||||
}
|
||||
/// <summary>
|
||||
/// Шаг перемещения
|
||||
/// </summary>
|
||||
public void MakeStep()
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (IsTargetDestinaion())
|
||||
{
|
||||
_state = Status.Finish;
|
||||
return;
|
||||
}
|
||||
MoveToTarget();
|
||||
}
|
||||
/// <summary>
|
||||
/// Перемещение влево
|
||||
/// </summary>
|
||||
/// <returns>Результат перемещения (true - удалось переместиться, false -
|
||||
/// неудача)</returns>
|
||||
protected bool MoveLeft() => MoveTo(Direction.Left);
|
||||
/// <summary>
|
||||
/// Перемещение вправо
|
||||
/// </summary>
|
||||
/// <returns>Результат перемещения (true - удалось переместиться,
|
||||
///false - неудача)</returns>
|
||||
protected bool MoveRight() => MoveTo(Direction.Right);
|
||||
/// <summary>
|
||||
/// Перемещение вверх
|
||||
/// </summary>
|
||||
/// <returns>Результат перемещения (true - удалось переместиться,
|
||||
///false - неудача)</returns>
|
||||
protected bool MoveUp() => MoveTo(Direction.Up);
|
||||
/// <summary>
|
||||
/// Перемещение вниз
|
||||
/// </summary>
|
||||
/// <returns>Результат перемещения (true - удалось переместиться,
|
||||
///false - неудача)</returns>
|
||||
protected bool MoveDown() => MoveTo(Direction.Down);
|
||||
/// <summary>
|
||||
/// Параметры объекта
|
||||
/// </summary>
|
||||
protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition;
|
||||
/// <summary>
|
||||
/// Шаг объекта
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected int? GetStep()
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _moveableObject?.GetStep;
|
||||
}
|
||||
/// <summary>
|
||||
/// Перемещение к цели
|
||||
/// </summary>
|
||||
protected abstract void MoveToTarget();
|
||||
/// <summary>
|
||||
/// Достигнута ли цель
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected abstract bool IsTargetDestinaion();
|
||||
/// <summary>
|
||||
/// Попытка перемещения в требуемом направлении
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
/// <returns>Результат попытки (true - удалось переместиться, false -
|
||||
/// неудача)</returns>
|
||||
private bool MoveTo(Direction direction)
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_moveableObject?.CheckCanMove(direction) ?? false)
|
||||
{
|
||||
_moveableObject.MoveObject(direction);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Cruiser.Drawing;
|
||||
|
||||
namespace Cruiser.MovementStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Реализация интерфейса IDrawningObject для работы с объектом DrawningCar (паттерн Adapter)
|
||||
/// </summary>
|
||||
public class DrawningObjectCar : IMoveableObject
|
||||
{
|
||||
private readonly DrawingCruiser? _drawningCruiser = null;
|
||||
public DrawningObjectCar(DrawingCruiser drawningCar)
|
||||
{
|
||||
_drawningCruiser = drawningCar;
|
||||
}
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_drawningCruiser == null || _drawningCruiser.EntityCruiser ==
|
||||
null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ObjectParameters(_drawningCruiser.GetPosX,
|
||||
_drawningCruiser.GetPosY, _drawningCruiser.GetWidth, _drawningCruiser.GetHeight);
|
||||
}
|
||||
}
|
||||
public int GetStep => (int)(_drawningCruiser?.EntityCruiser?.Step ?? 0);
|
||||
public bool CheckCanMove(Direction direction) =>
|
||||
_drawningCruiser?.CanMove(direction) ?? false;
|
||||
public void MoveObject(Direction direction) =>
|
||||
_drawningCruiser?.MoveTransport(direction);
|
||||
}
|
||||
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Cruiser.Drawing;
|
||||
namespace Cruiser.MovementStrategy
|
||||
{
|
||||
public interface IMoveableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Получение координаты X объекта
|
||||
/// </summary>
|
||||
ObjectParameters? GetObjectPosition { get; }
|
||||
/// <summary>
|
||||
/// Шаг объекта
|
||||
/// </summary>
|
||||
int GetStep { get; }
|
||||
/// <summary>
|
||||
/// Проверка, можно ли переместиться по нужному направлению
|
||||
/// </summary>
|
||||
/// <param name="direction"></param>
|
||||
/// <returns></returns>
|
||||
bool CheckCanMove(Direction direction);
|
||||
/// <summary>
|
||||
/// Изменение направления пермещения объекта
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
void MoveObject(Direction direction);
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cruiser.MovementStrategy
|
||||
{
|
||||
public class MoveToBorder : AbstractStrategy
|
||||
{
|
||||
protected override bool IsTargetDestinaion()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return objParams.RightBorder <= FieldWidth &&
|
||||
objParams.RightBorder + GetStep() >= FieldWidth &&
|
||||
objParams.DownBorder <= FieldHeight &&
|
||||
objParams.DownBorder + GetStep() >= FieldHeight;
|
||||
}
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var diffX = objParams.RightBorder - FieldWidth;
|
||||
if (Math.Abs(diffX) > GetStep())
|
||||
{
|
||||
if (diffX > 0)
|
||||
{
|
||||
MoveLeft();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveRight();
|
||||
}
|
||||
}
|
||||
var diffY = objParams.DownBorder - FieldHeight;
|
||||
if (Math.Abs(diffY) > GetStep())
|
||||
{
|
||||
if (diffY > 0)
|
||||
{
|
||||
MoveUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cruiser.MovementStrategy
|
||||
{
|
||||
public class MoveToCenter : AbstractStrategy
|
||||
{
|
||||
protected override bool IsTargetDestinaion()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return objParams.ObjectMiddleHorizontal <= FieldWidth / 2 &&
|
||||
objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 &&
|
||||
objParams.ObjectMiddleVertical <= FieldHeight / 2 &&
|
||||
objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
|
||||
}
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
|
||||
if (Math.Abs(diffX) > GetStep())
|
||||
{
|
||||
if (diffX > 0)
|
||||
{
|
||||
MoveLeft();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveRight();
|
||||
}
|
||||
}
|
||||
var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
|
||||
if (Math.Abs(diffY) > GetStep())
|
||||
{
|
||||
if (diffY > 0)
|
||||
{
|
||||
MoveUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cruiser.MovementStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Параметры-координаты объекта
|
||||
/// </summary>
|
||||
public class ObjectParameters
|
||||
{
|
||||
private readonly int _x;
|
||||
private readonly int _y;
|
||||
private readonly int _width;
|
||||
private readonly int _height;
|
||||
/// <summary>
|
||||
/// Левая граница
|
||||
/// </summary>
|
||||
public int LeftBorder => _x;
|
||||
/// <summary>
|
||||
/// Верхняя граница
|
||||
/// </summary>
|
||||
public int TopBorder => _y;
|
||||
/// <summary>
|
||||
/// Правая граница
|
||||
/// </summary>
|
||||
public int RightBorder => _x + _width;
|
||||
/// <summary>
|
||||
/// Нижняя граница
|
||||
/// </summary>
|
||||
public int DownBorder => _y + _height;
|
||||
/// <summary>
|
||||
/// Середина объекта
|
||||
/// </summary>
|
||||
public int ObjectMiddleHorizontal => _x + _width / 2;
|
||||
/// <summary>
|
||||
/// Середина объекта
|
||||
/// </summary>
|
||||
public int ObjectMiddleVertical => _y + _height / 2;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="x">Координата X</param>
|
||||
/// <param name="y">Координата Y</param>
|
||||
/// <param name="width">Ширина</param>
|
||||
/// <param name="height">Высота</param>
|
||||
public ObjectParameters(int x, int y, int width, int height)
|
||||
{
|
||||
_x = x;
|
||||
_y = y;
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cruiser.MovementStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Статус выполнения операции перемещения
|
||||
/// </summary>
|
||||
public enum Status
|
||||
{
|
||||
NotInit,
|
||||
InProgress,
|
||||
Finish
|
||||
}
|
||||
}
|
@ -1,8 +1,3 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
|
||||
namespace Cruiser
|
||||
{
|
||||
internal static class Program
|
||||
@ -15,29 +10,8 @@ namespace Cruiser
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
using (ServiceProvider serviceProvider = services.BuildServiceProvider())
|
||||
{
|
||||
Application.Run(serviceProvider.GetRequiredService<FormCruiserCollection>());
|
||||
}
|
||||
static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<FormCruiserCollection>().AddLogging(option =>
|
||||
{
|
||||
string[] path = Directory.GetCurrentDirectory().Split('\\');
|
||||
string pathNeed = "";
|
||||
for (int i = 0; i < path.Length - 3; i++)
|
||||
{
|
||||
pathNeed += path[i] + "\\";
|
||||
}
|
||||
var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile(path: $"{pathNeed}appsettings.json", optional: false, reloadOnChange: true).Build();
|
||||
var logger = new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger();
|
||||
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddSerilog(logger);
|
||||
});
|
||||
}
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
103
Cruiser/Properties/Resources.Designer.cs
generated
103
Cruiser/Properties/Resources.Designer.cs
generated
@ -1,103 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Cruiser.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("Cruiser.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Down {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Down", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Left {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Left", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Right {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Right", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Up {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Up", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,133 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="Left" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\resources\Left.jpg;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.jpg;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.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Right" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\resources\Right.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
@ -1,20 +0,0 @@
|
||||
{
|
||||
"Serilog": {
|
||||
"Using": [ "Serilog.Sinks.File" ],
|
||||
"MinimumLevel": "Information",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "Logs/log_.log",
|
||||
"rollingInterval": "Day",
|
||||
"outputTemplate": "[{Timestamp:HH:mm:ss.fff}]{Level:u4}: {Message:lj}{NewLine}{Exception}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
|
||||
"Properties": {
|
||||
"Application": "Cruiser"
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 2.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.5 KiB |
@ -1,31 +0,0 @@
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void pictureBoxCruiser_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#region buttonsClick
|
||||
private void buttonLeft_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void buttonDown_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void buttonUp_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void buttonRight_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
#endregion;
|
Loading…
Reference in New Issue
Block a user