lab_1
This commit is contained in:
parent
ddc1734726
commit
80c26c1b12
19
AirFighter/AirFighter/DirectionAirFighter.cs
Normal file
19
AirFighter/AirFighter/DirectionAirFighter.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
public enum DirectionAirFighter
|
||||||
|
{
|
||||||
|
Up = 1,
|
||||||
|
|
||||||
|
Down = 2,
|
||||||
|
|
||||||
|
Left = 3,
|
||||||
|
|
||||||
|
Right = 4
|
||||||
|
}
|
||||||
|
}
|
240
AirFighter/AirFighter/DrawningAirFighter.cs
Normal file
240
AirFighter/AirFighter/DrawningAirFighter.cs
Normal file
@ -0,0 +1,240 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
public class DrawningAirFighter
|
||||||
|
{
|
||||||
|
public EntityAirFighter? EntityAirFighter { get; private set; }
|
||||||
|
|
||||||
|
private int _pictureWidth;
|
||||||
|
|
||||||
|
private int _pictureHeight;
|
||||||
|
|
||||||
|
private int _startPosX;
|
||||||
|
|
||||||
|
private int _startPosY;
|
||||||
|
|
||||||
|
private readonly int _fighterWidth = 195;
|
||||||
|
|
||||||
|
private readonly int _fighterHeight = 166;
|
||||||
|
|
||||||
|
public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool wing, bool rocket, int width, int height)
|
||||||
|
{
|
||||||
|
if (width < _pictureWidth || height < _pictureHeight)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_pictureWidth = width;
|
||||||
|
_pictureHeight = height;
|
||||||
|
EntityAirFighter = new EntityAirFighter();
|
||||||
|
EntityAirFighter.Init(speed, weight, bodyColor, additionalColor, wing, rocket);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public void SetPosition(int x, int y)
|
||||||
|
{
|
||||||
|
if (x < 0)
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
else if (x > _pictureWidth - _fighterWidth)
|
||||||
|
{
|
||||||
|
x = _pictureWidth - _fighterWidth;
|
||||||
|
}
|
||||||
|
if (y < 0)
|
||||||
|
{
|
||||||
|
y = 0;
|
||||||
|
}
|
||||||
|
else if (y > _pictureHeight - _fighterHeight)
|
||||||
|
{
|
||||||
|
y = _pictureHeight - _fighterHeight;
|
||||||
|
}
|
||||||
|
_startPosX = x;
|
||||||
|
_startPosY = y;
|
||||||
|
}
|
||||||
|
public void MoveTransport(DirectionAirFighter direction)
|
||||||
|
{
|
||||||
|
if (EntityAirFighter == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
case DirectionAirFighter.Left:
|
||||||
|
if (_startPosX - EntityAirFighter.Step > 0)
|
||||||
|
{
|
||||||
|
_startPosX -= (int)EntityAirFighter.Step;
|
||||||
|
}
|
||||||
|
else if (_startPosX - EntityAirFighter.Step < 0)
|
||||||
|
{
|
||||||
|
_startPosX = _startPosX - _startPosX + 3;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DirectionAirFighter.Up:
|
||||||
|
if (_startPosY - EntityAirFighter.Step > 0)
|
||||||
|
{
|
||||||
|
_startPosY -= (int)EntityAirFighter.Step;
|
||||||
|
}
|
||||||
|
else if (_startPosY - EntityAirFighter.Step < 0)
|
||||||
|
{
|
||||||
|
_startPosY = _startPosY - _startPosY + 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DirectionAirFighter.Right:
|
||||||
|
if (_startPosX + EntityAirFighter.Step + _fighterWidth < _pictureWidth)
|
||||||
|
{
|
||||||
|
_startPosX += (int)EntityAirFighter.Step;
|
||||||
|
}
|
||||||
|
else if (_startPosX + EntityAirFighter.Step + _fighterWidth > _pictureWidth)
|
||||||
|
{
|
||||||
|
_startPosX += _pictureWidth - _startPosX - _fighterWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DirectionAirFighter.Down:
|
||||||
|
if (_startPosY + EntityAirFighter.Step + _fighterHeight < _pictureHeight)
|
||||||
|
{
|
||||||
|
_startPosY += (int)EntityAirFighter.Step;
|
||||||
|
}
|
||||||
|
else if (_startPosY + EntityAirFighter.Step + _fighterHeight > _pictureHeight)
|
||||||
|
{
|
||||||
|
_startPosY += _pictureHeight - _startPosY - _fighterHeight;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void DrawTransport(Graphics g)
|
||||||
|
{
|
||||||
|
if (EntityAirFighter == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Pen pen = new(EntityAirFighter.BodyColor, 2);
|
||||||
|
Brush brushBlack = new SolidBrush(EntityAirFighter.BodyColor);
|
||||||
|
|
||||||
|
PointF[] front = {
|
||||||
|
new(_startPosX + 160, _startPosY + 69),
|
||||||
|
new(_startPosX + 195, _startPosY + 83),
|
||||||
|
new(_startPosX + 160, _startPosY + 97)
|
||||||
|
};
|
||||||
|
|
||||||
|
PointF[] tailTop = {
|
||||||
|
new(_startPosX, _startPosY + 30),
|
||||||
|
new(_startPosX, _startPosY + 70),
|
||||||
|
new(_startPosX + 25, _startPosY + 70),
|
||||||
|
new(_startPosX + 25, _startPosY + 55)
|
||||||
|
};
|
||||||
|
|
||||||
|
PointF[] tailBottom = {
|
||||||
|
new(_startPosX, _startPosY + 96),
|
||||||
|
new(_startPosX, _startPosY + 136),
|
||||||
|
new(_startPosX + 25, _startPosY + 111),
|
||||||
|
new(_startPosX + 25, _startPosY + 96)
|
||||||
|
};
|
||||||
|
|
||||||
|
PointF[] wingTop =
|
||||||
|
{
|
||||||
|
new(_startPosX + 100, _startPosY),
|
||||||
|
new(_startPosX + 100, _startPosY + 70),
|
||||||
|
new(_startPosX + 75, _startPosY + 70),
|
||||||
|
new(_startPosX + 90, _startPosY),
|
||||||
|
};
|
||||||
|
PointF[] wingBottom =
|
||||||
|
{
|
||||||
|
new(_startPosX + 100, _startPosY + 96),
|
||||||
|
new(_startPosX + 100, _startPosY + 166),
|
||||||
|
new(_startPosX + 90, _startPosY + 166),
|
||||||
|
new(_startPosX + 75, _startPosY + 96),
|
||||||
|
};
|
||||||
|
|
||||||
|
g.DrawPolygon(pen, tailTop);
|
||||||
|
g.DrawPolygon(pen, tailBottom);
|
||||||
|
g.DrawPolygon(pen, wingTop);
|
||||||
|
g.DrawPolygon(pen, wingBottom);
|
||||||
|
g.DrawRectangle(pen, _startPosX, _startPosY + 70, 160, 26);
|
||||||
|
g.FillPolygon(brushBlack, front);
|
||||||
|
|
||||||
|
Brush additionalBrush = new SolidBrush(EntityAirFighter.AdditionalColor);
|
||||||
|
|
||||||
|
if (EntityAirFighter.Wing)
|
||||||
|
{
|
||||||
|
PointF[] topDopWing =
|
||||||
|
{
|
||||||
|
new(_startPosX + 78, _startPosY + 56),
|
||||||
|
new(_startPosX + 75, _startPosY + 70),
|
||||||
|
new(_startPosX + 55, _startPosY + 50),
|
||||||
|
new(_startPosX + 60, _startPosY + 45),
|
||||||
|
};
|
||||||
|
|
||||||
|
PointF[] bottomDopWing =
|
||||||
|
{
|
||||||
|
new(_startPosX + 78, _startPosY + 110),
|
||||||
|
new(_startPosX + 75, _startPosY + 96),
|
||||||
|
new(_startPosX + 55, _startPosY + 116),
|
||||||
|
new(_startPosX + 60, _startPosY + 121),
|
||||||
|
};
|
||||||
|
|
||||||
|
g.FillPolygon(additionalBrush, topDopWing);
|
||||||
|
g.FillPolygon(additionalBrush, bottomDopWing);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (EntityAirFighter.Rocket)
|
||||||
|
{
|
||||||
|
PointF[] topRocket1 =
|
||||||
|
{
|
||||||
|
new(_startPosX + 100, _startPosY + 20),
|
||||||
|
new(_startPosX + 100, _startPosY + 30),
|
||||||
|
new(_startPosX + 112, _startPosY + 30),
|
||||||
|
new(_startPosX + 120, _startPosY + 25),
|
||||||
|
new(_startPosX + 112, _startPosY + 20)
|
||||||
|
};
|
||||||
|
|
||||||
|
PointF[] topRocket2 =
|
||||||
|
{
|
||||||
|
new(_startPosX + 100, _startPosY + 35),
|
||||||
|
new(_startPosX + 100, _startPosY + 45),
|
||||||
|
new(_startPosX + 112, _startPosY + 45),
|
||||||
|
new(_startPosX + 120, _startPosY + 40),
|
||||||
|
new(_startPosX + 112, _startPosY + 35)
|
||||||
|
};
|
||||||
|
|
||||||
|
PointF[] bottomRocket1 =
|
||||||
|
{
|
||||||
|
new(_startPosX + 100, _startPosY + 146),
|
||||||
|
new(_startPosX + 100, _startPosY + 136),
|
||||||
|
new(_startPosX + 112, _startPosY + 136),
|
||||||
|
new(_startPosX + 120, _startPosY + 141),
|
||||||
|
new(_startPosX + 112, _startPosY + 146)
|
||||||
|
};
|
||||||
|
|
||||||
|
PointF[] bottomRocket2 =
|
||||||
|
{
|
||||||
|
new(_startPosX + 100, _startPosY + 131),
|
||||||
|
new(_startPosX + 100, _startPosY + 121),
|
||||||
|
new(_startPosX + 112, _startPosY + 121),
|
||||||
|
new(_startPosX + 120, _startPosY + 126),
|
||||||
|
new(_startPosX + 112, _startPosY + 131)
|
||||||
|
};
|
||||||
|
|
||||||
|
g.FillPolygon(additionalBrush, topRocket1);
|
||||||
|
g.FillPolygon(additionalBrush, topRocket2);
|
||||||
|
g.FillPolygon(additionalBrush, bottomRocket1);
|
||||||
|
g.FillPolygon(additionalBrush, bottomRocket2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
32
AirFighter/AirFighter/EntityAirFighter.cs
Normal file
32
AirFighter/AirFighter/EntityAirFighter.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
public class EntityAirFighter
|
||||||
|
{
|
||||||
|
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 Rocket { get; private set; }
|
||||||
|
public bool Wing { get; private set; }
|
||||||
|
public double Step => (double)Speed * 100 / Weight;
|
||||||
|
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool rocket, bool wing)
|
||||||
|
{
|
||||||
|
|
||||||
|
Speed = speed;
|
||||||
|
Weight = weight;
|
||||||
|
BodyColor = bodyColor;
|
||||||
|
AdditionalColor = additionalColor;
|
||||||
|
Rocket = rocket;
|
||||||
|
Wing = wing;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
39
AirFighter/AirFighter/Form1.Designer.cs
generated
39
AirFighter/AirFighter/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
|||||||
namespace AirFighter
|
|
||||||
{
|
|
||||||
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 AirFighter
|
|
||||||
{
|
|
||||||
public partial class Form1 : Form
|
|
||||||
{
|
|
||||||
public Form1()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
138
AirFighter/AirFighter/FormAirFighter.Designer.cs
generated
Normal file
138
AirFighter/AirFighter/FormAirFighter.Designer.cs
generated
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
partial class AirFighter
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
pictureBoxAirFighter = new PictureBox();
|
||||||
|
buttonLeft = new Button();
|
||||||
|
buttonDown = new Button();
|
||||||
|
buttonRight = new Button();
|
||||||
|
buttonUp = new Button();
|
||||||
|
buttonCreate = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxAirFighter).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// pictureBoxAirFighter
|
||||||
|
//
|
||||||
|
pictureBoxAirFighter.Dock = DockStyle.Fill;
|
||||||
|
pictureBoxAirFighter.Location = new Point(0, 0);
|
||||||
|
pictureBoxAirFighter.Name = "pictureBoxAirFighter";
|
||||||
|
pictureBoxAirFighter.Size = new Size(800, 450);
|
||||||
|
pictureBoxAirFighter.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||||
|
pictureBoxAirFighter.TabIndex = 0;
|
||||||
|
pictureBoxAirFighter.TabStop = false;
|
||||||
|
//
|
||||||
|
// buttonLeft
|
||||||
|
//
|
||||||
|
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonLeft.BackgroundImage = Properties.Resources.__png_3;
|
||||||
|
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
|
buttonLeft.Location = new Point(686, 370);
|
||||||
|
buttonLeft.Name = "buttonLeft";
|
||||||
|
buttonLeft.Size = new Size(30, 30);
|
||||||
|
buttonLeft.TabIndex = 1;
|
||||||
|
buttonLeft.UseVisualStyleBackColor = true;
|
||||||
|
buttonLeft.Click += buttonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonDown
|
||||||
|
//
|
||||||
|
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonDown.BackgroundImage = Properties.Resources.__png_2;
|
||||||
|
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
|
buttonDown.Location = new Point(722, 407);
|
||||||
|
buttonDown.Name = "buttonDown";
|
||||||
|
buttonDown.Size = new Size(30, 30);
|
||||||
|
buttonDown.TabIndex = 2;
|
||||||
|
buttonDown.UseVisualStyleBackColor = true;
|
||||||
|
buttonDown.Click += buttonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonRight
|
||||||
|
//
|
||||||
|
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonRight.BackgroundImage = Properties.Resources.__png_1;
|
||||||
|
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
|
buttonRight.Location = new Point(758, 370);
|
||||||
|
buttonRight.Name = "buttonRight";
|
||||||
|
buttonRight.Size = new Size(30, 30);
|
||||||
|
buttonRight.TabIndex = 3;
|
||||||
|
buttonRight.UseVisualStyleBackColor = true;
|
||||||
|
buttonRight.Click += buttonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonUp
|
||||||
|
//
|
||||||
|
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonUp.BackgroundImage = Properties.Resources.__png_4;
|
||||||
|
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
|
buttonUp.Location = new Point(722, 370);
|
||||||
|
buttonUp.Name = "buttonUp";
|
||||||
|
buttonUp.Size = new Size(30, 30);
|
||||||
|
buttonUp.TabIndex = 4;
|
||||||
|
buttonUp.UseVisualStyleBackColor = true;
|
||||||
|
buttonUp.Click += buttonMove_Click;
|
||||||
|
//
|
||||||
|
// buttonCreate
|
||||||
|
//
|
||||||
|
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
|
buttonCreate.BackColor = Color.Azure;
|
||||||
|
buttonCreate.Font = new Font("Times New Roman", 14.25F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
|
buttonCreate.Location = new Point(12, 405);
|
||||||
|
buttonCreate.Name = "buttonCreate";
|
||||||
|
buttonCreate.Size = new Size(95, 33);
|
||||||
|
buttonCreate.TabIndex = 5;
|
||||||
|
buttonCreate.Text = "Создать";
|
||||||
|
buttonCreate.UseVisualStyleBackColor = false;
|
||||||
|
buttonCreate.Click += buttonCreate_Click;
|
||||||
|
//
|
||||||
|
// AirFighter
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(buttonCreate);
|
||||||
|
Controls.Add(buttonUp);
|
||||||
|
Controls.Add(buttonRight);
|
||||||
|
Controls.Add(buttonDown);
|
||||||
|
Controls.Add(buttonLeft);
|
||||||
|
Controls.Add(pictureBoxAirFighter);
|
||||||
|
Name = "AirFighter";
|
||||||
|
Text = "AirFighter";
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxAirFighter).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private PictureBox pictureBoxAirFighter;
|
||||||
|
private Button buttonLeft;
|
||||||
|
private Button buttonDown;
|
||||||
|
private Button buttonRight;
|
||||||
|
private Button buttonUp;
|
||||||
|
private Button buttonCreate;
|
||||||
|
}
|
||||||
|
}
|
58
AirFighter/AirFighter/FormAirFighter.cs
Normal file
58
AirFighter/AirFighter/FormAirFighter.cs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
public partial class AirFighter : Form
|
||||||
|
{
|
||||||
|
private DrawningAirFighter? _drawningAirFighter;
|
||||||
|
public AirFighter()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
private void Draw()
|
||||||
|
{
|
||||||
|
if (_drawningAirFighter == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Bitmap bmp = new(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_drawningAirFighter.DrawTransport(gr);
|
||||||
|
pictureBoxAirFighter.Image = bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Random random = new();
|
||||||
|
_drawningAirFighter = new DrawningAirFighter();
|
||||||
|
_drawningAirFighter.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)), pictureBoxAirFighter.Width, pictureBoxAirFighter.Height);
|
||||||
|
_drawningAirFighter.SetPosition(random.Next(10, 100),
|
||||||
|
random.Next(10, 100));
|
||||||
|
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
private void buttonMove_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_drawningAirFighter == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case "buttonUp":
|
||||||
|
_drawningAirFighter.MoveTransport(DirectionAirFighter.Up);
|
||||||
|
break;
|
||||||
|
case "buttonDown":
|
||||||
|
_drawningAirFighter.MoveTransport(DirectionAirFighter.Down);
|
||||||
|
break;
|
||||||
|
case "buttonLeft":
|
||||||
|
_drawningAirFighter.MoveTransport(DirectionAirFighter.Left);
|
||||||
|
break;
|
||||||
|
case "buttonRight":
|
||||||
|
_drawningAirFighter.MoveTransport(DirectionAirFighter.Right);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -18,7 +18,7 @@
|
|||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, 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="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="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
</data>
|
</data>
|
@ -11,7 +11,7 @@ namespace AirFighter
|
|||||||
// 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 AirFighter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
113
AirFighter/AirFighter/Properties/Resources.Designer.cs
generated
Normal file
113
AirFighter/AirFighter/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Этот код создан программой.
|
||||||
|
// Исполняемая версия:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||||
|
// повторной генерации кода.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace AirFighter.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("AirFighter.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 @__png_1 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("--png-1", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap @__png_2 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("--png-2", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap @__png_3 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("--png-3", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap @__png_31 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("--png-31", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap @__png_4 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("--png-4", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
136
AirFighter/AirFighter/Properties/Resources.resx
Normal file
136
AirFighter/AirFighter/Properties/Resources.resx
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
<?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="--png-3" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\--png-3.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="--png-31" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\--png-31.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="--png-1" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\--png-1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="--png-2" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\--png-2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="--png-4" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\--png-4.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
BIN
AirFighter/AirFighter/Resources/--png-1.png
Normal file
BIN
AirFighter/AirFighter/Resources/--png-1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
AirFighter/AirFighter/Resources/--png-2.png
Normal file
BIN
AirFighter/AirFighter/Resources/--png-2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
AirFighter/AirFighter/Resources/--png-3.png
Normal file
BIN
AirFighter/AirFighter/Resources/--png-3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
AirFighter/AirFighter/Resources/--png-31.png
Normal file
BIN
AirFighter/AirFighter/Resources/--png-31.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
AirFighter/AirFighter/Resources/--png-4.png
Normal file
BIN
AirFighter/AirFighter/Resources/--png-4.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
Loading…
Reference in New Issue
Block a user