Revert "Revert "Revert "Revert "Revert "готовый проект"""""

This reverts commit aaa540c662.
This commit is contained in:
antoc0der 2023-10-09 12:20:34 +03:00
parent aaa540c662
commit 2c1cedade6
10 changed files with 77 additions and 439 deletions

View File

@ -1,20 +0,0 @@
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
}
}

View File

@ -1,149 +0,0 @@
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);
}
}
}
}

View File

@ -1,36 +0,0 @@
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;
}
}
}

View File

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

View File

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

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
The primary goals of this format is to allow a simple XML format The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes various data types are done through the TypeConverter classes
associated with the data types. associated with the data types.
Example: Example:
... ado.net/XML headers & schema ... ... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader> <resheader name="version">2.0</resheader>
@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment> <comment>This is a comment</comment>
</data> </data>
There are any number of "resheader" rows that contain simple There are any number of "resheader" rows that contain simple
name/value pairs. name/value pairs.
Each data row contains a name, and value. The row also contains a Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture. text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the Classes that don't support this are serialized and stored with the
mimetype set. mimetype set.
The mimetype is used for serialized objects, and tells the The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly: extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below. read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64 mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->

View File

@ -1,128 +0,0 @@
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;
}
}

View File

@ -1,73 +0,0 @@
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();
}
}
}

View File

@ -1,9 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProjectAirplaneWithRadar namespace ProjectAirplaneWithRadar
{ {
internal static class Program internal static class Program
@ -14,9 +8,10 @@ namespace ProjectAirplaneWithRadar
[STAThread] [STAThread]
static void Main() static void Main()
{ {
Application.EnableVisualStyles(); // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
Application.Run(new FormAirplaneWithRadar()); Application.Run(new Form1());
} }
} }
} }