Compare commits
No commits in common. "LabWork01" and "main" have entirely different histories.
@ -1,33 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Cruiser;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перечисление направлений
|
|
||||||
/// </summary>
|
|
||||||
public enum DirectionType
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Вверх
|
|
||||||
/// </summary>
|
|
||||||
Up = 1,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Вниз
|
|
||||||
/// </summary>
|
|
||||||
Down = 2,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Влево
|
|
||||||
/// </summary>
|
|
||||||
Left = 3,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Вправо
|
|
||||||
/// </summary>
|
|
||||||
Right = 4,
|
|
||||||
}
|
|
@ -1,227 +0,0 @@
|
|||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace Cruiser;
|
|
||||||
|
|
||||||
public class DrawingCruiser
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-сущность
|
|
||||||
/// </summary>
|
|
||||||
public EntityCruiser? EntityCruiser { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина окна
|
|
||||||
/// </summary>
|
|
||||||
private int? _pictureWidth;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Высота окна
|
|
||||||
/// </summary>
|
|
||||||
private int? _pictureHeight;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Левая координата корабля
|
|
||||||
/// </summary>
|
|
||||||
private int? _startPosX;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Верхняя координата корабля
|
|
||||||
/// </summary>
|
|
||||||
private int? _startPosY;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина прорисовки корабля
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _drawingCruiserWidth = 150;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Высота прорисовки корабля
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _drawingCruiserHeight = 50;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Инициализация
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed"><скорость/param>
|
|
||||||
/// <param name="weight"><вес/param>
|
|
||||||
/// <param name="bodycolor"><основной_цвет/param>
|
|
||||||
/// <param name="additionalcolor"><дополнительный_цвет/param>
|
|
||||||
/// <param name="bodykit"><наличие_надстроек/param>
|
|
||||||
/// <param name="arms"><наличие_вооружения/param>
|
|
||||||
/// <param name="anchor"><наличие_якоря/param>
|
|
||||||
public void Init(int speed, double weight, Color bodycolor, Color additionalcolor, bool bodykit, bool arms, bool anchor)
|
|
||||||
{
|
|
||||||
EntityCruiser = new EntityCruiser();
|
|
||||||
EntityCruiser.Init(speed, weight, bodycolor, additionalcolor, bodykit, arms, anchor);
|
|
||||||
_pictureWidth = null;
|
|
||||||
_pictureHeight = null;
|
|
||||||
_startPosX = null;
|
|
||||||
_startPosY = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Установка размеров окна
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="width"><Ширина/param>
|
|
||||||
/// <param name="height"><Высота/param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool SetPictureSize(int width, int height)
|
|
||||||
{
|
|
||||||
if (_pictureWidth < _drawingCruiserWidth || _pictureHeight < _drawingCruiserHeight)
|
|
||||||
{
|
|
||||||
if (_startPosX != null && _startPosY != null)
|
|
||||||
{
|
|
||||||
if (width < 0) width = 0;
|
|
||||||
else if (_startPosX + _drawingCruiserWidth > width) _startPosX = width - _drawingCruiserWidth;
|
|
||||||
if (height < 0) height = 0;
|
|
||||||
else if (_startPosY + _drawingCruiserHeight > height) _startPosY = height - _drawingCruiserHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO проверка, что объект "влезает" в размеры поля
|
|
||||||
// если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена
|
|
||||||
_pictureHeight = height;
|
|
||||||
_pictureWidth = width;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Установка позиции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="x"></param>
|
|
||||||
/// <param name="y"></param>
|
|
||||||
public void SetPosition(int x, int y)
|
|
||||||
{
|
|
||||||
_startPosX = x;
|
|
||||||
_startPosY = y;
|
|
||||||
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_startPosX + _drawingCruiserWidth > _pictureWidth)
|
|
||||||
{
|
|
||||||
_startPosX = _pictureWidth - _drawingCruiserWidth;
|
|
||||||
}
|
|
||||||
else if (_startPosX < 0)
|
|
||||||
{
|
|
||||||
_startPosX = 0;
|
|
||||||
}
|
|
||||||
if (_startPosY + _drawingCruiserHeight > _pictureHeight)
|
|
||||||
{
|
|
||||||
_startPosY = _pictureHeight - _drawingCruiserHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (_startPosY < 0)
|
|
||||||
{
|
|
||||||
_startPosY = 0;
|
|
||||||
}
|
|
||||||
//TODO если при установке объекта в эти координаты, он будет выходить за границы поля,
|
|
||||||
//то нужно изменить координаты, чтобы он остался в нужных размерах
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Движение объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool MoveTransport(DirectionType direction)
|
|
||||||
{
|
|
||||||
if (EntityCruiser == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (direction)
|
|
||||||
{
|
|
||||||
case DirectionType.Left:
|
|
||||||
if (_startPosX.Value - EntityCruiser.Step > 0)
|
|
||||||
{
|
|
||||||
_startPosX -= (int)EntityCruiser.Step;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case DirectionType.Up:
|
|
||||||
if (_startPosY.Value - EntityCruiser.Step > 0)
|
|
||||||
{
|
|
||||||
_startPosY -= (int)EntityCruiser.Step;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case DirectionType.Right:
|
|
||||||
if (_startPosX.Value + EntityCruiser.Step + _drawingCruiserWidth < _pictureWidth)
|
|
||||||
{
|
|
||||||
_startPosX += (int)EntityCruiser.Step;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case DirectionType.Down:
|
|
||||||
if (_startPosY.Value + EntityCruiser.Step + _drawingCruiserHeight < _pictureHeight)
|
|
||||||
{
|
|
||||||
_startPosY += (int)EntityCruiser.Step;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
default: return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Прорисовка объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="g"></param>
|
|
||||||
public void DrawTransport(Graphics g)
|
|
||||||
{
|
|
||||||
if (EntityCruiser == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Brush bodybrush = new SolidBrush(EntityCruiser.BodyColor);
|
|
||||||
|
|
||||||
//Массив точек
|
|
||||||
Pen pen = new(Color.Black);
|
|
||||||
Point p1 = new Point(_startPosX.Value + 5, _startPosY.Value);
|
|
||||||
Point p2 = new Point(_startPosX.Value + 100, _startPosY.Value);
|
|
||||||
Point p3 = new Point(_startPosX.Value + 150, _startPosY.Value + 25);
|
|
||||||
Point p4 = new Point(_startPosX.Value + 100, _startPosY.Value + 50);
|
|
||||||
Point p5 = new Point(_startPosX.Value + 5, _startPosY.Value + 50);
|
|
||||||
Point p6 = new Point(_startPosX.Value + 5, _startPosY.Value);
|
|
||||||
Point[] bodypoints = {p1, p2, p3, p4, p5, p6};
|
|
||||||
g.FillPolygon(bodybrush, bodypoints);
|
|
||||||
g.DrawPolygon(pen, bodypoints);
|
|
||||||
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 10, 5, 10);
|
|
||||||
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 30, 5, 10);
|
|
||||||
|
|
||||||
Brush additionalbrush = new SolidBrush(EntityCruiser.AdditionalColor);
|
|
||||||
|
|
||||||
if (EntityCruiser.Arms == true){
|
|
||||||
g.FillEllipse(additionalbrush, _startPosX.Value + 100, _startPosY.Value + 15, 20, 20);
|
|
||||||
g.DrawEllipse(pen, _startPosX.Value + 100, _startPosY.Value + 15, 20, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (EntityCruiser.Helicopter == true)
|
|
||||||
{
|
|
||||||
g.FillEllipse(additionalbrush, _startPosX.Value + 10, _startPosY.Value + 5, 40, 40);
|
|
||||||
g.DrawEllipse(pen, _startPosX.Value + 10, _startPosY.Value + 5, 40, 40);
|
|
||||||
Point ap1 = new Point(_startPosX.Value + 20, _startPosY.Value + 15);
|
|
||||||
Point ap2 = new Point(_startPosX.Value + 25, _startPosY.Value + 15);
|
|
||||||
Point ap3 = new Point(_startPosX.Value + 25, _startPosY.Value + 23);
|
|
||||||
Point ap4 = new Point(_startPosX.Value + 35, _startPosY.Value + 23);
|
|
||||||
Point ap5 = new Point(_startPosX.Value + 35, _startPosY.Value + 15);
|
|
||||||
Point ap6 = new Point(_startPosX.Value + 40, _startPosY.Value + 15);
|
|
||||||
Point ap7 = new Point(_startPosX.Value + 40, _startPosY.Value + 35);
|
|
||||||
Point ap8 = new Point(_startPosX.Value + 35, _startPosY.Value + 35);
|
|
||||||
Point ap9 = new Point(_startPosX.Value + 35, _startPosY.Value + 28);
|
|
||||||
Point ap10 = new Point(_startPosX.Value + 25, _startPosY.Value + 28);
|
|
||||||
Point ap11 = new Point(_startPosX.Value + 25, _startPosY.Value + 35);
|
|
||||||
Point ap12 = new Point(_startPosX.Value + 20, _startPosY.Value + 35);
|
|
||||||
Point[] abodypoints = { ap1, ap2, ap3, ap4, ap5, ap6, ap7, ap8, ap9, ap10, ap11, ap12};
|
|
||||||
g.FillPolygon(new SolidBrush(Color.White), abodypoints );
|
|
||||||
g.DrawPolygon(pen, abodypoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (EntityCruiser.BodyKit == true)
|
|
||||||
{
|
|
||||||
g.FillRectangle(additionalbrush, _startPosX.Value + 70, _startPosY.Value + 15, 20, 20);
|
|
||||||
g.DrawRectangle(pen, _startPosX.Value + 70, _startPosY.Value + 15, 20, 20);
|
|
||||||
g.FillRectangle(additionalbrush, _startPosX.Value + 60, _startPosY.Value + 20, 10, 10);
|
|
||||||
g.DrawRectangle(pen, _startPosX.Value + 60, _startPosY.Value + 20, 10, 10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
namespace Cruiser;
|
|
||||||
|
|
||||||
/// <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; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Дополнительный цвеь (детали)
|
|
||||||
/// </summary>
|
|
||||||
public Color AdditionalColor { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Наличие "надстроек"
|
|
||||||
/// </summary>
|
|
||||||
public bool BodyKit { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Наличие вооружения
|
|
||||||
/// </summary>
|
|
||||||
public bool Arms { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Наличие вертолетной площадки
|
|
||||||
/// </summary>
|
|
||||||
public bool Helicopter { 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>
|
|
||||||
/// <param name="additionalcolor"><Дополнительный_цвет/param>
|
|
||||||
/// <param name="bodykit"><Надстройки/param>
|
|
||||||
/// <param name="arms"><Вооружение/param>
|
|
||||||
/// <param name="anchor"><Якорь/param>
|
|
||||||
public void Init(int speed, double weight, Color bodycolor, Color additionalcolor, bool bodykit, bool arms, bool helicopter)
|
|
||||||
{
|
|
||||||
Speed = speed;
|
|
||||||
Weight = weight;
|
|
||||||
BodyColor = bodycolor;
|
|
||||||
AdditionalColor = additionalcolor;
|
|
||||||
BodyKit = bodykit;
|
|
||||||
Arms = arms;
|
|
||||||
Helicopter = helicopter;
|
|
||||||
}
|
|
||||||
}
|
|
39
Cruiser/Cruiser/Form1.Designer.cs
generated
Normal file
39
Cruiser/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/Cruiser/Form1.cs
Normal file
10
Cruiser/Cruiser/Form1.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace Cruiser
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
134
Cruiser/Cruiser/FormCruiser.Designer.cs
generated
134
Cruiser/Cruiser/FormCruiser.Designer.cs
generated
@ -1,134 +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();
|
|
||||||
buttonCreateCruiser = new Button();
|
|
||||||
buttonRight = new Button();
|
|
||||||
buttonDown = new Button();
|
|
||||||
buttonUp = new Button();
|
|
||||||
buttonLeft = 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(1002, 724);
|
|
||||||
pictureBoxCruiser.SizeMode = PictureBoxSizeMode.CenterImage;
|
|
||||||
pictureBoxCruiser.TabIndex = 9;
|
|
||||||
pictureBoxCruiser.TabStop = false;
|
|
||||||
//
|
|
||||||
// buttonCreateCruiser
|
|
||||||
//
|
|
||||||
buttonCreateCruiser.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
buttonCreateCruiser.Location = new Point(12, 678);
|
|
||||||
buttonCreateCruiser.Name = "buttonCreateCruiser";
|
|
||||||
buttonCreateCruiser.Size = new Size(80, 34);
|
|
||||||
buttonCreateCruiser.TabIndex = 8;
|
|
||||||
buttonCreateCruiser.Text = "Создать";
|
|
||||||
buttonCreateCruiser.Click += buttonCreate_Click;
|
|
||||||
//
|
|
||||||
// buttonRight
|
|
||||||
//
|
|
||||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonRight.BackgroundImage = Properties.Resources.arrowRight;
|
|
||||||
buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonRight.Location = new Point(955, 678);
|
|
||||||
buttonRight.Name = "buttonRight";
|
|
||||||
buttonRight.Size = new Size(35, 35);
|
|
||||||
buttonRight.TabIndex = 4;
|
|
||||||
buttonRight.UseVisualStyleBackColor = true;
|
|
||||||
buttonRight.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonDown
|
|
||||||
//
|
|
||||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonDown.BackgroundImage = Properties.Resources.arrowDown;
|
|
||||||
buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonDown.Location = new Point(914, 678);
|
|
||||||
buttonDown.Name = "buttonDown";
|
|
||||||
buttonDown.Size = new Size(35, 35);
|
|
||||||
buttonDown.TabIndex = 5;
|
|
||||||
buttonDown.UseVisualStyleBackColor = true;
|
|
||||||
buttonDown.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonUp
|
|
||||||
//
|
|
||||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonUp.BackgroundImage = Properties.Resources.arrowUp;
|
|
||||||
buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonUp.Location = new Point(914, 637);
|
|
||||||
buttonUp.Name = "buttonUp";
|
|
||||||
buttonUp.Size = new Size(35, 35);
|
|
||||||
buttonUp.TabIndex = 6;
|
|
||||||
buttonUp.UseVisualStyleBackColor = true;
|
|
||||||
buttonUp.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonLeft
|
|
||||||
//
|
|
||||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonLeft.BackgroundImage = Properties.Resources.arrowLeft;
|
|
||||||
buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonLeft.Location = new Point(873, 678);
|
|
||||||
buttonLeft.Name = "buttonLeft";
|
|
||||||
buttonLeft.Size = new Size(35, 35);
|
|
||||||
buttonLeft.TabIndex = 7;
|
|
||||||
buttonLeft.UseVisualStyleBackColor = true;
|
|
||||||
buttonLeft.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// FormCruiser
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(1002, 724);
|
|
||||||
Controls.Add(buttonLeft);
|
|
||||||
Controls.Add(buttonUp);
|
|
||||||
Controls.Add(buttonDown);
|
|
||||||
Controls.Add(buttonRight);
|
|
||||||
Controls.Add(buttonCreateCruiser);
|
|
||||||
Controls.Add(pictureBoxCruiser);
|
|
||||||
Name = "FormCruiser";
|
|
||||||
Text = "Круизер";
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCruiser).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private PictureBox pictureBoxCruiser;
|
|
||||||
private Button buttonCreateCruiser;
|
|
||||||
private Button buttonRight;
|
|
||||||
private Button buttonDown;
|
|
||||||
private Button buttonUp;
|
|
||||||
private Button buttonLeft;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
namespace Cruiser;
|
|
||||||
|
|
||||||
public partial class FormCruiser : Form
|
|
||||||
{
|
|
||||||
private DrawingCruiser? _drawingCruiser;
|
|
||||||
|
|
||||||
public FormCruiser()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Draw()
|
|
||||||
{
|
|
||||||
if (_drawingCruiser == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Bitmap bmp = new(pictureBoxCruiser.Width, pictureBoxCruiser.Height);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
_drawingCruiser.DrawTransport(gr);
|
|
||||||
pictureBoxCruiser.Image = bmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonCreate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random random = new();
|
|
||||||
_drawingCruiser = new DrawingCruiser();
|
|
||||||
_drawingCruiser.Init(random.Next(100, 300), random.Next(200, 400),
|
|
||||||
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)));
|
|
||||||
_drawingCruiser.SetPictureSize(pictureBoxCruiser.Width, pictureBoxCruiser.Height);
|
|
||||||
_drawingCruiser.SetPosition(random.Next(pictureBoxCruiser.Right - 200, pictureBoxCruiser.Right - 160), random.Next(pictureBoxCruiser.Bottom - 150, pictureBoxCruiser.Bottom - 100));
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_drawingCruiser == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
switch (name)
|
|
||||||
{
|
|
||||||
case "buttonUp":
|
|
||||||
result = _drawingCruiser.MoveTransport(DirectionType.Up);
|
|
||||||
break;
|
|
||||||
case "buttonDown":
|
|
||||||
result = _drawingCruiser.MoveTransport(DirectionType.Down);
|
|
||||||
break;
|
|
||||||
case "buttonLeft":
|
|
||||||
result = _drawingCruiser.MoveTransport(DirectionType.Left);
|
|
||||||
break;
|
|
||||||
case "buttonRight":
|
|
||||||
result = _drawingCruiser.MoveTransport(DirectionType.Right);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,7 +11,7 @@ namespace Cruiser
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new FormCruiser());
|
Application.Run(new Form1());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
103
Cruiser/Cruiser/Properties/Resources.Designer.cs
generated
103
Cruiser/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 arrowDown {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("arrowDown", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap arrowLeft {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("arrowLeft", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap arrowRight {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("arrowRight", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap arrowUp {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("arrowUp", 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="arrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\arrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="arrowRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\arrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="arrowLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\arrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="arrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\arrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
|
Binary file not shown.
Before Width: | Height: | Size: 7.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 6.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 6.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 7.3 KiB |
Loading…
Reference in New Issue
Block a user