создал форму
This commit is contained in:
parent
2c1cedade6
commit
1d8824c3e4
@ -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,6 +1,6 @@
|
||||
namespace ProjectAirplaneWithRadar
|
||||
{
|
||||
partial class Form1
|
||||
partial class FormAirplaneWithRadar
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -28,10 +28,16 @@
|
||||
/// </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";
|
||||
SuspendLayout();
|
||||
//
|
||||
// FormAirplaneWithRadar
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(882, 453);
|
||||
Name = "FormAirplaneWithRadar";
|
||||
Text = "FormAirplaneWithRadar";
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
@ -1,8 +1,8 @@
|
||||
namespace ProjectAirplaneWithRadar
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
public partial class FormAirplaneWithRadar : Form
|
||||
{
|
||||
public Form1()
|
||||
public FormAirplaneWithRadar()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
<?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
|
||||
|
||||
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>
|
||||
@ -26,36 +26,36 @@
|
||||
<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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
@ -11,7 +11,7 @@ namespace ProjectAirplaneWithRadar
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
Application.Run(new FormAirplaneWithRadar());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user