Лабораторная работа Hard №1
16
ProjectAirBomberHard/ProjectAirBomberHard/DirectionType.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAirBomberHard
|
||||
{
|
||||
public enum DirectionType
|
||||
{
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 3,
|
||||
Right = 4
|
||||
}
|
||||
}
|
195
ProjectAirBomberHard/ProjectAirBomberHard/DrawningAirBomber.cs
Normal file
@ -0,0 +1,195 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAirBomberHard
|
||||
{
|
||||
public class DrawningAirBomber
|
||||
{
|
||||
public EntityAirBomber? EntityAirBomber { get; private set; }
|
||||
private int _pictureWidth;
|
||||
private int _pictureHeight;
|
||||
private int _startPosX;
|
||||
private int _startPosY;
|
||||
private readonly int _bomberWidth = 160;
|
||||
private readonly int _bomberHeight = 118;
|
||||
private DrawningEngines drawningEngines;
|
||||
|
||||
public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bombs, bool fuelTanks, int engines, int width, int height)
|
||||
{
|
||||
if (width < _bomberWidth || height < _bomberHeight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
EntityAirBomber = new EntityAirBomber();
|
||||
EntityAirBomber.Init(speed, weight, bodyColor, additionalColor, bombs, fuelTanks, engines);
|
||||
|
||||
drawningEngines = new DrawningEngines();
|
||||
drawningEngines.SetAmount(engines);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (x < 0 || x + _bomberWidth > _pictureWidth)
|
||||
{
|
||||
x = _pictureWidth - _bomberWidth;
|
||||
}
|
||||
|
||||
if (y < 0 || y + _bomberWidth > _pictureHeight)
|
||||
{
|
||||
y = _pictureHeight - _bomberHeight;
|
||||
}
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
public void MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (EntityAirBomber == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
case DirectionType.Left:
|
||||
if (_startPosX - EntityAirBomber.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityAirBomber.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Up:
|
||||
if (_startPosY - EntityAirBomber.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityAirBomber.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Right:
|
||||
if (_startPosX + EntityAirBomber.Step + _bomberWidth < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityAirBomber.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Down:
|
||||
if (_startPosY + EntityAirBomber.Step + _bomberHeight < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityAirBomber.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void DrawBomber(Graphics g)
|
||||
{
|
||||
if (EntityAirBomber == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new SolidBrush(EntityAirBomber.AdditionalColor);
|
||||
Brush bodyColor = new SolidBrush(EntityAirBomber.BodyColor);
|
||||
Brush wingsColor = new SolidBrush(Color.DeepPink);
|
||||
if (EntityAirBomber.Bombs)
|
||||
{
|
||||
g.FillEllipse(additionalBrush, _startPosX + 140, _startPosY + 50, 15, 15);
|
||||
g.DrawEllipse(pen, _startPosX + 140, _startPosY + 50, 15, 15);
|
||||
g.FillEllipse(additionalBrush, _startPosX + 140, _startPosY + 30, 15, 15);
|
||||
g.DrawEllipse(pen, _startPosX + 140, _startPosY + 30, 15, 15);
|
||||
g.FillEllipse(additionalBrush, _startPosX + 140, _startPosY + 70, 15, 15);
|
||||
g.DrawEllipse(pen, _startPosX + 140, _startPosY + 70, 15, 15);
|
||||
}
|
||||
g.FillPolygon(additionalBrush, new Point[] //nose
|
||||
{
|
||||
new Point(_startPosX + 19, _startPosY + 50),
|
||||
new Point(_startPosX + 19, _startPosY + 69),
|
||||
new Point(_startPosX + 1, _startPosY + 59),
|
||||
}
|
||||
);
|
||||
g.FillRectangle(bodyColor, _startPosX + 20, _startPosY + 50, 120, 20); //body
|
||||
g.FillPolygon(additionalBrush, new Point[] //up left wing
|
||||
{
|
||||
new Point(_startPosX + 36, _startPosY + 49),
|
||||
new Point(_startPosX + 36, _startPosY + 1),
|
||||
new Point(_startPosX + 45, _startPosY + 1),
|
||||
new Point(_startPosX + 55, _startPosY + 49),
|
||||
}
|
||||
);
|
||||
g.FillPolygon(additionalBrush, new Point[] //down left wing
|
||||
{
|
||||
new Point(_startPosX + 36, _startPosY + 71),
|
||||
new Point(_startPosX + 36, _startPosY + 116),
|
||||
new Point(_startPosX + 45, _startPosY + 116),
|
||||
new Point(_startPosX + 54, _startPosY + 71),
|
||||
}
|
||||
);
|
||||
g.FillPolygon(wingsColor, new Point[] //up right wing
|
||||
{
|
||||
new Point(_startPosX + 120, _startPosY + 49),
|
||||
new Point(_startPosX + 120, _startPosY + 42),
|
||||
new Point(_startPosX + 140, _startPosY + 7),
|
||||
new Point(_startPosX + 140, _startPosY + 49),
|
||||
}
|
||||
);
|
||||
g.FillPolygon(wingsColor, new Point[] //down right wing
|
||||
{
|
||||
new Point(_startPosX + 120, _startPosY + 70),
|
||||
new Point(_startPosX + 120, _startPosY + 77),
|
||||
new Point(_startPosX + 140, _startPosY + 112),
|
||||
new Point(_startPosX + 140, _startPosY + 70),
|
||||
}
|
||||
);
|
||||
|
||||
g.DrawPolygon(pen, new Point[] //nose
|
||||
{
|
||||
new Point(_startPosX + 20, _startPosY + 49),
|
||||
new Point(_startPosX + 20, _startPosY + 70),
|
||||
new Point(_startPosX, _startPosY + 59),
|
||||
}
|
||||
);
|
||||
g.DrawRectangle(pen, _startPosX + 19, _startPosY + 49, 121, 21); //body
|
||||
g.DrawPolygon(pen, new Point[] //up left wing
|
||||
{
|
||||
new Point(_startPosX + 35, _startPosY + 49),
|
||||
new Point(_startPosX + 35, _startPosY),
|
||||
new Point(_startPosX + 45, _startPosY),
|
||||
new Point(_startPosX + 55, _startPosY + 49),
|
||||
}
|
||||
);
|
||||
g.DrawPolygon(pen, new Point[] //down left wing
|
||||
{
|
||||
new Point(_startPosX + 36, _startPosY + 71),
|
||||
new Point(_startPosX + 36, _startPosY + 116),
|
||||
new Point(_startPosX + 45, _startPosY + 116),
|
||||
new Point(_startPosX + 54, _startPosY + 71),
|
||||
}
|
||||
);
|
||||
g.DrawPolygon(pen, new Point[] //up right wing
|
||||
{
|
||||
new Point(_startPosX + 120, _startPosY + 49),
|
||||
new Point(_startPosX + 120, _startPosY + 42),
|
||||
new Point(_startPosX + 140, _startPosY + 7),
|
||||
new Point(_startPosX + 140, _startPosY + 49),
|
||||
}
|
||||
);
|
||||
g.DrawPolygon(pen, new Point[] //down right wing
|
||||
{
|
||||
new Point(_startPosX + 120, _startPosY + 70),
|
||||
new Point(_startPosX + 120, _startPosY + 77),
|
||||
new Point(_startPosX + 140, _startPosY + 112),
|
||||
new Point(_startPosX + 140, _startPosY + 70),
|
||||
}
|
||||
);
|
||||
if (EntityAirBomber.FuelTanks)
|
||||
{
|
||||
g.FillRectangle(additionalBrush, _startPosX + 85, _startPosY + 34, 30, 15);
|
||||
g.DrawRectangle(pen, _startPosX + 85, _startPosY + 34, 30, 15);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 85, _startPosY + 70, 30, 15);
|
||||
g.DrawRectangle(pen, _startPosX + 85, _startPosY + 70, 30, 15);
|
||||
}
|
||||
drawningEngines.DrawEngines(g, _startPosX, _startPosY);
|
||||
}
|
||||
}
|
||||
}
|
89
ProjectAirBomberHard/ProjectAirBomberHard/DrawningEngines.cs
Normal file
@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAirBomberHard
|
||||
{
|
||||
internal class DrawningEngines
|
||||
{
|
||||
private Engines amount;
|
||||
public void SetAmount(int a)
|
||||
{
|
||||
if (a <= 2)
|
||||
{
|
||||
amount = Engines.Two;
|
||||
}
|
||||
else if (a == 4)
|
||||
{
|
||||
amount = Engines.Four;
|
||||
}
|
||||
else if (a >= 6)
|
||||
{
|
||||
amount = Engines.Six;
|
||||
}
|
||||
}
|
||||
public void DrawEngines(Graphics g, int _startPosX, int _startPosY)
|
||||
{
|
||||
Brush enginesColor = new SolidBrush(Color.Black);
|
||||
|
||||
g.FillPolygon(enginesColor, new Point[] //two up
|
||||
{
|
||||
new Point(_startPosX + 51, _startPosY + 30),
|
||||
new Point(_startPosX + 75, _startPosY + 30),
|
||||
new Point(_startPosX + 75, _startPosY + 40),
|
||||
new Point(_startPosX + 53, _startPosY + 40),
|
||||
}
|
||||
);
|
||||
g.FillPolygon(enginesColor, new Point[] //two down
|
||||
{
|
||||
new Point(_startPosX + 52, _startPosY + 80),
|
||||
new Point(_startPosX + 75, _startPosY + 80),
|
||||
new Point(_startPosX + 75, _startPosY + 90),
|
||||
new Point(_startPosX + 50, _startPosY + 90),
|
||||
}
|
||||
);
|
||||
|
||||
if (amount == Engines.Four || amount == Engines.Six)
|
||||
{
|
||||
g.FillPolygon(enginesColor, new Point[] //four up
|
||||
{
|
||||
new Point(_startPosX + 48, _startPosY + 18),
|
||||
new Point(_startPosX + 75, _startPosY + 18),
|
||||
new Point(_startPosX + 75, _startPosY + 28),
|
||||
new Point(_startPosX + 50, _startPosY + 28),
|
||||
}
|
||||
);
|
||||
g.FillPolygon(enginesColor, new Point[] //four down
|
||||
{
|
||||
new Point(_startPosX + 49, _startPosY + 92),
|
||||
new Point(_startPosX + 75, _startPosY + 92),
|
||||
new Point(_startPosX + 75, _startPosY + 102),
|
||||
new Point(_startPosX + 47, _startPosY + 102),
|
||||
}
|
||||
);
|
||||
}
|
||||
if (amount == Engines.Six)
|
||||
{
|
||||
g.FillPolygon(enginesColor, new Point[] //six up
|
||||
{
|
||||
new Point(_startPosX + 46, _startPosY + 6),
|
||||
new Point(_startPosX + 75, _startPosY + 6),
|
||||
new Point(_startPosX + 75, _startPosY + 16),
|
||||
new Point(_startPosX + 48, _startPosY + 16),
|
||||
}
|
||||
);
|
||||
g.FillPolygon(enginesColor, new Point[] //six down
|
||||
{
|
||||
new Point(_startPosX + 47, _startPosY + 104),
|
||||
new Point(_startPosX + 75, _startPosY + 104),
|
||||
new Point(_startPosX + 75, _startPosY + 114),
|
||||
new Point(_startPosX + 45, _startPosY + 114),
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
15
ProjectAirBomberHard/ProjectAirBomberHard/Engines.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAirBomberHard
|
||||
{
|
||||
public enum Engines
|
||||
{
|
||||
Two,
|
||||
Four,
|
||||
Six
|
||||
}
|
||||
}
|
31
ProjectAirBomberHard/ProjectAirBomberHard/EntityAirBomber.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAirBomberHard
|
||||
{
|
||||
public class EntityAirBomber
|
||||
{
|
||||
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 Bombs { get; private set; }
|
||||
public bool FuelTanks { get; private set; }
|
||||
public int Engines { get; private set; }
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bombs, bool fuelTanks, int engines)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
AdditionalColor = additionalColor;
|
||||
Bombs = bombs;
|
||||
FuelTanks = fuelTanks;
|
||||
Engines = engines;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,39 +0,0 @@
|
||||
namespace ProjectAirBomberHard
|
||||
{
|
||||
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 ProjectAirBomberHard
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
141
ProjectAirBomberHard/ProjectAirBomberHard/FormAirBomber.Designer.cs
generated
Normal file
@ -0,0 +1,141 @@
|
||||
namespace ProjectAirBomberHard
|
||||
{
|
||||
partial class FormAirBomber
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
buttonCreate = new Button();
|
||||
buttonLeft = new Button();
|
||||
buttonRight = new Button();
|
||||
buttonUp = new Button();
|
||||
buttonDown = new Button();
|
||||
pictureBoxAirBomber = new PictureBox();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxAirBomber).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreate.Location = new Point(38, 399);
|
||||
buttonCreate.Margin = new Padding(2, 2, 2, 2);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(149, 36);
|
||||
buttonCreate.TabIndex = 0;
|
||||
buttonCreate.Text = "Создать";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += buttonCreate_Click;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonLeft.BackgroundImage = ProjectAirBomberHard.Properties.Resources.arrowLeft;
|
||||
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonLeft.Location = new Point(641, 399);
|
||||
buttonLeft.Margin = new Padding(2, 2, 2, 2);
|
||||
buttonLeft.Name = "buttonLeft";
|
||||
buttonLeft.Size = new Size(36, 36);
|
||||
buttonLeft.TabIndex = 1;
|
||||
buttonLeft.UseVisualStyleBackColor = true;
|
||||
buttonLeft.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonRight.BackgroundImage = ProjectAirBomberHard.Properties.Resources.arrowRight;
|
||||
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonRight.Location = new Point(741, 399);
|
||||
buttonRight.Margin = new Padding(2, 2, 2, 2);
|
||||
buttonRight.Name = "buttonRight";
|
||||
buttonRight.Size = new Size(36, 36);
|
||||
buttonRight.TabIndex = 2;
|
||||
buttonRight.UseVisualStyleBackColor = true;
|
||||
buttonRight.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonUp.BackgroundImage = ProjectAirBomberHard.Properties.Resources.arrowUp;
|
||||
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonUp.Location = new Point(691, 349);
|
||||
buttonUp.Margin = new Padding(2, 2, 2, 2);
|
||||
buttonUp.Name = "buttonUp";
|
||||
buttonUp.Size = new Size(36, 36);
|
||||
buttonUp.TabIndex = 3;
|
||||
buttonUp.UseVisualStyleBackColor = true;
|
||||
buttonUp.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonDown.BackgroundImage = ProjectAirBomberHard.Properties.Resources.arrowDown;
|
||||
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonDown.Location = new Point(691, 399);
|
||||
buttonDown.Margin = new Padding(2, 2, 2, 2);
|
||||
buttonDown.Name = "buttonDown";
|
||||
buttonDown.Size = new Size(36, 36);
|
||||
buttonDown.TabIndex = 4;
|
||||
buttonDown.UseVisualStyleBackColor = true;
|
||||
buttonDown.Click += buttonMove_Click;
|
||||
//
|
||||
// pictureBoxAirBomber
|
||||
//
|
||||
pictureBoxAirBomber.Dock = DockStyle.Fill;
|
||||
pictureBoxAirBomber.Location = new Point(0, 0);
|
||||
pictureBoxAirBomber.Margin = new Padding(2, 2, 2, 2);
|
||||
pictureBoxAirBomber.Name = "pictureBoxAirBomber";
|
||||
pictureBoxAirBomber.Size = new Size(816, 468);
|
||||
pictureBoxAirBomber.TabIndex = 5;
|
||||
pictureBoxAirBomber.TabStop = false;
|
||||
//
|
||||
// FormAirBomber
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(816, 468);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(pictureBoxAirBomber);
|
||||
Margin = new Padding(2, 2, 2, 2);
|
||||
Name = "FormAirBomber";
|
||||
Text = "Бомбардировщик";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxAirBomber).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonCreate;
|
||||
private Button buttonLeft;
|
||||
private Button buttonRight;
|
||||
private Button buttonUp;
|
||||
private Button buttonDown;
|
||||
private PictureBox pictureBoxAirBomber;
|
||||
}
|
||||
}
|
57
ProjectAirBomberHard/ProjectAirBomberHard/FormAirBomber.cs
Normal file
@ -0,0 +1,57 @@
|
||||
namespace ProjectAirBomberHard
|
||||
{
|
||||
public partial class FormAirBomber : Form
|
||||
{
|
||||
private DrawningAirBomber? _drawningAirBomber;
|
||||
public FormAirBomber()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningAirBomber == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningAirBomber.DrawBomber(gr);
|
||||
pictureBoxAirBomber.Image = bmp;
|
||||
}
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
_drawningAirBomber = new DrawningAirBomber();
|
||||
_drawningAirBomber.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)),
|
||||
random.Next(1, 4) * 2, pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
|
||||
|
||||
_drawningAirBomber.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
private void buttonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningAirBomber == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_drawningAirBomber.MoveTransport(DirectionType.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_drawningAirBomber.MoveTransport(DirectionType.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_drawningAirBomber.MoveTransport(DirectionType.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_drawningAirBomber.MoveTransport(DirectionType.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
<?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
|
||||
|
||||
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>
|
||||
@ -26,36 +26,36 @@
|
||||
<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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
@ -1,4 +1,4 @@
|
||||
namespace ProjectAirBomberHard
|
||||
namespace ProjectAirBomberHard
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
@ -11,7 +11,7 @@ namespace ProjectAirBomberHard
|
||||
// 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 FormAirBomber());
|
||||
}
|
||||
}
|
||||
}
|
103
ProjectAirBomberHard/ProjectAirBomberHard/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ProjectAirBomberHard.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("ProjectAirBomberHard.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowDown {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowDown", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowLeft {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowLeft", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowRight {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowRight", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowUp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowUp", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,151 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="arrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowRight1" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowRight1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowDown1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowLeft1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowRight2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowRight1" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowRight11.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowUp1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.9 KiB |
BIN
ProjectAirBomberHard/ProjectAirBomberHard/Resources/arrowUp.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
ProjectAirBomberHard/ProjectAirBomberHard/Resources/arrowUp1.png
Normal file
After Width: | Height: | Size: 2.6 KiB |