Revert "Revert "Revert "Revert "готовый проект""""
This reverts commit 704a27c3aa
.
This commit is contained in:
parent
704a27c3aa
commit
aaa540c662
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAirplaneWithRadar
|
||||
{
|
||||
public enum Direction
|
||||
{
|
||||
// Вверх
|
||||
Up = 1,
|
||||
/// Вниз
|
||||
Down = 2,
|
||||
/// Влево
|
||||
Left = 3,
|
||||
/// Вправо
|
||||
Right = 4
|
||||
}
|
||||
}
|
@ -0,0 +1,149 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ProjectAirplaneWithRadar
|
||||
{
|
||||
public class DrawningAirplaneWithRadar
|
||||
{
|
||||
public EntityAirplaneWithRadar? EntityAirplaneWithRadar { get; private set; }
|
||||
public int _pictureWidth;
|
||||
public int _pictureHeight;
|
||||
public int _startPosX;
|
||||
public int _startPosY;
|
||||
private readonly int _airplaneWidth = 200;
|
||||
private readonly int _airplaneHeight = 78;
|
||||
public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool radar, bool dopbak, int width, int height)
|
||||
{
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
if (_airplaneWidth > _pictureWidth || _airplaneHeight > _pictureHeight)
|
||||
return false;
|
||||
EntityAirplaneWithRadar = new EntityAirplaneWithRadar();
|
||||
EntityAirplaneWithRadar.Init(speed, weight, bodyColor, additionalColor, radar, dopbak);
|
||||
return true;
|
||||
}
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if(x < 0 || y < 0 ||x+_airplaneWidth >= _pictureWidth|| y + _airplaneHeight >= _pictureHeight)
|
||||
{
|
||||
x = y = 10;
|
||||
_startPosX = x;
|
||||
_startPosY=y;
|
||||
}
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
public void MoveTransport(Direction direction)
|
||||
{
|
||||
if (EntityAirplaneWithRadar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
case Direction.Left:
|
||||
if (_startPosX - EntityAirplaneWithRadar.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityAirplaneWithRadar.Step;
|
||||
}
|
||||
break;
|
||||
case Direction.Up:
|
||||
if (_startPosY - EntityAirplaneWithRadar.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityAirplaneWithRadar.Step;
|
||||
}
|
||||
break;
|
||||
case Direction.Right:
|
||||
if (_startPosX + EntityAirplaneWithRadar.Step+_airplaneWidth < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityAirplaneWithRadar.Step;
|
||||
}
|
||||
break;
|
||||
case Direction.Down:
|
||||
if (_startPosY + EntityAirplaneWithRadar.Step+_airplaneHeight < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityAirplaneWithRadar.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void DrawTransport(Graphics g)
|
||||
{
|
||||
if(EntityAirplaneWithRadar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new Pen(Color.Black, 3);
|
||||
Brush additionalBrush = new SolidBrush(EntityAirplaneWithRadar.AdditionalColor);
|
||||
// корпус
|
||||
Brush br = new SolidBrush(EntityAirplaneWithRadar.BodyColor);
|
||||
g.DrawEllipse(pen, _startPosX, _startPosY+25,180, 30) ;
|
||||
g.FillEllipse(br, _startPosX, _startPosY+25, 180, 30);
|
||||
// крыло
|
||||
Brush blackBrush = new SolidBrush(Color.Black);
|
||||
g.FillEllipse(blackBrush, _startPosX + 70, _startPosY + 35, 80, 10);
|
||||
// стекла
|
||||
Pen blackPen = new Pen(Color.Black, 2);
|
||||
Brush blueBrush = new SolidBrush(Color.LightBlue);
|
||||
Point point1 = new Point(_startPosX+170, _startPosY+30);
|
||||
Point point2 = new Point(_startPosX+200, _startPosY+40);
|
||||
Point point3 = new Point(_startPosX+170, _startPosY + 50);
|
||||
Point[] curvePoints =
|
||||
{
|
||||
point1,
|
||||
point2,
|
||||
point3,
|
||||
};
|
||||
g.FillPolygon(blueBrush, curvePoints);
|
||||
g.DrawPolygon(blackPen, curvePoints);
|
||||
g.DrawLine(blackPen, _startPosX + 170, _startPosY + 40, _startPosX + 200, _startPosY + 40);
|
||||
// хвост
|
||||
Point point4 = new Point(_startPosX, _startPosY + 35);
|
||||
Point point5 = new Point(_startPosX, _startPosY +5 );
|
||||
Point point6 = new Point(_startPosX + 30, _startPosY + 35);
|
||||
Point[] curvePoints2 =
|
||||
{
|
||||
point4,
|
||||
point5,
|
||||
point6,
|
||||
};
|
||||
g.FillPolygon(br, curvePoints2);
|
||||
g.DrawPolygon(blackPen, curvePoints2);
|
||||
// шасси
|
||||
g.DrawLine(blackPen, _startPosX + 50, _startPosY + 55, _startPosX + 50, _startPosY + 70);
|
||||
g.DrawLine(blackPen, _startPosX + 150, _startPosY + 51, _startPosX + 150, _startPosY + 70);
|
||||
g.FillEllipse(blackBrush, _startPosX + 40, _startPosY + 65, 10, 10);
|
||||
g.FillEllipse(blackBrush, _startPosX + 50, _startPosY + 65, 10, 10);
|
||||
g.FillEllipse(blackBrush, _startPosX + 145, _startPosY + 65, 10, 10);
|
||||
if (EntityAirplaneWithRadar.DopBak)
|
||||
{
|
||||
//бак
|
||||
g.FillEllipse(additionalBrush, _startPosX, _startPosY + 45, 40, 20);
|
||||
g.DrawEllipse(blackPen, _startPosX, _startPosY + 45, 40, 20);
|
||||
}
|
||||
if (EntityAirplaneWithRadar.Radar)
|
||||
{
|
||||
//радар
|
||||
g.DrawLine(blackPen, _startPosX + 60, _startPosY + 25, _startPosX + 60, _startPosY + 15);
|
||||
g.DrawLine(blackPen, _startPosX + 60, _startPosY + 15, _startPosX + 67, _startPosY + 11);
|
||||
Point point7 = new Point(_startPosX + 60, _startPosY + 15);
|
||||
Point point8 = new Point(_startPosX + 60, _startPosY + 5);
|
||||
Point point9 = new Point(_startPosX + 70, _startPosY + 25);
|
||||
Point[] curvePoints3 =
|
||||
{
|
||||
point7,
|
||||
point8,
|
||||
point9,
|
||||
};
|
||||
g.FillPolygon(additionalBrush, curvePoints3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAirplaneWithRadar
|
||||
{
|
||||
public class EntityAirplaneWithRadar
|
||||
{
|
||||
//скорость
|
||||
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 Radar{ get; private set; }
|
||||
// наличие дополнительных топливных баков
|
||||
public bool DopBak{ get; private set; }
|
||||
//шаг перемещения самолета
|
||||
public double Step => (double)Speed*100/Weight;
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool radar, bool dopbak)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
AdditionalColor = additionalColor;
|
||||
Radar = radar;
|
||||
DopBak = dopbak;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
namespace ProjectAirplaneWithRadar
|
||||
{
|
||||
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 ProjectAirplaneWithRadar
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
128
ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplaneWithRadar.Designer.cs
generated
Normal file
128
ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplaneWithRadar.Designer.cs
generated
Normal file
@ -0,0 +1,128 @@
|
||||
namespace ProjectAirplaneWithRadar
|
||||
{
|
||||
partial class FormAirplaneWithRadar
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
pictureBoxAirplaneWithRadar = new PictureBox();
|
||||
buttonCreate = new Button();
|
||||
buttonDown = new Button();
|
||||
buttonRight = new Button();
|
||||
buttonLeft = new Button();
|
||||
buttonUp = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxAirplaneWithRadar).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBoxAirplaneWithRadar
|
||||
//
|
||||
pictureBoxAirplaneWithRadar.Dock = DockStyle.Fill;
|
||||
pictureBoxAirplaneWithRadar.Location = new Point(0, 0);
|
||||
pictureBoxAirplaneWithRadar.Name = "pictureBoxAirplaneWithRadar";
|
||||
pictureBoxAirplaneWithRadar.Size = new Size(882, 453);
|
||||
pictureBoxAirplaneWithRadar.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||
pictureBoxAirplaneWithRadar.TabIndex = 0;
|
||||
pictureBoxAirplaneWithRadar.TabStop = false;
|
||||
pictureBoxAirplaneWithRadar.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(12, 412);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(94, 29);
|
||||
buttonCreate.TabIndex = 1;
|
||||
buttonCreate.Text = "Create";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += buttonCreate_Click;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
buttonDown.Location = new Point(766, 396);
|
||||
buttonDown.Name = "buttonDown";
|
||||
buttonDown.Size = new Size(49, 45);
|
||||
buttonDown.TabIndex = 2;
|
||||
buttonDown.Text = "↓";
|
||||
buttonDown.UseVisualStyleBackColor = true;
|
||||
buttonDown.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
buttonRight.Location = new Point(821, 396);
|
||||
buttonRight.Name = "buttonRight";
|
||||
buttonRight.Size = new Size(49, 45);
|
||||
buttonRight.TabIndex = 3;
|
||||
buttonRight.Text = "→";
|
||||
buttonRight.UseVisualStyleBackColor = true;
|
||||
buttonRight.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
buttonLeft.Location = new Point(711, 396);
|
||||
buttonLeft.Name = "buttonLeft";
|
||||
buttonLeft.Size = new Size(49, 45);
|
||||
buttonLeft.TabIndex = 4;
|
||||
buttonLeft.Text = "←";
|
||||
buttonLeft.UseVisualStyleBackColor = true;
|
||||
buttonLeft.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
buttonUp.Location = new Point(766, 345);
|
||||
buttonUp.Name = "buttonUp";
|
||||
buttonUp.Size = new Size(49, 45);
|
||||
buttonUp.TabIndex = 5;
|
||||
buttonUp.Text = "↑";
|
||||
buttonUp.UseVisualStyleBackColor = true;
|
||||
buttonUp.Click += buttonMove_Click;
|
||||
//
|
||||
// FormAirplaneWithRadar
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(882, 453);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(pictureBoxAirplaneWithRadar);
|
||||
Name = "FormAirplaneWithRadar";
|
||||
Text = "FormAirplaneWithRadar";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxAirplaneWithRadar).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxAirplaneWithRadar;
|
||||
private Button buttonCreate;
|
||||
private Button buttonDown;
|
||||
private Button buttonRight;
|
||||
private Button buttonLeft;
|
||||
private Button buttonUp;
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ProjectAirplaneWithRadar
|
||||
{
|
||||
public partial class FormAirplaneWithRadar : Form
|
||||
{
|
||||
private DrawningAirplaneWithRadar? _drawningAirplaneWithRadar;
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawningAirplaneWithRadar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new Bitmap(pictureBoxAirplaneWithRadar.Width, pictureBoxAirplaneWithRadar.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningAirplaneWithRadar.DrawTransport(gr);
|
||||
pictureBoxAirplaneWithRadar.Image = bmp;
|
||||
}
|
||||
public FormAirplaneWithRadar()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new Random();
|
||||
_drawningAirplaneWithRadar = new DrawningAirplaneWithRadar();
|
||||
if (_drawningAirplaneWithRadar.Init
|
||||
(random.Next(100, 300), // speed
|
||||
random.Next(1000, 3000),// weight
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),// bodycolor
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), //additionalColor
|
||||
Convert.ToBoolean(random.Next(0, 2)), // radar
|
||||
Convert.ToBoolean(random.Next(0, 2)), //dopbak
|
||||
pictureBoxAirplaneWithRadar.Width, pictureBoxAirplaneWithRadar.Height))
|
||||
{
|
||||
_drawningAirplaneWithRadar.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
private void buttonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningAirplaneWithRadar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_drawningAirplaneWithRadar.MoveTransport(Direction.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_drawningAirplaneWithRadar.MoveTransport(Direction.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_drawningAirplaneWithRadar.MoveTransport(Direction.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_drawningAirplaneWithRadar.MoveTransport(Direction.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ProjectAirplaneWithRadar
|
||||
{
|
||||
internal static class Program
|
||||
@ -8,10 +14,9 @@ namespace ProjectAirplaneWithRadar
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
Application.EnableVisualStyles();
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
Application.Run(new FormAirplaneWithRadar());
|
||||
}
|
||||
}
|
||||
}
|
0
ProjectAirplaneWithRadar/Новый файл
Normal file
0
ProjectAirplaneWithRadar/Новый файл
Normal file
Loading…
Reference in New Issue
Block a user