This commit is contained in:
Alkin Ivan 2024-02-27 13:03:57 +04:00
parent e5206ac79f
commit 27cb2f471e
17 changed files with 764 additions and 56 deletions

View File

@ -8,4 +8,19 @@
<ImplicitUsings>enable</ImplicitUsings>
</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>

View File

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32901.215
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AirBomber", "AirBomber.csproj", "{15C0C31A-A5FF-4CDE-8018-2BD58B8D0687}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AirBomber", "AirBomber.csproj", "{4E086563-17EB-404C-9522-520DE8724E73}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -11,15 +11,15 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{15C0C31A-A5FF-4CDE-8018-2BD58B8D0687}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{15C0C31A-A5FF-4CDE-8018-2BD58B8D0687}.Debug|Any CPU.Build.0 = Debug|Any CPU
{15C0C31A-A5FF-4CDE-8018-2BD58B8D0687}.Release|Any CPU.ActiveCfg = Release|Any CPU
{15C0C31A-A5FF-4CDE-8018-2BD58B8D0687}.Release|Any CPU.Build.0 = Release|Any CPU
{4E086563-17EB-404C-9522-520DE8724E73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E086563-17EB-404C-9522-520DE8724E73}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E086563-17EB-404C-9522-520DE8724E73}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E086563-17EB-404C-9522-520DE8724E73}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9564BBD8-86D9-40BD-BE9B-F4281275A166}
SolutionGuid = {6D8F316D-DF53-4881-ACA9-0D4697D43D6A}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,27 @@
namespace AirBomber;
/// <summary>
/// Направление перемещения
/// </summary>
public enum DirectionType
{
/// <summary>
/// Вверх
/// </summary>
Up = 1,
/// <summary>
/// Вниз
/// </summary>
Down = 2,
/// <summary>
/// Влево
/// </summary>
Left = 3,
/// <summary>
/// Вправо
/// </summary>
Right = 4,
}

View File

@ -0,0 +1,261 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber;
/// <summary>
/// Класс, отвечающий за отрисовку и перемещение объекта-сущности
/// </summary>
public class DrawningAirBomber
{
/// <summary>
/// Класс-сущность
/// </summary>
public EntityAirBomber? EntityAirBomber { get; private set; }
/// <summary>
/// Ширина окна отрисовки
/// </summary>
private int? _pictureWidth;
/// <summary>
/// Высота окна отрисовки
/// </summary>
private int? _pictureHeight;
/// <summary>
/// Левая координата отрисовки бомбардировщика
/// </summary>
public int? _startPosX;
/// <summary>
/// Верхняя координата отрисовки бомбардировщика
/// </summary>
private int? _startPosY;
/// <summary>
/// Ширина отрисовки бомбардировщика
/// </summary>
private readonly int _drawningAirBomberWidth = 140;
/// <summary>
/// Высота отрисовки бомбардировщика
/// </summary>
private readonly int _drawningAirBomberHeight = 128;
/// <summary>
///
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="bombs">Признак наличия бомб</param>
/// <param name="fuelTanks">Признак наличия дополнительный топливных баков</param>
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bombs, bool fuelTanks)
{
EntityAirBomber = new EntityAirBomber();
EntityAirBomber.Init(speed, weight, bodyColor, additionalColor, bombs, fuelTanks);
_pictureHeight = null;
_pictureHeight = null;
_startPosX = null;
_startPosY = null;
}
/// <summary>
/// Установка границ поля
/// </summary>
/// <param name="width"><Ширина/param>
/// <param name="height">Высота</param>
/// <returns></returns>
public bool SetPictureSize(int width, int height)
{
if (_drawningAirBomberHeight > height || _drawningAirBomberWidth > width)
return false;
_pictureHeight = height;
_pictureWidth = width;
if (_startPosX.HasValue || _startPosY.HasValue)
{
if (_startPosX + _drawningAirBomberWidth > _pictureWidth)
_startPosX = _pictureWidth - _drawningAirBomberWidth;
else if (_startPosX < 0)
_startPosX = 0;
if (_startPosY + _drawningAirBomberHeight > _pictureHeight)
_startPosY = _pictureHeight - _drawningAirBomberHeight;
else if (_startPosY < 0)
_startPosY = 0;
}
return true;
}
/// <summary>
/// Установка позиции
/// </summary>
/// <param name="x">Координата X</param>
/// <param name="y">Координата Y</param>
public void SetPosition(int x, int y)
{
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
{
return;
}
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
return;
if (x + _drawningAirBomberWidth > _pictureWidth) _startPosX = _pictureWidth - _drawningAirBomberWidth;
else if (x < 0) _startPosX = 0;
else _startPosX = x;
if (y + _drawningAirBomberHeight > _pictureHeight) _startPosY = _pictureHeight - _drawningAirBomberHeight;
else if (y < 0) _startPosY = 0;
else _startPosY = y;
}
public bool MoveAirBomber(DirectionType direction)
{
if (EntityAirBomber == null || !_startPosX.HasValue || !_startPosY.HasValue)
{
return false;
}
switch (direction)
{
//влево
case DirectionType.Left:
if (_startPosX.Value - EntityAirBomber.Step > 0)
{
_startPosX -= (int)EntityAirBomber.Step;
}
return true;
//вверх
case DirectionType.Up:
if (_startPosY.Value - EntityAirBomber.Step > 0)
{
_startPosY -= (int)EntityAirBomber.Step;
}
return true;
//вправо
case DirectionType.Right :
if (_startPosX.Value + EntityAirBomber.Step + _drawningAirBomberWidth < _pictureWidth)
{
_startPosX += (int)EntityAirBomber.Step;
}
return true;
//вниз
case DirectionType.Down:
if (_startPosY + EntityAirBomber.Step + _drawningAirBomberHeight < _pictureHeight)
{
_startPosY += (int)EntityAirBomber.Step;
}
return true;
default:
return false;
}
}
/// <summary>
/// Прорисовка объекта
/// </summary>
/// <param name="g"></param>
public void DrawAirBomber(Graphics g)
{
if (EntityAirBomber == null || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
Pen pen = new(Color.Black);
Brush additionalBrush = new
SolidBrush(EntityAirBomber.AdditionalColor);
if (EntityAirBomber.FuelTanks)
{
//Дополнительные топливные баки
g.FillEllipse(additionalBrush, _startPosX.Value + 90, _startPosY.Value + 50, 29, 29);
g.DrawEllipse(pen, _startPosX.Value + 90, _startPosY.Value + 50, 29, 29);
g.FillEllipse(additionalBrush, _startPosX.Value + 30, _startPosY.Value + 50, 29, 29);
g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value + 50, 29, 29);
}
Brush brGreen = new SolidBrush(Color.Green);
Brush brRed = new SolidBrush(Color.Red);
Brush BodyBrush = new SolidBrush(EntityAirBomber.BodyColor);
//Бомбы
if (EntityAirBomber.Bombs)
{
Point[] Bomb1Point = { new Point(_startPosX.Value + 77, _startPosY.Value + 125), new Point(_startPosX.Value + 84, _startPosY.Value + 128), new Point(_startPosX.Value + 84, _startPosY.Value + 120), new Point(_startPosX.Value + 79, _startPosY.Value + 122) };
g.FillPolygon(brGreen, Bomb1Point);
g.DrawLine(pen, _startPosX.Value + 77, _startPosY.Value + 125, _startPosX.Value + 84, _startPosY.Value + 128);
g.DrawLine(pen, _startPosX.Value + 84, _startPosY.Value + 128, _startPosX.Value + 84, _startPosY.Value + 120);
g.DrawLine(pen, _startPosX.Value + 84, _startPosY.Value + 120, _startPosX.Value + 79, _startPosY.Value + 122);
g.FillRectangle(brGreen, _startPosX.Value + 65, _startPosY.Value + 121, 5, 5);
g.DrawRectangle(pen, _startPosX.Value + 65, _startPosY.Value + 121, 5, 5);
Point[] BombNose1Point = { new Point(_startPosX.Value + 65, _startPosY.Value + 119), new Point(_startPosX.Value + 60, _startPosY.Value + 123), new Point(_startPosX.Value + 65, _startPosY.Value + 128) };
g.FillPolygon(brRed, BombNose1Point);
Point[] Bomb2Point = { new Point(_startPosX.Value + 77, _startPosY.Value + 3), new Point(_startPosX.Value + 84, _startPosY.Value), new Point(_startPosX.Value + 84, _startPosY.Value + 8), new Point(_startPosX.Value + 79, _startPosY.Value + 6) };
g.FillPolygon(brGreen, Bomb2Point);
g.DrawLine(pen, _startPosX.Value + 77, _startPosY.Value + 3, _startPosX.Value + 84, _startPosY.Value);
g.DrawLine(pen, _startPosX.Value + 84, _startPosY.Value, _startPosX.Value + 84, _startPosY.Value + 8);
g.DrawLine(pen, _startPosX.Value + 84, _startPosY.Value + 8, _startPosX.Value + 79, _startPosY.Value + 6);
g.FillRectangle(brGreen, _startPosX.Value + 65, _startPosY.Value + 2, 5, 5);
g.DrawRectangle(pen, _startPosX.Value + 65, _startPosY.Value + 2, 5, 5);
Point[] BombNose2Point = { new Point(_startPosX.Value + 65, _startPosY.Value + 9), new Point(_startPosX.Value + 60, _startPosY.Value + 5), new Point(_startPosX.Value + 65, _startPosY.Value) };
g.FillPolygon(brRed, BombNose2Point);
}
//Корпус
Brush brGray = new SolidBrush(Color.Gray);
g.FillRectangle(BodyBrush, _startPosX.Value + 20, _startPosY.Value + 55, 120, 18);
g.DrawRectangle(pen, _startPosX.Value + 20, _startPosY.Value + 55, 120, 18);
//Нос
Brush brBlack = new SolidBrush(Color.Black);
Point[] NosePoints = { new Point(_startPosX.Value + 20, _startPosY.Value + 55), new Point(_startPosX.Value, _startPosY.Value + 64), new Point(_startPosX.Value + 20, _startPosY.Value + 73) };
g.FillPolygon(brBlack, NosePoints);
g.DrawLine(pen, _startPosX.Value + 20, _startPosY.Value + 55, _startPosX.Value, _startPosY.Value + 64);
g.DrawLine(pen, _startPosX.Value, _startPosY.Value + 64, _startPosX.Value + 20, _startPosY.Value + 73);
//Крылья
Point[] UpperWingPoint = { new Point(_startPosX.Value + 71, _startPosY.Value + 55), new Point(_startPosX.Value + 71, _startPosY.Value + 1), new Point(_startPosX.Value + 77, _startPosY.Value + 1), new Point(_startPosX.Value + 85, _startPosY.Value + 54) };
g.FillPolygon(BodyBrush, UpperWingPoint);
g.DrawLine(pen, _startPosX.Value + 70, _startPosY.Value + 55, _startPosX.Value + 70, _startPosY.Value);
g.DrawLine(pen, _startPosX.Value + 70, _startPosY.Value, _startPosX.Value + 77, _startPosY.Value);
g.DrawLine(pen, _startPosX.Value + 77, _startPosY.Value, _startPosX.Value + 85, _startPosY.Value + 55);
Point[] LowerWingPoint = { new Point(_startPosX.Value + 71, _startPosY.Value + 74), new Point(_startPosX.Value + 71, _startPosY.Value + 128), new Point(_startPosX.Value + 77, _startPosY.Value + 128), new Point(_startPosX.Value + 85, _startPosY.Value + 74) };
g.FillPolygon(BodyBrush, LowerWingPoint);
g.DrawLine(pen, _startPosX.Value + 70, _startPosY.Value + 73, _startPosX.Value + 70, _startPosY.Value + 128);
g.DrawLine(pen, _startPosX.Value + 70, _startPosY.Value + 128, _startPosX.Value + 77, _startPosY.Value + 128);
g.DrawLine(pen, _startPosX.Value + 77, _startPosY.Value + 128, _startPosX.Value + 85, _startPosY.Value + 73);
//Хвост
Point[] UpTailPoint = { new Point(_startPosX.Value + 140, _startPosY.Value + 55), new Point(_startPosX.Value + 140, _startPosY.Value + 27), new Point(_startPosX.Value + 120, _startPosY.Value + 46), new Point(_startPosX.Value + 120, _startPosY.Value + 55) };
g.FillPolygon(BodyBrush, UpTailPoint);
g.DrawLine(pen, _startPosX.Value + 140, _startPosY.Value + 55, _startPosX.Value + 140, _startPosY.Value + 27);
g.DrawLine(pen, _startPosX.Value + 140, _startPosY.Value + 27, _startPosX.Value + 120, _startPosY.Value + 46);
g.DrawLine(pen, _startPosX.Value + 120, _startPosY.Value + 46, _startPosX.Value + 120, _startPosY.Value + 55);
Point[] LowerTailPoint = { new Point(_startPosX.Value + 140, _startPosY.Value + 73), new Point(_startPosX.Value + 140, _startPosY.Value + 102), new Point(_startPosX.Value + 120, _startPosY.Value + 83), new Point(_startPosX.Value + 120, _startPosY.Value + 55) };
g.FillPolygon(BodyBrush, LowerTailPoint);
g.DrawLine(pen, _startPosX.Value + 140, _startPosY.Value + 73, _startPosX.Value + 140, _startPosY.Value + 102);
g.DrawLine(pen, _startPosX.Value + 140, _startPosY.Value + 102, _startPosX.Value + 120, _startPosY.Value + 83);
g.DrawLine(pen, _startPosX.Value + 120, _startPosY.Value + 83, _startPosX.Value + 120, _startPosY.Value + 73);
g.DrawLine(pen, _startPosX.Value + 140, _startPosY.Value + 73, _startPosX.Value + 100, _startPosY.Value + 73);
}
}

View File

@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
public class EntityAirBomber
{
/// <summary>
/// Скорость
/// </summary>
public int Speed { get; private set; }
/// <summary>
/// Вес
/// </summary>
public double Weight { get; private set; }
/// <summary>
/// Основной цвет
/// </summary>
public Color BodyColor { get; private set; }
/// <summary>
/// Дополнительный цвет
/// </summary>
public Color AdditionalColor { get; private set; }
/// <summary>
/// Признак (опция) наличия бомб
/// </summary>
public bool Bombs { get; private set; }
/// <summary>
/// Признак (опция) наличия дополнительных топливных баков
/// </summary>
public bool FuelTanks { get; private set; }
/// <summary>
/// Шаг перемещения
/// </summary>
public double Step => Speed * 100 / Weight;
/// <summary>
///
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="bombs">Признак наличия бомб</param>
/// <param name="fuelTanks">Признак наличия дополнительных топливных баков</param>
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bombs, bool fuelTanks)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
AdditionalColor = additionalColor;
Bombs = bombs;
FuelTanks = fuelTanks;
}
}
}

View File

@ -1,39 +0,0 @@
namespace AirBomber
{
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
}
}

View File

@ -1,10 +0,0 @@
namespace AirBomber
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

137
AirBomber/FormAirBomber.Designer.cs generated Normal file
View File

@ -0,0 +1,137 @@
namespace AirBomber
{
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()
{
this.buttonCreate = new System.Windows.Forms.Button();
this.ButtonRight = new System.Windows.Forms.Button();
this.ButtonUp = new System.Windows.Forms.Button();
this.ButtonLeft = new System.Windows.Forms.Button();
this.ButtonDown = new System.Windows.Forms.Button();
this.pictureBoxAirBomber = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirBomber)).BeginInit();
this.SuspendLayout();
//
// 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, 575);
this.buttonCreate.Name = "buttonCreate";
this.buttonCreate.Size = new System.Drawing.Size(128, 33);
this.buttonCreate.TabIndex = 0;
this.buttonCreate.Text = "Создать";
this.buttonCreate.UseVisualStyleBackColor = true;
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
//
// ButtonRight
//
this.ButtonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonRight.BackgroundImage = global::AirBomber.Properties.Resources.arrowRight;
this.ButtonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ButtonRight.Location = new System.Drawing.Point(905, 560);
this.ButtonRight.Name = "ButtonRight";
this.ButtonRight.Size = new System.Drawing.Size(50, 48);
this.ButtonRight.TabIndex = 1;
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::AirBomber.Properties.Resources.arrowUp;
this.ButtonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ButtonUp.Location = new System.Drawing.Point(849, 506);
this.ButtonUp.Name = "ButtonUp";
this.ButtonUp.Size = new System.Drawing.Size(50, 48);
this.ButtonUp.TabIndex = 2;
this.ButtonUp.UseVisualStyleBackColor = true;
this.ButtonUp.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::AirBomber.Properties.Resources.arrowLeft;
this.ButtonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ButtonLeft.Location = new System.Drawing.Point(793, 560);
this.ButtonLeft.Name = "ButtonLeft";
this.ButtonLeft.Size = new System.Drawing.Size(50, 48);
this.ButtonLeft.TabIndex = 3;
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 = global::AirBomber.Properties.Resources.arrowDown;
this.ButtonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ButtonDown.Location = new System.Drawing.Point(849, 560);
this.ButtonDown.Name = "ButtonDown";
this.ButtonDown.Size = new System.Drawing.Size(50, 48);
this.ButtonDown.TabIndex = 4;
this.ButtonDown.UseVisualStyleBackColor = true;
this.ButtonDown.Click += new System.EventHandler(this.ButtonMove_Click);
//
// pictureBoxAirBomber
//
this.pictureBoxAirBomber.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxAirBomber.Location = new System.Drawing.Point(0, 0);
this.pictureBoxAirBomber.Name = "pictureBoxAirBomber";
this.pictureBoxAirBomber.Size = new System.Drawing.Size(967, 621);
this.pictureBoxAirBomber.TabIndex = 5;
this.pictureBoxAirBomber.TabStop = false;
this.pictureBoxAirBomber.Click += new System.EventHandler(this.pictureBoxAirBomber_Click);
this.pictureBoxAirBomber.Resize += new System.EventHandler(this.PictureBoxResize);
//
// FormAirBomber
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(967, 621);
this.Controls.Add(this.ButtonDown);
this.Controls.Add(this.ButtonLeft);
this.Controls.Add(this.ButtonUp);
this.Controls.Add(this.ButtonRight);
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.pictureBoxAirBomber);
this.Name = "FormAirBomber";
this.Text = "AirBomber";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirBomber)).EndInit();
this.ResumeLayout(false);
}
#endregion
private Button buttonCreate;
private Button ButtonRight;
private Button ButtonUp;
private Button ButtonLeft;
private Button ButtonDown;
private PictureBox pictureBoxAirBomber;
}
}

View File

@ -0,0 +1,81 @@
namespace AirBomber
{
public partial class FormAirBomber : Form
{
private DrawningAirBomber _drawingAirBomber;
public FormAirBomber()
{
InitializeComponent();
}
private void Draw()
{
Bitmap bpm = new(pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
Graphics gr = Graphics.FromImage(bpm);
_drawingAirBomber.DrawAirBomber(gr);
pictureBoxAirBomber.Image = bpm;
}
private void buttonCreate_Click(object sender, EventArgs e)
{
Random random = new();
_drawingAirBomber = new DrawningAirBomber();
_drawingAirBomber.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)));
_drawingAirBomber.SetPictureSize(pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
_drawingAirBomber.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
private void pictureBoxAirBomber_Click(object sender, EventArgs e)
{
}
private void ButtonUp_Click(object sender, EventArgs e)
{
}
private void ButtonMove_Click(object sender, EventArgs e)
{
if (_drawingAirBomber == null)
{
return;
}
string name = ((Button)sender)?.Name ?? string.Empty;
bool result = false;
switch (name)
{
case "ButtonUp":
result = _drawingAirBomber.MoveAirBomber(DirectionType.Up);
break;
case "ButtonDown":
result = _drawingAirBomber.MoveAirBomber(DirectionType.Down);
break;
case "ButtonLeft":
result = _drawingAirBomber.MoveAirBomber(DirectionType.Left);
break;
case "ButtonRight":
result = _drawingAirBomber.MoveAirBomber(DirectionType.Right);
break;
}
if (result)
{
Draw();
}
}
private void PictureBoxResize(object sender, EventArgs e)
{
_drawingAirBomber?.SetPictureSize(pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
Draw();
}
}
}

View File

@ -0,0 +1,60 @@
<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>
</root>

View File

@ -11,7 +11,7 @@ namespace AirBomber
// 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
AirBomber/Properties/Resources.Designer.cs generated Normal file
View File

@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AirBomber.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("AirBomber.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));
}
}
}
}

View File

@ -117,4 +117,17 @@
<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\arrowDown1.jpg;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.jpg;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\arrowRight1.jpg;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.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB