Добавление родителей и ввод конструкторов

This commit is contained in:
AlyonaFr 2024-03-19 21:06:59 +04:00
parent 19bd24cf6c
commit 1310766ce8
8 changed files with 277 additions and 128 deletions

View File

@ -1,10 +1,4 @@
using System; namespace ProjectCatamaran.Drawnings;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCatamaran;
public enum DirectionType public enum DirectionType
{ {

View File

@ -1,14 +1,18 @@
namespace ProjectCatamaran; using ProjectCatamaran.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/// <summary> namespace ProjectCatamaran.Drawnings;
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
/// </summary> public class DrawningBoat
public class DrawningCatamaran
{ {
/// <summary> /// <summary>
/// Класс-сущность /// Класс-сущность
/// </summary> /// </summary>
public EntityCatamaran? EntityCatamaran { get; private set; } public EntityBoat? EntityBoat { get; protected set; }
/// <summary> /// <summary>
/// Ширина окна /// Ширина окна
@ -23,43 +27,56 @@ public class DrawningCatamaran
/// <summary> /// <summary>
/// Левая координата прорисовки катамарана /// Левая координата прорисовки катамарана
/// </summary> /// </summary>
private int? _startPosX; protected int? _startPosX;
/// <summary> /// <summary>
/// Верхняя координата прорисовки катамарана /// Верхняя координата прорисовки катамарана
/// </summary> /// </summary>
private int? _startPosY; protected int? _startPosY;
/// <summary> /// <summary>
/// Ширина прорисовки катамарана /// Ширина прорисовки катамарана
/// </summary> /// </summary>
private readonly int _drawningCatamaranWidth = 87; private readonly int _drawningCatamaranWidth = 80;
/// <summary> /// <summary>
/// Высота прорисовки катамарана /// Высота прорисовки катамарана
/// </summary> /// </summary>
private readonly int _drawningCatamaranHeight = 81; private readonly int _drawningCatamaranHeight = 62;
/// <summary> /// <summary>
/// Инициализация свойств /// Пустой конструктор
/// </summary> /// </summary>
/// <param name="speed"></param> private DrawningBoat()
/// <param name="weight"></param>
/// <param name="bodyColor"></param>
/// <param name="additionalColor"></param>
/// <param name="sail"></param>
/// <param name="leftfloater"></param>
/// <param name="rightfloater"></param>
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool sail,
bool leftfloater, bool rightfloater)
{ {
EntityCatamaran = new EntityCatamaran();
EntityCatamaran.Init(speed, weight, bodyColor, additionalColor, sail, leftfloater, rightfloater);
_pictureWidth = null; _pictureWidth = null;
_pictureHeight = null; _pictureHeight = null;
_startPosX = null; _startPosX = null;
_startPosY = null; _startPosY = null;
} }
/// <summary>
/// Конструктор
/// </summary>
/// <param name="speed"></param>
/// <param name="weight"></param>
/// <param name="bodyColor"></param
public DrawningBoat(int speed, double weight, Color bodyColor) : this()
{
EntityBoat = new EntityBoat(speed, weight, bodyColor);
}
/// <summary>
/// Конструктор для наследников
/// </summary>
/// <param name="drawningCatamaranWidth">Ширина прорисовки катамарана</param>
/// <param name="drawningCatamaranHeight">Высота прорисовки катамарана</param>
protected DrawningBoat(int drawningCatamaranWidth, int drawningCatamaranHeight) : this()
{
_drawningCatamaranWidth = drawningCatamaranWidth;
_drawningCatamaranHeight = drawningCatamaranHeight;
}
/// <summary> /// <summary>
/// Установка границ поля /// Установка границ поля
@ -98,14 +115,21 @@ public class DrawningCatamaran
return; return;
} }
if (x < 0 || x + _drawningCatamaranWidth > _pictureWidth || y < 0 || y + _drawningCatamaranHeight > _pictureHeight) if (x < 0 || x + _drawningCatamaranWidth > _pictureWidth)
{ {
_startPosX = _pictureWidth - _drawningCatamaranWidth; _startPosX = _pictureWidth - _drawningCatamaranWidth;
_startPosY = _pictureHeight - _drawningCatamaranHeight;
} }
else else
{ {
_startPosX = x; _startPosX = x;
}
if (y < 0 || y + _drawningCatamaranHeight > _pictureHeight)
{
_startPosY = _pictureHeight - _drawningCatamaranHeight;
}
else
{
_startPosY = y; _startPosY = y;
} }
} }
@ -117,7 +141,7 @@ public class DrawningCatamaran
/// <returns>- перемещение выполнено, false - перемещение невозможно</returns> /// <returns>- перемещение выполнено, false - перемещение невозможно</returns>
public bool MoveTransport(DirectionType direction) public bool MoveTransport(DirectionType direction)
{ {
if (EntityCatamaran == null || !_startPosX.HasValue || !_startPosY.HasValue) if (EntityBoat == null || !_startPosX.HasValue || !_startPosY.HasValue)
{ {
return false; return false;
} }
@ -125,31 +149,31 @@ public class DrawningCatamaran
{ {
//влево //влево
case DirectionType.Left: case DirectionType.Left:
if (_startPosX.Value - EntityCatamaran.Step > 0) if (_startPosX.Value - EntityBoat.Step > 0)
{ {
_startPosX -= (int)EntityCatamaran.Step; _startPosX -= (int)EntityBoat.Step;
} }
return true; return true;
//вверх //вверх
case DirectionType.Up: case DirectionType.Up:
if (_startPosY.Value - EntityCatamaran.Step > 0) if (_startPosY.Value - EntityBoat.Step > 0)
{ {
_startPosY -= (int)EntityCatamaran.Step; _startPosY -= (int)EntityBoat.Step;
} }
return true; return true;
// вправо // вправо
case DirectionType.Right: case DirectionType.Right:
if (_startPosX.Value + EntityCatamaran.Step + _drawningCatamaranWidth < _pictureWidth) if (_startPosX.Value + EntityBoat.Step + _drawningCatamaranWidth < _pictureWidth)
{ {
_startPosX += (int)EntityCatamaran.Step; _startPosX += (int)EntityBoat.Step;
return true; return true;
} }
return true; return true;
//вниз //вниз
case DirectionType.Down: case DirectionType.Down:
if (_startPosY.Value + EntityCatamaran.Step + _drawningCatamaranHeight < _pictureHeight) if (_startPosY.Value + EntityBoat.Step + _drawningCatamaranHeight < _pictureHeight)
{ {
_startPosY += (int)EntityCatamaran.Step; _startPosY += (int)EntityBoat.Step;
} }
return true; return true;
default: default:
@ -161,57 +185,30 @@ public class DrawningCatamaran
/// Прорисовка объекта /// Прорисовка объекта
/// </summary> /// </summary>
/// <param name="g"></param> /// <param name="g"></param>
public void DrawTransport(Graphics g) public virtual void DrawTransport(Graphics g)
{ {
if (EntityCatamaran == null || !_startPosX.HasValue || !_startPosY.HasValue) if (EntityBoat == null || !_startPosX.HasValue || !_startPosY.HasValue)
{ {
return; return;
} }
Pen pen = new(Color.Black); Pen pen = new(Color.Black);
Brush bodyColorBrush = new SolidBrush(EntityCatamaran.BodyColor); Brush bodyColorBrush = new SolidBrush(EntityBoat.BodyColor);
Brush additionalBrush = new SolidBrush(EntityCatamaran.AdditionalColor);
//тело катамарана //тело катамарана
g.FillRectangle(bodyColorBrush, _startPosX.Value + 10, _startPosY.Value + 40, 57, 30); g.FillRectangle(bodyColorBrush, _startPosX.Value, _startPosY.Value + 32, 57, 30);
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 40, 57, 30); g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 32, 57, 30);
g.FillEllipse(bodyColorBrush, _startPosX.Value + 20, _startPosY.Value + 48, 40, 13); g.FillEllipse(bodyColorBrush, _startPosX.Value + 9, _startPosY.Value + 40, 40, 13);
g.DrawEllipse(pen, _startPosX.Value + 20, _startPosY.Value + 48, 40, 13); g.DrawEllipse(pen, _startPosX.Value + 9, _startPosY.Value + 40, 40, 13);
//нос катамарана //нос катамарана
Point[] Nose = new Point[3]; Point[] Nose = new Point[3];
Nose[0].X = _startPosX.Value + 67; Nose[0].Y = _startPosY.Value + 40; Nose[0].X = _startPosX.Value + 57; Nose[0].Y = _startPosY.Value + 32;
Nose[1].X = _startPosX.Value + 88; Nose[1].Y = _startPosY.Value + 55; Nose[1].X = _startPosX.Value + 80; Nose[1].Y = _startPosY.Value + 47;
Nose[2].X = _startPosX.Value + 67; Nose[2].Y = _startPosY.Value + 70; Nose[2].X = _startPosX.Value + 57; Nose[2].Y = _startPosY.Value + 62;
g.FillPolygon(bodyColorBrush, Nose); g.FillPolygon(bodyColorBrush, Nose);
g.DrawPolygon(pen, Nose); g.DrawPolygon(pen, Nose);
//поплавки
if (EntityCatamaran.Leftfloater)
{
g.FillEllipse(additionalBrush, _startPosX.Value + 10, _startPosY.Value + 27, 57, 13);
g.DrawEllipse(pen, _startPosX.Value + 10, _startPosY.Value + 27, 57, 13);
} }
if (EntityCatamaran.Rightfloater)
{
g.FillEllipse(additionalBrush, _startPosX.Value + 10, _startPosY.Value + 70, 57, 13);
g.DrawEllipse(pen, _startPosX.Value + 10, _startPosY.Value + 70, 57, 13);
}
//флаг
if (EntityCatamaran.Sail)
{
g.DrawLine(pen, _startPosX.Value + 38, _startPosY.Value + 55, _startPosX.Value + 38, _startPosY.Value + 10);
Point[] Flag = new Point[3];
Flag[0].X = _startPosX.Value + 38; Flag[0].Y = _startPosY.Value + 10;
Flag[1].X = _startPosX.Value + 55; Flag[1].Y = _startPosY.Value + 45;
Flag[2].X = _startPosX.Value + 38; Flag[2].Y = _startPosY.Value + 45;
g.FillPolygon(additionalBrush, Flag);
g.DrawPolygon(pen, Flag);
}
}
} }

View File

@ -0,0 +1,95 @@
using ProjectCatamaran.Entities;
namespace ProjectCatamaran.Drawnings;
/// <summary>
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
/// </summary>
public class DrawningCatamaran : DrawningBoat
{
/// <summary>
/// Ширина окна
/// </summary>
private int? _pictureWidth;
/// <summary>
/// Высота окна
/// </summary>
private int? _pictureHeight;
/// <summary>
/// Левая координата прорисовки катамарана
/// </summary>
private int? GetPosX => _startPosX;
/// <summary>
/// Верхняя координата прорисовки катамарана
/// </summary>
private int? GetPosY => _startPosY;
/// <summary>
/// Ширина прорисовки катамарана
/// </summary>
private readonly int _drawningCatamaranWidth = 79;
/// <summary>
/// Высота прорисовки катамарана
/// </summary>
private readonly int _drawningCatamaranHeight = 75;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="speed"></param>
/// <param name="weight"></param>
/// <param name="bodyColor"></param>
/// <param name="additionalColor"></param>
/// <param name="sail"></param>
/// <param name="leftfloater"></param>
/// <param name="rightfloater"></param>
public DrawningCatamaran(int speed, double weight, Color bodyColor, Color additionalColor, bool sail, bool leftfloater, bool rightfloater) : base(79, 75)
{
EntityBoat = new EntityCatamaran(speed, weight, bodyColor, additionalColor, sail, leftfloater, rightfloater);
}
public override void DrawTransport(Graphics g)
{
if (EntityBoat == null || EntityBoat is not EntityCatamaran catamaran || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
Pen pen = new(Color.Black);
Brush additionalBrush = new SolidBrush(catamaran.AdditionalColor);
base.DrawTransport(g);
//поплавки
if (catamaran.Leftfloater)
{
g.FillEllipse(additionalBrush, _startPosX.Value, _startPosY.Value + 20, 57, 13);
g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 20, 57, 13);
}
if (catamaran.Rightfloater)
{
g.FillEllipse(additionalBrush, _startPosX.Value, _startPosY.Value + 62, 57, 13);
g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 62, 57, 13);
}
//флаг
if (catamaran.Sail)
{
g.DrawLine(pen, _startPosX.Value + 29, _startPosY.Value + 48, _startPosX.Value + 29, _startPosY.Value);
Point[] Flag = new Point[3];
Flag[0].X = _startPosX.Value + 29; Flag[0].Y = _startPosY.Value + 38;
Flag[1].X = _startPosX.Value + 48; Flag[1].Y = _startPosY.Value + 38;
Flag[2].X = _startPosX.Value + 29; Flag[2].Y = _startPosY.Value;
g.FillPolygon(additionalBrush, Flag);
g.DrawPolygon(pen, Flag);
}
}
}

View File

@ -1,24 +1,10 @@
namespace ProjectCatamaran; namespace ProjectCatamaran.Entities;
/// <summary> /// <summary>
/// Класс-сущность "Катамаран" /// Класс-сущность "Катамаран"
/// </summary> /// </summary>
public class EntityCatamaran public class EntityCatamaran : EntityBoat
{ {
/// <summary>
/// Скорость
/// </summary>
public int Speed { get; private set; }
/// <summary>
/// Вес
/// </summary>
public double Weight { get; private set; }
/// <summary>
/// Основной цвет
/// </summary>
public Color BodyColor { get; private set; }
/// <summary> /// <summary>
/// Дополнительный цвет (для опциональных элементов) /// Дополнительный цвет (для опциональных элементов)
@ -40,14 +26,9 @@ public class EntityCatamaran
/// </summary> /// </summary>
public bool Sail { get; private set; } public bool Sail { get; private set; }
/// <summary>
///
/// </summary>
public double Step => Speed * 100 / Weight;
/// <summary> /// <summary>
/// /// Инициализация полей объекта-класса катамарана
/// </summary> /// </summary>
/// <param name="speed">Скорость</param> /// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param> /// <param name="weight">Вес</param>
@ -56,11 +37,8 @@ public class EntityCatamaran
/// <param name="leftfloater">Признак наличия левого поплавка</param> /// <param name="leftfloater">Признак наличия левого поплавка</param>
/// <param name="rightfloater">Признак наличия правого поплавка</param> /// <param name="rightfloater">Признак наличия правого поплавка</param>
/// <param name="sail">Признак наличия паруса</param> /// <param name="sail">Признак наличия паруса</param>
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool leftfloater, bool rightfloater, bool sail) public EntityCatamaran(int speed, double weight, Color bodyColor, Color additionalColor, bool leftfloater, bool rightfloater, bool sail) : base(speed, weight, bodyColor)
{ {
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
AdditionalColor = additionalColor; AdditionalColor = additionalColor;
Leftfloater = leftfloater; Leftfloater = leftfloater;
Rightfloater = rightfloater; Rightfloater = rightfloater;

View File

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCatamaran.Entities;
/// <summary>
/// Класс-сущности "Катамарана_1"
/// </summary>
public class EntityBoat
{
/// <summary>
/// Скорость
/// </summary>
public int Speed { get; private set; }
/// <summary>
/// Вес
/// </summary>
public double Weight { get; private set; }
/// <summary>
/// Основной цвет
/// </summary>
public Color BodyColor { get; private set; }
/// <summary>
///
/// </summary>
public double Step => Speed * 100 / Weight;
/// <summary>
/// Конструктор сущности
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param>
public EntityBoat(int speed, double weight, Color bodyColor)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
}
}

View File

@ -34,6 +34,7 @@
buttonLeft = new Button(); buttonLeft = new Button();
buttonDown = new Button(); buttonDown = new Button();
buttonRight = new Button(); buttonRight = new Button();
buttonCreatBoat = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxCatamaran).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBoxCatamaran).BeginInit();
SuspendLayout(); SuspendLayout();
// //
@ -45,16 +46,15 @@
pictureBoxCatamaran.Size = new Size(800, 450); pictureBoxCatamaran.Size = new Size(800, 450);
pictureBoxCatamaran.TabIndex = 0; pictureBoxCatamaran.TabIndex = 0;
pictureBoxCatamaran.TabStop = false; pictureBoxCatamaran.TabStop = false;
pictureBoxCatamaran.Click += ButtonMove_Click;
// //
// buttonCreateCatamaran // buttonCreateCatamaran
// //
buttonCreateCatamaran.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; buttonCreateCatamaran.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreateCatamaran.Location = new Point(12, 409); buttonCreateCatamaran.Location = new Point(12, 409);
buttonCreateCatamaran.Name = "buttonCreateCatamaran"; buttonCreateCatamaran.Name = "buttonCreateCatamaran";
buttonCreateCatamaran.Size = new Size(94, 29); buttonCreateCatamaran.Size = new Size(203, 29);
buttonCreateCatamaran.TabIndex = 1; buttonCreateCatamaran.TabIndex = 1;
buttonCreateCatamaran.Text = "Создать"; buttonCreateCatamaran.Text = "Создать катамаран";
buttonCreateCatamaran.UseVisualStyleBackColor = true; buttonCreateCatamaran.UseVisualStyleBackColor = true;
buttonCreateCatamaran.Click += ButtonCreateCatamaran_Click; buttonCreateCatamaran.Click += ButtonCreateCatamaran_Click;
// //
@ -108,11 +108,23 @@
buttonRight.UseVisualStyleBackColor = false; buttonRight.UseVisualStyleBackColor = false;
buttonRight.Click += ButtonMove_Click; buttonRight.Click += ButtonMove_Click;
// //
// buttonCreatBoat
//
buttonCreatBoat.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreatBoat.Location = new Point(233, 409);
buttonCreatBoat.Name = "buttonCreatBoat";
buttonCreatBoat.Size = new Size(203, 29);
buttonCreatBoat.TabIndex = 6;
buttonCreatBoat.Text = "Создать лодку";
buttonCreatBoat.UseVisualStyleBackColor = true;
buttonCreatBoat.Click += ButtonCreatBoat_Click;
//
// FormCatamaran // FormCatamaran
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450); ClientSize = new Size(800, 450);
Controls.Add(buttonCreatBoat);
Controls.Add(buttonRight); Controls.Add(buttonRight);
Controls.Add(buttonDown); Controls.Add(buttonDown);
Controls.Add(buttonLeft); Controls.Add(buttonLeft);
@ -133,5 +145,6 @@
private Button buttonLeft; private Button buttonLeft;
private Button buttonDown; private Button buttonDown;
private Button buttonRight; private Button buttonRight;
private Button buttonCreatBoat;
} }
} }

View File

@ -7,6 +7,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using ProjectCatamaran.Drawnings;
namespace ProjectCatamaran namespace ProjectCatamaran
{ {
@ -15,7 +16,7 @@ namespace ProjectCatamaran
/// <summary> /// <summary>
/// Поле-объект для прорисовки объекта /// Поле-объект для прорисовки объекта
/// </summary> /// </summary>
private DrawningCatamaran? _drawningCatamaran; private DrawningBoat? _drawningBoat;
/// <summary> /// <summary>
/// Конструктор формы /// Конструктор формы
@ -25,40 +26,63 @@ namespace ProjectCatamaran
InitializeComponent(); InitializeComponent();
} }
/// <summary> /// <summary>
/// Обработка нажатия кнопки "Создать" /// Создание объекта класса-перемещения
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="type"></param>
/// <param name="e"></param> private void CreateObject(string type)
private void ButtonCreateCatamaran_Click(object sender, EventArgs e)
{ {
Random random = new(); Random random = new();
_drawningCatamaran = new DrawningCatamaran(); switch (type)
_drawningCatamaran.Init(random.Next(100, 300), random.Next(1000, 3000), {
case nameof(DrawningBoat):
_drawningBoat = new DrawningBoat(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(DrawningCatamaran):
_drawningBoat = new DrawningCatamaran(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)),
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)), Convert.ToBoolean(random.Next(0, 2))); Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
_drawningCatamaran.SetPictureSize(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height); break;
_drawningCatamaran.SetPosition(random.Next(10, 100), random.Next(10, 100)); default:
Draw(); return;
} }
_drawningBoat.SetPictureSize(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
_drawningBoat.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
/// <summary>
/// Обработка нажатия кнопки "Создать катамаран"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonCreateCatamaran_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningCatamaran));
/// <summary>
/// Обработка нажатия кнопки "Создать лодку"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonCreatBoat_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningBoat));
/// <summary> /// <summary>
/// Метод прорисовки катамарана /// Метод прорисовки катамарана
/// </summary> /// </summary>
private void Draw() private void Draw()
{ {
if (_drawningCatamaran == null) if (_drawningBoat == null)
{ {
return; return;
} }
Bitmap bmp = new(pictureBoxCatamaran.Width, Bitmap bmp = new(pictureBoxCatamaran.Width,
pictureBoxCatamaran.Height); pictureBoxCatamaran.Height);
Graphics gr = Graphics.FromImage(bmp); Graphics gr = Graphics.FromImage(bmp);
_drawningCatamaran.DrawTransport(gr); _drawningBoat.DrawTransport(gr);
pictureBoxCatamaran.Image = bmp; pictureBoxCatamaran.Image = bmp;
} }
@ -70,7 +94,7 @@ namespace ProjectCatamaran
private void ButtonMove_Click(object sender, EventArgs e) private void ButtonMove_Click(object sender, EventArgs e)
{ {
if (_drawningCatamaran == null) if (_drawningBoat == null)
{ {
return; return;
} }
@ -79,16 +103,16 @@ namespace ProjectCatamaran
switch (name) switch (name)
{ {
case "buttonUp": case "buttonUp":
result = _drawningCatamaran.MoveTransport(DirectionType.Up); result = _drawningBoat.MoveTransport(DirectionType.Up);
break; break;
case "buttonDown": case "buttonDown":
result = _drawningCatamaran.MoveTransport(DirectionType.Down); result = _drawningBoat.MoveTransport(DirectionType.Down);
break; break;
case "buttonLeft": case "buttonLeft":
result = _drawningCatamaran.MoveTransport(DirectionType.Left); result = _drawningBoat.MoveTransport(DirectionType.Left);
break; break;
case "buttonRight": case "buttonRight":
result = _drawningCatamaran.MoveTransport(DirectionType.Right); result = _drawningBoat.MoveTransport(DirectionType.Right);
break; break;
} }
if (result) if (result)
@ -97,5 +121,6 @@ namespace ProjectCatamaran
} }
} }
} }
} }

View File

@ -1,4 +1,4 @@
namespace ProjectCatamaran namespace ProjectCatamaran.Resources
{ {
internal static class Program internal static class Program
{ {