Сдал лаб03

This commit is contained in:
357Sharonov 2024-03-27 13:59:35 +04:00
parent 58cd3ac83e
commit 49024c4c17
4 changed files with 50 additions and 32 deletions

View File

@ -9,12 +9,12 @@ public abstract class AbstractCompany
/// <summary>
/// Размер места (ширина)
/// </summary>
protected readonly int _placeSizeWidth = 210;
protected readonly int _placeSizeWidth = 180;
/// <summary>
/// Размер места (высота)
/// </summary>
protected readonly int _placeSizeHeight = 80;
protected readonly int _placeSizeHeight = 100;
/// <summary>
/// Ширина окна

View File

@ -21,28 +21,38 @@ public class PlanePark : AbstractCompany
protected override void DrawBackgound(Graphics g)
{
int width = _pictureWidth / _placeSizeWidth;
int height = _pictureHeight / _placeSizeHeight;
Pen pen = new(Color.Black, 3);
for (int i = 0; i < width; i++)
int width = _pictureWidth - 1;
int height = _pictureHeight / 2;
Pen pen = new(Color.RosyBrown, 3);
g.DrawLine(pen, width, height, 5, height);
g.DrawLine(pen, width, height - 100, 5, height - 100);
Pen pen2 = new(Color.Black, 3);
for (int i = 0; i < _pictureWidth; i+=50)
{
for (int j = 0; j < height + 1; ++j)
{
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth - 15, j * _placeSizeHeight);
}
g.DrawLine(pen2, width-i, height - 50, width - (i+30), height -50);
}
}
protected override void SetObjectsPosition()
{
int count = 0;
for (int y = 5; y + 50 < _pictureHeight; y += 90)
int megacount = 0;
for (int y = _pictureHeight - 100; y - 50 > 0; y -= 100)
{
for (int x = 5; x + 200 < _pictureWidth; x += _placeSizeHeight + 90)
megacount++;
if (y < _pictureHeight / 2 && y > (_pictureHeight / 2) - 100)
{
y -= 200;
}
for (int x = _pictureWidth - 200; x - 120 > 0; x -= _placeSizeHeight + 75)
{
_collection?.Get(count)?.SetPictureSize(_pictureWidth, _pictureHeight);
_collection?.Get(count)?.SetPosition(x, y);
count++;
}
}
}

View File

@ -35,7 +35,7 @@
maskedTextBox = new MaskedTextBox();
buttonAddSeaplane = new Button();
buttonAddBasicSeaplane = new Button();
comboBoxSelectorCompany = new ComboBox();
СomboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
groupBoxTools.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
@ -49,11 +49,11 @@
groupBoxTools.Controls.Add(maskedTextBox);
groupBoxTools.Controls.Add(buttonAddSeaplane);
groupBoxTools.Controls.Add(buttonAddBasicSeaplane);
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Controls.Add(СomboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(872, 0);
groupBoxTools.Location = new Point(854, 0);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(180, 579);
groupBoxTools.Size = new Size(180, 398);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
@ -68,6 +68,7 @@
buttonRefresh.TabIndex = 6;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
buttonRefresh.Click += ButtonRefresh_Click;
//
// buttonGoToCheck
//
@ -79,6 +80,7 @@
buttonGoToCheck.TabIndex = 5;
buttonGoToCheck.Text = "Передать на тесты";
buttonGoToCheck.UseVisualStyleBackColor = true;
buttonGoToCheck.Click += ButtonGoToCheck_Click;
//
// buttonDelSeaplane
//
@ -90,6 +92,7 @@
buttonDelSeaplane.TabIndex = 4;
buttonDelSeaplane.Text = "Удалить самолет";
buttonDelSeaplane.UseVisualStyleBackColor = true;
buttonDelSeaplane.Click += ButtonnDelSeaplane_Click;
//
// maskedTextBox
//
@ -110,6 +113,7 @@
buttonAddSeaplane.TabIndex = 2;
buttonAddSeaplane.Text = "Добавление гидросамолета";
buttonAddSeaplane.UseVisualStyleBackColor = true;
buttonAddSeaplane.Click += ButtonAddSeaplane_Click;
//
// buttonAddBasicSeaplane
//
@ -121,24 +125,25 @@
buttonAddBasicSeaplane.TabIndex = 1;
buttonAddBasicSeaplane.Text = "Добавление самолета";
buttonAddBasicSeaplane.UseVisualStyleBackColor = true;
buttonAddBasicSeaplane.Click += ButtonAddBasicSeaplane_Click;
//
// comboBoxSelectorCompany
// СomboBoxSelectorCompany
//
comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
comboBoxSelectorCompany.Location = new Point(6, 22);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(168, 23);
comboBoxSelectorCompany.TabIndex = 0;
comboBoxSelectorCompany.SelectedIndexChanged += СomboBoxSelectorCompany_SelectedIndexChanged;
СomboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
СomboBoxSelectorCompany.FormattingEnabled = true;
СomboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
СomboBoxSelectorCompany.Location = new Point(6, 22);
СomboBoxSelectorCompany.Name = "СomboBoxSelectorCompany";
СomboBoxSelectorCompany.Size = new Size(168, 23);
СomboBoxSelectorCompany.TabIndex = 0;
СomboBoxSelectorCompany.SelectedIndexChanged += СomboBoxSelectorCompany_SelectedIndexChanged;
//
// pictureBox
//
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 0);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(872, 579);
pictureBox.Size = new Size(854, 398);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
@ -146,11 +151,12 @@
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1052, 579);
ClientSize = new Size(1034, 398);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
Name = "FormPlaneCollection";
Text = "Коллекция самолетов";
Load += FormPlaneCollection_Load;
groupBoxTools.ResumeLayout(false);
groupBoxTools.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
@ -161,7 +167,7 @@
private GroupBox groupBoxTools;
private Button buttonAddBasicSeaplane;
private ComboBox comboBoxSelectorCompany;
private ComboBox СomboBoxSelectorCompany;
private Button buttonAddSeaplane;
private Button buttonGoToCheck;
private Button buttonDelSeaplane;

View File

@ -27,13 +27,13 @@ public partial class FormPlaneCollection : Form
/// <param name="e"></param>
private void СomboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comboBoxSelectorCompany.Text)
switch (СomboBoxSelectorCompany.Text)
{
case "Хранилище":
_company = new PlanePark(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawingBasicSeaplane>());
break;
}
}
/// <summary>
@ -71,8 +71,7 @@ public partial class FormPlaneCollection : Form
case nameof(DrawingSeaplane):
// TODO вызов диалогового окна для выбора цвета
drawingBasicSeaplane = new DrawingSeaplane(random.Next(100, 300), random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
GetColor(random), GetColor(random),
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
break;
default:
@ -187,5 +186,8 @@ public partial class FormPlaneCollection : Form
pictureBox.Image = _company.Show();
}
private void FormPlaneCollection_Load(object sender, EventArgs e)
{
}
}