Merge pull request 'Karamushko M.K. lab1_base' (#2) from lab1_base into master
Reviewed-on: http://student.git.athene.tech/maxKarme/PIbd-12_Karamushko_M.K._AirFighter._Base/pulls/2
This commit is contained in:
commit
077a99d63a
@ -8,4 +8,19 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="Properties\Resources.Designer.cs">
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Update="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
16
AirFighter/AirFighter/Direction.cs
Normal file
16
AirFighter/AirFighter/Direction.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
internal enum Direction
|
||||||
|
{
|
||||||
|
Up,
|
||||||
|
Right,
|
||||||
|
Left,
|
||||||
|
Down
|
||||||
|
}
|
||||||
|
}
|
156
AirFighter/AirFighter/DrawingAirFighter.cs
Normal file
156
AirFighter/AirFighter/DrawingAirFighter.cs
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
internal class DrawingAirFighter
|
||||||
|
{
|
||||||
|
public EntityAirFighter AirFighter { get; private set; }
|
||||||
|
|
||||||
|
private float _startPosX;
|
||||||
|
private float _startPosY;
|
||||||
|
|
||||||
|
private int? _pictureWidth = null;
|
||||||
|
private int? _pictureHeight = null;
|
||||||
|
|
||||||
|
private readonly int _airFighterWidth = 195;
|
||||||
|
private readonly int _airFighterHeight = 166;
|
||||||
|
|
||||||
|
public void Init(int speed, float weight, Color bodyColor)
|
||||||
|
{
|
||||||
|
AirFighter = new EntityAirFighter();
|
||||||
|
AirFighter.Init(speed, weight, bodyColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPosition(int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
if (width < _airFighterWidth || height < _airFighterHeight) return;
|
||||||
|
|
||||||
|
if (x + _airFighterWidth > width || x < 0) return;
|
||||||
|
if (y + _airFighterHeight > height || y < 0) return;
|
||||||
|
|
||||||
|
_startPosX = x;
|
||||||
|
_startPosY = y;
|
||||||
|
|
||||||
|
_pictureWidth = width;
|
||||||
|
_pictureHeight = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MoveTransport(Direction direction)
|
||||||
|
{
|
||||||
|
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
case Direction.Right:
|
||||||
|
if (_startPosX + _airFighterWidth + AirFighter.Step < _pictureWidth)
|
||||||
|
{
|
||||||
|
_startPosX += AirFighter.Step;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Direction.Left:
|
||||||
|
if (_startPosX - AirFighter.Step > 0)
|
||||||
|
{
|
||||||
|
_startPosX -= AirFighter.Step;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Direction.Up:
|
||||||
|
if (_startPosY - AirFighter.Step > 0)
|
||||||
|
{
|
||||||
|
_startPosY -= AirFighter.Step;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Direction.Down:
|
||||||
|
if (_startPosY + _airFighterHeight + AirFighter.Step < _pictureHeight)
|
||||||
|
{
|
||||||
|
_startPosY += AirFighter.Step;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DrawTransport(Graphics g)
|
||||||
|
{
|
||||||
|
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pen pen = new(AirFighter.BodyColor);
|
||||||
|
Brush brushBlack = new SolidBrush(AirFighter.BodyColor);
|
||||||
|
|
||||||
|
PointF[] front = {
|
||||||
|
new(_startPosX + 160, _startPosY + 70),
|
||||||
|
new(_startPosX + 195, _startPosY + 83),
|
||||||
|
new(_startPosX + 160, _startPosY + 96)
|
||||||
|
};
|
||||||
|
|
||||||
|
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.FillPolygon(brushBlack, front);
|
||||||
|
g.DrawPolygon(pen, tailTop);
|
||||||
|
g.DrawPolygon(pen, tailBottom);
|
||||||
|
g.DrawPolygon(pen, wingTop);
|
||||||
|
g.DrawPolygon(pen, wingBottom);
|
||||||
|
g.DrawRectangle(pen, _startPosX, _startPosY + 70, 160, 26);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ChangeBorders(int width, int height)
|
||||||
|
{
|
||||||
|
_pictureWidth = width;
|
||||||
|
_pictureHeight = height;
|
||||||
|
if (_pictureWidth <= _airFighterWidth || _pictureHeight <= _airFighterHeight)
|
||||||
|
{
|
||||||
|
_pictureWidth = null;
|
||||||
|
_pictureHeight = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_startPosX + _airFighterWidth > _pictureWidth)
|
||||||
|
{
|
||||||
|
_startPosX = _pictureWidth.Value - _airFighterWidth;
|
||||||
|
}
|
||||||
|
if (_startPosY + _airFighterHeight > _pictureHeight)
|
||||||
|
{
|
||||||
|
_startPosY = _pictureHeight.Value - _airFighterHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
26
AirFighter/AirFighter/EntityAirFighter.cs
Normal file
26
AirFighter/AirFighter/EntityAirFighter.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
internal class EntityAirFighter
|
||||||
|
{
|
||||||
|
public int Speed { get; private set; }
|
||||||
|
public float Weight { get; private set; }
|
||||||
|
public Color BodyColor { get; private set; }
|
||||||
|
|
||||||
|
public float Step => Speed * 100 / Weight;
|
||||||
|
|
||||||
|
public void Init(int speed, float weight, Color bodyColor)
|
||||||
|
{
|
||||||
|
Random rnd = new();
|
||||||
|
|
||||||
|
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
||||||
|
Weight = weight <= 0 ? rnd.Next(50, 70) : weight;
|
||||||
|
BodyColor = bodyColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
185
AirFighter/AirFighter/FormAirFighter.Designer.cs
generated
Normal file
185
AirFighter/AirFighter/FormAirFighter.Designer.cs
generated
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
partial class FormAirFighter
|
||||||
|
{
|
||||||
|
/// <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.CreateButton = new System.Windows.Forms.Button();
|
||||||
|
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||||
|
this.DownButton = new System.Windows.Forms.Button();
|
||||||
|
this.UpButton = new System.Windows.Forms.Button();
|
||||||
|
this.LeftButton = new System.Windows.Forms.Button();
|
||||||
|
this.RightButton = new System.Windows.Forms.Button();
|
||||||
|
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
||||||
|
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
|
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
|
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||||
|
this.statusStrip1.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// CreateButton
|
||||||
|
//
|
||||||
|
this.CreateButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.CreateButton.Location = new System.Drawing.Point(12, 390);
|
||||||
|
this.CreateButton.Name = "CreateButton";
|
||||||
|
this.CreateButton.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.CreateButton.TabIndex = 0;
|
||||||
|
this.CreateButton.Text = "создать";
|
||||||
|
this.CreateButton.UseVisualStyleBackColor = true;
|
||||||
|
this.CreateButton.Click += new System.EventHandler(this.CreateButton_Click);
|
||||||
|
//
|
||||||
|
// pictureBox
|
||||||
|
//
|
||||||
|
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.pictureBox.Name = "pictureBox";
|
||||||
|
this.pictureBox.Size = new System.Drawing.Size(800, 450);
|
||||||
|
this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||||
|
this.pictureBox.TabIndex = 1;
|
||||||
|
this.pictureBox.TabStop = false;
|
||||||
|
this.pictureBox.Resize += new System.EventHandler(this.PictureBox_Resize);
|
||||||
|
//
|
||||||
|
// DownButton
|
||||||
|
//
|
||||||
|
this.DownButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.DownButton.BackgroundImage = global::AirFighter.Properties.Resources.down;
|
||||||
|
this.DownButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.DownButton.Location = new System.Drawing.Point(727, 389);
|
||||||
|
this.DownButton.Name = "DownButton";
|
||||||
|
this.DownButton.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
||||||
|
this.DownButton.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.DownButton.TabIndex = 2;
|
||||||
|
this.DownButton.UseVisualStyleBackColor = true;
|
||||||
|
this.DownButton.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// UpButton
|
||||||
|
//
|
||||||
|
this.UpButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.UpButton.BackgroundImage = global::AirFighter.Properties.Resources.up;
|
||||||
|
this.UpButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.UpButton.Location = new System.Drawing.Point(727, 354);
|
||||||
|
this.UpButton.Name = "UpButton";
|
||||||
|
this.UpButton.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
||||||
|
this.UpButton.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.UpButton.TabIndex = 3;
|
||||||
|
this.UpButton.UseVisualStyleBackColor = true;
|
||||||
|
this.UpButton.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// LeftButton
|
||||||
|
//
|
||||||
|
this.LeftButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.LeftButton.BackgroundImage = global::AirFighter.Properties.Resources.left;
|
||||||
|
this.LeftButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.LeftButton.Location = new System.Drawing.Point(691, 389);
|
||||||
|
this.LeftButton.Name = "LeftButton";
|
||||||
|
this.LeftButton.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
||||||
|
this.LeftButton.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.LeftButton.TabIndex = 4;
|
||||||
|
this.LeftButton.UseVisualStyleBackColor = true;
|
||||||
|
this.LeftButton.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// RightButton
|
||||||
|
//
|
||||||
|
this.RightButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.RightButton.BackgroundImage = global::AirFighter.Properties.Resources.right;
|
||||||
|
this.RightButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.RightButton.Location = new System.Drawing.Point(763, 389);
|
||||||
|
this.RightButton.Name = "RightButton";
|
||||||
|
this.RightButton.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
||||||
|
this.RightButton.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.RightButton.TabIndex = 5;
|
||||||
|
this.RightButton.UseVisualStyleBackColor = true;
|
||||||
|
this.RightButton.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// statusStrip1
|
||||||
|
//
|
||||||
|
this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||||
|
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.toolStripStatusLabelSpeed,
|
||||||
|
this.toolStripStatusLabelWeight,
|
||||||
|
this.toolStripStatusLabelBodyColor});
|
||||||
|
this.statusStrip1.Location = new System.Drawing.Point(0, 424);
|
||||||
|
this.statusStrip1.Name = "statusStrip1";
|
||||||
|
this.statusStrip1.Size = new System.Drawing.Size(800, 26);
|
||||||
|
this.statusStrip1.TabIndex = 6;
|
||||||
|
this.statusStrip1.Text = "statusStrip1";
|
||||||
|
//
|
||||||
|
// toolStripStatusLabelSpeed
|
||||||
|
//
|
||||||
|
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
|
||||||
|
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(74, 20);
|
||||||
|
this.toolStripStatusLabelSpeed.Text = "скорость:";
|
||||||
|
//
|
||||||
|
// toolStripStatusLabelWeight
|
||||||
|
//
|
||||||
|
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
|
||||||
|
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(35, 20);
|
||||||
|
this.toolStripStatusLabelWeight.Text = "вес:";
|
||||||
|
//
|
||||||
|
// toolStripStatusLabelBodyColor
|
||||||
|
//
|
||||||
|
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
|
||||||
|
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(43, 20);
|
||||||
|
this.toolStripStatusLabelBodyColor.Text = "цвет:";
|
||||||
|
//
|
||||||
|
// FormAirFighter
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.statusStrip1);
|
||||||
|
this.Controls.Add(this.RightButton);
|
||||||
|
this.Controls.Add(this.LeftButton);
|
||||||
|
this.Controls.Add(this.UpButton);
|
||||||
|
this.Controls.Add(this.DownButton);
|
||||||
|
this.Controls.Add(this.CreateButton);
|
||||||
|
this.Controls.Add(this.pictureBox);
|
||||||
|
this.Name = "FormAirFighter";
|
||||||
|
this.Text = "Form1";
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||||
|
this.statusStrip1.ResumeLayout(false);
|
||||||
|
this.statusStrip1.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button CreateButton;
|
||||||
|
private PictureBox pictureBox;
|
||||||
|
private Button DownButton;
|
||||||
|
private Button UpButton;
|
||||||
|
private Button LeftButton;
|
||||||
|
private Button RightButton;
|
||||||
|
private StatusStrip statusStrip1;
|
||||||
|
private ToolStripStatusLabel toolStripStatusLabelSpeed;
|
||||||
|
private ToolStripStatusLabel toolStripStatusLabelWeight;
|
||||||
|
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
|
||||||
|
}
|
||||||
|
}
|
72
AirFighter/AirFighter/FormAirFighter.cs
Normal file
72
AirFighter/AirFighter/FormAirFighter.cs
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
namespace AirFighter
|
||||||
|
{
|
||||||
|
public partial class FormAirFighter : Form
|
||||||
|
{
|
||||||
|
private DrawingAirFighter _airFighter;
|
||||||
|
|
||||||
|
public FormAirFighter()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Random rnd = new();
|
||||||
|
|
||||||
|
_airFighter = new DrawingAirFighter();
|
||||||
|
|
||||||
|
_airFighter.Init(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||||
|
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||||
|
|
||||||
|
_airFighter.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBox.Width, pictureBox.Height);
|
||||||
|
|
||||||
|
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_airFighter.AirFighter.Speed}";
|
||||||
|
toolStripStatusLabelWeight.Text = $"Âåñ: {_airFighter.AirFighter.Weight}";
|
||||||
|
toolStripStatusLabelBodyColor.Text = $"Öâåò: { _airFighter.AirFighter.BodyColor.Name}";
|
||||||
|
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string name = ((Button)sender).Name ?? string.Empty;
|
||||||
|
|
||||||
|
switch(name)
|
||||||
|
{
|
||||||
|
case "UpButton":
|
||||||
|
_airFighter?.MoveTransport(Direction.Up);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "LeftButton":
|
||||||
|
_airFighter?.MoveTransport(Direction.Left);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "DownButton":
|
||||||
|
_airFighter?.MoveTransport(Direction.Down);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "RightButton":
|
||||||
|
_airFighter?.MoveTransport(Direction.Right);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PictureBox_Resize(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_airFighter?.ChangeBorders(pictureBox.Width, pictureBox.Height);
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Draw()
|
||||||
|
{
|
||||||
|
if (pictureBox.Width == 0 || pictureBox.Height == 0) return;
|
||||||
|
Bitmap bmp = new(pictureBox.Width, pictureBox.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_airFighter?.DrawTransport(gr);
|
||||||
|
pictureBox.Image = bmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
63
AirFighter/AirFighter/FormAirFighter.resx
Normal file
63
AirFighter/AirFighter/FormAirFighter.resx
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<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>
|
||||||
|
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
@ -11,7 +11,7 @@ namespace 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 FormAirFighter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
103
AirFighter/AirFighter/Properties/Resources.Designer.cs
generated
Normal file
103
AirFighter/AirFighter/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <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 down {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("down", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap left {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("left", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap right {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("right", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap up {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("up", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -117,4 +117,17 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
|
<data name="right" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\right.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="down" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="left" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\left.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="up" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
BIN
AirFighter/AirFighter/Resources/down.png
Normal file
BIN
AirFighter/AirFighter/Resources/down.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
BIN
AirFighter/AirFighter/Resources/left.png
Normal file
BIN
AirFighter/AirFighter/Resources/left.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
BIN
AirFighter/AirFighter/Resources/right.png
Normal file
BIN
AirFighter/AirFighter/Resources/right.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
BIN
AirFighter/AirFighter/Resources/up.png
Normal file
BIN
AirFighter/AirFighter/Resources/up.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Loading…
Reference in New Issue
Block a user