LabWork01 #1

Merged
eegov merged 3 commits from LabWork01 into master 2022-10-21 09:01:17 +04:00
19 changed files with 520 additions and 42 deletions
Showing only changes of commit 0caa128262 - Show all commits

View File

@ -8,4 +8,19 @@
<ImplicitUsings>enable</ImplicitUsings>
</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>

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
internal enum Direction
{
Up = 1,
Down = 2,
Left = 3,
Right = 4
}
}

View File

@ -0,0 +1,116 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
internal class DrawningBomber
Review

Имя класса не соответствует указаному в задании

Имя класса не соответствует указаному в задании
{
public EntityAirBomber AirBomber { private set; get; }
private float _startPosX;
private float _startPosY;
private int? _pictureWidth = null;
private int? _pictureHeight = null;
private readonly int _airBomberWidth = 100;
private readonly int _airBomberHeight = 100;
public void Init(int speed, float weight, Color bodyColor)
{
AirBomber = new EntityAirBomber();
AirBomber.Init(speed, weight, bodyColor);
}
public void SetPosition(int x, int y, int width, int height)
{
if (x > _pictureWidth || x < 0) return;
Review

Не учтены все условия, при которых объект может выйти за границы

Не учтены все условия, при которых объект может выйти за границы
else _startPosX = x;
if (y > _pictureHeight || y < 0) return;
else _startPosY = y;
_pictureWidth = width;
_pictureHeight = height;
}
public void MoveTransport(Direction direction)
{
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue)
{
return;
}
switch (direction)
{
case Direction.Right:
if (_startPosX + _airBomberWidth + AirBomber.Step < _pictureWidth)
{
_startPosX += AirBomber.Step;
}
break;
case Direction.Left:
if (_startPosX - AirBomber.Step > 0)
{
_startPosX -= AirBomber.Step;
}
break;
case Direction.Up:
if (_startPosY - AirBomber.Step > 0)
{
_startPosY -= AirBomber.Step;
}
break;
case Direction.Down:
if (_startPosY + _airBomberHeight + AirBomber.Step < _pictureHeight)
{
_startPosY += AirBomber.Step;
}
break;
}
}
public void DrawTransport(Graphics g)
{
if (_startPosX < 0 || _startPosY < 0 || !_pictureHeight.HasValue || !_pictureWidth.HasValue)
{
return;
}
Pen pen = new(Color.Black);
SolidBrush brush = new SolidBrush(AirBomber?.BodyColor ?? Color.Cyan);
g.FillPolygon(brush, new[] {
new Point((int)(_startPosX + _airBomberWidth), (int)(_startPosY + _airBomberHeight / 2 - 20)),
new Point((int)(_startPosX + _airBomberWidth), (int)(_startPosY + _airBomberHeight / 2 + 20)),
new Point((int)(_startPosX + _airBomberWidth - 10), (int)(_startPosY + _airBomberHeight / 2 + 10)),
new Point((int)(_startPosX + _airBomberWidth - 10), (int)(_startPosY + _airBomberHeight / 2 - 10))
});
g.FillPolygon(brush, new[] {
new Point((int)(_startPosX + _airBomberWidth / 2), (int)(_startPosY)),
new Point((int)(_startPosX + _airBomberWidth / 2 + 10), (int)(_startPosY)),
new Point((int)(_startPosX + _airBomberWidth / 2 + 20), (int)(_startPosY + _airBomberHeight / 2)),
new Point((int)(_startPosX + _airBomberWidth / 2 + 10), (int)(_startPosY + _airBomberHeight)),
new Point((int)(_startPosX + _airBomberWidth / 2), (int)(_startPosY + _airBomberHeight))
});
}
public void ChangeBorders(int width, int height)
{
_pictureWidth = width;
_pictureHeight = height;
if (_pictureWidth <= _airBomberWidth || _pictureHeight <= _airBomberHeight)
{
_pictureWidth = null;
_pictureHeight = null;
return;
}
if (_startPosX + _airBomberWidth > _pictureWidth)
{
_startPosX = _pictureWidth.Value - _airBomberWidth;
}
if (_startPosY + _airBomberHeight > _pictureHeight)
{
_startPosY = _pictureHeight.Value - _airBomberHeight;
}
}
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
internal class EntityAirBomber
Review

Имя класса не соответствует указаному в задании

Имя класса не соответствует указаному в задании
{
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(40, 70) : weight;
BodyColor = bodyColor;
}
}
}

View File

@ -1,39 +0,0 @@
namespace AirBomber
{
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,167 @@
namespace AirBomber
{
partial class FormAirBomber
{
/// <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.pictureBoxAirBomber = new System.Windows.Forms.PictureBox();
this.statusStrip = 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();
this.buttonCreate = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirBomber)).BeginInit();
this.statusStrip.SuspendLayout();
this.SuspendLayout();
//
// pictureBoxAirBomber
//
this.pictureBoxAirBomber.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxAirBomber.Location = new System.Drawing.Point(0, 0);
this.pictureBoxAirBomber.Name = "pictureBoxAirBomber";
this.pictureBoxAirBomber.Size = new System.Drawing.Size(800, 450);
this.pictureBoxAirBomber.TabIndex = 0;
this.pictureBoxAirBomber.TabStop = false;
//
// statusStrip
//
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabelSpeed,
this.toolStripStatusLabelWeight,
this.toolStripStatusLabelBodyColor});
this.statusStrip.Location = new System.Drawing.Point(0, 428);
this.statusStrip.Name = "statusStrip";
this.statusStrip.Size = new System.Drawing.Size(800, 22);
this.statusStrip.TabIndex = 1;
//
// toolStripStatusLabelSpeed
//
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(62, 17);
this.toolStripStatusLabelSpeed.Text = "Скорость:";
//
// toolStripStatusLabelWeight
//
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(29, 17);
this.toolStripStatusLabelWeight.Text = "Вес:";
//
// toolStripStatusLabelBodyColor
//
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(36, 17);
this.toolStripStatusLabelBodyColor.Text = "Цвет:";
//
// buttonCreate
//
this.buttonCreate.Location = new System.Drawing.Point(12, 390);
this.buttonCreate.Name = "buttonCreate";
this.buttonCreate.Size = new System.Drawing.Size(79, 35);
this.buttonCreate.TabIndex = 2;
this.buttonCreate.Text = "Создать";
this.buttonCreate.UseVisualStyleBackColor = true;
//
// button2
//
this.button2.BackgroundImage = global::AirBomber.Properties.Resources.ArrowUp;
this.button2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.button2.Location = new System.Drawing.Point(722, 367);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(30, 30);
this.button2.TabIndex = 3;
this.button2.UseVisualStyleBackColor = true;
//
// button3
//
this.button3.BackgroundImage = global::AirBomber.Properties.Resources.ArrowLeft;
this.button3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.button3.Location = new System.Drawing.Point(686, 403);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(30, 30);
this.button3.TabIndex = 4;
this.button3.UseVisualStyleBackColor = true;
//
// button4
//
this.button4.BackgroundImage = global::AirBomber.Properties.Resources.ArrowDown;
this.button4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.button4.Location = new System.Drawing.Point(722, 403);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(30, 30);
this.button4.TabIndex = 5;
this.button4.UseVisualStyleBackColor = true;
//
// button5
//
this.button5.BackgroundImage = global::AirBomber.Properties.Resources.ArrowRight;
this.button5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.button5.Location = new System.Drawing.Point(758, 403);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(30, 30);
this.button5.TabIndex = 6;
this.button5.UseVisualStyleBackColor = true;
//
// FormAirBomber
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.button5);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.statusStrip);
this.Controls.Add(this.pictureBoxAirBomber);
this.Name = "FormAirBomber";
this.Text = "Бомбардировщик";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirBomber)).EndInit();
this.statusStrip.ResumeLayout(false);
this.statusStrip.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private PictureBox pictureBoxAirBomber;
private StatusStrip statusStrip;
private ToolStripStatusLabel toolStripStatusLabelSpeed;
private ToolStripStatusLabel toolStripStatusLabelWeight;
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
private Button buttonCreate;
private Button button2;
private Button button3;
private Button button4;
private Button button5;
}
}

View File

@ -1,8 +1,8 @@
namespace AirBomber
{
public partial class Form1 : Form
public partial class FormAirBomber : Form
Review

Имя класса не соответствует указаному в задании

Имя класса не соответствует указаному в задании
{
public Form1()
public FormAirBomber()
{
InitializeComponent();
}

View 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="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -11,7 +11,7 @@ namespace AirBomber
// 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 FormAirBomber());
}
}
}

View File

@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AirBomber.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("AirBomber.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 ArrowDown {
get {
object obj = ResourceManager.GetObject("ArrowDown", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap ArrowLeft {
get {
object obj = ResourceManager.GetObject("ArrowLeft", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap ArrowRight {
get {
object obj = ResourceManager.GetObject("ArrowRight", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap ArrowUp {
get {
object obj = ResourceManager.GetObject("ArrowUp", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -117,4 +117,17 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="ArrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ArrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="ArrowLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ArrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="ArrowRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ArrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="ArrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ArrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
Images/ArrowDown.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
Images/ArrowLeft.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
Images/ArrowRight.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
Images/ArrowUp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB