Lab03 Готовая

This commit is contained in:
ivans 2024-04-09 13:54:43 +04:00
parent 1c816e6597
commit 73b879b9c6
10 changed files with 513 additions and 495 deletions

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net7.0-windows7.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>

View File

@ -8,7 +8,7 @@ using AirBomber.Drawnings;
namespace AirBomber.CollectionGenericObjects;
/// <summary>
/// Абстракция компании, хранящий коллекцию самолеток
/// Абстракция компании, хранящий коллекцию самолетов
/// </summary>
public abstract class AbstractCompany
{
@ -20,7 +20,7 @@ public abstract class AbstractCompany
/// <summary>
/// Размер места (высота)
/// </summary>
protected readonly int _placeSizeHeight = 80;
protected readonly int _placeSizeHeight = 150;
/// <summary>
/// Ширина окна
@ -33,7 +33,7 @@ public abstract class AbstractCompany
protected readonly int _pictureHeight;
/// <summary>
/// Коллекция самолетов
/// Коллекция лодок
/// </summary>
protected ICollectionGenericObjects<DrawningAirPlane>? _collection = null;
@ -47,7 +47,7 @@ public abstract class AbstractCompany
/// </summary>
/// <param name="picWidth">Ширина окна</param>
/// <param name="picHeight">Высота окна</param>
/// <param name="collection">Коллекция самолетов</param>
/// <param name="collection">Коллекция лодок</param>
public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects<DrawningAirPlane> collection)
{
_pictureWidth = picWidth;
@ -60,11 +60,11 @@ public abstract class AbstractCompany
/// Перегрузка оператора сложения для класса
/// </summary>
/// <param name="company">Компания</param>
/// <param name="airplane">Добавляемый объект</param>
/// <param name="boat">Добавляемый объект</param>
/// <returns></returns>
public static int operator +(AbstractCompany company, DrawningAirPlane airplane)
public static int operator +(AbstractCompany company, DrawningAirPlane boat)
{
return company._collection?.Insert(airplane) ?? -1;
return company._collection?.Insert(boat) ?? -1;
}
/// <summary>

View File

@ -23,30 +23,32 @@ public class AirPlaneSharingService : AbstractCompany
protected override void DrawBackground(Graphics g)
{
Color backgroundColor = Color.SkyBlue;
Color backgroundColor = Color.Gray;
using (Brush brush = new SolidBrush(backgroundColor))
{
g.FillRectangle(brush, new Rectangle(0, 0, _pictureWidth, _pictureHeight));
}
Pen pen = new Pen(Color.Brown, 3);
int offsetX = 10, offsetY = -12;
int x = 1 + offsetX, y = _pictureHeight - _placeSizeHeight + offsetY;
int x = _pictureWidth - _placeSizeWidth, y = offsetY;
numRows = 0;
while (y >= 0)
while (y + _placeSizeHeight <= _pictureHeight)
{
int numCols = 0;
while (x + _placeSizeWidth <= _pictureWidth)
int initialX = x; // сохраняем начальное значение x
while (x >= 0)
{
numCols++;
g.DrawLine(pen, x, y, x + _placeSizeWidth / 2, y);
g.DrawLine(pen, x, y, x, y + _placeSizeHeight + 4);
locCoord.Add(new Tuple<int, int>(x, y));
x += _placeSizeWidth + 2;
x -= _placeSizeWidth + 2;
}
numRows++;
x = 1 + offsetX;
y -= _placeSizeHeight + 5 + offsetY;
x = initialX; // возвращаем x к начальному значению после завершения строки
y += _placeSizeHeight + 5 + offsetY;
}
numCols = numCols; // сохраняем значение numCols для использования в других методах
}
protected override void SetObjectsPosition()

View File

@ -28,151 +28,127 @@
/// </summary>
private void InitializeComponent()
{
this.buttonCreateAirPlane = new System.Windows.Forms.Button();
this.ButtonRight = new System.Windows.Forms.Button();
this.ButtonUp = new System.Windows.Forms.Button();
this.ButtonLeft = new System.Windows.Forms.Button();
this.ButtonDown = new System.Windows.Forms.Button();
this.pictureBoxAirBomber = new System.Windows.Forms.PictureBox();
this.buttonCreateAirBomber = new System.Windows.Forms.Button();
this.comboBoxStrategy = new System.Windows.Forms.ComboBox();
this.buttonStrategyStep = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirBomber)).BeginInit();
this.SuspendLayout();
//
// buttonCreateAirPlane
//
this.buttonCreateAirPlane.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonCreateAirPlane.Location = new System.Drawing.Point(12, 575);
this.buttonCreateAirPlane.Name = "buttonCreateAirPlane";
this.buttonCreateAirPlane.Size = new System.Drawing.Size(233, 33);
this.buttonCreateAirPlane.TabIndex = 0;
this.buttonCreateAirPlane.Text = "Создать Военный самолет";
this.buttonCreateAirPlane.UseVisualStyleBackColor = true;
this.buttonCreateAirPlane.Click += new System.EventHandler(this.ButtonCreateAirPlane_Click);
ButtonRight = new Button();
ButtonUp = new Button();
ButtonLeft = new Button();
ButtonDown = new Button();
pictureBoxAirBomber = new PictureBox();
comboBoxStrategy = new ComboBox();
buttonStrategyStep = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxAirBomber).BeginInit();
SuspendLayout();
//
// ButtonRight
//
this.ButtonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonRight.BackgroundImage = global::AirBomber.Properties.Resources.arrowRight;
this.ButtonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ButtonRight.Location = new System.Drawing.Point(905, 560);
this.ButtonRight.Name = "ButtonRight";
this.ButtonRight.Size = new System.Drawing.Size(50, 48);
this.ButtonRight.TabIndex = 1;
this.ButtonRight.UseVisualStyleBackColor = true;
this.ButtonRight.Click += new System.EventHandler(this.ButtonMove_Click);
ButtonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
ButtonRight.BackgroundImage = Properties.Resources.arrowRight;
ButtonRight.BackgroundImageLayout = ImageLayout.Stretch;
ButtonRight.Location = new Point(792, 420);
ButtonRight.Margin = new Padding(3, 2, 3, 2);
ButtonRight.Name = "ButtonRight";
ButtonRight.Size = new Size(44, 36);
ButtonRight.TabIndex = 1;
ButtonRight.UseVisualStyleBackColor = true;
ButtonRight.Click += ButtonMove_Click;
//
// ButtonUp
//
this.ButtonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonUp.BackgroundImage = global::AirBomber.Properties.Resources.arrowUp;
this.ButtonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ButtonUp.Location = new System.Drawing.Point(849, 506);
this.ButtonUp.Name = "ButtonUp";
this.ButtonUp.Size = new System.Drawing.Size(50, 48);
this.ButtonUp.TabIndex = 2;
this.ButtonUp.UseVisualStyleBackColor = true;
this.ButtonUp.Click += new System.EventHandler(this.ButtonMove_Click);
ButtonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
ButtonUp.BackgroundImage = Properties.Resources.arrowUp;
ButtonUp.BackgroundImageLayout = ImageLayout.Stretch;
ButtonUp.Location = new Point(743, 380);
ButtonUp.Margin = new Padding(3, 2, 3, 2);
ButtonUp.Name = "ButtonUp";
ButtonUp.Size = new Size(44, 36);
ButtonUp.TabIndex = 2;
ButtonUp.UseVisualStyleBackColor = true;
ButtonUp.Click += ButtonMove_Click;
//
// ButtonLeft
//
this.ButtonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonLeft.BackgroundImage = global::AirBomber.Properties.Resources.arrowLeft;
this.ButtonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ButtonLeft.Location = new System.Drawing.Point(793, 560);
this.ButtonLeft.Name = "ButtonLeft";
this.ButtonLeft.Size = new System.Drawing.Size(50, 48);
this.ButtonLeft.TabIndex = 3;
this.ButtonLeft.UseVisualStyleBackColor = true;
this.ButtonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
ButtonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
ButtonLeft.BackgroundImage = Properties.Resources.arrowLeft;
ButtonLeft.BackgroundImageLayout = ImageLayout.Stretch;
ButtonLeft.Location = new Point(694, 420);
ButtonLeft.Margin = new Padding(3, 2, 3, 2);
ButtonLeft.Name = "ButtonLeft";
ButtonLeft.Size = new Size(44, 36);
ButtonLeft.TabIndex = 3;
ButtonLeft.UseVisualStyleBackColor = true;
ButtonLeft.Click += ButtonMove_Click;
//
// ButtonDown
//
this.ButtonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonDown.BackgroundImage = global::AirBomber.Properties.Resources.arrowDown;
this.ButtonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ButtonDown.Location = new System.Drawing.Point(849, 560);
this.ButtonDown.Name = "ButtonDown";
this.ButtonDown.Size = new System.Drawing.Size(50, 48);
this.ButtonDown.TabIndex = 4;
this.ButtonDown.UseVisualStyleBackColor = true;
this.ButtonDown.Click += new System.EventHandler(this.ButtonMove_Click);
ButtonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
ButtonDown.BackgroundImage = Properties.Resources.arrowDown;
ButtonDown.BackgroundImageLayout = ImageLayout.Stretch;
ButtonDown.Location = new Point(743, 420);
ButtonDown.Margin = new Padding(3, 2, 3, 2);
ButtonDown.Name = "ButtonDown";
ButtonDown.Size = new Size(44, 36);
ButtonDown.TabIndex = 4;
ButtonDown.UseVisualStyleBackColor = true;
ButtonDown.Click += ButtonMove_Click;
//
// pictureBoxAirBomber
//
this.pictureBoxAirBomber.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBoxAirBomber.Location = new System.Drawing.Point(0, 0);
this.pictureBoxAirBomber.Name = "pictureBoxAirBomber";
this.pictureBoxAirBomber.Size = new System.Drawing.Size(967, 621);
this.pictureBoxAirBomber.TabIndex = 5;
this.pictureBoxAirBomber.TabStop = false;
//
// buttonCreateAirBomber
//
this.buttonCreateAirBomber.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.buttonCreateAirBomber.Location = new System.Drawing.Point(283, 576);
this.buttonCreateAirBomber.Name = "buttonCreateAirBomber";
this.buttonCreateAirBomber.Size = new System.Drawing.Size(220, 33);
this.buttonCreateAirBomber.TabIndex = 6;
this.buttonCreateAirBomber.Text = "Создать Бомбардировщик";
this.buttonCreateAirBomber.UseVisualStyleBackColor = true;
this.buttonCreateAirBomber.Click += new System.EventHandler(this.ButtonCreateAirBomber_Click);
pictureBoxAirBomber.Dock = DockStyle.Fill;
pictureBoxAirBomber.Location = new Point(0, 0);
pictureBoxAirBomber.Margin = new Padding(3, 2, 3, 2);
pictureBoxAirBomber.Name = "pictureBoxAirBomber";
pictureBoxAirBomber.Size = new Size(846, 466);
pictureBoxAirBomber.TabIndex = 5;
pictureBoxAirBomber.TabStop = false;
//
// comboBoxStrategy
//
this.comboBoxStrategy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.comboBoxStrategy.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxStrategy.FormattingEnabled = true;
this.comboBoxStrategy.Items.AddRange(new object[] {
"К центру ",
"К краю"});
this.comboBoxStrategy.Location = new System.Drawing.Point(804, 12);
this.comboBoxStrategy.Name = "comboBoxStrategy";
this.comboBoxStrategy.Size = new System.Drawing.Size(151, 28);
this.comboBoxStrategy.TabIndex = 7;
comboBoxStrategy.Anchor = AnchorStyles.Top | AnchorStyles.Right;
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxStrategy.FormattingEnabled = true;
comboBoxStrategy.Items.AddRange(new object[] { "К центру ", "К краю" });
comboBoxStrategy.Location = new Point(704, 9);
comboBoxStrategy.Margin = new Padding(3, 2, 3, 2);
comboBoxStrategy.Name = "comboBoxStrategy";
comboBoxStrategy.Size = new Size(133, 23);
comboBoxStrategy.TabIndex = 7;
//
// buttonStrategyStep
//
this.buttonStrategyStep.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonStrategyStep.Location = new System.Drawing.Point(804, 74);
this.buttonStrategyStep.Name = "buttonStrategyStep";
this.buttonStrategyStep.Size = new System.Drawing.Size(94, 29);
this.buttonStrategyStep.TabIndex = 8;
this.buttonStrategyStep.Text = "Шаг";
this.buttonStrategyStep.UseVisualStyleBackColor = true;
this.buttonStrategyStep.Click += new System.EventHandler(this.buttonStrategyStep_Click);
buttonStrategyStep.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonStrategyStep.Location = new Point(704, 56);
buttonStrategyStep.Margin = new Padding(3, 2, 3, 2);
buttonStrategyStep.Name = "buttonStrategyStep";
buttonStrategyStep.Size = new Size(82, 22);
buttonStrategyStep.TabIndex = 8;
buttonStrategyStep.Text = "Шаг";
buttonStrategyStep.UseVisualStyleBackColor = true;
buttonStrategyStep.Click += buttonStrategyStep_Click;
//
// FormAirBomber
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(967, 621);
this.Controls.Add(this.buttonStrategyStep);
this.Controls.Add(this.comboBoxStrategy);
this.Controls.Add(this.buttonCreateAirBomber);
this.Controls.Add(this.ButtonDown);
this.Controls.Add(this.ButtonLeft);
this.Controls.Add(this.ButtonUp);
this.Controls.Add(this.ButtonRight);
this.Controls.Add(this.buttonCreateAirPlane);
this.Controls.Add(this.pictureBoxAirBomber);
this.Name = "FormAirBomber";
this.Text = "AirBomber";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirBomber)).EndInit();
this.ResumeLayout(false);
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(846, 466);
Controls.Add(buttonStrategyStep);
Controls.Add(comboBoxStrategy);
Controls.Add(ButtonDown);
Controls.Add(ButtonLeft);
Controls.Add(ButtonUp);
Controls.Add(ButtonRight);
Controls.Add(pictureBoxAirBomber);
Margin = new Padding(3, 2, 3, 2);
Name = "FormAirBomber";
Text = "AirBomber";
((System.ComponentModel.ISupportInitialize)pictureBoxAirBomber).EndInit();
ResumeLayout(false);
}
#endregion
private Button buttonCreateAirPlane;
private Button ButtonRight;
private Button ButtonUp;
private Button ButtonLeft;
private Button ButtonDown;
private PictureBox pictureBoxAirBomber;
private Button buttonCreateAirBomber;
private ComboBox comboBoxStrategy;
private Button buttonStrategyStep;
}

View File

@ -11,8 +11,22 @@ public partial class FormAirBomber : Form
/// Ïîëå-îáúåêò äëÿ ïðîðèñîâêè îáúåêòà
/// </summary>
private DrawningAirPlane? _drawningAirPlane;
/// <summary>
/// Ñòðàòåãèÿ ïåðåìåùåíèÿ
/// </summary>
private AbstractStrategy? _strategy;
public DrawningAirPlane SetAirPlane
{
set
{
_drawningAirPlane = value;
_drawningAirPlane.SetPictureSize(pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
comboBoxStrategy.Enabled = true;
_strategy = null;
Draw();
}
}
public FormAirBomber()
{
InitializeComponent();
@ -38,52 +52,6 @@ public partial class FormAirBomber : Form
}
/// <summary>
/// Ñîçäàíèå îáúåêòà
/// </summary>
/// <param name="type"></param>
private void CreateObject(string type)
{
Random random = new();
switch (type)
{
case nameof(DrawningAirPlane):
_drawningAirPlane = new DrawningAirPlane(random.Next(30, 100), random.Next(100, 500),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
break;
case nameof(DrawningAirBomber):
_drawningAirPlane = new DrawningAirBomber(random.Next(30, 100), random.Next(100, 500),
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)));
break;
default:
return;
}
_drawningAirPlane.SetPictureSize(pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
_drawningAirPlane.SetPosition(random.Next(15, 100), random.Next(15, 100));
_strategy = null;
comboBoxStrategy.Enabled = true;
Draw();
}
/// <summary>
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Ñîçäàòü áîìáàðäèðîâùèê"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonCreateAirBomber_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAirBomber));
/// <summary>
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Ñîçäàòü âîåííûé ñàìîëåò"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonCreateAirPlane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAirPlane));
private void ButtonMove_Click(object sender, EventArgs e)
{
if (_drawningAirPlane == null)

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

@ -1,5 +1,5 @@
namespace AirBomber;
namespace AirBomber
{
partial class FormAirPlaneCollection
{
/// <summary>
@ -29,14 +29,14 @@ partial class FormAirPlaneCollection
private void InitializeComponent()
{
groupBoxTools = new GroupBox();
comboBoxSelectorCompany = new ComboBox();
buttonAddAirPlane = new Button();
buttonAddAirBomber = new Button();
pictureBox = new PictureBox();
maskedTextBox = new MaskedTextBox();
buttonDelAirPlane = new Button();
buttonGoToCheck = new Button();
buttonRefresh = new Button();
buttonGoToCheck = new Button();
buttonDelAirPlane = new Button();
maskedTextBox = new MaskedTextBox();
buttonAddAirBomber = new Button();
buttonAddAirPlane = new Button();
comboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
groupBoxTools.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
SuspendLayout();
@ -51,12 +51,74 @@ partial class FormAirPlaneCollection
groupBoxTools.Controls.Add(buttonAddAirPlane);
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(784, 0);
groupBoxTools.Location = new Point(793, 0);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(214, 650);
groupBoxTools.Size = new Size(167, 644);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
groupBoxTools.Text = "Инструманты";
//
// buttonRefresh
//
buttonRefresh.Location = new Point(12, 463);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(143, 43);
buttonRefresh.TabIndex = 6;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
buttonRefresh.Click += ButtonRefresh_Click;
//
// buttonGoToCheck
//
buttonGoToCheck.Location = new Point(12, 370);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(143, 41);
buttonGoToCheck.TabIndex = 5;
buttonGoToCheck.Text = "Передать на тесты";
buttonGoToCheck.UseVisualStyleBackColor = true;
buttonGoToCheck.Click += ButtonGoToCheck_Click;
//
// buttonDelAirPlane
//
buttonDelAirPlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonDelAirPlane.Location = new Point(12, 275);
buttonDelAirPlane.Name = "buttonDelAirPlane";
buttonDelAirPlane.Size = new Size(143, 39);
buttonDelAirPlane.TabIndex = 4;
buttonDelAirPlane.Text = "Удалить Самолет";
buttonDelAirPlane.UseVisualStyleBackColor = true;
buttonDelAirPlane.Click += ButtonRemoveAirPlane_Click;
//
// maskedTextBox
//
maskedTextBox.Location = new Point(12, 246);
maskedTextBox.Mask = "00";
maskedTextBox.Name = "maskedTextBox";
maskedTextBox.Size = new Size(143, 23);
maskedTextBox.TabIndex = 3;
maskedTextBox.ValidatingType = typeof(int);
//
// buttonAddAirBomber
//
buttonAddAirBomber.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddAirBomber.Location = new Point(12, 124);
buttonAddAirBomber.Name = "buttonAddAirBomber";
buttonAddAirBomber.Size = new Size(143, 42);
buttonAddAirBomber.TabIndex = 2;
buttonAddAirBomber.Text = "Добавление Бомбардировщика";
buttonAddAirBomber.UseVisualStyleBackColor = true;
buttonAddAirBomber.Click += buttonAddAirBomber_Click;
//
// buttonAddAirPlane
//
buttonAddAirPlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddAirPlane.Location = new Point(12, 77);
buttonAddAirPlane.Name = "buttonAddAirPlane";
buttonAddAirPlane.Size = new Size(143, 41);
buttonAddAirPlane.TabIndex = 1;
buttonAddAirPlane.Text = "Добавление самолета";
buttonAddAirPlane.UseVisualStyleBackColor = true;
buttonAddAirPlane.Click += buttonAddAirPlane_Click;
//
// comboBoxSelectorCompany
//
@ -64,83 +126,30 @@ partial class FormAirPlaneCollection
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
comboBoxSelectorCompany.Location = new Point(14, 39);
comboBoxSelectorCompany.Location = new Point(12, 31);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(188, 28);
comboBoxSelectorCompany.Size = new Size(143, 23);
comboBoxSelectorCompany.TabIndex = 0;
//
// buttonAddAirPlane
//
buttonAddAirPlane.Location = new Point(14, 128);
buttonAddAirPlane.Name = "buttonAddAirPlane";
buttonAddAirPlane.Size = new Size(188, 42);
buttonAddAirPlane.TabIndex = 1;
buttonAddAirPlane.Text = "Добавление самолета";
buttonAddAirPlane.UseVisualStyleBackColor = true;
//
// buttonAddAirBomber
//
buttonAddAirBomber.Location = new Point(14, 189);
buttonAddAirBomber.Name = "buttonAddAirBomber";
buttonAddAirBomber.Size = new Size(188, 50);
buttonAddAirBomber.TabIndex = 2;
buttonAddAirBomber.Text = "Добавление Бомбардировщика";
buttonAddAirBomber.UseVisualStyleBackColor = true;
comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged;
//
// pictureBox
//
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 0);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(784, 650);
pictureBox.Size = new Size(793, 644);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
// maskedTextBox
//
maskedTextBox.Location = new Point(14, 272);
maskedTextBox.Mask = "00";
maskedTextBox.Name = "maskedTextBox";
maskedTextBox.Size = new Size(188, 27);
maskedTextBox.TabIndex = 3;
maskedTextBox.ValidatingType = typeof(int);
//
// buttonDelAirPlane
//
buttonDelAirPlane.Location = new Point(14, 327);
buttonDelAirPlane.Name = "buttonDelAirPlane";
buttonDelAirPlane.Size = new Size(188, 59);
buttonDelAirPlane.TabIndex = 4;
buttonDelAirPlane.Text = "Удалить самолет";
buttonDelAirPlane.UseVisualStyleBackColor = true;
//
// buttonGoToCheck
//
buttonGoToCheck.Location = new Point(14, 443);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(188, 59);
buttonGoToCheck.TabIndex = 5;
buttonGoToCheck.Text = "Передать на тесты";
buttonGoToCheck.UseVisualStyleBackColor = true;
//
// buttonRefresh
//
buttonRefresh.Location = new Point(14, 569);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(188, 59);
buttonRefresh.TabIndex = 6;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
//
// FormAirPlaneCollection
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(998, 650);
ClientSize = new Size(960, 644);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
Name = "FormAirPlaneCollection";
Text = "Коллекция самолетов";
Text = "FormAirPlaneCollection";
groupBoxTools.ResumeLayout(false);
groupBoxTools.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
@ -150,12 +159,13 @@ partial class FormAirPlaneCollection
#endregion
private GroupBox groupBoxTools;
private Button buttonAddAirPlane;
private ComboBox comboBoxSelectorCompany;
private Button buttonAddAirBomber;
private Button buttonAddAirPlane;
private PictureBox pictureBox;
private Button buttonGoToCheck;
private Button buttonDelAirPlane;
private MaskedTextBox maskedTextBox;
private Button buttonGoToCheck;
private Button buttonRefresh;
}
}

View File

@ -1,4 +1,5 @@
using AirBomber.CollectionGenericObjects;
using AirBomber.Drawnings;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -9,9 +10,9 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AirBomber;
public partial class FormBoatCollection : Form
namespace AirBomber
{
public partial class FormAirPlaneCollection : Form
{
/// <summary>
/// Компания
@ -21,7 +22,7 @@ public partial class FormBoatCollection : Form
/// <summary>
/// Конструктор
/// </summary>
public FormBoatCollection()
public FormAirPlaneCollection()
{
InitializeComponent();
}
@ -36,7 +37,7 @@ public partial class FormBoatCollection : Form
switch (comboBoxSelectorCompany.Text)
{
case "Хранилище":
_company = new BoatSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningBoat>());
_company = new AirPlaneSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningAirPlane>());
break;
}
}
@ -51,16 +52,16 @@ public partial class FormBoatCollection : Form
{
return;
}
DrawningBoat _drawningBoat;
DrawningAirPlane _drawningAirPlane;
Random random = new();
switch (type)
{
case nameof(DrawningBoat):
_drawningBoat = new DrawningBoat(random.Next(30, 70), random.Next(100, 500),
case nameof(DrawningAirPlane):
_drawningAirPlane = new DrawningAirPlane(random.Next(30, 70), random.Next(100, 500),
GetColor(random));
break;
case nameof(DrawningCatamaran):
_drawningBoat = new DrawningCatamaran(random.Next(30, 70), random.Next(100, 500),
case nameof(DrawningAirBomber):
_drawningAirPlane = new DrawningAirBomber(random.Next(30, 70), random.Next(100, 500),
GetColor(random), GetColor(random),
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
break;
@ -69,7 +70,7 @@ public partial class FormBoatCollection : Form
}
if (_company + _drawningBoat != -1)
if (_company + _drawningAirPlane != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
@ -85,14 +86,14 @@ public partial class FormBoatCollection : Form
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonAddBoat_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningBoat));
private void buttonAddAirPlane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAirPlane));
/// <summary>
/// Добавление спортивного автомобиля
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonAddCatamaran_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningCatamaran));
private void buttonAddAirBomber_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAirBomber));
/// <summary>
/// Получение цвета
@ -116,9 +117,9 @@ public partial class FormBoatCollection : Form
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonRemoveBoat_Click(object sender, EventArgs e)
private void ButtonRemoveAirPlane_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text) || _company == null)
if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null)
{
return;
}
@ -128,7 +129,7 @@ public partial class FormBoatCollection : Form
return;
}
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
int pos = Convert.ToInt32(maskedTextBox.Text);
if (_company - pos != null)
{
MessageBox.Show("Объект удален");
@ -152,7 +153,7 @@ public partial class FormBoatCollection : Form
return;
}
DrawningBoat? airplane = null;
DrawningAirPlane? airplane = null;
int counter = 100;
while (airplane == null)
{
@ -169,8 +170,8 @@ public partial class FormBoatCollection : Form
return;
}
FormCatamaran form = new FormCatamaran();
form.SetBoat = airplane;
FormAirBomber form = new FormAirBomber();
form.SetAirPlane = airplane;
form.ShowDialog();
}
@ -189,3 +190,4 @@ public partial class FormBoatCollection : Form
pictureBox.Image = _company.Show();
}
}
}

View File

@ -11,7 +11,7 @@ namespace AirBomber
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new FormAirBomber());
Application.Run(new FormAirPlaneCollection());
}
}
}