Лабораторная работа №7

This commit is contained in:
Олег Кудринский 2024-05-04 23:59:32 +04:00
parent 1739ded8c2
commit 09a77f8654
3 changed files with 72 additions and 46 deletions

View File

@ -15,7 +15,7 @@ namespace ProjectContainerShip.CollectionGenericObjects;
/// <summary> /// <summary>
/// Размер места (высота) /// Размер места (высота)
/// </summary> /// </summary>
protected readonly int _placeSizeHeight = 80; protected readonly int _placeSizeHeight = 82;
/// <summary> /// <summary>
/// Ширина окна /// Ширина окна

View File

@ -32,11 +32,15 @@ public class ShipPortService : AbstractCompany
for (int i = 0; i < (_collection?.Count ?? 0); i++) for (int i = 0; i < (_collection?.Count ?? 0); i++)
{ {
if (_collection.Get(i) != null) try
{ {
_collection.Get(i).SetPictureSize(_pictureWidth, _pictureHeight); if (_collection.Get(i) != null)
_collection.Get(i).SetPosition(_placeSizeWidth * curWidth + 55, curHeight * _placeSizeHeight + 20); {
_collection.Get(i).SetPictureSize(_pictureWidth, _pictureHeight);
_collection.Get(i).SetPosition(_placeSizeWidth * curWidth + 55, curHeight * _placeSizeHeight + 20);
}
} }
catch (Exception) { }
if (curWidth > 0) if (curWidth > 0)
curWidth--; curWidth--;
else else

View File

@ -67,9 +67,11 @@
groupBoxTools.Controls.Add(comboBoxSelectorCompany); groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right; groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.ForeColor = Color.Black; groupBoxTools.ForeColor = Color.Black;
groupBoxTools.Location = new Point(1601, 40); groupBoxTools.Location = new Point(722, 24);
groupBoxTools.Margin = new Padding(2, 1, 2, 1);
groupBoxTools.Name = "groupBoxTools"; groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(388, 1072); groupBoxTools.Padding = new Padding(2, 1, 2, 1);
groupBoxTools.Size = new Size(209, 497);
groupBoxTools.TabIndex = 0; groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false; groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты"; groupBoxTools.Text = "Инструменты";
@ -83,17 +85,19 @@
panelCompanyTools.Controls.Add(buttonRefresh); panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Dock = DockStyle.Bottom; panelCompanyTools.Dock = DockStyle.Bottom;
panelCompanyTools.Enabled = false; panelCompanyTools.Enabled = false;
panelCompanyTools.Location = new Point(3, 598); panelCompanyTools.Location = new Point(2, 275);
panelCompanyTools.Margin = new Padding(2, 1, 2, 1);
panelCompanyTools.Name = "panelCompanyTools"; panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(382, 471); panelCompanyTools.Size = new Size(205, 221);
panelCompanyTools.TabIndex = 10; panelCompanyTools.TabIndex = 10;
// //
// buttonAddShip // buttonAddShip
// //
buttonAddShip.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; buttonAddShip.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddShip.Location = new Point(3, 70); buttonAddShip.Location = new Point(2, 33);
buttonAddShip.Margin = new Padding(2, 1, 2, 1);
buttonAddShip.Name = "buttonAddShip"; buttonAddShip.Name = "buttonAddShip";
buttonAddShip.Size = new Size(370, 77); buttonAddShip.Size = new Size(198, 36);
buttonAddShip.TabIndex = 1; buttonAddShip.TabIndex = 1;
buttonAddShip.Text = "Добавление корабля"; buttonAddShip.Text = "Добавление корабля";
buttonAddShip.UseVisualStyleBackColor = true; buttonAddShip.UseVisualStyleBackColor = true;
@ -101,19 +105,21 @@
// //
// maskedTextBox // maskedTextBox
// //
maskedTextBox.Location = new Point(3, 201); maskedTextBox.Location = new Point(2, 94);
maskedTextBox.Margin = new Padding(2, 1, 2, 1);
maskedTextBox.Mask = "00"; maskedTextBox.Mask = "00";
maskedTextBox.Name = "maskedTextBox"; maskedTextBox.Name = "maskedTextBox";
maskedTextBox.Size = new Size(370, 39); maskedTextBox.Size = new Size(201, 23);
maskedTextBox.TabIndex = 3; maskedTextBox.TabIndex = 3;
maskedTextBox.ValidatingType = typeof(int); maskedTextBox.ValidatingType = typeof(int);
// //
// buttonRemoveShip // buttonRemoveShip
// //
buttonRemoveShip.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; buttonRemoveShip.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRemoveShip.Location = new Point(3, 246); buttonRemoveShip.Location = new Point(2, 115);
buttonRemoveShip.Margin = new Padding(2, 1, 2, 1);
buttonRemoveShip.Name = "buttonRemoveShip"; buttonRemoveShip.Name = "buttonRemoveShip";
buttonRemoveShip.Size = new Size(370, 77); buttonRemoveShip.Size = new Size(198, 36);
buttonRemoveShip.TabIndex = 4; buttonRemoveShip.TabIndex = 4;
buttonRemoveShip.Text = "Удалить корабль"; buttonRemoveShip.Text = "Удалить корабль";
buttonRemoveShip.UseVisualStyleBackColor = true; buttonRemoveShip.UseVisualStyleBackColor = true;
@ -122,9 +128,10 @@
// buttonGoToCheck // buttonGoToCheck
// //
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonGoToCheck.Location = new Point(3, 329); buttonGoToCheck.Location = new Point(2, 154);
buttonGoToCheck.Margin = new Padding(2, 1, 2, 1);
buttonGoToCheck.Name = "buttonGoToCheck"; buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(370, 77); buttonGoToCheck.Size = new Size(198, 36);
buttonGoToCheck.TabIndex = 5; buttonGoToCheck.TabIndex = 5;
buttonGoToCheck.Text = "Передать на тесты"; buttonGoToCheck.Text = "Передать на тесты";
buttonGoToCheck.UseVisualStyleBackColor = true; buttonGoToCheck.UseVisualStyleBackColor = true;
@ -133,9 +140,10 @@
// buttonRefresh // buttonRefresh
// //
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Location = new Point(3, 412); buttonRefresh.Location = new Point(2, 193);
buttonRefresh.Margin = new Padding(2, 1, 2, 1);
buttonRefresh.Name = "buttonRefresh"; buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(370, 77); buttonRefresh.Size = new Size(198, 36);
buttonRefresh.TabIndex = 6; buttonRefresh.TabIndex = 6;
buttonRefresh.Text = "Обновить"; buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true; buttonRefresh.UseVisualStyleBackColor = true;
@ -143,9 +151,10 @@
// //
// buttonCreateCompany // buttonCreateCompany
// //
buttonCreateCompany.Location = new Point(6, 546); buttonCreateCompany.Location = new Point(3, 256);
buttonCreateCompany.Margin = new Padding(2, 1, 2, 1);
buttonCreateCompany.Name = "buttonCreateCompany"; buttonCreateCompany.Name = "buttonCreateCompany";
buttonCreateCompany.Size = new Size(370, 46); buttonCreateCompany.Size = new Size(199, 22);
buttonCreateCompany.TabIndex = 9; buttonCreateCompany.TabIndex = 9;
buttonCreateCompany.Text = "Создать компанию"; buttonCreateCompany.Text = "Создать компанию";
buttonCreateCompany.UseVisualStyleBackColor = true; buttonCreateCompany.UseVisualStyleBackColor = true;
@ -161,17 +170,19 @@
panelStorage.Controls.Add(textBoxCollectionName); panelStorage.Controls.Add(textBoxCollectionName);
panelStorage.Controls.Add(labelCollectionName); panelStorage.Controls.Add(labelCollectionName);
panelStorage.Dock = DockStyle.Top; panelStorage.Dock = DockStyle.Top;
panelStorage.Location = new Point(3, 35); panelStorage.Location = new Point(2, 17);
panelStorage.Margin = new Padding(2, 1, 2, 1);
panelStorage.Name = "panelStorage"; panelStorage.Name = "panelStorage";
panelStorage.Size = new Size(382, 459); panelStorage.Size = new Size(205, 215);
panelStorage.TabIndex = 8; panelStorage.TabIndex = 8;
// //
// radioButtonMassive // radioButtonMassive
// //
radioButtonMassive.AutoSize = true; radioButtonMassive.AutoSize = true;
radioButtonMassive.Location = new Point(39, 91); radioButtonMassive.Location = new Point(21, 43);
radioButtonMassive.Margin = new Padding(2, 1, 2, 1);
radioButtonMassive.Name = "radioButtonMassive"; radioButtonMassive.Name = "radioButtonMassive";
radioButtonMassive.Size = new Size(128, 36); radioButtonMassive.Size = new Size(67, 19);
radioButtonMassive.TabIndex = 7; radioButtonMassive.TabIndex = 7;
radioButtonMassive.TabStop = true; radioButtonMassive.TabStop = true;
radioButtonMassive.Text = "Массив"; radioButtonMassive.Text = "Массив";
@ -179,9 +190,10 @@
// //
// buttonCollectionDel // buttonCollectionDel
// //
buttonCollectionDel.Location = new Point(3, 387); buttonCollectionDel.Location = new Point(2, 181);
buttonCollectionDel.Margin = new Padding(2, 1, 2, 1);
buttonCollectionDel.Name = "buttonCollectionDel"; buttonCollectionDel.Name = "buttonCollectionDel";
buttonCollectionDel.Size = new Size(370, 46); buttonCollectionDel.Size = new Size(199, 22);
buttonCollectionDel.TabIndex = 6; buttonCollectionDel.TabIndex = 6;
buttonCollectionDel.Text = "Удалить коллекцию"; buttonCollectionDel.Text = "Удалить коллекцию";
buttonCollectionDel.UseVisualStyleBackColor = true; buttonCollectionDel.UseVisualStyleBackColor = true;
@ -190,16 +202,19 @@
// listBoxCollection // listBoxCollection
// //
listBoxCollection.FormattingEnabled = true; listBoxCollection.FormattingEnabled = true;
listBoxCollection.Location = new Point(3, 185); listBoxCollection.ItemHeight = 15;
listBoxCollection.Location = new Point(2, 87);
listBoxCollection.Margin = new Padding(2, 1, 2, 1);
listBoxCollection.Name = "listBoxCollection"; listBoxCollection.Name = "listBoxCollection";
listBoxCollection.Size = new Size(370, 196); listBoxCollection.Size = new Size(201, 94);
listBoxCollection.TabIndex = 5; listBoxCollection.TabIndex = 5;
// //
// buttonCollectionAdd // buttonCollectionAdd
// //
buttonCollectionAdd.Location = new Point(3, 133); buttonCollectionAdd.Location = new Point(2, 62);
buttonCollectionAdd.Margin = new Padding(2, 1, 2, 1);
buttonCollectionAdd.Name = "buttonCollectionAdd"; buttonCollectionAdd.Name = "buttonCollectionAdd";
buttonCollectionAdd.Size = new Size(370, 46); buttonCollectionAdd.Size = new Size(199, 22);
buttonCollectionAdd.TabIndex = 4; buttonCollectionAdd.TabIndex = 4;
buttonCollectionAdd.Text = "Добавить коллекцию"; buttonCollectionAdd.Text = "Добавить коллекцию";
buttonCollectionAdd.UseVisualStyleBackColor = true; buttonCollectionAdd.UseVisualStyleBackColor = true;
@ -208,9 +223,10 @@
// radioButtonList // radioButtonList
// //
radioButtonList.AutoSize = true; radioButtonList.AutoSize = true;
radioButtonList.Location = new Point(215, 91); radioButtonList.Location = new Point(116, 43);
radioButtonList.Margin = new Padding(2, 1, 2, 1);
radioButtonList.Name = "radioButtonList"; radioButtonList.Name = "radioButtonList";
radioButtonList.Size = new Size(125, 36); radioButtonList.Size = new Size(66, 19);
radioButtonList.TabIndex = 3; radioButtonList.TabIndex = 3;
radioButtonList.TabStop = true; radioButtonList.TabStop = true;
radioButtonList.Text = "Список"; radioButtonList.Text = "Список";
@ -218,17 +234,19 @@
// //
// textBoxCollectionName // textBoxCollectionName
// //
textBoxCollectionName.Location = new Point(3, 46); textBoxCollectionName.Location = new Point(2, 22);
textBoxCollectionName.Margin = new Padding(2, 1, 2, 1);
textBoxCollectionName.Name = "textBoxCollectionName"; textBoxCollectionName.Name = "textBoxCollectionName";
textBoxCollectionName.Size = new Size(370, 39); textBoxCollectionName.Size = new Size(201, 23);
textBoxCollectionName.TabIndex = 1; textBoxCollectionName.TabIndex = 1;
// //
// labelCollectionName // labelCollectionName
// //
labelCollectionName.AutoSize = true; labelCollectionName.AutoSize = true;
labelCollectionName.Location = new Point(69, 11); labelCollectionName.Location = new Point(37, 5);
labelCollectionName.Margin = new Padding(2, 0, 2, 0);
labelCollectionName.Name = "labelCollectionName"; labelCollectionName.Name = "labelCollectionName";
labelCollectionName.Size = new Size(251, 32); labelCollectionName.Size = new Size(125, 15);
labelCollectionName.TabIndex = 0; labelCollectionName.TabIndex = 0;
labelCollectionName.Text = "Название коллекции:"; labelCollectionName.Text = "Название коллекции:";
// //
@ -238,18 +256,20 @@
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true; comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" }); comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
comboBoxSelectorCompany.Location = new Point(6, 500); comboBoxSelectorCompany.Location = new Point(3, 234);
comboBoxSelectorCompany.Margin = new Padding(2, 1, 2, 1);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(370, 40); comboBoxSelectorCompany.Size = new Size(201, 23);
comboBoxSelectorCompany.TabIndex = 0; comboBoxSelectorCompany.TabIndex = 0;
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged; comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
// //
// pictureBox // pictureBox
// //
pictureBox.Dock = DockStyle.Fill; pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 40); pictureBox.Location = new Point(0, 24);
pictureBox.Margin = new Padding(2, 1, 2, 1);
pictureBox.Name = "pictureBox"; pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(1601, 1072); pictureBox.Size = new Size(722, 497);
pictureBox.TabIndex = 1; pictureBox.TabIndex = 1;
pictureBox.TabStop = false; pictureBox.TabStop = false;
// //
@ -259,7 +279,8 @@
menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem }); menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
menuStrip.Location = new Point(0, 0); menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip"; menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(1989, 40); menuStrip.Padding = new Padding(3, 1, 0, 1);
menuStrip.Size = new Size(931, 24);
menuStrip.TabIndex = 2; menuStrip.TabIndex = 2;
menuStrip.Text = "menuStrip1"; menuStrip.Text = "menuStrip1";
// //
@ -267,14 +288,14 @@
// //
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem }); файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem });
файлToolStripMenuItem.Name = айлToolStripMenuItem"; файлToolStripMenuItem.Name = айлToolStripMenuItem";
файлToolStripMenuItem.Size = new Size(90, 36); файлToolStripMenuItem.Size = new Size(48, 22);
файлToolStripMenuItem.Text = "Файл"; файлToolStripMenuItem.Text = "Файл";
// //
// saveToolStripMenuItem // saveToolStripMenuItem
// //
saveToolStripMenuItem.Name = "saveToolStripMenuItem"; saveToolStripMenuItem.Name = "saveToolStripMenuItem";
saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S; saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
saveToolStripMenuItem.Size = new Size(361, 44); saveToolStripMenuItem.Size = new Size(181, 22);
saveToolStripMenuItem.Text = "Сохранение"; saveToolStripMenuItem.Text = "Сохранение";
saveToolStripMenuItem.Click += SaveToolStripMenuItem_Click; saveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
// //
@ -282,7 +303,7 @@
// //
loadToolStripMenuItem.Name = "loadToolStripMenuItem"; loadToolStripMenuItem.Name = "loadToolStripMenuItem";
loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L; loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
loadToolStripMenuItem.Size = new Size(361, 44); loadToolStripMenuItem.Size = new Size(181, 22);
loadToolStripMenuItem.Text = "Загрузка"; loadToolStripMenuItem.Text = "Загрузка";
loadToolStripMenuItem.Click += LoadToolStripMenuItem_Click; loadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
// //
@ -296,13 +317,14 @@
// //
// FormShipCollection // FormShipCollection
// //
AutoScaleDimensions = new SizeF(13F, 32F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1989, 1112); ClientSize = new Size(931, 521);
Controls.Add(pictureBox); Controls.Add(pictureBox);
Controls.Add(groupBoxTools); Controls.Add(groupBoxTools);
Controls.Add(menuStrip); Controls.Add(menuStrip);
MainMenuStrip = menuStrip; MainMenuStrip = menuStrip;
Margin = new Padding(2, 1, 2, 1);
Name = "FormShipCollection"; Name = "FormShipCollection";
Text = "Коллекция кораблей"; Text = "Коллекция кораблей";
groupBoxTools.ResumeLayout(false); groupBoxTools.ResumeLayout(false);