Merge pull request 'Markov D.P. LabWork01' (#1) from LabWork01 into master
Reviewed-on: http://student.git.athene.tech/khehelk/PIbd-21_Markov_D.P._ContainerShip_Base/pulls/1
This commit is contained in:
commit
c079f99485
16
ContainerShip/ContainerShip/Direction.cs
Normal file
16
ContainerShip/ContainerShip/Direction.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ContainerShip
|
||||
{
|
||||
internal enum Direction
|
||||
{
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 3,
|
||||
Right = 4
|
||||
}
|
||||
}
|
128
ContainerShip/ContainerShip/DrawingShip.cs
Normal file
128
ContainerShip/ContainerShip/DrawingShip.cs
Normal file
@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ContainerShip
|
||||
{
|
||||
internal class DrawingShip
|
||||
{
|
||||
public EntityShip Ship { get; private set; }
|
||||
private float _startPosX;
|
||||
private float _startPosY;
|
||||
private int? _pictureWidth = null;
|
||||
private int? _pictureHeight = null;
|
||||
|
||||
protected readonly int _shipWidth = 100;
|
||||
protected readonly int _shipHeight = 60;
|
||||
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Ship = new EntityShip();
|
||||
Ship.Init(speed, weight, bodyColor);
|
||||
}
|
||||
|
||||
public void SetPosition(int x, int y, int width, int height)
|
||||
{
|
||||
if (x < 0 || y < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (x + _shipWidth > width || y + _shipHeight > height)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
}
|
||||
|
||||
public void MoveShip(Direction direction)
|
||||
{
|
||||
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
case Direction.Right:
|
||||
if (_startPosX + _shipWidth + Ship.Step < _pictureWidth)
|
||||
{
|
||||
_startPosX += Ship.Step;
|
||||
}
|
||||
break;
|
||||
case Direction.Left:
|
||||
if (_startPosX - Ship.Step > 0)
|
||||
{
|
||||
_startPosX -= Ship.Step;
|
||||
}
|
||||
break;
|
||||
case Direction.Up:
|
||||
if (_startPosY - Ship.Step > 0)
|
||||
{
|
||||
_startPosY -= Ship.Step;
|
||||
}
|
||||
break;
|
||||
case Direction.Down:
|
||||
if (_startPosY + _shipHeight + Ship.Step < _pictureHeight)
|
||||
{
|
||||
_startPosY += Ship.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawTransport(Graphics g)
|
||||
{
|
||||
if (_startPosX < 0 || _startPosY < 0
|
||||
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush brRed = new SolidBrush(Color.Red);
|
||||
Brush brMain = new SolidBrush(Ship?.BodyColor ?? Color.Blue);
|
||||
|
||||
//Границы основания корабля
|
||||
PointF point1 = new PointF(_startPosX, _startPosY+30);
|
||||
PointF point2 = new PointF(_startPosX+100, _startPosY+30);
|
||||
PointF point3 = new PointF(_startPosX + 80, _startPosY + 60);
|
||||
PointF point4 = new PointF(_startPosX + 20, _startPosY + 60);
|
||||
PointF[] shipBorder = new PointF[4] {point1, point2, point3, point4};
|
||||
g.DrawPolygon(pen, shipBorder);
|
||||
//Границы верхней палубы
|
||||
g.DrawRectangle(pen, _startPosX + 20, _startPosY, 60, 30);
|
||||
//Заливка основания корабля
|
||||
g.FillPolygon(brRed, shipBorder);
|
||||
//Заливка верхней палубы
|
||||
g.FillRectangle(brMain, _startPosX + 21, _startPosY + 1, 59, 29);
|
||||
|
||||
|
||||
}
|
||||
public void ChangeBorders(int width, int height)
|
||||
{
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
if (_pictureWidth <= _shipWidth || _pictureHeight <= _shipHeight)
|
||||
{
|
||||
_pictureWidth = null;
|
||||
_pictureHeight = null;
|
||||
return;
|
||||
}
|
||||
if (_startPosX + _shipWidth > _pictureWidth)
|
||||
{
|
||||
_startPosX = _pictureWidth.Value - _shipWidth;
|
||||
}
|
||||
if (_startPosY + _shipHeight > _pictureHeight)
|
||||
{
|
||||
_startPosY = _pictureHeight.Value - _shipHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
25
ContainerShip/ContainerShip/EntityShip.cs
Normal file
25
ContainerShip/ContainerShip/EntityShip.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ContainerShip
|
||||
{
|
||||
internal class EntityShip
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
public float Weight { get; private set; }
|
||||
public Color BodyColor { get; private set; }
|
||||
public int Step => (int)Speed * 100 / (int)Weight;
|
||||
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Random random = new Random();
|
||||
Speed = speed <= 0 ? random.Next(50, 150) : speed;
|
||||
Weight = weight <= 0 ? random.Next(50, 150) : weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
39
ContainerShip/ContainerShip/Form1.Designer.cs
generated
39
ContainerShip/ContainerShip/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
||||
namespace ContainerShip
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
namespace ContainerShip
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,120 +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>
|
||||
</root>
|
180
ContainerShip/ContainerShip/FormShip.Designer.cs
generated
Normal file
180
ContainerShip/ContainerShip/FormShip.Designer.cs
generated
Normal file
@ -0,0 +1,180 @@
|
||||
namespace ContainerShip
|
||||
{
|
||||
partial class FormShip
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormShip));
|
||||
this.pictureBoxShip = new System.Windows.Forms.PictureBox();
|
||||
this.buttonCreate = new System.Windows.Forms.Button();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.statusStrip = new System.Windows.Forms.StatusStrip();
|
||||
this.toolStripStatusSpeed = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxShip)).BeginInit();
|
||||
this.statusStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxShip
|
||||
//
|
||||
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, 428);
|
||||
this.pictureBoxShip.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBoxShip.TabIndex = 3;
|
||||
this.pictureBoxShip.TabStop = false;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
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, 402);
|
||||
this.buttonCreate.Name = "buttonCreate";
|
||||
this.buttonCreate.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCreate.TabIndex = 4;
|
||||
this.buttonCreate.Text = "Создать";
|
||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||
this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonUp.BackgroundImage")));
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonUp.Location = new System.Drawing.Point(722, 359);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonUp.TabIndex = 5;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonRight.BackgroundImage")));
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonRight.Location = new System.Drawing.Point(758, 395);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonRight.TabIndex = 6;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonLeft.BackgroundImage")));
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(686, 395);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonLeft.TabIndex = 7;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonDown.BackgroundImage")));
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonDown.Location = new System.Drawing.Point(722, 395);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonDown.TabIndex = 8;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// statusStrip
|
||||
//
|
||||
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripStatusSpeed,
|
||||
this.toolStripStatusWeight,
|
||||
this.toolStripStatusBodyColor});
|
||||
this.statusStrip.Location = new System.Drawing.Point(0, 428);
|
||||
this.statusStrip.Name = "statusStrip";
|
||||
this.statusStrip.Size = new System.Drawing.Size(800, 22);
|
||||
this.statusStrip.TabIndex = 9;
|
||||
//
|
||||
// toolStripStatusSpeed
|
||||
//
|
||||
this.toolStripStatusSpeed.Name = "toolStripStatusSpeed";
|
||||
this.toolStripStatusSpeed.Size = new System.Drawing.Size(65, 17);
|
||||
this.toolStripStatusSpeed.Text = "Скорость: ";
|
||||
//
|
||||
// toolStripStatusWeight
|
||||
//
|
||||
this.toolStripStatusWeight.Name = "toolStripStatusWeight";
|
||||
this.toolStripStatusWeight.Size = new System.Drawing.Size(32, 17);
|
||||
this.toolStripStatusWeight.Text = "Вес: ";
|
||||
//
|
||||
// toolStripStatusBodyColor
|
||||
//
|
||||
this.toolStripStatusBodyColor.Name = "toolStripStatusBodyColor";
|
||||
this.toolStripStatusBodyColor.Size = new System.Drawing.Size(39, 17);
|
||||
this.toolStripStatusBodyColor.Text = "Цвет: ";
|
||||
//
|
||||
// FormShip
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.buttonDown);
|
||||
this.Controls.Add(this.buttonLeft);
|
||||
this.Controls.Add(this.buttonRight);
|
||||
this.Controls.Add(this.buttonUp);
|
||||
this.Controls.Add(this.buttonCreate);
|
||||
this.Controls.Add(this.pictureBoxShip);
|
||||
this.Controls.Add(this.statusStrip);
|
||||
this.Name = "FormShip";
|
||||
this.Text = "FormShip";
|
||||
this.Resize += new System.EventHandler(this.PictureBoxShip_Resize);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxShip)).EndInit();
|
||||
this.statusStrip.ResumeLayout(false);
|
||||
this.statusStrip.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxShip;
|
||||
private Button buttonCreate;
|
||||
private Button buttonUp;
|
||||
private Button buttonRight;
|
||||
private Button buttonLeft;
|
||||
private Button buttonDown;
|
||||
private StatusStrip statusStrip;
|
||||
private ToolStripStatusLabel toolStripStatusSpeed;
|
||||
private ToolStripStatusLabel toolStripStatusWeight;
|
||||
private ToolStripStatusLabel toolStripStatusBodyColor;
|
||||
}
|
||||
}
|
69
ContainerShip/ContainerShip/FormShip.cs
Normal file
69
ContainerShip/ContainerShip/FormShip.cs
Normal file
@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ContainerShip
|
||||
{
|
||||
public partial class FormShip : Form
|
||||
{
|
||||
private DrawingShip _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 ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_ship?.MoveShip(Direction.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_ship?.MoveShip(Direction.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_ship?.MoveShip(Direction.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_ship?.MoveShip(Direction.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_ship = new DrawingShip();
|
||||
_ship.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256),
|
||||
rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
_ship.SetPosition(rnd.Next(10, 100), rnd.Next(60, 100), pictureBoxShip.Width, pictureBoxShip.Height);
|
||||
toolStripStatusSpeed.Text = $"Скорость: {_ship.Ship.Speed}";
|
||||
toolStripStatusWeight.Text = $"Вес: {_ship.Ship.Weight}";
|
||||
toolStripStatusBodyColor.Text = $"Цвет: {_ship.Ship.BodyColor.Name}";
|
||||
Draw();
|
||||
}
|
||||
private void PictureBoxShip_Resize(object sender, EventArgs e)
|
||||
{
|
||||
_ship?.ChangeBorders(pictureBoxShip.Width, pictureBoxShip.Height);
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
112
ContainerShip/ContainerShip/FormShip.resx
Normal file
112
ContainerShip/ContainerShip/FormShip.resx
Normal file
@ -0,0 +1,112 @@
|
||||
<root>
|
||||
<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.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="buttonUp.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAAEMAAABHCAIAAADTOW0yAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vgAADr4B6kKxwAAAAVVJREFUaEPtz0ESgzAMQ9He/9J08zsDNECUWMVl/HYtsWS/lqeoS/KpS/q8Pvjt
|
||||
ZOzgiA/+tXEVsP4W3zws6SzewguD+GhWPsa7aMG5LHuF16EiQ1mzDzNxwhJZUMFkkJg4VtMxHyEgi6VG
|
||||
kTJtNoh15pA1ZyqFRSKQOGE8ghXikDtqcJ7yaKQPGRmm1oMOnTxJoRNNIm2MKj/6FMIMJb9Ca7feAeJ/
|
||||
i+4+Xa8JvgMbdLh+SuR92OPKxTvC7sY2p84eEZMDOx07fEFAJmx2oP2Z0XzYr6XxjaGs2PLL/gPPc2PX
|
||||
rc2/PPwHbLxSl9yNjVf2f/EwN3bdav97jjwPOnR1iQ0durrEhg5dXWJDh64usaFDV5fY0KGrS2zo0NUl
|
||||
NnTo6hIbOnR1iQ0durrEhg5dXWJDh64usaFDNzhJbTTSh0wNp1KX5FOX5FOX5FOX5POUS5blDVXxX38K
|
||||
WOldAAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
<data name="buttonRight.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAAEcAAABDCAYAAADOIRgJAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vQAADr0BR/uQrQAAAStJREFUeF7t0NkKwzAMRNH8/0+nHSjFBFvxIsvaDsyrsO91p6aMQ8g4hIxDUBnn
|
||||
uq7/TlIXpwxzOpCJONgJZuJg0kzFwSSZi4NJMRkHk2A2Drab6TjYTubjYLu4iIPt4CYOxs1VHIzT0LXa
|
||||
YzSOS/el2iM0j4PbONgq13GwFe7jYLNCxMFmhImDjQoVBxsRLg7WK2QcrEfYONib0HEwSvg4WEvG+a0m
|
||||
4xR7yjjFnjJOsaeM81tNxvmuJXwcSug4b8LG6REyTq9wcUaEijMqTJwZIeLMch9nhes4q9zG4TB0pfYI
|
||||
jePCd4lJ7bMj4+QqDjc3cXZwEWcX83F2Mh1nN7NxJJiMI8VcHEmm4kgzE+cEE3FOURcHNIQBlXG0yDiE
|
||||
jEPIOISMQ8g4Tff9AfqQ4vhbQUgmAAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
<data name="buttonLeft.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAAEcAAABDCAYAAADOIRgJAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vQAADr0BR/uQrQAAAaVJREFUeF7tkEFuxDAMA/P/T6f1YYtgO1HoxHYowwPMTZAobvvilFVOwConYJUT
|
||||
sMoJWOUEvFrOtm1/OvJaqmMxrgW9koiKKboxPBGV8tGNoYmokKNuDEtEZXzrxpBEVATpRvdEVMKZbnRN
|
||||
RAVEutEtET1/pRtdEtHjim40T0RPq7rRNBE9XKMbzRLRs47W0KQcCuGsyuNy6Li7Ko/KocMZVLldDh3N
|
||||
osqtcuhgJlWqy6Fj2VSpKocOZVRFnqQjWVWRJulAZlUuJ2l5dlXCSVo8gyqnk7R0FlVwkhbOpMq/SVo2
|
||||
myqrnIBVTgBO0sKZVDmdpKWzqBJO0uIZVLmcpOXZVZEm6UBmVeRJOpJVFX3yFzqUUZWqcgp0LJsq1eUU
|
||||
6GAmVW6VU6CjWVS5XU6BDmdQ5VE5BTrursrjcgoUwFmVJuUUKISjNTQrp0BhanSjeSJ6WtWNLonocUU3
|
||||
uiWi5690o2siKiDSje6JqIQz3RiSiIog3RiWiMr41o2hiaiQo24MT0SlfHTjlURUTNGN1xKtci5wLqbg
|
||||
mcqEVU7AKidglXPKvv8AlW/i+GiZZt4AAAAASUVORK5CYII=
|
||||
</value>
|
||||
</data>
|
||||
<data name="buttonDown.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAAEMAAABHCAYAAABcW/plAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vQAADr0BR/uQrQAAAVdJREFUeF7t0MsOgzAQQ1H+/6epvGhlVQYSMjMJyEfyNo+77fbjGMQxiGMQxyCO
|
||||
QRyDOAZxDOIYJDzGtm3lixIaQz20ahEcgzgGcQziGMQxiGMQxyCOQRyDOAZxDOIYxDGIYxDHII5BHIM4
|
||||
BnEM4hjEMYhjEMcgjkFOT1GXvmXKYQx1wNv2zzGIY5DDGKAOeMuU0xigDnr6jlzGAHXgU3emKQaog5+2
|
||||
K80xQF3wlLXoigHqotXXqjsGqAtXXY9bMUBdvNp63Y4B6gGr7I6hGKAeMnt3DccA9aBZGxESA9TDqjcq
|
||||
LAaoB1YtQmgMUA/NXpTwGKAenLVIKTFAPTx60dJigPpA1DKkxgD1kdFlSY8B6kN3l6kkBqiP9S5bWQxQ
|
||||
H2xdhdIYoD56tSrlMUB9+GiVpsQA9fH/VZsWA1SA72aYGgNWCQHTY8AKIWCJGKtwDOIYxDF+9v0DSS3i
|
||||
+O80JVAAAAAASUVORK5CYII=
|
||||
</value>
|
||||
</data>
|
||||
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -11,7 +11,7 @@ namespace ContainerShip
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
Application.Run(new FormShip());
|
||||
}
|
||||
}
|
||||
}
|
BIN
ContainerShip/ContainerShip/img/ArrowDown.png
Normal file
BIN
ContainerShip/ContainerShip/img/ArrowDown.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 478 B |
BIN
ContainerShip/ContainerShip/img/ArrowLeft.png
Normal file
BIN
ContainerShip/ContainerShip/img/ArrowLeft.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 472 B |
BIN
ContainerShip/ContainerShip/img/ArrowRight.png
Normal file
BIN
ContainerShip/ContainerShip/img/ArrowRight.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 473 B |
BIN
ContainerShip/ContainerShip/img/ArrowUp.png
Normal file
BIN
ContainerShip/ContainerShip/img/ArrowUp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 448 B |
BIN
ContainerShip/ContainerShip/img/Arrows1_right-13-512.webp
Normal file
BIN
ContainerShip/ContainerShip/img/Arrows1_right-13-512.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
Loading…
Reference in New Issue
Block a user