PIbd-14 Pruidze_I.K. LabWork02 Simple #2

Closed
Delphy wants to merge 3 commits from Lab2 into master
17 changed files with 1012 additions and 1 deletions

View File

@ -0,0 +1,9 @@
namespace ProjectCruiser.DrawningSamples;
public enum DirectionType
{
Unknown = -1,
Up = 1,
Down = 2,
Left = 3,
Right = 4
}

View File

@ -0,0 +1,173 @@
using ProjectCruiser.Entities;
namespace ProjectCruiser.DrawningSamples;
public class DrawningBase
{
// Класс-сущность
public EntityBase? EntityTransport { get; protected set; }
private int? _pictureWidth; // Ширина окна
private int? _pictureHeight; // Высота окна
protected int? _startPosX; // < protected
protected int? _startPosY; // < protected
private readonly int _drawningWidth = 302; // Ширина прорисовки автомобиля
private readonly int _drawningHeight = 42; // Высота прорисовки автомобиля
// Инициализация свойств (теперь через конструктор)
public DrawningBase(int speed, double weight, Color bodyColor) : this()
{
EntityTransport = new EntityBase(speed, weight, bodyColor);
}
private DrawningBase()
{
_pictureWidth = null;
_pictureHeight = null;
_startPosX = null;
_startPosY = null;
}
// protected >
protected DrawningBase(int drawningCarWidth, int drawningCarHeight) : this()
{
_drawningWidth = drawningCarWidth;
_pictureHeight = drawningCarHeight;
}
public int getHeight() // для создания объекта в нижнем левом углу (*)
{
return _drawningHeight;
}
// Установка границ поля
public bool SetPictureSize(int w, int h)
{
if (w < _drawningWidth || h < _drawningHeight)
// canvas always bigger then obj to fit it
{
return false;
}
_pictureWidth = w;
_pictureHeight = h;
if (_startPosX != null || _startPosY != null)
{
SetPosition(_startPosX.Value, _startPosY.Value);
}
return true;
}
public void SetPosition(int x, int y)
{
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
{
return;
}
if (x > _pictureWidth - _drawningWidth) _startPosX =
_pictureWidth - _drawningWidth;
else if (x < 0) _startPosX = 0;
else _startPosX = x;
if (y > _pictureHeight - _drawningHeight) _startPosY =
_pictureHeight.Value - _drawningHeight;
else if (y < 0) _startPosY = 0;
else _startPosY = y;
}
public bool MoveTransport(DirectionType direction)
{
if (EntityTransport == null || !_startPosX.HasValue || !_startPosY.HasValue)
{
return false;
}
switch (direction)
{
//влево
case DirectionType.Left:
if (_startPosX.Value - EntityTransport.Step > 0)
{
_startPosX -= (int)EntityTransport.Step;
}
return true;
//вверх
case DirectionType.Up:
if (_startPosY.Value - EntityTransport.Step > 0)
{
_startPosY -= (int)EntityTransport.Step;
}
return true;
// вправо
case DirectionType.Right:
if (_startPosX.Value + _drawningWidth + EntityTransport.Step
< _pictureWidth.Value)
{
_startPosX += (int)EntityTransport.Step;
}
return true;
//вниз
case DirectionType.Down:
if (_startPosY.Value + _drawningHeight + EntityTransport.Step
< _pictureHeight.Value)
{
_startPosY += (int)EntityTransport.Step;
}
return true;
default:
return false;
// Перемещение объекта (удалось перемещение - true \ false)
}
}
public virtual void DrawTransport(Graphics g) // < virtual
{
if (EntityTransport == null || !_startPosX.HasValue ||
!_startPosY.HasValue)
{
return;
}
Pen pen = new(Color.Black, 2);
Brush mainBrush = new SolidBrush(EntityTransport.MainColor);
//границы cruiser
Point point0 = new Point(_startPosX.Value + 2, _startPosY.Value + 7);
Point point1 = new Point(_startPosX.Value + 2, _startPosY.Value + 30);
Point point2 = new Point(_startPosX.Value + 184, _startPosY.Value + 42);
Point point3 = new Point(_startPosX.Value + 260, _startPosY.Value + 34);
Point point4 = new Point(_startPosX.Value + 300, _startPosY.Value + 22);
Point point5 = new Point(_startPosX.Value + 260, _startPosY.Value + 10);
Point point6 = new Point(_startPosX.Value + 184, _startPosY.Value + 2);
Point[] boarders = {
point0,
point1,
point2,
point3,
point4,
point5,
point6
};
g.DrawPolygon(pen, boarders);
g.FillPolygon(mainBrush, boarders);
// салон на верхней палубе
int y_h = EntityTransport.values[1];
g.DrawRectangle(pen, _startPosX.Value + 100, _startPosY.Value + y_h, 38, 24);
g.DrawRectangle(pen, _startPosX.Value + 110, _startPosY.Value + y_h + 6, 20, 12);
g.FillRectangle(mainBrush, _startPosX.Value + 110, _startPosY.Value + y_h + 6, 20, 12);
g.DrawRectangle(pen, _startPosX.Value + 117, _startPosY.Value + y_h + 18, 6, 20);
g.FillRectangle(mainBrush, _startPosX.Value + 117, _startPosY.Value + y_h + 18, 6, 20);
}
public int? GetPosX => _startPosX;
public int? GetPosY => _startPosY;
public int GetWidth => _drawningWidth;
public int GetHeight => _drawningHeight;
}

View File

@ -0,0 +1,54 @@
using System.Drawing.Drawing2D;
using ProjectCruiser.Entities;
namespace ProjectCruiser.DrawningSamples;
public class DrawningCruiser : DrawningBase
{
// Инициализация свойств (все параметры класса (сущности))
public DrawningCruiser(int speed, double weight, Color bodyColor,
Color additionalColor, bool pads, bool hangar) : base(302, 42)
// all additional featchures 'inside' object, so size remains
{
EntityTransport = new EntityCruiser(speed, weight,
bodyColor, additionalColor, pads, hangar);
}
public override void DrawTransport(Graphics g)
{
if (EntityTransport == null || EntityTransport is not EntityCruiser ship ||
!_startPosX.HasValue || !_startPosY.HasValue) // [ !!! ] :O
{
return;
}
Pen pen = new(Color.Black, 2);
Brush PadBrush = new HatchBrush(HatchStyle.DottedDiamond, Color.LightGray, Color.Black);
Brush additionalBrush = new SolidBrush(ship.AdditionalColor);
//границы cruiser <...>
// &
// салон на верхней палубе :
base.DrawTransport(g);
// вертолетная площадка
if (ship.HelicopterPads)
{
g.DrawEllipse(pen, _startPosX.Value + 170, _startPosY.Value + 11, 20, 20);
g.FillEllipse(PadBrush, _startPosX.Value + 170, _startPosY.Value + 11, 20, 20);
}
// ангар
if (ship.Hangar)
{
int n = EntityTransport.values[2];
if (n == 1) g.FillRectangle(additionalBrush, _startPosX.Value + 250, _startPosY.Value + 20, 14, 7);
else
{
g.FillRectangle(additionalBrush, _startPosX.Value + 80, _startPosY.Value + 10, 10, 20);
g.FillRectangle(additionalBrush, _startPosX.Value + 70, _startPosY.Value + 12, 8, 12);
}
}
}
}

View File

@ -0,0 +1,27 @@
namespace ProjectCruiser.Entities;
public class EntityBase
{
// свойства
public int Speed { get; private set; } // скорость
public double Weight { get; private set; } // вес
public Color MainColor { get; private set; } // основной цвет
// public bool Deckhouse { get; private set; } // салон на верхней палубе
public double Step => Speed * 100 / Weight;
public int[] values = { 0, 0, 0 };
public EntityBase(int speed, double weight, Color mainc)
// (bool) deckhouse -> default TRUE now
{
Random rn = new();
Speed = speed;
Weight = weight;
MainColor = mainc;
// Deckhouse = deckhouse;
values[0] = rn.Next(1, 4);
values[1] = rn.Next(5, 10);
values[2] = rn.Next(1, 3);
}
}

View File

@ -0,0 +1,19 @@
namespace ProjectCruiser.Entities;
public class EntityCruiser : EntityBase
{
public Color AdditionalColor { get; private set; } // доп. цвет
// признаки (наличия)
public bool HelicopterPads { get; private set; } // вертолетная площадка
public bool Hangar { get; private set; } // ангар
public EntityCruiser(int speed, double weight, Color mainc,
Color additionalColor, bool pads, bool hangar)
: base(speed, weight, mainc)
{
AdditionalColor = additionalColor;
HelicopterPads = pads;
Hangar = hangar;
}
}

View File

@ -0,0 +1,88 @@
namespace ProjectCruiser.MoveStrategy;
public abstract class AbstractStrategy
{
// Перемещаемый объект
private IMoveableObj? _moveableObject;
// Статус перемещения (default установка)
private StrategyStatus _state = StrategyStatus.NotInit;
// Ширина поля
protected int FieldWidth { get; private set; }
// Высота поля
protected int FieldHeight { get; private set; }
// Получение статуса
public StrategyStatus GetStatus() { return _state; }
// Установка данных
public void SetData(IMoveableObj moveableObject, int width, int height)
{
if (moveableObject == null)
{
_state = StrategyStatus.NotInit;
return;
}
_state = StrategyStatus.InProgress;
_moveableObject = moveableObject;
FieldWidth = width;
FieldHeight = height;
}
// Шаг перемещения
public void MakeStep()
{
if (_state != StrategyStatus.InProgress)
{
return;
}
if (IsTargetDestination())
{
_state = StrategyStatus.Finish;
return;
}
MoveToTarget();
}
// Результаты перемещения
protected bool MoveLeft() => MoveTo(MovementDirection.Left);
protected bool MoveRight() => MoveTo(MovementDirection.Right);
protected bool MoveUp() => MoveTo(MovementDirection.Up);
protected bool MoveDown() => MoveTo(MovementDirection.Down);
// Параметры объекта
protected ObjParameters? GetObjectParameters =>
_moveableObject?.GetObjectPosition;
// Шаг объекта
protected int? GetStep()
{
if (_state != StrategyStatus.InProgress)
{
return null;
}
return _moveableObject?.GetStep;
}
// Перемещение к цели
protected abstract void MoveToTarget();
// Проверка, достигнута ли цель
protected abstract bool IsTargetDestination();
/// Попытка перемещения в требуемом направлении
/// <param name="movementDirection">Направление</param>
/// <returns>Результат попытки (true - удалось переместиться, false - неудача)</returns>
private bool MoveTo(MovementDirection movementDirection)
{
if (_state != StrategyStatus.InProgress)
{
return false;
}
return _moveableObject?.TryMoveObject(movementDirection) ?? false;
}
}

View File

@ -0,0 +1,16 @@
namespace ProjectCruiser.MoveStrategy;
// Интерфейс для работы с перемещаемым объектом
public interface IMoveableObj
{
// Получение координат объекта
ObjParameters? GetObjectPosition { get; }
// Получение шага объекта
int GetStep { get; }
/// Попытка переместить объект в указанном направлении
/// <param name="direction">Направление</param>
/// <returns>true - объект перемещен, false - перемещение невозможно</returns>
bool TryMoveObject(MovementDirection direction);
}

View File

@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCruiser.MoveStrategy;
public class MoveToBorder : AbstractStrategy
{
protected override bool IsTargetDestination()
{
ObjParameters? objP = GetObjectParameters;
if (objP == null)
{
return false;
}
return FieldWidth - GetStep() < objP.RightBorder
&& FieldHeight - GetStep() < objP.DownBorder;
}
protected override void MoveToTarget()
{
ObjParameters? objP = GetObjectParameters;
if (objP == null)
{
return;
}
int s = (int)GetStep();
int diffx = objP.RightBorder - FieldWidth;
if (Math.Abs(diffx) > GetStep())
{
if (diffx > 0)
{
MoveLeft();
}
else { MoveRight(); }
}
int diffy = objP.DownBorder - FieldHeight; // (... - s) - step unnecessary
if (Math.Abs(diffy) > GetStep())
{
if (diffy > 0)
{
MoveUp();
}
else { MoveDown(); }
}
}
}

View File

@ -0,0 +1,50 @@
namespace ProjectCruiser.MoveStrategy;
public class MoveToCentre : AbstractStrategy
{
protected override bool IsTargetDestination()
{
ObjParameters? objP = GetObjectParameters;
if (objP == null)
{
return false;
}
return objP.ObjectMiddleHorizontal - GetStep()
<= FieldWidth / 2 && objP.ObjectMiddleHorizontal
+ GetStep() >= FieldWidth / 2
&& objP.ObjectMiddleVertical - GetStep()
<= FieldHeight / 2 && objP.ObjectMiddleVertical
+ GetStep() >= FieldHeight / 2;
}
protected override void MoveToTarget()
{
ObjParameters? objP = GetObjectParameters;
if (objP == null)
{
return;
}
int diffx = objP.ObjectMiddleHorizontal - FieldWidth / 2;
if (Math.Abs(diffx) > GetStep())
{
if (diffx > 0)
{
MoveLeft();
}
else { MoveRight(); }
}
int diffy = objP.ObjectMiddleVertical - FieldHeight / 2;
if (Math.Abs(diffy) > GetStep())
{
if (diffy > 0)
{
MoveUp();
}
else { MoveDown(); }
}
}
}

View File

@ -0,0 +1,56 @@
using ProjectCruiser.DrawningSamples;
namespace ProjectCruiser.MoveStrategy;
// Класс-реализация IMoveableObject с использованием DrawningBase
public class MoveableTransport : IMoveableObj
{
// Поле-объект класса Drawning(Transport) или его наследника
private readonly DrawningBase? _car = null;
public MoveableTransport(DrawningBase car)
{
_car = car;
}
public ObjParameters? GetObjectPosition
{
get
{
if (_car == null || _car.EntityTransport == null ||
!_car.GetPosX.HasValue || !_car.GetPosY.HasValue)
{
return null;
}
return new ObjParameters(_car.GetPosX.Value,
_car.GetPosY.Value, _car.GetWidth, _car.GetHeight);
}
}
public int GetStep => (int)(_car?.EntityTransport?.Step ?? 0);
public bool TryMoveObject(MovementDirection direction)
{
if (_car == null || _car.EntityTransport == null)
{
return false;
}
return _car.MoveTransport(GetDirectionType(direction));
}
/// Конвертация из MovementDirection в DirectionType
/// <param name="direction">MovementDirection</param>
/// <returns>DirectionType</returns>
private static DirectionType GetDirectionType(MovementDirection direction)
{
return direction switch
{
MovementDirection.Left => DirectionType.Left,
MovementDirection.Right => DirectionType.Right,
MovementDirection.Up => DirectionType.Up,
MovementDirection.Down => DirectionType.Down,
_ => DirectionType.Unknown,
};
}
}

View File

@ -0,0 +1,10 @@
namespace ProjectCruiser.MoveStrategy;
// Направление перемещения
public enum MovementDirection
{
Up = 1,
Down = 2,
Left = 3,
Right = 4
}

View File

@ -0,0 +1,29 @@
namespace ProjectCruiser.MoveStrategy;
// Параметры-координаты объекта
public class ObjParameters
{
private readonly int _x;
private readonly int _y;
private readonly int _width; // Ширина объекта
private readonly int _height; // Высота объекта
public int LeftBorder => _x; // Левая граница
public int TopBorder => _y; // Верхняя граница
public int RightBorder => _x + _width; // Правая граница
public int DownBorder => _y + _height; // Нижняя граница
// Вертикальная середина объекта
public int ObjectMiddleHorizontal => _x + _width / 2;
// Горизонтальная середина объекта
public int ObjectMiddleVertical => _y + _height / 2;
public ObjParameters(int x, int y, int width, int height)
{
_x = x;
_y = y;
_width = width;
_height = height;
}
}

View File

@ -0,0 +1,13 @@
namespace ProjectCruiser.MoveStrategy;
// Статус выполнения операции перемещения
public enum StrategyStatus
{
// готово к началу
NotInit,
// Выполняется
InProgress,
// Завершено
Finish
}

152
ProjectCruiser/OceanForm1.Designer.cs generated Normal file
View File

@ -0,0 +1,152 @@
namespace ProjectCruiser;
partial class OceanForm1
{
/// Required designer variable.
private System.ComponentModel.IContainer components = null;
/// Clean up any resources being used.
/// <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
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
private void InitializeComponent()
{
btnLeftArrow = new Button();
btnDownArrow = new Button();
btnRightArrow = new Button();
btnUpArrow = new Button();
btnCreateBase = new Button();
pictureBoxCr = new PictureBox();
comboBoxStrategy = new ComboBox();
btnCreateAdvanced = new Button();
btnActivateStrategy = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxCr).BeginInit();
SuspendLayout();
//
// btnLeftArrow
//
btnLeftArrow.Location = new Point(926, 445);
btnLeftArrow.Name = "btnLeftArrow";
btnLeftArrow.Size = new Size(141, 132);
btnLeftArrow.TabIndex = 0;
btnLeftArrow.UseVisualStyleBackColor = true;
btnLeftArrow.Click += BtnMove_Click;
//
// btnDownArrow
//
btnDownArrow.Location = new Point(1073, 445);
btnDownArrow.Name = "btnDownArrow";
btnDownArrow.Size = new Size(141, 132);
btnDownArrow.TabIndex = 1;
btnDownArrow.UseVisualStyleBackColor = true;
btnDownArrow.Click += BtnMove_Click;
//
// btnRightArrow
//
btnRightArrow.Location = new Point(1220, 445);
btnRightArrow.Name = "btnRightArrow";
btnRightArrow.Size = new Size(141, 132);
btnRightArrow.TabIndex = 2;
btnRightArrow.UseVisualStyleBackColor = true;
btnRightArrow.Click += BtnMove_Click;
//
// btnUpArrow
//
btnUpArrow.Location = new Point(1073, 307);
btnUpArrow.Name = "btnUpArrow";
btnUpArrow.Size = new Size(141, 132);
btnUpArrow.TabIndex = 3;
btnUpArrow.UseVisualStyleBackColor = true;
btnUpArrow.Click += BtnMove_Click;
//
// btnCreateBase
//
btnCreateBase.Location = new Point(928, 12);
btnCreateBase.Name = "btnCreateBase";
btnCreateBase.Size = new Size(433, 46);
btnCreateBase.TabIndex = 4;
btnCreateBase.Text = "Create base object";
btnCreateBase.UseVisualStyleBackColor = true;
btnCreateBase.Click += btnCreateBase_Click;
//
// pictureBoxCr
//
pictureBoxCr.Dock = DockStyle.Fill;
pictureBoxCr.Location = new Point(0, 0);
pictureBoxCr.Name = "pictureBoxCr";
pictureBoxCr.Size = new Size(1375, 778);
pictureBoxCr.TabIndex = 5;
pictureBoxCr.TabStop = false;
//
// comboBoxStrategy
//
comboBoxStrategy.FormattingEnabled = true;
comboBoxStrategy.Items.AddRange(new object[] { "centre", "border" });
comboBoxStrategy.Location = new Point(928, 120);
comboBoxStrategy.Name = "comboBoxStrategy";
comboBoxStrategy.Size = new Size(435, 40);
comboBoxStrategy.TabIndex = 6;
//
// btnCreateAdvanced
//
btnCreateAdvanced.Location = new Point(928, 58);
btnCreateAdvanced.Name = "btnCreateAdvanced";
btnCreateAdvanced.Size = new Size(433, 46);
btnCreateAdvanced.TabIndex = 7;
btnCreateAdvanced.Text = "Create advanced object";
btnCreateAdvanced.UseVisualStyleBackColor = true;
btnCreateAdvanced.Click += btnCreateAdvanced_Click;
//
// btnActivateStrategy
//
btnActivateStrategy.Location = new Point(928, 166);
btnActivateStrategy.Name = "btnActivateStrategy";
btnActivateStrategy.Size = new Size(435, 46);
btnActivateStrategy.TabIndex = 8;
btnActivateStrategy.Text = "Activate path";
btnActivateStrategy.UseVisualStyleBackColor = true;
btnActivateStrategy.Click += ButtonStrategyStep_Click;
//
// OceanForm1
//
AutoScaleDimensions = new SizeF(13F, 32F);
AutoScaleMode = AutoScaleMode.Font;
BackColor = Color.Turquoise;
ClientSize = new Size(1375, 778);
Controls.Add(btnActivateStrategy);
Controls.Add(btnCreateAdvanced);
Controls.Add(comboBoxStrategy);
Controls.Add(btnCreateBase);
Controls.Add(btnUpArrow);
Controls.Add(btnRightArrow);
Controls.Add(btnDownArrow);
Controls.Add(btnLeftArrow);
Controls.Add(pictureBoxCr);
Name = "OceanForm1";
Text = "OceanForm1";
((System.ComponentModel.ISupportInitialize)pictureBoxCr).EndInit();
ResumeLayout(false);
}
#endregion
private Button btnLeftArrow;
private Button btnDownArrow;
private Button btnRightArrow;
private Button btnUpArrow;
private Button btnCreateBase;
private PictureBox pictureBoxCr;
private ComboBox comboBoxStrategy;
private Button btnCreateAdvanced;
private Button btnActivateStrategy;
}

View File

@ -0,0 +1,142 @@
using ProjectCruiser.DrawningSamples;
using ProjectCruiser.MoveStrategy;
namespace ProjectCruiser
{
public partial class OceanForm1 : Form
{
// Поле-объект для прорисовки объекта
private DrawningBase? _drawningCruiser;
// Стратегия перемещения
private AbstractStrategy? _strategy;
public OceanForm1()
{
InitializeComponent();
_strategy = null;
}
// Метод прорисовки transport
private void Draw()
{
if (_drawningCruiser == null)
{
return;
}
Bitmap bmp = new(pictureBoxCr.Width, pictureBoxCr.Height);
Graphics gr = Graphics.FromImage(bmp);
_drawningCruiser.DrawTransport(gr);
pictureBoxCr.Image = bmp;
}
// Обработка нажатия кнопок "Create(...)"
private void btnCreateBase_Click(object sender, EventArgs e) =>
CreateObject(nameof(DrawningBase));
private void btnCreateAdvanced_Click(object sender, EventArgs e) =>
CreateObject(nameof(DrawningCruiser));
// Создание объекта класса-перемещения
/// <param name="type">Тип создаваемого объекта</param>
private void CreateObject(string type)
{
Random random = new();
switch (type)
{
case nameof(DrawningBase):
_drawningCruiser = new DrawningBase(random.Next(100, 300), random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
break;
case nameof(DrawningCruiser):
_drawningCruiser = new DrawningCruiser(random.Next(100, 300), random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
break;
default:
return;
}
_drawningCruiser.SetPictureSize(pictureBoxCr.Width, pictureBoxCr.Height);
_drawningCruiser.SetPosition(random.Next(10, 100),
pictureBoxCr.Height - random.Next(10, 100) - _drawningCruiser.getHeight());
_strategy = null;
comboBoxStrategy.Enabled = true;
Draw();
}
private void BtnMove_Click(object sender, EventArgs e)
{
if (_drawningCruiser == null)
{
return;
}
string name = ((Button)sender)?.Name ?? string.Empty;
bool result = false;
switch (name)
{
case "btnUpArrow":
result =
_drawningCruiser.MoveTransport(DirectionType.Up);
break;
case "btnDownArrow":
result =
_drawningCruiser.MoveTransport(DirectionType.Down);
break;
case "btnLeftArrow":
result =
_drawningCruiser.MoveTransport(DirectionType.Left);
break;
case "btnRightArrow":
result =
_drawningCruiser.MoveTransport(DirectionType.Right);
break;
}
if (result)
{
Draw();
}
}
private void ButtonStrategyStep_Click(object sender, EventArgs e)
{
if (_drawningCruiser == null)
{
return;
}
if (comboBoxStrategy.Enabled)
{
_strategy = comboBoxStrategy.SelectedIndex switch
{
0 => new MoveToCentre(),
1 => new MoveToBorder(),
_ => null,
};
if (_strategy == null)
{
return;
}
_strategy.SetData(new MoveableTransport(_drawningCruiser),
pictureBoxCr.Width, pictureBoxCr.Height);
}
if (_strategy == null)
{
return;
}
comboBoxStrategy.Enabled = false;
_strategy.MakeStep();
Draw();
if (_strategy.GetStatus() == StrategyStatus.Finish)
{
comboBoxStrategy.Enabled = true;
_strategy = null;
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -11,7 +11,7 @@ namespace ProjectCruiser
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
Application.Run(new OceanForm1());
}
}
}