PIbd-21 Makarov D.V. Lab 01 #1
25
AirplaneWithRadar/AirplaneWithRadar.sln
Normal file
25
AirplaneWithRadar/AirplaneWithRadar.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.6.33815.320
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AirplaneWithRadar", "AirplaneWithRadar\AirplaneWithRadar.csproj", "{AF704CA3-06A3-4E16-BD8E-E38D724F52C4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{AF704CA3-06A3-4E16-BD8E-E38D724F52C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AF704CA3-06A3-4E16-BD8E-E38D724F52C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AF704CA3-06A3-4E16-BD8E-E38D724F52C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AF704CA3-06A3-4E16-BD8E-E38D724F52C4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {C29B6A34-9081-42AD-A30A-C976A7E636B5}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
120
AirplaneWithRadar/AirplaneWithRadar/.resx
Normal file
120
AirplaneWithRadar/AirplaneWithRadar/.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?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>
|
||||
</root>
|
11
AirplaneWithRadar/AirplaneWithRadar/AirplaneWithRadar.csproj
Normal file
11
AirplaneWithRadar/AirplaneWithRadar/AirplaneWithRadar.csproj
Normal file
@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
18
AirplaneWithRadar/AirplaneWithRadar/Class1.cs
Normal file
18
AirplaneWithRadar/AirplaneWithRadar/Class1.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Plane
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
private int x;
|
||||
public int y { private get; set; }
|
||||
public int Sum(int num1, int num2)
|
||||
{
|
||||
return num1 + num2;
|
||||
}
|
||||
}
|
||||
}
|
16
AirplaneWithRadar/AirplaneWithRadar/Movement.cs
Normal file
16
AirplaneWithRadar/AirplaneWithRadar/Movement.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Plane
|
||||
{
|
||||
public enum Movement
|
||||
{
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 3,
|
||||
Right = 4,
|
||||
}
|
||||
}
|
217
AirplaneWithRadar/AirplaneWithRadar/Paint.cs
Normal file
217
AirplaneWithRadar/AirplaneWithRadar/Paint.cs
Normal file
@ -0,0 +1,217 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Plane
|
||||
{
|
||||
public class Paint
|
||||
eegov
commented
Имя класса не соответствует указаному в задании Имя класса не соответствует указаному в задании
|
||||
{
|
||||
public PlaneEntity? PlaneEntity { get; private set; }
|
||||
private int pictWidth;
|
||||
private int pictHeight;
|
||||
private int startPosX;
|
||||
private int startPosY;
|
||||
private readonly int planeWidth = 140;
|
||||
private readonly int planeHeight = 60;
|
||||
|
||||
public bool Init(int speed, double weight, Color mainColor, Color additColor, bool radarOnBoard, bool additFuelPod, int width, int height)
|
||||
{
|
||||
if (planeWidth > width || planeHeight > height) { return false; }
|
||||
|
||||
pictHeight = height;
|
||||
pictWidth = width;
|
||||
PlaneEntity = new PlaneEntity();
|
||||
PlaneEntity.Init(speed, weight, mainColor, additColor, radarOnBoard, additFuelPod);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (x + planeWidth < pictWidth && y + planeHeight < pictHeight)
|
||||
eegov
commented
Не учтены все условия, при которых объект может выйти за границы Не учтены все условия, при которых объект может выйти за границы
|
||||
{
|
||||
startPosX = x;
|
||||
startPosY = y;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x > pictWidth)
|
||||
{
|
||||
while (x + planeWidth > pictWidth)
|
||||
{
|
||||
x -= 1;
|
||||
}
|
||||
}
|
||||
if (y > pictWidth)
|
||||
{
|
||||
while (y + planeHeight > pictHeight)
|
||||
{
|
||||
y -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Move(Movement dir)
|
||||
{
|
||||
if (PlaneEntity == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (dir)
|
||||
{
|
||||
case Movement.Left:
|
||||
if (startPosX - PlaneEntity.Step > 0)
|
||||
{
|
||||
startPosX -= (int) PlaneEntity.Step;
|
||||
}
|
||||
break;
|
||||
case Movement.Up:
|
||||
if (startPosY - PlaneEntity.Step > 0)
|
||||
{
|
||||
startPosY -= (int) PlaneEntity.Step;
|
||||
}
|
||||
break;
|
||||
case Movement.Right:
|
||||
if (startPosX + planeWidth + PlaneEntity.Step < pictWidth)
|
||||
{
|
||||
startPosX += (int)PlaneEntity.Step;
|
||||
}
|
||||
break;
|
||||
case Movement.Down:
|
||||
if (startPosY + planeHeight + PlaneEntity.Step < pictHeight)
|
||||
{
|
||||
startPosY += (int)PlaneEntity.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void DrawTransport(Graphics g)
|
||||
{
|
||||
if (PlaneEntity == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
Brush mainBrush = new SolidBrush(PlaneEntity.MainColor);
|
||||
Brush additBrush = new SolidBrush(PlaneEntity.AdditColor);
|
||||
|
||||
//основа
|
||||
|
||||
g.DrawLine(pen, new Point(startPosX + planeWidth / 44, startPosY + planeHeight / 2), new Point(startPosX + planeWidth - planeWidth / 6, startPosY + planeHeight / 2));
|
||||
g.DrawLine(pen, new Point(startPosX + planeWidth / 44, startPosY + planeHeight - planeHeight / 8), new Point(startPosX + planeWidth - planeWidth / 6, startPosY + planeHeight - planeHeight / 8));
|
||||
|
||||
|
||||
g.DrawArc(pen, new Rectangle(startPosX, startPosY + planeHeight / 2, planeWidth / 24, planeHeight/2 - planeHeight / 8), 90.0f, 180.0f);
|
||||
|
||||
DrawTriangle(g, pen,
|
||||
startPosX + planeWidth - planeWidth / 6, startPosY + planeHeight / 2, // 1
|
||||
startPosX + planeWidth, startPosY + 5 * planeHeight / 7, // 2
|
||||
startPosX + planeWidth - planeWidth / 6, startPosY + planeHeight - planeHeight / 8); // 3
|
||||
|
||||
DrawTriangle(g, pen,
|
||||
startPosX, startPosY, // 1
|
||||
startPosX + planeWidth/4, startPosY + planeHeight/2, // 2
|
||||
startPosX, startPosY + planeHeight / 2); // 3
|
||||
g.DrawLine(pen, new Point(startPosX + planeWidth - planeWidth / 6, startPosY + 5 * planeHeight / 7),
|
||||
new Point(startPosX + planeWidth, startPosY + 5 * planeHeight / 7));
|
||||
// колеса
|
||||
g.DrawLine(pen, new Point(startPosX + planeWidth / 4, startPosY + planeHeight - planeHeight / 8),
|
||||
new Point(startPosX + planeWidth / 4, startPosY + planeHeight - planeHeight / 11));
|
||||
g.DrawLine(pen, new Point(startPosX + planeWidth - 2 * planeWidth / 9, startPosY + planeHeight - planeHeight / 8),
|
||||
new Point(startPosX + planeWidth - 2 * planeWidth / 9, startPosY + planeHeight - planeHeight / 11));
|
||||
g.DrawEllipse(pen, new Rectangle(startPosX + planeWidth / 4 - planeWidth / 23, startPosY + 11 * planeHeight / 12,
|
||||
planeHeight / 12, planeHeight / 12));
|
||||
g.DrawEllipse(pen, new Rectangle(startPosX + planeWidth / 4 + planeWidth / 72, startPosY + 11 * planeHeight / 12,
|
||||
planeHeight / 12, planeHeight / 12));
|
||||
|
||||
g.DrawEllipse(pen, new Rectangle(startPosX + planeWidth - 5 * planeWidth / 21, startPosY + 11 * planeHeight / 12,
|
||||
planeHeight / 12, planeHeight / 12));
|
||||
|
||||
FillRoundedRectangle(g,new SolidBrush(Color.Black), new Rectangle(startPosX + 2*planeWidth / 9, startPosY + planeHeight / 2 + planeHeight / 7, planeWidth/2 ,planeHeight/7), 5);
|
||||
FillRoundedRectangle(g, new SolidBrush(Color.Black), new Rectangle(startPosX, startPosY + planeHeight / 2 - planeHeight/9, planeWidth / 5, planeHeight / 6), 5);
|
||||
|
||||
if (PlaneEntity.RadarOnBoard) {
|
||||
g.DrawLine(pen, new Point(startPosX + planeWidth / 3, startPosY + planeHeight / 2), new Point(startPosX + planeWidth / 3, startPosY + planeHeight / 3));
|
||||
g.FillPie(additBrush, new Rectangle(startPosX + planeWidth / 4, startPosY + planeHeight / 10, planeWidth / 6, planeHeight / 4), 30.0f, 180.0f);
|
||||
}
|
||||
if (PlaneEntity.AdditFuelPod)
|
||||
{
|
||||
FillRoundedRectangle(g, additBrush, new Rectangle(startPosX, startPosY + planeHeight - 2*planeHeight / 5, planeWidth / 5, planeHeight / 6), 5);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawTriangle(Graphics g, Pen pen, int x1, int y1, int x2, int y2, int x3, int y3)
|
||||
{
|
||||
Point p1 = new Point(x1, y1);
|
||||
Point p2 = new Point(x2, y2);
|
||||
Point p3 = new Point(x3, y3);
|
||||
g.DrawLine(pen, p1, p2);
|
||||
g.DrawLine(pen, p2, p3);
|
||||
g.DrawLine(pen, p3, p1);
|
||||
}
|
||||
|
||||
private static GraphicsPath RoundedRect(Rectangle bounds, int radius)
|
||||
{
|
||||
int diameter = radius * 2;
|
||||
Size size = new Size(diameter, diameter);
|
||||
Rectangle arc = new Rectangle(bounds.Location, size);
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
|
||||
if (radius == 0)
|
||||
{
|
||||
path.AddRectangle(bounds);
|
||||
return path;
|
||||
}
|
||||
|
||||
// top left arc
|
||||
path.AddArc(arc, 180, 90);
|
||||
|
||||
// top right arc
|
||||
arc.X = bounds.Right - diameter;
|
||||
path.AddArc(arc, 270, 90);
|
||||
|
||||
// bottom right arc
|
||||
arc.Y = bounds.Bottom - diameter;
|
||||
path.AddArc(arc, 0, 90);
|
||||
|
||||
// bottom left arc
|
||||
arc.X = bounds.Left;
|
||||
path.AddArc(arc, 90, 90);
|
||||
|
||||
path.CloseFigure();
|
||||
return path;
|
||||
}
|
||||
|
||||
private static void DrawRoundedRectangle(Graphics graphics, Pen pen, Rectangle bounds, int cornerRadius)
|
||||
{
|
||||
if (graphics == null)
|
||||
throw new ArgumentNullException(nameof(graphics));
|
||||
if (pen == null)
|
||||
throw new ArgumentNullException(nameof(pen));
|
||||
|
||||
using (GraphicsPath path = RoundedRect(bounds, cornerRadius))
|
||||
{
|
||||
graphics.DrawPath(pen, path);
|
||||
}
|
||||
}
|
||||
|
||||
private static void FillRoundedRectangle(Graphics graphics, Brush brush, Rectangle bounds, int cornerRadius)
|
||||
{
|
||||
if (graphics == null)
|
||||
throw new ArgumentNullException(nameof(graphics));
|
||||
if (brush == null)
|
||||
throw new ArgumentNullException(nameof(brush));
|
||||
|
||||
using (GraphicsPath path = RoundedRect(bounds, cornerRadius))
|
||||
{
|
||||
graphics.FillPath(brush, path);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
29
AirplaneWithRadar/AirplaneWithRadar/PlaneEntity.cs
Normal file
29
AirplaneWithRadar/AirplaneWithRadar/PlaneEntity.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Plane
|
||||
{
|
||||
public class PlaneEntity
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
public double Weight { get; private set; }
|
||||
public Color MainColor { get; private set; }
|
||||
public Color AdditColor { get; private set; }
|
||||
public bool RadarOnBoard { get; private set; }
|
||||
public bool AdditFuelPod { get; private set; }
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
|
||||
public void Init(int speed, double weight, Color mainColor, Color additColor, bool radarOnBoard, bool additFuelPod)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
MainColor = mainColor;
|
||||
AdditColor = additColor;
|
||||
RadarOnBoard = radarOnBoard;
|
||||
AdditFuelPod = additFuelPod;
|
||||
}
|
||||
}
|
||||
}
|
133
AirplaneWithRadar/AirplaneWithRadar/PlaneVisual.Designer.cs
generated
Normal file
133
AirplaneWithRadar/AirplaneWithRadar/PlaneVisual.Designer.cs
generated
Normal file
@ -0,0 +1,133 @@
|
||||
namespace Plane
|
||||
{
|
||||
partial class PlaneVisual
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
CreateButton = new Button();
|
||||
UpButton = new Button();
|
||||
LeftButton = new Button();
|
||||
DownButton = new Button();
|
||||
RightButton = new Button();
|
||||
PlanesPictureBox = new PictureBox();
|
||||
((System.ComponentModel.ISupportInitialize)PlanesPictureBox).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// CreateButton
|
||||
//
|
||||
CreateButton.Location = new Point(30, 391);
|
||||
CreateButton.Name = "CreateButton";
|
||||
CreateButton.Size = new Size(120, 40);
|
||||
CreateButton.TabIndex = 0;
|
||||
CreateButton.Text = "Создать";
|
||||
CreateButton.UseVisualStyleBackColor = true;
|
||||
CreateButton.Click += CreateButton_Click;
|
||||
//
|
||||
// UpButton
|
||||
//
|
||||
UpButton.Font = new Font("Segoe UI", 20F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
UpButton.Location = new Point(692, 345);
|
||||
UpButton.Name = "UpButton";
|
||||
UpButton.Size = new Size(40, 40);
|
||||
UpButton.TabIndex = 1;
|
||||
UpButton.Text = "↑";
|
||||
UpButton.TextAlign = ContentAlignment.TopCenter;
|
||||
UpButton.UseVisualStyleBackColor = true;
|
||||
UpButton.Click += buttonMove_Click;
|
||||
//
|
||||
// LeftButton
|
||||
//
|
||||
LeftButton.Font = new Font("Segoe UI", 22F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
LeftButton.Location = new Point(646, 391);
|
||||
LeftButton.Name = "LeftButton";
|
||||
LeftButton.Size = new Size(40, 40);
|
||||
LeftButton.TabIndex = 2;
|
||||
LeftButton.Text = "←";
|
||||
LeftButton.TextAlign = ContentAlignment.TopCenter;
|
||||
LeftButton.UseVisualStyleBackColor = true;
|
||||
LeftButton.Click += buttonMove_Click;
|
||||
//
|
||||
// DownButton
|
||||
//
|
||||
DownButton.Font = new Font("Segoe UI", 22F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
DownButton.Location = new Point(692, 391);
|
||||
DownButton.Name = "DownButton";
|
||||
DownButton.Size = new Size(40, 40);
|
||||
DownButton.TabIndex = 3;
|
||||
DownButton.Text = "↓";
|
||||
DownButton.TextAlign = ContentAlignment.TopCenter;
|
||||
DownButton.UseVisualStyleBackColor = true;
|
||||
DownButton.Click += buttonMove_Click;
|
||||
//
|
||||
// RightButton
|
||||
//
|
||||
RightButton.Font = new Font("Segoe UI", 22F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
RightButton.Location = new Point(735, 391);
|
||||
RightButton.Name = "RightButton";
|
||||
RightButton.Size = new Size(40, 40);
|
||||
RightButton.TabIndex = 4;
|
||||
RightButton.Text = "→";
|
||||
RightButton.UseVisualStyleBackColor = true;
|
||||
RightButton.Click += buttonMove_Click;
|
||||
//
|
||||
// PlanesPictureBox
|
||||
//
|
||||
PlanesPictureBox.Dock = DockStyle.Fill;
|
||||
PlanesPictureBox.Location = new Point(0, 0);
|
||||
PlanesPictureBox.Name = "PlanesPictureBox";
|
||||
PlanesPictureBox.Size = new Size(800, 450);
|
||||
PlanesPictureBox.TabIndex = 5;
|
||||
PlanesPictureBox.TabStop = false;
|
||||
//
|
||||
// PlaneVisual
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(RightButton);
|
||||
Controls.Add(DownButton);
|
||||
Controls.Add(LeftButton);
|
||||
Controls.Add(UpButton);
|
||||
Controls.Add(CreateButton);
|
||||
Controls.Add(PlanesPictureBox);
|
||||
Name = "PlaneVisual";
|
||||
Text = "Flying Plane";
|
||||
Load += Form1_Load;
|
||||
((System.ComponentModel.ISupportInitialize)PlanesPictureBox).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button CreateButton;
|
||||
private Button UpButton;
|
||||
private Button LeftButton;
|
||||
private Button DownButton;
|
||||
private Button RightButton;
|
||||
private PictureBox PlanesPictureBox;
|
||||
}
|
||||
}
|
66
AirplaneWithRadar/AirplaneWithRadar/PlaneVisual.cs
Normal file
66
AirplaneWithRadar/AirplaneWithRadar/PlaneVisual.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using System;
|
||||
|
||||
namespace Plane
|
||||
{
|
||||
public partial class PlaneVisual : System.Windows.Forms.Form
|
||||
{
|
||||
private Paint? PaintPlanes;
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
if (PaintPlanes == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bitmap = new Bitmap(PlanesPictureBox.Width, PlanesPictureBox.Height);
|
||||
Graphics gr = Graphics.FromImage(bitmap);
|
||||
PaintPlanes.DrawTransport(gr);
|
||||
PlanesPictureBox.Image = bitmap;
|
||||
}
|
||||
public PlaneVisual()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
eegov
commented
Пустых методов быть не должно Пустых методов быть не должно
|
||||
{
|
||||
}
|
||||
|
||||
private void buttonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (PaintPlanes == null) { return; }
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
|
||||
switch (name)
|
||||
{
|
||||
case "UpButton":
|
||||
PaintPlanes.Move(Movement.Up);
|
||||
break;
|
||||
case "DownButton":
|
||||
PaintPlanes.Move(Movement.Down);
|
||||
break;
|
||||
case "LeftButton":
|
||||
PaintPlanes.Move(Movement.Left);
|
||||
break;
|
||||
case "RightButton":
|
||||
PaintPlanes.Move(Movement.Right);
|
||||
break;
|
||||
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void CreateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
Random random = new Random();
|
||||
PaintPlanes = new Paint();
|
||||
PaintPlanes.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)), PlanesPictureBox.Width, PlanesPictureBox.Height);
|
||||
PaintPlanes.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
120
AirplaneWithRadar/AirplaneWithRadar/PlaneVisual.resx
Normal file
120
AirplaneWithRadar/AirplaneWithRadar/PlaneVisual.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?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>
|
||||
</root>
|
17
AirplaneWithRadar/AirplaneWithRadar/Program.cs
Normal file
17
AirplaneWithRadar/AirplaneWithRadar/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace Plane
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new PlaneVisual());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user
Дополнительное задание в гит не заливается