файлы лабораторной

This commit is contained in:
Ivan_Starostin 2023-12-19 19:32:23 +04:00
parent 60f34c49b3
commit 0208828b09
2 changed files with 37 additions and 15 deletions

View File

@ -17,7 +17,7 @@ namespace ProjectLainer
{ {
int index = listBoxStorages.SelectedIndex; int index = listBoxStorages.SelectedIndex;
listBoxStorages.Items.Clear(); listBoxStorages.Items.Clear();
foreach (string key in _storage.Keys) foreach (string key in _storage.Keys)
{ {
listBoxStorages.Items.Add(key); listBoxStorages.Items.Add(key);
@ -29,7 +29,7 @@ namespace ProjectLainer
{ {
listBoxStorages.SelectedIndex = index; listBoxStorages.SelectedIndex = index;
} }
} }
} }
private void ButtonAddObject_Click(object sender, EventArgs e) private void ButtonAddObject_Click(object sender, EventArgs e)
{ {
@ -66,19 +66,9 @@ namespace ProjectLainer
{ {
return; return;
} }
LainerForm form = new(); var formLinerConfig = new FormLainerConfig();
if (form.ShowDialog() == DialogResult.OK) formLinerConfig.AddEvent(AddLainer);
{ formLinerConfig.Show();
if (obj + form.SelectedLainer)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowLainers();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
} }
private void ButtonRemove_Click(object sender, EventArgs e) private void ButtonRemove_Click(object sender, EventArgs e)
{ {
@ -126,5 +116,26 @@ namespace ProjectLainer
{ {
pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowLainers(); pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowLainers();
} }
private void AddLainer(DrawingEntity lainer)
{
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
if (obj + lainer)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowLainers();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
} }
} }

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProjectLainer.DrawningObjects;
namespace Lainers
{
public delegate void LainerDelegate(DrawingEntity lainer);
}