4 Commits
lab2 ... lab5

Author SHA1 Message Date
4acd470e61 5ая готовая 2023-12-02 09:05:27 +04:00
8d4cfb88f8 убрано сообщение в лог. классе 2023-12-02 08:36:43 +04:00
d745ee3256 лаб 4 2023-11-18 12:13:53 +04:00
eca2e72650 лаб 3 2023-11-18 10:47:46 +04:00
20 changed files with 1728 additions and 227 deletions

View File

@@ -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;
@@ -66,6 +70,13 @@ namespace ProjectAirbus.Drawnings
};
}
// изменение границы поля, когда закрываем конфиг
public void ChangeBordersPicture(int width, int height)
{
_pictureWidth = width;
_pictureHeight = height;
}
public void SetPosition(int x, int y)
{
if (x >= _pictureWidth || y >= _pictureHeight)
@@ -151,6 +162,5 @@ namespace ProjectAirbus.Drawnings
g.DrawEllipse(pen, _startPosX, _startPosY + 14, 14, 5);
g.FillEllipse(brYellow, _startPosX, _startPosY + 14, 14, 5);
}
}
}

View File

@@ -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)

View File

@@ -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; }
@@ -20,5 +20,10 @@ namespace ProjectAirbus.Entities
Weight = weight;
BodyColor = bodyColor;
}
public void ChangeBodyColor(Color bodyColor)
{
BodyColor = bodyColor;
}
}
}

View File

@@ -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; }
@@ -19,5 +19,10 @@ namespace ProjectAirbus.Entities
IsCompartment = isCompartment;
IsAdditionalEngine = isAdditionalEngine;
}
public void ChangeColorAdditional(Color additionalColor)
{
AdditionalColor = additionalColor;
}
}
}

View File

@@ -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;
}
}

197
Airbus/FormAirbusCollection.Designer.cs generated Normal file
View File

@@ -0,0 +1,197 @@
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()
{
buttonAddAirbus = new Button();
pictureBoxCollection = new PictureBox();
labelInstruments = new Label();
buttonUpdate = new Button();
buttonDeleteAirbus = new Button();
colorDialog = new ColorDialog();
maskedTextBoxNumber = new MaskedTextBox();
label1 = new Label();
listBoxStorages = new ListBox();
buttonAddStorage = new Button();
buttonDeleteStorage = new Button();
textBoxStorageName = new TextBox();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
SuspendLayout();
//
// buttonAddAirbus
//
buttonAddAirbus.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonAddAirbus.Location = new Point(572, 332);
buttonAddAirbus.Name = "buttonAddAirbus";
buttonAddAirbus.Size = new Size(137, 28);
buttonAddAirbus.TabIndex = 0;
buttonAddAirbus.Text = "Добавить самолёт";
buttonAddAirbus.UseVisualStyleBackColor = true;
buttonAddAirbus.Click += buttonAddAirbus_Click;
//
// pictureBoxCollection
//
pictureBoxCollection.Location = new Point(0, 0);
pictureBoxCollection.Name = "pictureBoxCollection";
pictureBoxCollection.Size = new Size(552, 436);
pictureBoxCollection.TabIndex = 1;
pictureBoxCollection.TabStop = false;
//
// labelInstruments
//
labelInstruments.Anchor = AnchorStyles.Top | AnchorStyles.Right;
labelInstruments.AutoSize = true;
labelInstruments.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
labelInstruments.Location = new Point(580, 0);
labelInstruments.Name = "labelInstruments";
labelInstruments.Size = new Size(108, 21);
labelInstruments.TabIndex = 2;
labelInstruments.Text = "Инструменты";
//
// buttonUpdate
//
buttonUpdate.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonUpdate.Location = new Point(572, 130);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(131, 25);
buttonUpdate.TabIndex = 3;
buttonUpdate.Text = "Обновить набор";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += buttonUpdate_Click;
//
// buttonDeleteAirbus
//
buttonDeleteAirbus.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonDeleteAirbus.Location = new Point(572, 392);
buttonDeleteAirbus.Name = "buttonDeleteAirbus";
buttonDeleteAirbus.Size = new Size(137, 28);
buttonDeleteAirbus.TabIndex = 4;
buttonDeleteAirbus.Text = "Удалить самолёт";
buttonDeleteAirbus.UseVisualStyleBackColor = true;
buttonDeleteAirbus.Click += buttonDeleteAirbus_Click;
//
// maskedTextBoxNumber
//
maskedTextBoxNumber.Anchor = AnchorStyles.Top | AnchorStyles.Right;
maskedTextBoxNumber.Location = new Point(572, 365);
maskedTextBoxNumber.Mask = "00";
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
maskedTextBoxNumber.Size = new Size(138, 23);
maskedTextBoxNumber.TabIndex = 5;
maskedTextBoxNumber.ValidatingType = typeof(int);
//
// label1
//
label1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
label1.AutoSize = true;
label1.Location = new Point(572, 38);
label1.Name = "label1";
label1.Size = new Size(52, 15);
label1.TabIndex = 7;
label1.Text = "Наборы";
//
// listBoxStorages
//
listBoxStorages.FormattingEnabled = true;
listBoxStorages.ItemHeight = 15;
listBoxStorages.Location = new Point(572, 160);
listBoxStorages.Margin = new Padding(3, 2, 3, 2);
listBoxStorages.Name = "listBoxStorages";
listBoxStorages.Size = new Size(132, 109);
listBoxStorages.TabIndex = 8;
listBoxStorages.SelectedIndexChanged += listBoxObjects_SelectedIndexChanged;
//
// buttonAddStorage
//
buttonAddStorage.Location = new Point(572, 102);
buttonAddStorage.Margin = new Padding(3, 2, 3, 2);
buttonAddStorage.Name = "buttonAddStorage";
buttonAddStorage.Size = new Size(131, 25);
buttonAddStorage.TabIndex = 9;
buttonAddStorage.Text = "Добавить набор";
buttonAddStorage.UseVisualStyleBackColor = true;
buttonAddStorage.Click += buttonAddStorage_Click;
//
// buttonDeleteStorage
//
buttonDeleteStorage.Location = new Point(572, 273);
buttonDeleteStorage.Margin = new Padding(3, 2, 3, 2);
buttonDeleteStorage.Name = "buttonDeleteStorage";
buttonDeleteStorage.Size = new Size(131, 25);
buttonDeleteStorage.TabIndex = 10;
buttonDeleteStorage.Text = "Удалить набор";
buttonDeleteStorage.UseVisualStyleBackColor = true;
buttonDeleteStorage.Click += buttonDeleteStorage_Click;
//
// textBoxStorageName
//
textBoxStorageName.Location = new Point(572, 77);
textBoxStorageName.Margin = new Padding(3, 2, 3, 2);
textBoxStorageName.Name = "textBoxStorageName";
textBoxStorageName.Size = new Size(132, 23);
textBoxStorageName.TabIndex = 11;
//
// FormAirbusCollection
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(724, 443);
Controls.Add(textBoxStorageName);
Controls.Add(buttonDeleteStorage);
Controls.Add(buttonAddStorage);
Controls.Add(listBoxStorages);
Controls.Add(label1);
Controls.Add(buttonAddAirbus);
Controls.Add(maskedTextBoxNumber);
Controls.Add(buttonDeleteAirbus);
Controls.Add(buttonUpdate);
Controls.Add(labelInstruments);
Controls.Add(pictureBoxCollection);
Name = "FormAirbusCollection";
Text = "Набор самолётов";
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonAddAirbus;
private PictureBox pictureBoxCollection;
private Label labelInstruments;
private Button buttonUpdate;
private Button buttonDeleteAirbus;
private ColorDialog colorDialog;
private MaskedTextBox maskedTextBoxNumber;
private Label label1;
private ListBox listBoxStorages;
private Button buttonAddStorage;
private Button buttonDeleteStorage;
private TextBox textBoxStorageName;
}
}

View File

@@ -0,0 +1,164 @@
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 AirbusGenericStorage _storage;
public FormAirbusCollection()
{
InitializeComponent();
_storage = new AirbusGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
}
// заполнение лист бокс
private void ReloadObjects()
{
int index = listBoxStorages.SelectedIndex;
listBoxStorages.Items.Clear();
for (int i = 0; i < _storage.Keys.Count; i++)
{
listBoxStorages.Items.Add(_storage.Keys[i]);
}
if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count))
{
listBoxStorages.SelectedIndex = 0;
}
else if (listBoxStorages.Items.Count > 0 && index > -1 && index < listBoxStorages.Items.Count)
{
listBoxStorages.SelectedIndex = index;
}
}
// добавить набор в коллекцию
private void buttonAddStorage_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxStorageName.Text))
{
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_storage.AddSet(textBoxStorageName.Text);
ReloadObjects();
}
// выбрать набор
private void listBoxObjects_SelectedIndexChanged(object sender, EventArgs e)
{
pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowAirbus();
}
// удалить набор
private void buttonDeleteStorage_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
_storage.DelSet(listBoxStorages.SelectedItem.ToString() ?? string.Empty);
ReloadObjects();
}
}
// добавить самолёт в набор
private void buttonAddAirbus_Click(object sender, EventArgs e)
{
var formAirbusConfig = new FormAirbusConfig();
formAirbusConfig.AddEvent(AddAirbusInSet);
formAirbusConfig.Show();
}
private void AddAirbusInSet(DrawningAirbus _airbus)
{
if (listBoxStorages.SelectedIndex == -1)
{
MessageBox.Show("Не выбран набор");
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
// меняем границы после закрытия конфига
_airbus.ChangeBordersPicture(Width, Height);
if (obj + _airbus != -1)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowAirbus();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
// удалить самолёт
private void buttonDeleteAirbus_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int pos = 0;
try
{
pos = Convert.ToInt32(maskedTextBoxNumber.Text);
}
catch
{
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (obj - pos)
{
MessageBox.Show("Объект удален");
pictureBoxCollection.Image = obj.ShowAirbus();
}
else
{
MessageBox.Show("Не удалось удалить объект");
}
}
// обновить рисунок по набору
private void buttonUpdate_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
pictureBoxCollection.Image = obj.ShowAirbus();
}
}
}

View File

@@ -0,0 +1,126 @@
<?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>
<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>36</value>
</metadata>
</root>

357
Airbus/FormAirbusConfig.Designer.cs generated Normal file
View File

@@ -0,0 +1,357 @@
namespace ProjectAirbus
{
partial class FormAirbusConfig
{
/// <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()
{
groupBoxConfig = new GroupBox();
numericUpDownWeight = new NumericUpDown();
numericUpDownSpeed = new NumericUpDown();
checkBoxAdditionalEngine = new CheckBox();
checkBoxCompartment = new CheckBox();
labelWeight = new Label();
labelSpeed = new Label();
groupBoxColors = new GroupBox();
panelSilver = new Panel();
panelOrange = new Panel();
panelWhite = new Panel();
panelGreen = new Panel();
panelViolet = new Panel();
panelBlue = new Panel();
panelYellow = new Panel();
labelComplexObject = new Label();
labelSimpleObject = new Label();
panelRed = new Panel();
buttonOk = new Button();
buttonCancel = new Button();
pictureBoxObject = new PictureBox();
labelBodyColor = new Label();
labelAdditionalColor = new Label();
panelObject = new Panel();
groupBoxConfig.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
groupBoxColors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
panelObject.SuspendLayout();
SuspendLayout();
//
// groupBoxConfig
//
groupBoxConfig.Controls.Add(numericUpDownWeight);
groupBoxConfig.Controls.Add(numericUpDownSpeed);
groupBoxConfig.Controls.Add(checkBoxAdditionalEngine);
groupBoxConfig.Controls.Add(checkBoxCompartment);
groupBoxConfig.Controls.Add(labelWeight);
groupBoxConfig.Controls.Add(labelSpeed);
groupBoxConfig.Controls.Add(groupBoxColors);
groupBoxConfig.Location = new Point(24, 16);
groupBoxConfig.Name = "groupBoxConfig";
groupBoxConfig.Size = new Size(620, 243);
groupBoxConfig.TabIndex = 0;
groupBoxConfig.TabStop = false;
groupBoxConfig.Text = "Параметры";
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(106, 88);
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownWeight.Name = "numericUpDownWeight";
numericUpDownWeight.Size = new Size(79, 27);
numericUpDownWeight.TabIndex = 7;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(106, 41);
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownSpeed.Name = "numericUpDownSpeed";
numericUpDownSpeed.Size = new Size(79, 27);
numericUpDownSpeed.TabIndex = 6;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// checkBoxAdditionalEngine
//
checkBoxAdditionalEngine.AutoSize = true;
checkBoxAdditionalEngine.Location = new Point(22, 151);
checkBoxAdditionalEngine.Name = "checkBoxAdditionalEngine";
checkBoxAdditionalEngine.Size = new Size(204, 24);
checkBoxAdditionalEngine.TabIndex = 4;
checkBoxAdditionalEngine.Text = "Добавить доп. двигатель";
checkBoxAdditionalEngine.UseVisualStyleBackColor = true;
//
// checkBoxCompartment
//
checkBoxCompartment.AutoSize = true;
checkBoxCompartment.Location = new Point(22, 186);
checkBoxCompartment.Name = "checkBoxCompartment";
checkBoxCompartment.Size = new Size(243, 24);
checkBoxCompartment.TabIndex = 3;
checkBoxCompartment.Text = "Добавить пассажирский отсек";
checkBoxCompartment.UseVisualStyleBackColor = true;
//
// labelWeight
//
labelWeight.AutoSize = true;
labelWeight.Location = new Point(22, 95);
labelWeight.Name = "labelWeight";
labelWeight.Size = new Size(36, 20);
labelWeight.TabIndex = 2;
labelWeight.Text = "Вес:";
//
// labelSpeed
//
labelSpeed.AutoSize = true;
labelSpeed.Location = new Point(22, 43);
labelSpeed.Name = "labelSpeed";
labelSpeed.Size = new Size(80, 20);
labelSpeed.TabIndex = 1;
labelSpeed.Text = "Скорость: ";
//
// groupBoxColors
//
groupBoxColors.Controls.Add(panelSilver);
groupBoxColors.Controls.Add(panelOrange);
groupBoxColors.Controls.Add(panelWhite);
groupBoxColors.Controls.Add(panelGreen);
groupBoxColors.Controls.Add(panelViolet);
groupBoxColors.Controls.Add(panelBlue);
groupBoxColors.Controls.Add(panelYellow);
groupBoxColors.Controls.Add(labelComplexObject);
groupBoxColors.Controls.Add(labelSimpleObject);
groupBoxColors.Controls.Add(panelRed);
groupBoxColors.Location = new Point(310, 21);
groupBoxColors.Name = "groupBoxColors";
groupBoxColors.Size = new Size(279, 212);
groupBoxColors.TabIndex = 0;
groupBoxColors.TabStop = false;
groupBoxColors.Text = "Цвета";
//
// panelSilver
//
panelSilver.BackColor = Color.Silver;
panelSilver.Location = new Point(148, 96);
panelSilver.Name = "panelSilver";
panelSilver.Size = new Size(40, 40);
panelSilver.TabIndex = 3;
//
// panelOrange
//
panelOrange.BackColor = Color.DarkOrange;
panelOrange.Location = new Point(204, 96);
panelOrange.Name = "panelOrange";
panelOrange.Size = new Size(40, 40);
panelOrange.TabIndex = 3;
//
// panelWhite
//
panelWhite.BackColor = Color.White;
panelWhite.Location = new Point(93, 96);
panelWhite.Name = "panelWhite";
panelWhite.Size = new Size(40, 40);
panelWhite.TabIndex = 3;
//
// panelGreen
//
panelGreen.BackColor = Color.LimeGreen;
panelGreen.Location = new Point(38, 96);
panelGreen.Name = "panelGreen";
panelGreen.Size = new Size(40, 40);
panelGreen.TabIndex = 3;
//
// panelViolet
//
panelViolet.BackColor = Color.MediumVioletRed;
panelViolet.Location = new Point(204, 43);
panelViolet.Name = "panelViolet";
panelViolet.Size = new Size(40, 40);
panelViolet.TabIndex = 3;
//
// panelBlue
//
panelBlue.BackColor = Color.MediumBlue;
panelBlue.Location = new Point(148, 43);
panelBlue.Name = "panelBlue";
panelBlue.Size = new Size(40, 40);
panelBlue.TabIndex = 3;
//
// panelYellow
//
panelYellow.BackColor = Color.Yellow;
panelYellow.Location = new Point(93, 43);
panelYellow.Name = "panelYellow";
panelYellow.Size = new Size(40, 40);
panelYellow.TabIndex = 3;
//
// labelComplexObject
//
labelComplexObject.BorderStyle = BorderStyle.FixedSingle;
labelComplexObject.Location = new Point(148, 157);
labelComplexObject.Name = "labelComplexObject";
labelComplexObject.RightToLeft = RightToLeft.No;
labelComplexObject.Size = new Size(120, 38);
labelComplexObject.TabIndex = 4;
labelComplexObject.Text = "Продвинутый";
labelComplexObject.TextAlign = ContentAlignment.MiddleCenter;
labelComplexObject.MouseDown += labelObject_MouseDown;
//
// labelSimpleObject
//
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(14, 157);
labelSimpleObject.Name = "labelSimpleObject";
labelSimpleObject.Size = new Size(120, 38);
labelSimpleObject.TabIndex = 3;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
labelSimpleObject.MouseDown += labelObject_MouseDown;
//
// panelRed
//
panelRed.BackColor = Color.Red;
panelRed.Location = new Point(38, 43);
panelRed.Name = "panelRed";
panelRed.Size = new Size(40, 40);
panelRed.TabIndex = 2;
//
// buttonOk
//
buttonOk.Location = new Point(666, 212);
buttonOk.Name = "buttonOk";
buttonOk.Size = new Size(107, 43);
buttonOk.TabIndex = 0;
buttonOk.Text = "Добавить";
buttonOk.UseVisualStyleBackColor = true;
buttonOk.Click += buttonOk_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(796, 212);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(107, 43);
buttonCancel.TabIndex = 1;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(18, 55);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(227, 109);
pictureBoxObject.TabIndex = 0;
pictureBoxObject.TabStop = false;
//
// labelBodyColor
//
labelBodyColor.AllowDrop = true;
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
labelBodyColor.Location = new Point(18, 9);
labelBodyColor.Name = "labelBodyColor";
labelBodyColor.Size = new Size(107, 38);
labelBodyColor.TabIndex = 2;
labelBodyColor.Text = "Цвет";
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
labelBodyColor.DragDrop += labelBodyColor_DragDrop;
labelBodyColor.DragEnter += labelColor_DragEnter;
//
// labelAdditionalColor
//
labelAdditionalColor.AllowDrop = true;
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
labelAdditionalColor.Location = new Point(138, 9);
labelAdditionalColor.Name = "labelAdditionalColor";
labelAdditionalColor.Size = new Size(107, 38);
labelAdditionalColor.TabIndex = 3;
labelAdditionalColor.Text = "Доп. цвет";
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
labelAdditionalColor.DragDrop += labelAdditionalColor_DragDrop;
labelAdditionalColor.DragEnter += labelColor_DragEnter;
//
// panelObject
//
panelObject.AllowDrop = true;
panelObject.Controls.Add(pictureBoxObject);
panelObject.Controls.Add(labelAdditionalColor);
panelObject.Controls.Add(labelBodyColor);
panelObject.Location = new Point(650, 27);
panelObject.Name = "panelObject";
panelObject.Size = new Size(264, 171);
panelObject.TabIndex = 2;
panelObject.DragDrop += panelObject_DragDrop;
panelObject.DragEnter += panelObject_DragEnter;
//
// FormAirbusConfig
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(952, 283);
Controls.Add(panelObject);
Controls.Add(groupBoxConfig);
Controls.Add(buttonOk);
Controls.Add(buttonCancel);
Name = "FormAirbusConfig";
Text = "Конструирование самолёта";
groupBoxConfig.ResumeLayout(false);
groupBoxConfig.PerformLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
groupBoxColors.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
panelObject.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxConfig;
private CheckBox checkBoxAdditionalEngine;
private CheckBox checkBoxCompartment;
private Label labelWeight;
private Label labelSpeed;
private GroupBox groupBoxColors;
private NumericUpDown numericUpDownWeight;
private NumericUpDown numericUpDownSpeed;
private Panel panelRed;
private Button buttonCancel;
private Button buttonOk;
private Label labelComplexObject;
private Label labelSimpleObject;
private Label labelAdditionalColor;
private Label labelBodyColor;
private PictureBox pictureBoxObject;
private Panel panelObject;
private Panel panelSilver;
private Panel panelOrange;
private Panel panelWhite;
private Panel panelGreen;
private Panel panelViolet;
private Panel panelBlue;
private Panel panelYellow;
}
}

157
Airbus/FormAirbusConfig.cs Normal file
View File

@@ -0,0 +1,157 @@
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.Drawnings;
using ProjectAirbus.Entities;
namespace ProjectAirbus
{
public partial class FormAirbusConfig : Form
{
// выбранный самолёт
DrawningAirbus? _airbus = null;
// событие
private event Action<DrawningAirbus> EventAddAirbus;
// конструктор
public FormAirbusConfig()
{
InitializeComponent();
panelRed.MouseDown += PanelColor_MouseDown;
panelBlue.MouseDown += PanelColor_MouseDown;
panelGreen.MouseDown += PanelColor_MouseDown;
panelOrange.MouseDown += PanelColor_MouseDown;
panelViolet.MouseDown += PanelColor_MouseDown;
panelSilver.MouseDown += PanelColor_MouseDown;
panelWhite.MouseDown += PanelColor_MouseDown;
panelYellow.MouseDown += PanelColor_MouseDown;
buttonCancel.Click += (sender, e) => Close();
}
// добавить событие
public void AddEvent(Action<DrawningAirbus> ev)
{
if (EventAddAirbus == null)
{
EventAddAirbus = ev;
}
else
{
EventAddAirbus += ev;
}
}
// цвета
private void labelColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
{
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
}
// перекрашиваем базовый
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
{
if (_airbus == null)
return;
Color bodyColor = (Color)e.Data?.GetData(typeof(Color));
_airbus.EntityAirbus.ChangeBodyColor(bodyColor);
DrawAirbus();
}
// перекрашиваем доп
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
{
if (_airbus == null)
return;
Color addColor = (Color)e.Data?.GetData(typeof(Color));
if (_airbus is DrawningPlane)
{
EntityPlane _plane = _airbus.EntityAirbus as EntityPlane;
_plane.ChangeColorAdditional(addColor);
}
else
{
MessageBox.Show("Нельзя задать доп. цвет обычному самолёту");
}
DrawAirbus();
}
// объект
private void panelObject_DragEnter(object sender, DragEventArgs e)
{
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
// передаём информацию при нажатии на label
private void labelObject_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
}
// что делаем при приеме информации
private void panelObject_DragDrop(object sender, DragEventArgs e)
{
switch (e.Data?.GetData(DataFormats.Text).ToString())
{
case "labelSimpleObject":
_airbus = new DrawningAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value,
Color.White, pictureBoxObject.Width, pictureBoxObject.Height);
break;
case "labelComplexObject":
_airbus = new DrawningPlane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value,
Color.White, Color.Black, checkBoxCompartment.Checked, checkBoxAdditionalEngine.Checked,
pictureBoxObject.Width, pictureBoxObject.Height);
break;
}
DrawAirbus();
}
// добавить самолёт
private void buttonOk_Click(object sender, EventArgs e)
{
if (_airbus == null)
return;
EventAddAirbus?.Invoke(_airbus);
Close();
}
// отрисовать самолёт
private void DrawAirbus()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_airbus?.SetPosition(5, 5);
_airbus?.DrawTransport(gr);
pictureBoxObject.Image = bmp;
}
}
}

View 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>

211
Airbus/FormPlane.Designer.cs generated Normal file
View 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;
}
}

View File

@@ -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;
}
}
}

View File

@@ -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">

View File

@@ -0,0 +1,103 @@
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.GetAirbus(pos) == null)
{
return false;
}
return collect?._collection.Remove(pos) ?? false;
}
// получение объекта IMoveableObjecr
public U? GetU(int pos)
{
return (U?)_collection[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 = _pictureWidth / _placeSizeWidth - 1;
int y = _pictureHeight / _placeSizeHeight - 1;
foreach (var airbus in _collection.GetAirbus())
{
if (airbus != null)
{
if (x < 0)
{
x = _pictureWidth / _placeSizeWidth - 1;
--y;
}
airbus.SetPosition(_placeSizeWidth * x, _placeSizeHeight * y);
airbus.DrawTransport(g);
--x;
}
}
}
}
}

View File

@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using ProjectAirbus.Drawnings;
using ProjectAirbus.MovementStrategy;
namespace ProjectAirbus.Generics
{
// Класс для хранения коллекции
internal class AirbusGenericStorage
{
//Словарь (хранилище)
readonly Dictionary<string, AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>> _airbusStorages;
//Возвращение списка названий наборов
public List<string> Keys => _airbusStorages.Keys.ToList();
//Ширина окна отрисовки
private readonly int _pictureWidth;
//Высота окна отрисовки
private readonly int _pictureHeight;
public AirbusGenericStorage(int pictureWidth, int pictureHeight)
{
_airbusStorages = new Dictionary<string, AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
// Добавление набора
public void AddSet(string name)
{
// проверка, что нет набора с таким именем
foreach (string nameStorage in Keys)
{
if (nameStorage == name)
{
return;
}
}
_airbusStorages.Add(name, new AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>(_pictureWidth, _pictureHeight));
}
// Удаление набора
public void DelSet(string name)
{
if ( _airbusStorages.ContainsKey(name))
{
_airbusStorages.Remove(name);
}
}
// Доступ к набору
public AirbusGenericCollection<DrawningAirbus, DrawningObjectAirbus>? this[string ind]
{
get
{
if (_airbusStorages.ContainsKey(ind))
{
return _airbusStorages[ind];
}
return null;
}
}
}
}

View File

@@ -0,0 +1,97 @@
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 List<T?> _places;
// кол-во объектов
public int Count => _places.Count;
// максимальное количество
private readonly int _maxCount;
public SetGeneric(int count)
{
_maxCount = count;
_places = new List<T?>(count);
}
// Добавление объекта в начало набора
public int Insert(T airbus)
{
if (_places.Count >= _maxCount)
{
return -1;
}
_places.Insert(0, airbus);
return 0;
}
// Добавление объекта в набор на конкретную позицию
public bool Insert(T airbus, int position)
{
if (Count >= _maxCount || position < 0 || position >= Count)
{
return false;
}
_places.Insert(position, airbus);
return true;
}
// Удаление объекта из набора с конкретной позиции
public bool Remove(int position)
{
if (position < 0 || position >= Count)
{
return false;
}
_places.RemoveAt(position);
return true;
}
// Получение объекта из набора по позиции
public T? this[int position]
{
get
{
if (position < 0 || position >= Count)
{
return null;
}
return _places[position];
}
set
{
if (position < 0 || Count >= _maxCount)
{
return;
}
_places.Insert(position, value);
}
}
// Проход по списку
public IEnumerable<T?> GetAirbus(int? maxAirbus = null)
{
for (int i = 0; i < _places.Count; ++i)
{
yield return _places[i];
if (maxAirbus.HasValue && i == maxAirbus.Value)
{
yield break;
}
}
}
}
}

View File

@@ -3,7 +3,7 @@ using ProjectAirbus.Entities;
namespace ProjectAirbus.MovementStrategy
{
internal interface IMoveableObject
public interface IMoveableObject
{
ObjectParameters? GetObjectPosition { get; }

View File

@@ -1,6 +1,6 @@
namespace ProjectAirbus.MovementStrategy
{
internal class ObjectParameters
public class ObjectParameters
{
private readonly int _x;
private readonly int _y;

View File

@@ -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());
}
}
}