1 лаба
This commit is contained in:
parent
0ec2965ca6
commit
ad1b457f40
50
Cruiser/Cruiser/Cruiser.cs
Normal file
50
Cruiser/Cruiser/Cruiser.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Cruiser
|
||||||
|
{
|
||||||
|
public class Cruiser
|
||||||
|
{
|
||||||
|
|
||||||
|
public int Speed { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public double Weight { get; private set; }
|
||||||
|
|
||||||
|
public Color BodyColor { get; private set; }
|
||||||
|
|
||||||
|
public Color AdditionalColor { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
public bool Headlights { get; private set; }
|
||||||
|
public bool HelicopterPad { get; private set; }
|
||||||
|
|
||||||
|
public bool Coating { get; private set; }
|
||||||
|
public double Step => (double)Speed * 100 / Weight;
|
||||||
|
|
||||||
|
/// <param name="speed">Скорость</param>
|
||||||
|
/// <param name="weight">Вес автомобиля</param>
|
||||||
|
/// <param name="bodyColor">Основной цвет</param>
|
||||||
|
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||||
|
/// <param name="headlights">Признак наличия передних фар</param>
|
||||||
|
/// <param name="helicopterPad">Признак наличия площадки для вертолета</param>
|
||||||
|
/// <param name="coating">Признак наличия покрытия</param>
|
||||||
|
public void Init(int speed, double weight, Color bodyColor, Color
|
||||||
|
additionalColor, bool headlights, bool helicopterPad, bool coating)
|
||||||
|
{
|
||||||
|
Speed = speed;
|
||||||
|
Weight = weight;
|
||||||
|
BodyColor = bodyColor;
|
||||||
|
AdditionalColor = additionalColor;
|
||||||
|
|
||||||
|
Headlights = headlights;
|
||||||
|
HelicopterPad = helicopterPad;
|
||||||
|
Coating = coating;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -8,4 +8,19 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="Properties\Resources.Designer.cs">
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Update="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
30
Cruiser/Cruiser/Direction.cs
Normal file
30
Cruiser/Cruiser/Direction.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Cruiser
|
||||||
|
{
|
||||||
|
public enum Direction
|
||||||
|
{
|
||||||
|
/// Вверх
|
||||||
|
|
||||||
|
/// </summary>
|
||||||
|
Up = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// Вниз
|
||||||
|
/// </summary>
|
||||||
|
Down = 2,
|
||||||
|
/// <summary>
|
||||||
|
/// Влево
|
||||||
|
/// </summary>
|
||||||
|
Left = 3,
|
||||||
|
/// <summary>
|
||||||
|
/// Вправо
|
||||||
|
/// </summary>
|
||||||
|
Right = 4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
200
Cruiser/Cruiser/DrawningCruiser.cs
Normal file
200
Cruiser/Cruiser/DrawningCruiser.cs
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Cruiser
|
||||||
|
{
|
||||||
|
public class DrawningCruiser
|
||||||
|
{
|
||||||
|
|
||||||
|
public Cruiser? Cruiser { get; private set; }
|
||||||
|
|
||||||
|
private int _pictureWidth;
|
||||||
|
|
||||||
|
private int _pictureHeight;
|
||||||
|
|
||||||
|
private int _startPosX;
|
||||||
|
|
||||||
|
private int _startPosY;
|
||||||
|
|
||||||
|
private readonly int _cruiserWidth = 150;
|
||||||
|
|
||||||
|
|
||||||
|
private readonly int _cruiserHeight = 50;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <param name="speed">Скорость</param>
|
||||||
|
/// <param name="weight">Вес</param>
|
||||||
|
/// <param name="bodyColor">Цвет кузова</param>
|
||||||
|
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||||
|
/// <param name="headlights">Признак наличия фар</param>
|
||||||
|
/// <param name="helicopterPad">Признак наличия антикрыла</param>
|
||||||
|
/// <param name="coating">Признак наличия гоночной полосы</param>
|
||||||
|
/// <param name="width">Ширина картинки</param>
|
||||||
|
/// <param name="height">Высота картинки</param>
|
||||||
|
/// <returns>true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах</returns>
|
||||||
|
|
||||||
|
public bool Init(int speed, double weight, Color bodyColor, Color
|
||||||
|
additionalColor, bool headlights, bool helicopterPad, bool coating, int width, int height)
|
||||||
|
{
|
||||||
|
|
||||||
|
_pictureWidth = width;
|
||||||
|
_pictureHeight = height;
|
||||||
|
if (_pictureHeight > _cruiserWidth && _pictureWidth > _cruiserHeight)
|
||||||
|
{
|
||||||
|
Cruiser = new Cruiser();
|
||||||
|
Cruiser.Init(speed, weight, bodyColor, additionalColor,
|
||||||
|
headlights, helicopterPad, coating);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <param name="x">Координата X</param>
|
||||||
|
/// <param name="y">Координата Y</param>
|
||||||
|
public void SetPosition(int x, int y)
|
||||||
|
{
|
||||||
|
if (Cruiser == null) return;
|
||||||
|
while (x + _cruiserWidth > _pictureWidth)
|
||||||
|
{
|
||||||
|
x -= (int)Cruiser.Step;
|
||||||
|
}
|
||||||
|
while (x < 0)
|
||||||
|
{
|
||||||
|
x += (int)Cruiser.Step;
|
||||||
|
}
|
||||||
|
while (y + _cruiserHeight > _pictureHeight)
|
||||||
|
{
|
||||||
|
y -= (int)Cruiser.Step;
|
||||||
|
}
|
||||||
|
while (y < 0)
|
||||||
|
{
|
||||||
|
y += (int)Cruiser.Step;
|
||||||
|
}
|
||||||
|
|
||||||
|
_startPosX = x;
|
||||||
|
_startPosY = y;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <param name="direction">Направление</param>
|
||||||
|
public void MoveTransport(Direction direction)
|
||||||
|
{
|
||||||
|
if (Cruiser == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
|
||||||
|
case Direction.Left:
|
||||||
|
if (_startPosX - Cruiser.Step > 0)
|
||||||
|
{
|
||||||
|
_startPosX -= (int)Cruiser.Step;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Direction.Up:
|
||||||
|
if (_startPosY - Cruiser.Step > 0)
|
||||||
|
{
|
||||||
|
_startPosY -= (int)Cruiser.Step;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Direction.Right:
|
||||||
|
if (_startPosX + Cruiser.Step + _cruiserWidth < _pictureWidth)
|
||||||
|
{
|
||||||
|
_startPosX += (int)Cruiser.Step;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Direction.Down:
|
||||||
|
if (_startPosY + Cruiser.Step + _cruiserHeight < _pictureHeight)
|
||||||
|
{
|
||||||
|
_startPosY += (int)Cruiser.Step;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <param name="g"></param>
|
||||||
|
public void DrawTransport(Graphics g)
|
||||||
|
{
|
||||||
|
if (Cruiser == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Pen pen = new(Color.Black);
|
||||||
|
Brush additionalBrush = new
|
||||||
|
SolidBrush(Cruiser.AdditionalColor);
|
||||||
|
|
||||||
|
|
||||||
|
//границы автомобиля
|
||||||
|
|
||||||
|
|
||||||
|
g.DrawEllipse(pen, _startPosX + 15, _startPosY + 5, 20, 20);
|
||||||
|
g.DrawEllipse(pen, _startPosX + 15, _startPosY + 35, 20, 20);
|
||||||
|
g.DrawRectangle(pen, _startPosX + 9, _startPosY + 15, 10, 30);
|
||||||
|
g.DrawRectangle(pen, _startPosX + 90, _startPosY + 15, 10,
|
||||||
|
30);
|
||||||
|
g.DrawRectangle(pen, _startPosX + 20, _startPosY + 4, 70, 52);
|
||||||
|
|
||||||
|
//если есть доп.фонари
|
||||||
|
if (Cruiser.Headlights)
|
||||||
|
{
|
||||||
|
|
||||||
|
Brush brYellow = new SolidBrush(Color.Yellow);
|
||||||
|
g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 5, 20,
|
||||||
|
20);
|
||||||
|
g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 35, 20,
|
||||||
|
20);
|
||||||
|
}
|
||||||
|
//основание лодки!!!
|
||||||
|
Brush br = new SolidBrush(Cruiser.BodyColor);
|
||||||
|
g.FillRectangle(br, _startPosX + 10, _startPosY + 15, 10, 30);
|
||||||
|
g.FillRectangle(br, _startPosX + 90, _startPosY + 15, 10, 30);
|
||||||
|
g.FillRectangle(br, _startPosX + 20, _startPosY + 5, 70, 50);
|
||||||
|
Point[] points = new Point[3];// нос лодки
|
||||||
|
points[0] = new Point(_startPosX + 100, _startPosY + 5);
|
||||||
|
points[1] = new Point(_startPosX + 100, _startPosY + 55);
|
||||||
|
points[2] = new Point(_startPosX + 100 + 50, _startPosY + 50 / 2);
|
||||||
|
g.FillPolygon(Brushes.Pink, points);
|
||||||
|
//границы носа лодки
|
||||||
|
Point[] points1 = new Point[3];// нос лодки
|
||||||
|
points1[0] = new Point(_startPosX + 100, _startPosY + 5);
|
||||||
|
points1[1] = new Point(_startPosX + 100, _startPosY + 55);
|
||||||
|
points1[2] = new Point(_startPosX + 100 + 50, _startPosY + 50 / 2);
|
||||||
|
g.DrawPolygon(pen, points1);
|
||||||
|
g.FillRectangle(Brushes.Black, _startPosX + 5, _startPosY + 15, 10, 10);
|
||||||
|
g.FillRectangle(Brushes.Black, _startPosX + 5, _startPosY + 35, 10, 10);
|
||||||
|
|
||||||
|
//если есть ракетные шахты, добавить условие
|
||||||
|
g.DrawRectangle(Pens.Black, _startPosX + 35,
|
||||||
|
_startPosY + 23, 15, 15);
|
||||||
|
g.DrawRectangle(Pens.Black, _startPosX + 50,
|
||||||
|
_startPosY + 19, 30, 25);
|
||||||
|
|
||||||
|
if (Cruiser.HelicopterPad)
|
||||||
|
{
|
||||||
|
//если есть площадка под вертолет
|
||||||
|
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 20, 20, 20);
|
||||||
|
}
|
||||||
|
if (Cruiser.Coating)
|
||||||
|
{
|
||||||
|
//если есть спец покрытие для площадки под вертолет
|
||||||
|
g.FillEllipse(Brushes.Red, _startPosX + 90, _startPosY + 20, 20, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
171
Cruiser/Cruiser/Form1.Designer.cs
generated
171
Cruiser/Cruiser/Form1.Designer.cs
generated
@ -1,6 +1,6 @@
|
|||||||
namespace Cruiser
|
namespace Cruiser
|
||||||
{
|
{
|
||||||
partial class Form1
|
partial class CruiserForm
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
@ -11,14 +11,7 @@
|
|||||||
/// Clean up any resources being used.
|
/// Clean up any resources being used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
/// <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
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
@ -29,6 +22,13 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.button1 = new System.Windows.Forms.Button();
|
this.button1 = new System.Windows.Forms.Button();
|
||||||
|
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||||
|
this.buttonDown = new System.Windows.Forms.Button();
|
||||||
|
this.buttonLeft = new System.Windows.Forms.Button();
|
||||||
|
this.buttonRight = new System.Windows.Forms.Button();
|
||||||
|
this.buttonUp = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCreate = new System.Windows.Forms.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// button1
|
// button1
|
||||||
@ -40,20 +40,155 @@
|
|||||||
this.button1.Text = "button1";
|
this.button1.Text = "button1";
|
||||||
this.button1.UseVisualStyleBackColor = true;
|
this.button1.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// Form1
|
// pictureBox1
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
this.pictureBox1.Name = "pictureBox1";
|
||||||
this.Controls.Add(this.button1);
|
this.pictureBox1.Size = new System.Drawing.Size(667, 358);
|
||||||
this.Name = "Form1";
|
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||||
this.Text = "Form1";
|
this.pictureBox1.TabIndex = 0;
|
||||||
|
this.pictureBox1.TabStop = false;
|
||||||
|
//
|
||||||
|
// buttonDown
|
||||||
|
//
|
||||||
|
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonDown.BackgroundImage = global::Cruiser.Properties.Resources.вниз;
|
||||||
|
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||||
|
this.buttonDown.Location = new System.Drawing.Point(543, 306);
|
||||||
|
this.buttonDown.Name = "buttonDown";
|
||||||
|
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.buttonDown.TabIndex = 1;
|
||||||
|
this.buttonDown.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDown.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 = global::Cruiser.Properties.Resources.влево;
|
||||||
|
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||||
|
this.buttonLeft.Location = new System.Drawing.Point(517, 306);
|
||||||
|
this.buttonLeft.Name = "buttonLeft";
|
||||||
|
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.buttonLeft.TabIndex = 2;
|
||||||
|
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonLeft.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 = global::Cruiser.Properties.Resources.вправо;
|
||||||
|
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||||
|
this.buttonRight.Location = new System.Drawing.Point(567, 306);
|
||||||
|
this.buttonRight.Name = "buttonRight";
|
||||||
|
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.buttonRight.TabIndex = 3;
|
||||||
|
this.buttonRight.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// buttonUp
|
||||||
|
//
|
||||||
|
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonUp.BackgroundImage = global::Cruiser.Properties.Resources.вверх;
|
||||||
|
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||||
|
this.buttonUp.Location = new System.Drawing.Point(543, 284);
|
||||||
|
this.buttonUp.Name = "buttonUp";
|
||||||
|
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.buttonUp.TabIndex = 4;
|
||||||
|
this.buttonUp.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// 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(36, 302);
|
||||||
|
this.buttonCreate.Name = "buttonCreate";
|
||||||
|
this.buttonCreate.Size = new System.Drawing.Size(112, 34);
|
||||||
|
this.buttonCreate.TabIndex = 5;
|
||||||
|
this.buttonCreate.Text = "Создать";
|
||||||
|
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCreate.Click += new System.EventHandler(this.ButtonCreateSportCar_Click);
|
||||||
|
//
|
||||||
|
// CruiserForm
|
||||||
|
//
|
||||||
|
this.ClientSize = new System.Drawing.Size(667, 358);
|
||||||
|
this.Controls.Add(this.buttonCreate);
|
||||||
|
this.Controls.Add(this.buttonUp);
|
||||||
|
this.Controls.Add(this.buttonRight);
|
||||||
|
this.Controls.Add(this.buttonLeft);
|
||||||
|
this.Controls.Add(this.buttonDown);
|
||||||
|
this.Controls.Add(this.pictureBox1);
|
||||||
|
this.Name = "CruiserForm";
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonCreateSportCar_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Random random = new();
|
||||||
|
_drawningCruiser = new DrawningCruiser();
|
||||||
|
_drawningCruiser.Init(random.Next(100, 300),
|
||||||
|
random.Next(1000, 3000),
|
||||||
|
Color.FromArgb(random.Next(0, 256), random.Next(0, 256),
|
||||||
|
random.Next(0, 256)),
|
||||||
|
Color.FromArgb(random.Next(0, 256), random.Next(0, 256),
|
||||||
|
random.Next(0, 256)),
|
||||||
|
Convert.ToBoolean(random.Next(0, 2)),
|
||||||
|
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), pictureBox1.Width, pictureBox1.Height);
|
||||||
|
_drawningCruiser.SetPosition(random.Next(10, 100),
|
||||||
|
random.Next(10, 100));
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_drawningCruiser == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case "buttonUp":
|
||||||
|
_drawningCruiser.MoveTransport(Direction.Up);
|
||||||
|
break;
|
||||||
|
case "buttonDown":
|
||||||
|
_drawningCruiser.MoveTransport(Direction.Down);
|
||||||
|
break;
|
||||||
|
case "buttonLeft":
|
||||||
|
_drawningCruiser.MoveTransport(Direction.Left);
|
||||||
|
break;
|
||||||
|
case "buttonRight":
|
||||||
|
_drawningCruiser.MoveTransport(Direction.Right);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button button1;
|
|
||||||
|
private void Draw()
|
||||||
|
{
|
||||||
|
if (_drawningCruiser == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Bitmap bmp = new(pictureBox1.Width,
|
||||||
|
pictureBox1.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_drawningCruiser.DrawTransport(gr);
|
||||||
|
pictureBox1.Image = bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button button1;
|
||||||
|
private PictureBox pictureBox1;
|
||||||
|
private Button buttonDown;
|
||||||
|
private Button buttonLeft;
|
||||||
|
private Button buttonRight;
|
||||||
|
private Button buttonUp;
|
||||||
|
private Button buttonCreate;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,10 +1,19 @@
|
|||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Cruiser
|
namespace Cruiser
|
||||||
{
|
{
|
||||||
public partial class Form1 : Form
|
|
||||||
|
public partial class CruiserForm : Form
|
||||||
{
|
{
|
||||||
public Form1()
|
private DrawningCruiser? _drawningCruiser;
|
||||||
|
public CruiserForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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 Form1());
|
Application.Run(new CruiserForm());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
103
Cruiser/Cruiser/Properties/Resources.Designer.cs
generated
Normal file
103
Cruiser/Cruiser/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <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 вверх {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("вверх", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap влево {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("влево", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap вниз {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("вниз", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap вправо {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("вправо", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
133
Cruiser/Cruiser/Properties/Resources.resx
Normal file
133
Cruiser/Cruiser/Properties/Resources.resx
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
<?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="вниз" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\вниз.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="влево" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\влево.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="вверх" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\вверх.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="вправо" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\вправо.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
BIN
Cruiser/Cruiser/Resources/вверх.jpg
Normal file
BIN
Cruiser/Cruiser/Resources/вверх.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
BIN
Cruiser/Cruiser/Resources/влево.png
Normal file
BIN
Cruiser/Cruiser/Resources/влево.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
BIN
Cruiser/Cruiser/Resources/вниз.png
Normal file
BIN
Cruiser/Cruiser/Resources/вниз.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
BIN
Cruiser/Cruiser/Resources/вправо.png
Normal file
BIN
Cruiser/Cruiser/Resources/вправо.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
Loading…
x
Reference in New Issue
Block a user