Удаление лишних файлов и редактирование имен

This commit is contained in:
Алина Батылкина 2022-10-04 18:21:50 +04:00
parent fb6cec9d63
commit 2c914942f3
7 changed files with 93 additions and 93 deletions

View File

@ -3,23 +3,23 @@
/// <summary>
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
/// </summary>
internal class DrawningWarmlyShip
internal class DrawningShip
{
public EntityWarmlyShip WarmlyShip { get; private set; }
public EntityShip Ship { get; private set; }
private float _startPosX;
private float _startPosY;
private int? _pictureWidth = null;
private int? _pictureHeight = null;
private readonly int _WarmlyShipWidth = 80;
private readonly int _WarmlyShipHeight = 50;
private readonly int _shipWidth = 80;
private readonly int _shipHeight = 50;
public void Init(int speed, float weight, Color сolor)
{
WarmlyShip = new EntityWarmlyShip();
WarmlyShip.Init(speed, weight, сolor);
Ship = new EntityShip();
Ship.Init(speed, weight, сolor);
}
public void SetPosition(int x, int y, int width, int height)
{
if (x + _WarmlyShipWidth <= width && y + _WarmlyShipHeight <= height && x >= 0 && y >= 0)
if (x + _shipWidth <= width && y + _shipHeight <= height && x >= 0 && y >= 0)
{
_startPosX = x;
_startPosY = y;
@ -37,30 +37,30 @@
{
// вправо
case Direction.Right:
if (_startPosX + _WarmlyShipWidth + WarmlyShip.Step + 60 < _pictureWidth)
if (_startPosX + _shipWidth + Ship.Step + 60 < _pictureWidth)
{
_startPosX += WarmlyShip.Step;
_startPosX += Ship.Step;
}
break;
//влево
case Direction.Left:
if (_startPosX - WarmlyShip.Step > 0)
if (_startPosX - Ship.Step > 0)
{
_startPosX -= WarmlyShip.Step;
_startPosX -= Ship.Step;
}
break;
//вверх
case Direction.Up:
if (_startPosY - WarmlyShip.Step > 0)
if (_startPosY - Ship.Step > 0)
{
_startPosY -= WarmlyShip.Step;
_startPosY -= Ship.Step;
}
break;
//вниз
case Direction.Down:
if (_startPosY + _WarmlyShipHeight + WarmlyShip.Step + 40 < _pictureHeight)
if (_startPosY + _shipHeight + Ship.Step + 40 < _pictureHeight)
{
_startPosY += WarmlyShip.Step;
_startPosY += Ship.Step;
}
break;
}
@ -76,7 +76,7 @@
//выделяем рамкой крышу
Brush br = new SolidBrush(WarmlyShip?.BodyColor ?? Color.Black);
Brush br = new SolidBrush(Ship?.BodyColor ?? Color.Black);
g.FillRectangle(br, _startPosX + 29, _startPosY + 5, 80, 20);
g.DrawRectangle(pen, _startPosX + 29, _startPosY + 5, 80, 20);
//g.DrawLine(pen, _startPosX, _startPosY + 25, _startPosX + 135, _startPosY + 25);
@ -106,19 +106,19 @@
{
_pictureWidth = width;
_pictureHeight = height;
if (_pictureWidth <= _WarmlyShipWidth || _pictureHeight <= _WarmlyShipHeight)
if (_pictureWidth <= _shipWidth || _pictureHeight <= _shipHeight)
{
_pictureWidth = null;
_pictureHeight = null;
return;
}
if (_startPosX + _WarmlyShipWidth > _pictureWidth)
if (_startPosX + _shipWidth > _pictureWidth)
{
_startPosX = _pictureWidth.Value - _WarmlyShipWidth;
_startPosX = _pictureWidth.Value - _shipWidth;
}
if (_startPosY + _WarmlyShipHeight > _pictureHeight)
if (_startPosY + _shipHeight > _pictureHeight)
{
_startPosY = _pictureHeight.Value - _WarmlyShipHeight;
_startPosY = _pictureHeight.Value - _shipHeight;
}
}
}

View File

@ -1,6 +1,6 @@
namespace WarmlyShip
{
internal class EntityWarmlyShip
internal class EntityShip
{
public int Speed { get; private set; }
public float Weight { get; private set; }

View File

@ -1,6 +1,6 @@
namespace WarmlyShip
{
partial class FormWarmlyShip
partial class FormShip
{
/// <summary>
/// Required designer variable.
@ -28,7 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.pictureBoxWarmlyShip = new System.Windows.Forms.PictureBox();
this.pictureBoxShip = new System.Windows.Forms.PictureBox();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusSpeed = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusWeight = new System.Windows.Forms.ToolStripStatusLabel();
@ -38,18 +38,18 @@
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxWarmlyShip)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxShip)).BeginInit();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// pictureBoxWarmlyShip
// pictureBoxShip
//
this.pictureBoxWarmlyShip.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxWarmlyShip.Location = new System.Drawing.Point(0, 0);
this.pictureBoxWarmlyShip.Name = "pictureBoxWarmlyShip";
this.pictureBoxWarmlyShip.Size = new System.Drawing.Size(800, 450);
this.pictureBoxWarmlyShip.TabIndex = 0;
this.pictureBoxWarmlyShip.TabStop = false;
this.pictureBoxShip.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxShip.Location = new System.Drawing.Point(0, 0);
this.pictureBoxShip.Name = "pictureBoxShip";
this.pictureBoxShip.Size = new System.Drawing.Size(800, 450);
this.pictureBoxShip.TabIndex = 0;
this.pictureBoxShip.TabStop = false;
//
// statusStrip1
//
@ -140,7 +140,7 @@
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.buttonMove_Click);
//
// FormWarmlyShip
// FormShip
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
@ -151,10 +151,10 @@
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.pictureBoxWarmlyShip);
this.Name = "FormWarmlyShip";
this.Controls.Add(this.pictureBoxShip);
this.Name = "FormShip";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxWarmlyShip)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxShip)).EndInit();
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
@ -164,7 +164,7 @@
#endregion
private PictureBox pictureBoxWarmlyShip;
private PictureBox pictureBoxShip;
private StatusStrip statusStrip1;
private ToolStripStatusLabel toolStripStatusSpeed;
private ToolStripStatusLabel toolStripStatusWeight;

View File

@ -0,0 +1,55 @@
namespace WarmlyShip
{
public partial class FormShip : Form
{
private DrawningShip _ship;
public FormShip()
{
InitializeComponent();
}
private void Draw()
{
Bitmap bmp = new(pictureBoxShip.Width, pictureBoxShip.Height);
Graphics gr = Graphics.FromImage(bmp);
_ship?.DrawTransport(gr);
pictureBoxShip.Image = bmp;
}
private void buttonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
_ship = new DrawningShip();
_ship.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_ship.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxShip.Width, pictureBoxShip.Height);
toolStripStatusSpeed.Text = $"Ñêîðîñòü: {_ship.Ship.Speed}";
toolStripStatusWeight.Text = $"Âåñ: {_ship.Ship.Weight}";
toolStripStatusColor.Text = $"Öâåò: {_ship.Ship.BodyColor.Name}";
Draw();
}
private void PictureBoxShip_Resize(object sender, EventArgs e)
{
_ship?.ChangeBorders(pictureBoxShip.Width, pictureBoxShip.Height);
Draw();
}
private void buttonMove_Click(object sender, EventArgs e)
{
//ïîëó÷àåì èìÿ êíîïêè
string name = ((Button)sender)?.Name ?? string.Empty;
switch (name)
{
case "buttonUp":
_ship?.MoveTransport(Direction.Up);
break;
case "buttonDown":
_ship?.MoveTransport(Direction.Down);
break;
case "buttonLeft":
_ship?.MoveTransport(Direction.Left);
break;
case "buttonRight":
_ship?.MoveTransport(Direction.Right);
break;
}
Draw();
}
}
}

View File

@ -1,55 +0,0 @@
namespace WarmlyShip
{
public partial class FormWarmlyShip : Form
{
private DrawningWarmlyShip _warmlyship;
public FormWarmlyShip()
{
InitializeComponent();
}
private void Draw()
{
Bitmap bmp = new(pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
Graphics gr = Graphics.FromImage(bmp);
_warmlyship?.DrawTransport(gr);
pictureBoxWarmlyShip.Image = bmp;
}
private void buttonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
_warmlyship = new DrawningWarmlyShip();
_warmlyship.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_warmlyship.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
toolStripStatusSpeed.Text = $"Ñêîðîñòü: {_warmlyship.WarmlyShip.Speed}";
toolStripStatusWeight.Text = $"Âåñ: {_warmlyship.WarmlyShip.Weight}";
toolStripStatusColor.Text = $"Öâåò: {_warmlyship.WarmlyShip.BodyColor.Name}";
Draw();
}
private void PictureBoxCar_Resize(object sender, EventArgs e)
{
_warmlyship?.ChangeBorders(pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
Draw();
}
private void buttonMove_Click(object sender, EventArgs e)
{
//ïîëó÷àåì èìÿ êíîïêè
string name = ((Button)sender)?.Name ?? string.Empty;
switch (name)
{
case "buttonUp":
_warmlyship?.MoveTransport(Direction.Up);
break;
case "buttonDown":
_warmlyship?.MoveTransport(Direction.Down);
break;
case "buttonLeft":
_warmlyship?.MoveTransport(Direction.Left);
break;
case "buttonRight":
_warmlyship?.MoveTransport(Direction.Right);
break;
}
Draw();
}
}
}

View File

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