Третья лабораторная работа

This commit is contained in:
10Г Егор Романов 2022-10-10 19:53:02 +03:00
parent ef272fb946
commit 3e6dcd8f81
2 changed files with 12 additions and 41 deletions

View File

@ -33,27 +33,16 @@ namespace HoistingCrane
InitializeComponent(); InitializeComponent();
} }
listBoxMaps.Items.Clear(); private MapWithSetHoistingCraneGeneric<DrawingObjectHoistingCrane, AbstractMap> _mapHoistingCraneCollectionGeneric;
for (int i = 0; i < _mapsCollection.Keys.Count; i++)
{ {
listBoxMaps.Items.Add(_mapsCollection.Keys[i]);
} }
if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count))
{
listBoxMaps.SelectedIndex = 0;
}
else if (listBoxMaps.Items.Count > 0 && index > -1 && index < listBoxMaps.Items.Count)
{
listBoxMaps.SelectedIndex = index;
}
}
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
{ {
AbstractMap map = null; AbstractMap map = null;
switch (comboBoxSelectorMap.Text) switch (comboBoxSelectorMap.Text)
{ {
case "Простая карта":
map = new SimpleMap(); map = new SimpleMap();
break; break;
case "Вторая карта": case "Вторая карта":
@ -108,28 +97,14 @@ namespace HoistingCrane
{ {
return; return;
} }
if (MessageBox.Show($"Удалить карту {listBoxMaps.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
_mapsCollection.DelMap(listBoxMaps.SelectedItem?.ToString() ?? string.Empty);
ReloadMaps();
_logger.LogInformation($"Удалена карта {listBoxMaps.SelectedItem?.ToString()}");
}
}
private void ButtonAddHoistingCrane_Click(object sender, EventArgs e) private void ButtonAddHoistingCrane_Click(object sender, EventArgs e)
{ {
if (_mapHoistingCraneCollectionGeneric == null) if (_mapHoistingCraneCollectionGeneric == null)
{ {
var formHoistingCraneConfig = new FormHoistingCraneConfig();
formHoistingCraneConfig.AddEvent(AddHoistingCrane);
formHoistingCraneConfig.Show();
} }
private void AddHoistingCrane(DrawingHoistingCrane drawingHoistingCrane)
{ {
DrawingObjectHoistingCrane hoistingCrane = new DrawingObjectHoistingCrane(drawingHoistingCrane);
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + hoistingCrane != -1)
{ {
MessageBox.Show("Объект добавлен"); MessageBox.Show("Объект добавлен");
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
} }
else else
{ {
@ -137,8 +112,6 @@ namespace HoistingCrane
} }
} }
} }
}
}
private void ButtonRemoveHoistingCrane_Click(object sender, EventArgs e) private void ButtonRemoveHoistingCrane_Click(object sender, EventArgs e)
{ {
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text)) if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
@ -202,7 +175,6 @@ namespace HoistingCrane
enums = Direction.Right; enums = Direction.Right;
break; break;
} }
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(enums);
} }
private void pictureBox_Click(object sender, EventArgs e) private void pictureBox_Click(object sender, EventArgs e)

View File

@ -107,7 +107,6 @@ namespace HoistingCrane
} }
} }
private void DrawHoistingCranes(Graphics gr)
{ {
int heightEl = _pictureHeight / _placeSizeHeight; int heightEl = _pictureHeight / _placeSizeHeight;
int widthEl = _pictureWidth / _placeSizeWidth; int widthEl = _pictureWidth / _placeSizeWidth;