Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
552b55aeca | |||
8721d19621 | |||
9671af356a | |||
6eb7548f3e | |||
614a721e04 | |||
7e743b4b3b | |||
714420d726 | |||
5db329405b | |||
1dcad5809b | |||
8cdbd27e93 |
@ -6,70 +6,114 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AircraftCarrier
|
namespace AircraftCarrier
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
||||||
|
/// </summary>
|
||||||
internal class DrawingWarship
|
internal class DrawingWarship
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Класс-сущность
|
||||||
|
/// </summary>
|
||||||
public EntityWarship Warship { get; private set; }
|
public EntityWarship Warship { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Левая координата отрисовки военного корабля
|
||||||
|
/// </summary>
|
||||||
private float _startPosX;
|
private float _startPosX;
|
||||||
|
/// <summary>
|
||||||
|
/// Верхняя кооридната отрисовки военного корабля
|
||||||
|
/// </summary>
|
||||||
private float _startPosY;
|
private float _startPosY;
|
||||||
|
/// <summary>
|
||||||
|
/// Ширина окна отрисовки
|
||||||
|
/// </summary>
|
||||||
private int? _pictureWidth = null;
|
private int? _pictureWidth = null;
|
||||||
|
/// <summary>
|
||||||
|
/// Высота окна отрисовки
|
||||||
|
/// </summary>
|
||||||
private int? _pictureHeight = null;
|
private int? _pictureHeight = null;
|
||||||
|
/// <summary>
|
||||||
|
/// Ширина отрисовки военного корабля
|
||||||
|
/// </summary>
|
||||||
private readonly int _warshipWidth = 94;
|
private readonly int _warshipWidth = 94;
|
||||||
|
/// <summary>
|
||||||
|
/// Высота отрисовки военного корабля
|
||||||
|
/// </summary>
|
||||||
private readonly int _warshipHeight = 40;
|
private readonly int _warshipHeight = 40;
|
||||||
|
/// <summary>
|
||||||
|
/// Инициализация свойств
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="speed">Скорость</param>
|
||||||
|
/// <param name="weight">Вес военного корабля</param>
|
||||||
|
/// <param name="bodyColor">Цвет главной палубы</param>
|
||||||
public void Init(int speed, float weight, Color bodyColor)
|
public void Init(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
Warship = new EntityWarship();
|
Warship = new EntityWarship();
|
||||||
Warship.Init(speed, weight, bodyColor);
|
Warship.Init(speed, weight, bodyColor);
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Установка позиции военного корабля
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x"></param>
|
||||||
|
/// <param name="y"></param>
|
||||||
|
/// <param name="width"></param>
|
||||||
|
/// <param name="height"></param>
|
||||||
public void SetPosition(int x, int y, int width, int height)
|
public void SetPosition(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
_startPosX = x; _startPosY = y;
|
if (width >= x + _warshipWidth && height >= y + _warshipHeight && x >= 0 && y >= 0)
|
||||||
_pictureWidth = width; _pictureHeight = height;
|
{
|
||||||
|
_startPosX = x;
|
||||||
|
_startPosY = y;
|
||||||
|
_pictureWidth = width;
|
||||||
|
_pictureHeight = height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Изменение направления пермещения
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="direction">Направление</param>
|
||||||
public void MoveTransport(Direction direction)
|
public void MoveTransport(Direction direction)
|
||||||
{
|
{
|
||||||
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
|
// вправо
|
||||||
case Direction.Right:
|
case Direction.Right:
|
||||||
if (_startPosX + _warshipWidth + Warship.Step < _pictureWidth)
|
if (_startPosX + _warshipWidth + Warship.Step < _pictureWidth)
|
||||||
{
|
{
|
||||||
_startPosX += Warship.Step;
|
_startPosX += Warship.Step;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
//влево
|
||||||
case Direction.Left:
|
case Direction.Left:
|
||||||
if (_startPosX > 0)
|
if(_startPosX - Warship.Step > 0)
|
||||||
{
|
{
|
||||||
_startPosX -= Warship.Step;
|
_startPosX -= Warship.Step;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
//вверх
|
||||||
case Direction.Up:
|
case Direction.Up:
|
||||||
if (_startPosY > 0)
|
if (_startPosY - Warship.Step > 0)
|
||||||
{
|
{
|
||||||
_startPosY -= Warship.Step;
|
_startPosY -= Warship.Step;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
//вниз
|
||||||
case Direction.Down:
|
case Direction.Down:
|
||||||
if (_startPosY + _warshipHeight + Warship.Step < _pictureHeight)
|
if (_startPosY + _warshipHeight + Warship.Step < _pictureHeight)
|
||||||
{
|
{
|
||||||
_startPosY += Warship.Step;
|
_startPosY += Warship.Step;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Отрисовка военного корабля
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g"></param>
|
||||||
public void DrawTransport(Graphics g)
|
public void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
if (_startPosX < 0 || _startPosY < 0
|
if (_startPosX < 0 || _startPosY < 0
|
||||||
@ -102,9 +146,9 @@ namespace AircraftCarrier
|
|||||||
|
|
||||||
//границы мачты
|
//границы мачты
|
||||||
g.DrawEllipse(pen, _startPosX + 59, _startPosY + 13, 15, 15);
|
g.DrawEllipse(pen, _startPosX + 59, _startPosY + 13, 15, 15);
|
||||||
|
|
||||||
//палуба
|
//палуба
|
||||||
g.FillRectangle(brWhite, _startPosX + 44, _startPosY + 10, 10,20);
|
g.FillRectangle(brWhite, _startPosX + 44, _startPosY + 10, 10, 20);
|
||||||
g.FillRectangle(brWhite, _startPosX + 24, _startPosY + 15, 20, 10);
|
g.FillRectangle(brWhite, _startPosX + 24, _startPosY + 15, 20, 10);
|
||||||
|
|
||||||
//границы палуба
|
//границы палуба
|
||||||
@ -113,14 +157,15 @@ namespace AircraftCarrier
|
|||||||
|
|
||||||
//двигатели
|
//двигатели
|
||||||
Brush brBlack = new SolidBrush(Color.Black);
|
Brush brBlack = new SolidBrush(Color.Black);
|
||||||
g.FillRectangle(brBlack, _startPosX, _startPosY + 5, 4,10);
|
g.FillRectangle(brBlack, _startPosX, _startPosY + 5, 4, 10);
|
||||||
g.FillRectangle(brBlack, _startPosX, _startPosY + 23, 4, 10);
|
g.FillRectangle(brBlack, _startPosX, _startPosY + 23, 4, 10);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Смена границ формы отрисовки
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="width">Ширина картинки</param>
|
||||||
|
/// <param name="height">Высота картинки</param>
|
||||||
public void ChangeBorders(int width, int height)
|
public void ChangeBorders(int width, int height)
|
||||||
{
|
{
|
||||||
_pictureWidth = width;
|
_pictureWidth = width;
|
||||||
@ -140,5 +185,6 @@ namespace AircraftCarrier
|
|||||||
_startPosY = _pictureHeight.Value - _warshipHeight;
|
_startPosY = _pictureHeight.Value - _warshipHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,5 @@ namespace AircraftCarrier
|
|||||||
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
|
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
|
||||||
BodyColor = bodyColor;
|
BodyColor = bodyColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,17 +29,17 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.pictureBoxWarship = new System.Windows.Forms.PictureBox();
|
this.pictureBoxWarship = new System.Windows.Forms.PictureBox();
|
||||||
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
this.statusStrip = new System.Windows.Forms.StatusStrip();
|
||||||
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
|
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
|
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
this.buttonCreate = new System.Windows.Forms.Button();
|
this.buttonCreate = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDown = new System.Windows.Forms.Button();
|
||||||
this.buttonUp = new System.Windows.Forms.Button();
|
this.buttonUp = new System.Windows.Forms.Button();
|
||||||
this.buttonLeft = new System.Windows.Forms.Button();
|
this.buttonLeft = new System.Windows.Forms.Button();
|
||||||
this.buttonDawn = new System.Windows.Forms.Button();
|
|
||||||
this.buttonRight = new System.Windows.Forms.Button();
|
this.buttonRight = new System.Windows.Forms.Button();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxWarship)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxWarship)).BeginInit();
|
||||||
this.statusStrip1.SuspendLayout();
|
this.statusStrip.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// pictureBoxWarship
|
// pictureBoxWarship
|
||||||
@ -47,23 +47,22 @@
|
|||||||
this.pictureBoxWarship.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.pictureBoxWarship.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.pictureBoxWarship.Location = new System.Drawing.Point(0, 0);
|
this.pictureBoxWarship.Location = new System.Drawing.Point(0, 0);
|
||||||
this.pictureBoxWarship.Name = "pictureBoxWarship";
|
this.pictureBoxWarship.Name = "pictureBoxWarship";
|
||||||
this.pictureBoxWarship.Size = new System.Drawing.Size(855, 501);
|
this.pictureBoxWarship.Size = new System.Drawing.Size(510, 426);
|
||||||
this.pictureBoxWarship.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
this.pictureBoxWarship.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||||
this.pictureBoxWarship.TabIndex = 0;
|
this.pictureBoxWarship.TabIndex = 0;
|
||||||
this.pictureBoxWarship.TabStop = false;
|
this.pictureBoxWarship.TabStop = false;
|
||||||
this.pictureBoxWarship.Resize += new System.EventHandler(this.pictureBoxWarship_Resize);
|
this.pictureBoxWarship.Resize += new System.EventHandler(this.PictureBoxWarship_Resize);
|
||||||
//
|
//
|
||||||
// statusStrip1
|
// statusStrip
|
||||||
//
|
//
|
||||||
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.toolStripStatusLabelSpeed,
|
this.toolStripStatusLabelSpeed,
|
||||||
this.toolStripStatusLabelWeight,
|
this.toolStripStatusLabelWeight,
|
||||||
this.toolStripStatusLabelBodyColor});
|
this.toolStripStatusLabelBodyColor});
|
||||||
this.statusStrip1.Location = new System.Drawing.Point(0, 501);
|
this.statusStrip.Location = new System.Drawing.Point(0, 426);
|
||||||
this.statusStrip1.Name = "statusStrip1";
|
this.statusStrip.Name = "statusStrip";
|
||||||
this.statusStrip1.Size = new System.Drawing.Size(855, 22);
|
this.statusStrip.Size = new System.Drawing.Size(510, 22);
|
||||||
this.statusStrip1.TabIndex = 1;
|
this.statusStrip.TabIndex = 1;
|
||||||
this.statusStrip1.Text = "statusStrip1";
|
|
||||||
//
|
//
|
||||||
// toolStripStatusLabelSpeed
|
// toolStripStatusLabelSpeed
|
||||||
//
|
//
|
||||||
@ -86,23 +85,36 @@
|
|||||||
// buttonCreate
|
// buttonCreate
|
||||||
//
|
//
|
||||||
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
this.buttonCreate.Location = new System.Drawing.Point(12, 475);
|
this.buttonCreate.Location = new System.Drawing.Point(12, 393);
|
||||||
this.buttonCreate.Name = "buttonCreate";
|
this.buttonCreate.Name = "buttonCreate";
|
||||||
this.buttonCreate.Size = new System.Drawing.Size(75, 23);
|
this.buttonCreate.Size = new System.Drawing.Size(75, 23);
|
||||||
this.buttonCreate.TabIndex = 2;
|
this.buttonCreate.TabIndex = 2;
|
||||||
this.buttonCreate.Text = "Create";
|
this.buttonCreate.Text = "Create";
|
||||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||||
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
|
this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
|
||||||
|
//
|
||||||
|
// buttonDown
|
||||||
|
//
|
||||||
|
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonDown.BackgroundImage = global::AircraftCarrier.Properties.Resources.ArrowDown;
|
||||||
|
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonDown.Location = new System.Drawing.Point(428, 386);
|
||||||
|
this.buttonDown.Name = "buttonDown";
|
||||||
|
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.buttonDown.TabIndex = 3;
|
||||||
|
this.buttonDown.Text = " ";
|
||||||
|
this.buttonDown.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
//
|
//
|
||||||
// buttonUp
|
// buttonUp
|
||||||
//
|
//
|
||||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonUp.BackgroundImage = global::AircraftCarrier.Properties.Resources.ArrowUp;
|
this.buttonUp.BackgroundImage = global::AircraftCarrier.Properties.Resources.ArrowUp;
|
||||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonUp.Location = new System.Drawing.Point(777, 432);
|
this.buttonUp.Location = new System.Drawing.Point(428, 350);
|
||||||
this.buttonUp.Name = "buttonUp";
|
this.buttonUp.Name = "buttonUp";
|
||||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||||
this.buttonUp.TabIndex = 3;
|
this.buttonUp.TabIndex = 4;
|
||||||
this.buttonUp.Text = " ";
|
this.buttonUp.Text = " ";
|
||||||
this.buttonUp.UseVisualStyleBackColor = true;
|
this.buttonUp.UseVisualStyleBackColor = true;
|
||||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
@ -112,33 +124,20 @@
|
|||||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonLeft.BackgroundImage = global::AircraftCarrier.Properties.Resources.ArrowLeft;
|
this.buttonLeft.BackgroundImage = global::AircraftCarrier.Properties.Resources.ArrowLeft;
|
||||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonLeft.Location = new System.Drawing.Point(741, 468);
|
this.buttonLeft.Location = new System.Drawing.Point(392, 386);
|
||||||
this.buttonLeft.Name = "buttonLeft";
|
this.buttonLeft.Name = "buttonLeft";
|
||||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||||
this.buttonLeft.TabIndex = 4;
|
this.buttonLeft.TabIndex = 5;
|
||||||
this.buttonLeft.Text = " ";
|
this.buttonLeft.Text = " ";
|
||||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
//
|
//
|
||||||
// buttonDawn
|
|
||||||
//
|
|
||||||
this.buttonDawn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonDawn.BackgroundImage = global::AircraftCarrier.Properties.Resources.AarrowDown;
|
|
||||||
this.buttonDawn.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonDawn.Location = new System.Drawing.Point(777, 468);
|
|
||||||
this.buttonDawn.Name = "buttonDawn";
|
|
||||||
this.buttonDawn.Size = new System.Drawing.Size(30, 30);
|
|
||||||
this.buttonDawn.TabIndex = 5;
|
|
||||||
this.buttonDawn.Text = " ";
|
|
||||||
this.buttonDawn.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDawn.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonRight
|
// buttonRight
|
||||||
//
|
//
|
||||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonRight.BackgroundImage = global::AircraftCarrier.Properties.Resources.ArrowRight;
|
this.buttonRight.BackgroundImage = global::AircraftCarrier.Properties.Resources.ArrowRight;
|
||||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonRight.Location = new System.Drawing.Point(813, 468);
|
this.buttonRight.Location = new System.Drawing.Point(464, 386);
|
||||||
this.buttonRight.Name = "buttonRight";
|
this.buttonRight.Name = "buttonRight";
|
||||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||||
this.buttonRight.TabIndex = 6;
|
this.buttonRight.TabIndex = 6;
|
||||||
@ -150,19 +149,19 @@
|
|||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(855, 523);
|
this.ClientSize = new System.Drawing.Size(510, 448);
|
||||||
this.Controls.Add(this.buttonRight);
|
this.Controls.Add(this.buttonRight);
|
||||||
this.Controls.Add(this.buttonDawn);
|
|
||||||
this.Controls.Add(this.buttonLeft);
|
this.Controls.Add(this.buttonLeft);
|
||||||
this.Controls.Add(this.buttonUp);
|
this.Controls.Add(this.buttonUp);
|
||||||
|
this.Controls.Add(this.buttonDown);
|
||||||
this.Controls.Add(this.buttonCreate);
|
this.Controls.Add(this.buttonCreate);
|
||||||
this.Controls.Add(this.pictureBoxWarship);
|
this.Controls.Add(this.pictureBoxWarship);
|
||||||
this.Controls.Add(this.statusStrip1);
|
this.Controls.Add(this.statusStrip);
|
||||||
this.Name = "FormWarship";
|
this.Name = "FormWarship";
|
||||||
this.Text = " Warship";
|
this.Text = "Warship";
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxWarship)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxWarship)).EndInit();
|
||||||
this.statusStrip1.ResumeLayout(false);
|
this.statusStrip.ResumeLayout(false);
|
||||||
this.statusStrip1.PerformLayout();
|
this.statusStrip.PerformLayout();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
@ -171,14 +170,14 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private PictureBox pictureBoxWarship;
|
private PictureBox pictureBoxWarship;
|
||||||
private StatusStrip statusStrip1;
|
private StatusStrip statusStrip;
|
||||||
private ToolStripStatusLabel toolStripStatusLabelSpeed;
|
private ToolStripStatusLabel toolStripStatusLabelSpeed;
|
||||||
private ToolStripStatusLabel toolStripStatusLabelWeight;
|
private ToolStripStatusLabel toolStripStatusLabelWeight;
|
||||||
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
|
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
|
||||||
private Button buttonCreate;
|
private Button buttonCreate;
|
||||||
|
private Button buttonDown;
|
||||||
private Button buttonUp;
|
private Button buttonUp;
|
||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
private Button buttonDawn;
|
|
||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,15 +3,13 @@ namespace AircraftCarrier
|
|||||||
public partial class FormWarship : Form
|
public partial class FormWarship : Form
|
||||||
{
|
{
|
||||||
private DrawingWarship _warship;
|
private DrawingWarship _warship;
|
||||||
|
|
||||||
public FormWarship()
|
public FormWarship()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ìåòîä ïðîðèñîâêè ìàøèíû
|
/// Ìåòîä ïðîðèñîâêè âîåííîãî êîðàáëÿ
|
||||||
/// </summary>
|
/// </summary>
|
||||||
///
|
|
||||||
private void Draw()
|
private void Draw()
|
||||||
{
|
{
|
||||||
Bitmap bmp = new(pictureBoxWarship.Width, pictureBoxWarship.Height);
|
Bitmap bmp = new(pictureBoxWarship.Width, pictureBoxWarship.Height);
|
||||||
@ -19,9 +17,13 @@ namespace AircraftCarrier
|
|||||||
_warship?.DrawTransport(gr);
|
_warship?.DrawTransport(gr);
|
||||||
pictureBoxWarship.Image = bmp;
|
pictureBoxWarship.Image = bmp;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
private void buttonCreate_Click(object sender, EventArgs e)
|
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Create"
|
||||||
{
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
_warship = new DrawingWarship();
|
_warship = new DrawingWarship();
|
||||||
_warship.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
_warship.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||||
@ -31,15 +33,9 @@ namespace AircraftCarrier
|
|||||||
toolStripStatusLabelBodyColor.Text = $"Öâåò: {_warship.Warship.BodyColor.Name}";
|
toolStripStatusLabelBodyColor.Text = $"Öâåò: {_warship.Warship.BodyColor.Name}";
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Èçìåíåíèå ðàçìåðîâ ôîðìû
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
//ïîëó÷àåì èìÿ êíîïêè
|
|
||||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
@ -58,7 +54,6 @@ namespace AircraftCarrier
|
|||||||
}
|
}
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Èçìåíåíèå ðàçìåðîâ ôîðìû
|
/// Èçìåíåíèå ðàçìåðîâ ôîðìû
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -66,7 +61,7 @@ namespace AircraftCarrier
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void PictureBoxWarship_Resize(object sender, EventArgs e)
|
private void PictureBoxWarship_Resize(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_warship?.ChangeBorders(pictureBoxWarship.Width, pictureBoxWarship.Height);
|
_warship?.ChangeBorders(pictureBoxWarship.Width,pictureBoxWarship.Height);
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,10 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>59</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
@ -63,9 +63,9 @@ namespace AircraftCarrier.Properties {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static System.Drawing.Bitmap AarrowDown {
|
internal static System.Drawing.Bitmap ArrowDown {
|
||||||
get {
|
get {
|
||||||
object obj = ResourceManager.GetObject("AarrowDown", resourceCulture);
|
object obj = ResourceManager.GetObject("ArrowDown", resourceCulture);
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,45 +99,5 @@ namespace AircraftCarrier.Properties {
|
|||||||
return ((System.Drawing.Bitmap)(obj));
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,20 +118,8 @@
|
|||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
<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">
|
<data name="ArrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\left.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\ArrowDown.png;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.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="down" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="up" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="AarrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\AarrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
</data>
|
||||||
<data name="ArrowLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<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>
|
<value>..\Resources\ArrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Binary file not shown.
Before Width: | Height: | Size: 20 KiB |
Binary file not shown.
Before Width: | Height: | Size: 20 KiB |
Binary file not shown.
Before Width: | Height: | Size: 20 KiB |
Binary file not shown.
Before Width: | Height: | Size: 20 KiB |
Loading…
x
Reference in New Issue
Block a user