лаб 3
This commit is contained in:
parent
ca85f1e742
commit
eca2e72650
@ -4,10 +4,11 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectAirbus.Entities;
|
||||
using ProjectAirbus.MovementStrategy;
|
||||
|
||||
namespace ProjectAirbus.Drawnings
|
||||
{
|
||||
internal class DrawningAirbus
|
||||
public class DrawningAirbus
|
||||
{
|
||||
public EntityAirbus? EntityAirbus { get; protected set; }
|
||||
private int _pictureWidth;
|
||||
@ -19,6 +20,9 @@ namespace ProjectAirbus.Drawnings
|
||||
protected readonly int _airbusWidth = 89;
|
||||
protected readonly int _airbusHeight = 34;
|
||||
|
||||
// Получение объекта IMoveableObject из объекта DrawningCar
|
||||
public IMoveableObject GetMoveableObject => new DrawningObjectAirbus(this);
|
||||
|
||||
// доработки для интерфейса
|
||||
public int GetPosX => _startPosX;
|
||||
public int GetPosY => _startPosY;
|
||||
@ -151,6 +155,5 @@ namespace ProjectAirbus.Drawnings
|
||||
g.DrawEllipse(pen, _startPosX, _startPosY + 14, 14, 5);
|
||||
g.FillEllipse(brYellow, _startPosX, _startPosY + 14, 14, 5);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ using ProjectAirbus.Entities;
|
||||
|
||||
namespace ProjectAirbus.Drawnings
|
||||
{
|
||||
internal class DrawningPlane : DrawningAirbus
|
||||
public class DrawningPlane : DrawningAirbus
|
||||
{
|
||||
public DrawningPlane(int speed, double weight, Color bodyColor, Color additionalColor,bool isCompartment, bool isAdditionalEngine, int width, int height) :
|
||||
base (speed, weight, bodyColor, width, height, 110, 60)
|
||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAirbus.Entities
|
||||
{
|
||||
internal class EntityAirbus
|
||||
public class EntityAirbus
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
public double Weight { get; private set; }
|
||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAirbus.Entities
|
||||
{
|
||||
internal class EntityPlane : EntityAirbus
|
||||
public class EntityPlane : EntityAirbus
|
||||
{
|
||||
public Color AdditionalColor { get; private set; }
|
||||
public bool IsCompartment { get; private set; }
|
||||
|
188
Airbus/FormAirbus.Designer.cs
generated
188
Airbus/FormAirbus.Designer.cs
generated
@ -1,188 +0,0 @@
|
||||
namespace ProjectAirbus
|
||||
{
|
||||
partial class FormAirbus
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormAirbus));
|
||||
pictureAirBus=new PictureBox();
|
||||
buttonUp=new Button();
|
||||
buttonLeft=new Button();
|
||||
buttonDown=new Button();
|
||||
buttonRight=new Button();
|
||||
buttonCreate=new Button();
|
||||
buttonCreateSuperAirbus=new Button();
|
||||
buttonStep=new Button();
|
||||
comboBoxStrategy=new ComboBox();
|
||||
((System.ComponentModel.ISupportInitialize)pictureAirBus).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureAirBus
|
||||
//
|
||||
pictureAirBus.Dock=DockStyle.Fill;
|
||||
pictureAirBus.Location=new Point(0, 0);
|
||||
pictureAirBus.Name="pictureAirBus";
|
||||
pictureAirBus.Size=new Size(790, 410);
|
||||
pictureAirBus.SizeMode=PictureBoxSizeMode.AutoSize;
|
||||
pictureAirBus.TabIndex=0;
|
||||
pictureAirBus.TabStop=false;
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
buttonUp.Anchor=AnchorStyles.Bottom|AnchorStyles.Right;
|
||||
buttonUp.BackgroundImage=(Image)resources.GetObject("buttonUp.BackgroundImage");
|
||||
buttonUp.BackgroundImageLayout=ImageLayout.Stretch;
|
||||
buttonUp.FlatAppearance.BorderColor=Color.Black;
|
||||
buttonUp.FlatAppearance.BorderSize=7;
|
||||
buttonUp.Location=new Point(679, 309);
|
||||
buttonUp.Name="buttonUp";
|
||||
buttonUp.Size=new Size(48, 44);
|
||||
buttonUp.TabIndex=1;
|
||||
buttonUp.UseVisualStyleBackColor=true;
|
||||
buttonUp.Click+=buttonMove_Click;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
buttonLeft.Anchor=AnchorStyles.Bottom|AnchorStyles.Right;
|
||||
buttonLeft.BackColor=SystemColors.Control;
|
||||
buttonLeft.BackgroundImage=(Image)resources.GetObject("buttonLeft.BackgroundImage");
|
||||
buttonLeft.BackgroundImageLayout=ImageLayout.Stretch;
|
||||
buttonLeft.FlatAppearance.BorderColor=Color.Black;
|
||||
buttonLeft.FlatAppearance.BorderSize=7;
|
||||
buttonLeft.Location=new Point(630, 354);
|
||||
buttonLeft.Name="buttonLeft";
|
||||
buttonLeft.Size=new Size(48, 44);
|
||||
buttonLeft.TabIndex=2;
|
||||
buttonLeft.UseVisualStyleBackColor=false;
|
||||
buttonLeft.Click+=buttonMove_Click;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
buttonDown.Anchor=AnchorStyles.Bottom|AnchorStyles.Right;
|
||||
buttonDown.BackgroundImage=(Image)resources.GetObject("buttonDown.BackgroundImage");
|
||||
buttonDown.BackgroundImageLayout=ImageLayout.Stretch;
|
||||
buttonDown.FlatAppearance.BorderColor=Color.Black;
|
||||
buttonDown.FlatAppearance.BorderSize=7;
|
||||
buttonDown.Location=new Point(679, 354);
|
||||
buttonDown.Name="buttonDown";
|
||||
buttonDown.Size=new Size(48, 44);
|
||||
buttonDown.TabIndex=3;
|
||||
buttonDown.UseVisualStyleBackColor=true;
|
||||
buttonDown.Click+=buttonMove_Click;
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
buttonRight.Anchor=AnchorStyles.Bottom|AnchorStyles.Right;
|
||||
buttonRight.BackgroundImage=(Image)resources.GetObject("buttonRight.BackgroundImage");
|
||||
buttonRight.BackgroundImageLayout=ImageLayout.Stretch;
|
||||
buttonRight.FlatAppearance.BorderColor=Color.Black;
|
||||
buttonRight.FlatAppearance.BorderSize=7;
|
||||
buttonRight.Location=new Point(728, 354);
|
||||
buttonRight.Name="buttonRight";
|
||||
buttonRight.Size=new Size(48, 44);
|
||||
buttonRight.TabIndex=4;
|
||||
buttonRight.UseVisualStyleBackColor=true;
|
||||
buttonRight.Click+=buttonMove_Click;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Anchor=AnchorStyles.Bottom|AnchorStyles.Left;
|
||||
buttonCreate.Location=new Point(12, 347);
|
||||
buttonCreate.Name="buttonCreate";
|
||||
buttonCreate.Size=new Size(128, 51);
|
||||
buttonCreate.TabIndex=5;
|
||||
buttonCreate.Text="Создать самолёт";
|
||||
buttonCreate.UseVisualStyleBackColor=true;
|
||||
buttonCreate.Click+=buttonCreate_Click;
|
||||
//
|
||||
// buttonCreateSuperAirbus
|
||||
//
|
||||
buttonCreateSuperAirbus.Anchor=AnchorStyles.Bottom|AnchorStyles.Left;
|
||||
buttonCreateSuperAirbus.Location=new Point(146, 347);
|
||||
buttonCreateSuperAirbus.Name="buttonCreateSuperAirbus";
|
||||
buttonCreateSuperAirbus.Size=new Size(127, 51);
|
||||
buttonCreateSuperAirbus.TabIndex=6;
|
||||
buttonCreateSuperAirbus.Text="Создать суперсамолёт";
|
||||
buttonCreateSuperAirbus.UseVisualStyleBackColor=true;
|
||||
buttonCreateSuperAirbus.Click+=buttonCreateSuperAirbus_Click;
|
||||
//
|
||||
// buttonStep
|
||||
//
|
||||
buttonStep.Anchor=AnchorStyles.Top|AnchorStyles.Right;
|
||||
buttonStep.Location=new Point(671, 51);
|
||||
buttonStep.Name="buttonStep";
|
||||
buttonStep.Size=new Size(105, 37);
|
||||
buttonStep.TabIndex=7;
|
||||
buttonStep.Text="Шаг";
|
||||
buttonStep.UseVisualStyleBackColor=true;
|
||||
buttonStep.Click+=buttonStep_Click;
|
||||
//
|
||||
// comboBoxStrategy
|
||||
//
|
||||
comboBoxStrategy.Anchor=AnchorStyles.Top|AnchorStyles.Right;
|
||||
comboBoxStrategy.DropDownStyle=ComboBoxStyle.DropDownList;
|
||||
comboBoxStrategy.FormattingEnabled=true;
|
||||
comboBoxStrategy.Items.AddRange(new object[] { "1", "2" });
|
||||
comboBoxStrategy.Location=new Point(622, 22);
|
||||
comboBoxStrategy.Name="comboBoxStrategy";
|
||||
comboBoxStrategy.Size=new Size(156, 23);
|
||||
comboBoxStrategy.TabIndex=8;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
AutoScaleDimensions=new SizeF(7F, 15F);
|
||||
AutoScaleMode=AutoScaleMode.Font;
|
||||
ClientSize=new Size(790, 410);
|
||||
Controls.Add(comboBoxStrategy);
|
||||
Controls.Add(buttonStep);
|
||||
Controls.Add(buttonCreateSuperAirbus);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(pictureAirBus);
|
||||
Name="Form1";
|
||||
Text="FormAirbus";
|
||||
((System.ComponentModel.ISupportInitialize)pictureAirBus).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureAirBus;
|
||||
private Button buttonUp;
|
||||
private Button buttonLeft;
|
||||
private Button buttonDown;
|
||||
private Button buttonRight;
|
||||
private Button buttonCreate;
|
||||
private Button buttonCreateSuperAirbus;
|
||||
private Button buttonStep;
|
||||
private ComboBox comboBoxStrategy;
|
||||
}
|
||||
}
|
128
Airbus/FormAirbusCollection.Designer.cs
generated
Normal file
128
Airbus/FormAirbusCollection.Designer.cs
generated
Normal file
@ -0,0 +1,128 @@
|
||||
namespace ProjectAirbus
|
||||
{
|
||||
partial class FormAirbusCollection
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
buttonAdd=new Button();
|
||||
pictureBoxCollection=new PictureBox();
|
||||
labelInstruments=new Label();
|
||||
buttonUpdate=new Button();
|
||||
buttonDelete=new Button();
|
||||
colorDialog=new ColorDialog();
|
||||
maskedTextBoxNumber=new MaskedTextBox();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Anchor=AnchorStyles.Top|AnchorStyles.Right;
|
||||
buttonAdd.Location=new Point(457, 34);
|
||||
buttonAdd.Name="buttonAdd";
|
||||
buttonAdd.Size=new Size(137, 28);
|
||||
buttonAdd.TabIndex=0;
|
||||
buttonAdd.Text="Добавить самолёт";
|
||||
buttonAdd.UseVisualStyleBackColor=true;
|
||||
buttonAdd.Click+=buttonAdd_Click;
|
||||
//
|
||||
// pictureBoxCollection
|
||||
//
|
||||
pictureBoxCollection.Location=new Point(0, 0);
|
||||
pictureBoxCollection.Name="pictureBoxCollection";
|
||||
pictureBoxCollection.Size=new Size(424, 453);
|
||||
pictureBoxCollection.TabIndex=1;
|
||||
pictureBoxCollection.TabStop=false;
|
||||
//
|
||||
// labelInstruments
|
||||
//
|
||||
labelInstruments.Anchor=AnchorStyles.Top|AnchorStyles.Right;
|
||||
labelInstruments.AutoSize=true;
|
||||
labelInstruments.Location=new Point(449, 9);
|
||||
labelInstruments.Name="labelInstruments";
|
||||
labelInstruments.Size=new Size(83, 15);
|
||||
labelInstruments.TabIndex=2;
|
||||
labelInstruments.Text="Инструменты";
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Anchor=AnchorStyles.Top|AnchorStyles.Right;
|
||||
buttonUpdate.Location=new Point(457, 212);
|
||||
buttonUpdate.Name="buttonUpdate";
|
||||
buttonUpdate.Size=new Size(137, 28);
|
||||
buttonUpdate.TabIndex=3;
|
||||
buttonUpdate.Text="Обновить коллекцию";
|
||||
buttonUpdate.UseVisualStyleBackColor=true;
|
||||
buttonUpdate.Click+=buttonUpdate_Click;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Anchor=AnchorStyles.Top|AnchorStyles.Right;
|
||||
buttonDelete.Location=new Point(457, 140);
|
||||
buttonDelete.Name="buttonDelete";
|
||||
buttonDelete.Size=new Size(137, 28);
|
||||
buttonDelete.TabIndex=4;
|
||||
buttonDelete.Text="Удалить самолёт";
|
||||
buttonDelete.UseVisualStyleBackColor=true;
|
||||
buttonDelete.Click+=buttonDelete_Click;
|
||||
//
|
||||
// maskedTextBoxNumber
|
||||
//
|
||||
maskedTextBoxNumber.Anchor=AnchorStyles.Top|AnchorStyles.Right;
|
||||
maskedTextBoxNumber.Location=new Point(457, 111);
|
||||
maskedTextBoxNumber.Name="maskedTextBoxNumber";
|
||||
maskedTextBoxNumber.Size=new Size(100, 23);
|
||||
maskedTextBoxNumber.TabIndex=5;
|
||||
//
|
||||
// FormAirbusCollection
|
||||
//
|
||||
AutoScaleDimensions=new SizeF(7F, 15F);
|
||||
AutoScaleMode=AutoScaleMode.Font;
|
||||
ClientSize=new Size(607, 455);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(maskedTextBoxNumber);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(labelInstruments);
|
||||
Controls.Add(pictureBoxCollection);
|
||||
Name="FormAirbusCollection";
|
||||
Text="Набор самолётов";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonAdd;
|
||||
private PictureBox pictureBoxCollection;
|
||||
private Label labelInstruments;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonDelete;
|
||||
private ColorDialog colorDialog;
|
||||
private MaskedTextBox maskedTextBoxNumber;
|
||||
}
|
||||
}
|
79
Airbus/FormAirbusCollection.cs
Normal file
79
Airbus/FormAirbusCollection.cs
Normal file
@ -0,0 +1,79 @@
|
||||
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;
|
||||
using ProjectAirbus.Generics;
|
||||
using ProjectAirbus.Drawnings;
|
||||
using ProjectAirbus.MovementStrategy;
|
||||
|
||||
namespace ProjectAirbus
|
||||
{
|
||||
public partial class FormAirbusCollection : Form
|
||||
{
|
||||
// Набор объектов
|
||||
private readonly AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus> _airbus;
|
||||
|
||||
public FormAirbusCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
_airbus = new AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
}
|
||||
|
||||
// добавить в набор
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormPlane form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (_airbus + form.SelectedAirbus != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = _airbus.ShowAirbus();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// удалить
|
||||
private void buttonDelete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = 0;
|
||||
try
|
||||
{
|
||||
pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("Ошибка ввода данных");
|
||||
return;
|
||||
}
|
||||
if (_airbus - pos)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxCollection.Image = _airbus.ShowAirbus();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
|
||||
// обновить
|
||||
private void buttonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxCollection.Image = _airbus.ShowAirbus();
|
||||
}
|
||||
}
|
||||
}
|
66
Airbus/FormAirbusCollection.resx
Normal file
66
Airbus/FormAirbusCollection.resx
Normal file
@ -0,0 +1,66 @@
|
||||
<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="colorDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>79</value>
|
||||
</metadata>
|
||||
</root>
|
211
Airbus/FormPlane.Designer.cs
generated
Normal file
211
Airbus/FormPlane.Designer.cs
generated
Normal file
@ -0,0 +1,211 @@
|
||||
namespace ProjectAirbus
|
||||
{
|
||||
partial class FormPlane
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormPlane));
|
||||
pictureAirBus = new PictureBox();
|
||||
buttonUp = new Button();
|
||||
buttonLeft = new Button();
|
||||
buttonDown = new Button();
|
||||
buttonRight = new Button();
|
||||
buttonCreate = new Button();
|
||||
buttonCreateSuperAirbus = new Button();
|
||||
buttonStep = new Button();
|
||||
comboBoxStrategy = new ComboBox();
|
||||
buttonSelectedAirbus = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureAirBus).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureAirBus
|
||||
//
|
||||
pictureAirBus.Dock = DockStyle.Fill;
|
||||
pictureAirBus.Location = new Point(0, 0);
|
||||
pictureAirBus.Margin = new Padding(3, 4, 3, 4);
|
||||
pictureAirBus.Name = "pictureAirBus";
|
||||
pictureAirBus.Size = new Size(903, 547);
|
||||
pictureAirBus.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||
pictureAirBus.TabIndex = 0;
|
||||
pictureAirBus.TabStop = false;
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonUp.BackgroundImage = (Image)resources.GetObject("buttonUp.BackgroundImage");
|
||||
buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonUp.FlatAppearance.BorderColor = Color.Black;
|
||||
buttonUp.FlatAppearance.BorderSize = 7;
|
||||
buttonUp.Location = new Point(776, 412);
|
||||
buttonUp.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonUp.Name = "buttonUp";
|
||||
buttonUp.Size = new Size(55, 59);
|
||||
buttonUp.TabIndex = 1;
|
||||
buttonUp.UseVisualStyleBackColor = true;
|
||||
buttonUp.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonLeft.BackColor = SystemColors.Control;
|
||||
buttonLeft.BackgroundImage = (Image)resources.GetObject("buttonLeft.BackgroundImage");
|
||||
buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonLeft.FlatAppearance.BorderColor = Color.Black;
|
||||
buttonLeft.FlatAppearance.BorderSize = 7;
|
||||
buttonLeft.Location = new Point(720, 472);
|
||||
buttonLeft.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonLeft.Name = "buttonLeft";
|
||||
buttonLeft.Size = new Size(55, 59);
|
||||
buttonLeft.TabIndex = 2;
|
||||
buttonLeft.UseVisualStyleBackColor = false;
|
||||
buttonLeft.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonDown.BackgroundImage = (Image)resources.GetObject("buttonDown.BackgroundImage");
|
||||
buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonDown.FlatAppearance.BorderColor = Color.Black;
|
||||
buttonDown.FlatAppearance.BorderSize = 7;
|
||||
buttonDown.Location = new Point(776, 472);
|
||||
buttonDown.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonDown.Name = "buttonDown";
|
||||
buttonDown.Size = new Size(55, 59);
|
||||
buttonDown.TabIndex = 3;
|
||||
buttonDown.UseVisualStyleBackColor = true;
|
||||
buttonDown.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonRight.BackgroundImage = (Image)resources.GetObject("buttonRight.BackgroundImage");
|
||||
buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonRight.FlatAppearance.BorderColor = Color.Black;
|
||||
buttonRight.FlatAppearance.BorderSize = 7;
|
||||
buttonRight.Location = new Point(832, 472);
|
||||
buttonRight.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonRight.Name = "buttonRight";
|
||||
buttonRight.Size = new Size(55, 59);
|
||||
buttonRight.TabIndex = 4;
|
||||
buttonRight.UseVisualStyleBackColor = true;
|
||||
buttonRight.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreate.Location = new Point(14, 481);
|
||||
buttonCreate.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(146, 50);
|
||||
buttonCreate.TabIndex = 5;
|
||||
buttonCreate.Text = "Создать аэробус";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += buttonCreate_Click;
|
||||
//
|
||||
// buttonCreateSuperAirbus
|
||||
//
|
||||
buttonCreateSuperAirbus.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreateSuperAirbus.Location = new Point(166, 481);
|
||||
buttonCreateSuperAirbus.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonCreateSuperAirbus.Name = "buttonCreateSuperAirbus";
|
||||
buttonCreateSuperAirbus.Size = new Size(145, 50);
|
||||
buttonCreateSuperAirbus.TabIndex = 6;
|
||||
buttonCreateSuperAirbus.Text = "Создать самолёт";
|
||||
buttonCreateSuperAirbus.UseVisualStyleBackColor = true;
|
||||
buttonCreateSuperAirbus.Click += buttonCreateSuperAirbus_Click;
|
||||
//
|
||||
// buttonStep
|
||||
//
|
||||
buttonStep.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonStep.Location = new Point(767, 68);
|
||||
buttonStep.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonStep.Name = "buttonStep";
|
||||
buttonStep.Size = new Size(120, 49);
|
||||
buttonStep.TabIndex = 7;
|
||||
buttonStep.Text = "Шаг";
|
||||
buttonStep.UseVisualStyleBackColor = true;
|
||||
buttonStep.Click += buttonStep_Click;
|
||||
//
|
||||
// comboBoxStrategy
|
||||
//
|
||||
comboBoxStrategy.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxStrategy.FormattingEnabled = true;
|
||||
comboBoxStrategy.Items.AddRange(new object[] { "1", "2" });
|
||||
comboBoxStrategy.Location = new Point(711, 29);
|
||||
comboBoxStrategy.Margin = new Padding(3, 4, 3, 4);
|
||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
||||
comboBoxStrategy.Size = new Size(178, 28);
|
||||
comboBoxStrategy.TabIndex = 8;
|
||||
//
|
||||
// buttonSelectedAirbus
|
||||
//
|
||||
buttonSelectedAirbus.Location = new Point(427, 481);
|
||||
buttonSelectedAirbus.Name = "buttonSelectedAirbus";
|
||||
buttonSelectedAirbus.Size = new Size(137, 50);
|
||||
buttonSelectedAirbus.TabIndex = 9;
|
||||
buttonSelectedAirbus.Text = "Выбрать";
|
||||
buttonSelectedAirbus.UseVisualStyleBackColor = true;
|
||||
buttonSelectedAirbus.Click += buttonSelectedAirbus_Click;
|
||||
//
|
||||
// FormPlane
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(903, 547);
|
||||
Controls.Add(buttonSelectedAirbus);
|
||||
Controls.Add(comboBoxStrategy);
|
||||
Controls.Add(buttonStep);
|
||||
Controls.Add(buttonCreateSuperAirbus);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(pictureAirBus);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormPlane";
|
||||
Text = "FormPlane";
|
||||
((System.ComponentModel.ISupportInitialize)pictureAirBus).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureAirBus;
|
||||
private Button buttonUp;
|
||||
private Button buttonLeft;
|
||||
private Button buttonDown;
|
||||
private Button buttonRight;
|
||||
private Button buttonCreate;
|
||||
private Button buttonCreateSuperAirbus;
|
||||
private Button buttonStep;
|
||||
private ComboBox comboBoxStrategy;
|
||||
private Button buttonSelectedAirbus;
|
||||
}
|
||||
}
|
@ -4,14 +4,19 @@ using ProjectAirbus.Entities;
|
||||
|
||||
namespace ProjectAirbus
|
||||
{
|
||||
public partial class FormAirbus : Form
|
||||
public partial class FormPlane : Form
|
||||
{
|
||||
private DrawningAirbus? _drawningAirbus;
|
||||
private AbstractStrategy? _abstractStrategy;
|
||||
|
||||
public FormAirbus()
|
||||
// Выбранный автомобиль
|
||||
public DrawningAirbus? SelectedAirbus { get; private set; }
|
||||
|
||||
public FormPlane()
|
||||
{
|
||||
InitializeComponent();
|
||||
_abstractStrategy = null;
|
||||
SelectedAirbus = null;
|
||||
}
|
||||
|
||||
// прорисовка самолёта
|
||||
@ -27,33 +32,19 @@ namespace ProjectAirbus
|
||||
pictureAirBus.Image = bmp;
|
||||
}
|
||||
|
||||
private void buttonDown_Click(object sender, EventArgs e)
|
||||
{
|
||||
buttonMove_Click(sender, e);
|
||||
}
|
||||
|
||||
private void buttonUp_Click(object sender, EventArgs e)
|
||||
{
|
||||
buttonMove_Click(sender, e);
|
||||
}
|
||||
|
||||
private void buttonRight_Click(object sender, EventArgs e)
|
||||
{
|
||||
buttonMove_Click(sender, e);
|
||||
}
|
||||
|
||||
private void buttonLeft_Click(object sender, EventArgs e)
|
||||
{
|
||||
buttonMove_Click(sender, e);
|
||||
}
|
||||
|
||||
// кнопка "Создать самолёт"
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new Random();
|
||||
_drawningAirbus = new DrawningAirbus(random.Next(200, 400), random.Next(1000, 3000),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||
pictureAirBus.Width, pictureAirBus.Height);
|
||||
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialog.Color;
|
||||
}
|
||||
|
||||
_drawningAirbus = new DrawningAirbus(random.Next(100, 300), random.Next(1000, 3000),
|
||||
color, pictureAirBus.Width, pictureAirBus.Height);
|
||||
|
||||
_drawningAirbus.SetPosition(random.Next(10, 200), random.Next(10, 200));
|
||||
Draw();
|
||||
@ -64,10 +55,23 @@ namespace ProjectAirbus
|
||||
private void buttonCreateSuperAirbus_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new Random();
|
||||
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||
//выбор основного цвета
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialog.Color;
|
||||
}
|
||||
|
||||
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||
//TODO дополнительного цвета
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
dopColor = dialog.Color;
|
||||
}
|
||||
|
||||
_drawningAirbus = new DrawningPlane(random.Next(200, 400), 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)),
|
||||
color, dopColor, Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)),
|
||||
pictureAirBus.Width, pictureAirBus.Height);
|
||||
|
||||
_drawningAirbus.SetPosition(random.Next(10, 200), random.Next(10, 200));
|
||||
@ -131,5 +135,10 @@ namespace ProjectAirbus
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSelectedAirbus_Click(object sender, EventArgs e)
|
||||
{
|
||||
SelectedAirbus = _drawningAirbus;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,64 @@
|
||||
<root>
|
||||
<?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">
|
112
Airbus/Generics/AirbusGenericCollection.cs
Normal file
112
Airbus/Generics/AirbusGenericCollection.cs
Normal file
@ -0,0 +1,112 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectAirbus.Drawnings;
|
||||
using ProjectAirbus.MovementStrategy;
|
||||
|
||||
namespace ProjectAirbus.Generics
|
||||
{
|
||||
internal class AirbusGenericCollection<T, U>
|
||||
where T : DrawningAirbus
|
||||
where U : IMoveableObject
|
||||
{
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
// Размер занимаемого места
|
||||
private readonly int _placeSizeWidth = 89;
|
||||
private readonly int _placeSizeHeight = 34;
|
||||
// коллекция
|
||||
private readonly SetGeneric<T> _collection;
|
||||
|
||||
public AirbusGenericCollection(int picWidth, int picHeight)
|
||||
{
|
||||
int width = picWidth / _placeSizeWidth;
|
||||
int height = picHeight / _placeSizeHeight;
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
|
||||
_collection = new SetGeneric<T>(width * height);
|
||||
}
|
||||
public static int operator +(AirbusGenericCollection<T, U> collect, T? obj)
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
return collect._collection.Insert(obj);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public static bool operator -(AirbusGenericCollection<T, U> collect, int pos)
|
||||
{
|
||||
if (collect._collection.Get(pos) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return collect?._collection.Remove(pos) ?? false;
|
||||
}
|
||||
|
||||
// получение объекта IMoveableObjecr
|
||||
public U? GetU(int pos)
|
||||
{
|
||||
return (U?)_collection.Get(pos)?.GetMoveableObject;
|
||||
}
|
||||
|
||||
// вывод всего набора
|
||||
public Bitmap ShowAirbus()
|
||||
{
|
||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
DrawBackground(gr);
|
||||
DrawObjects(gr);
|
||||
return bmp;
|
||||
}
|
||||
|
||||
// прорисовка фона
|
||||
private void DrawBackground(Graphics gr)
|
||||
{
|
||||
Pen pen = new(Color.Black, 3);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; ++i)
|
||||
{
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
|
||||
{
|
||||
// линия разметки
|
||||
gr.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
|
||||
gr.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// прорисовка объекта
|
||||
private void DrawObjects(Graphics g)
|
||||
{
|
||||
// координаты
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
for (int i = 0; i <= _collection.Count; ++i)
|
||||
{
|
||||
DrawningAirbus _airbus = _collection.Get(i);
|
||||
if (_airbus == null)
|
||||
{
|
||||
++x;
|
||||
if (x >= _pictureWidth / _placeSizeWidth)
|
||||
{
|
||||
x = 0;
|
||||
++y;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
_airbus.SetPosition(_placeSizeWidth * x, _placeSizeHeight * y);
|
||||
_airbus.DrawTransport(g);
|
||||
++x;
|
||||
// новая строка
|
||||
if (x >= _pictureWidth / _placeSizeWidth)
|
||||
{
|
||||
x = 0;
|
||||
++y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
105
Airbus/Generics/SetGeneric.cs
Normal file
105
Airbus/Generics/SetGeneric.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAirbus.Generics
|
||||
{
|
||||
internal class SetGeneric<T>
|
||||
where T : class
|
||||
{
|
||||
// список объекторв
|
||||
private readonly T?[] _places;
|
||||
// кол-во объектов
|
||||
public int Count => _places.Length - 1;
|
||||
public SetGeneric(int count)
|
||||
{
|
||||
_places = new T?[count];
|
||||
}
|
||||
|
||||
// Добавление объекта в набор
|
||||
public int Insert(T airbus)
|
||||
{
|
||||
// проверка, что элемент массива по этой позиции пустой, если нет, то
|
||||
int pos = Count - 1;
|
||||
if (_places[Count] != null)
|
||||
{
|
||||
// проверка, что после вставляемого элемента в массиве есть пустой элемент
|
||||
for (int i = pos; i > 0; --i)
|
||||
{
|
||||
if (_places[i] == null)
|
||||
{
|
||||
pos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// сдвиг всех объектов, находящихся слева от позиции до первого пустого элемента
|
||||
for (int i = pos + 1; i <= Count; ++i)
|
||||
{
|
||||
_places[i - 1] = _places[i];
|
||||
}
|
||||
}
|
||||
_places[Count] = airbus;
|
||||
return pos;
|
||||
}
|
||||
|
||||
// Добавление объекта в набор на конкретную позицию
|
||||
public bool Insert(T airbus, int position)
|
||||
{
|
||||
// проверка позиции
|
||||
if (position < 0 || position > Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// проверка, что элемент массива по этой позиции пустой, если нет, то
|
||||
if (_places[Count] != null)
|
||||
{
|
||||
// проверка, что после вставляемого элемента в массиве есть пустой элемент
|
||||
int pos = Count;
|
||||
for (int i = Count; i > 0; --i)
|
||||
{
|
||||
|
||||
if (_places[i] == null)
|
||||
{
|
||||
pos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// сдвиг всех объектов, находящихся слева от позиции до первого пустого элемента
|
||||
for (int i = Count; i >= pos; --i)
|
||||
{
|
||||
_places[i - 1] = _places[i];
|
||||
}
|
||||
}
|
||||
_places[Count] = airbus;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Удаление объекта из набора с конкретной позиции
|
||||
public bool Remove(int position)
|
||||
{
|
||||
// проверка позиции
|
||||
if (position < 0 || position > Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// удалить объект из массива, присвоив элементу массива значение null
|
||||
_places[position] = null;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Получение объекта из набора по позиции
|
||||
public T? Get(int position)
|
||||
{
|
||||
// проверка позиции
|
||||
if (position < 0 || position > Count)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _places[position];
|
||||
}
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@ using ProjectAirbus.Entities;
|
||||
|
||||
namespace ProjectAirbus.MovementStrategy
|
||||
{
|
||||
internal interface IMoveableObject
|
||||
public interface IMoveableObject
|
||||
{
|
||||
ObjectParameters? GetObjectPosition { get; }
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
namespace ProjectAirbus.MovementStrategy
|
||||
{
|
||||
internal class ObjectParameters
|
||||
{
|
||||
public class ObjectParameters
|
||||
{
|
||||
private readonly int _x;
|
||||
private readonly int _y;
|
||||
private readonly int _width;
|
||||
@ -23,5 +23,5 @@
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace ProjectAirbus
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormAirbus());
|
||||
Application.Run(new FormAirbusCollection());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user