Compare commits

...

2 Commits

Author SHA1 Message Date
44a4339f45 lab4 is done 2023-11-29 20:45:45 +04:00
a7f0b62f08 lab4 is done 2023-11-29 20:38:43 +04:00
3 changed files with 24 additions and 13 deletions

View File

@ -65,8 +65,7 @@ namespace ProjectTank
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ListBoxObjects_SelectedIndexChanged(object sender,
EventArgs e)
private void ListBoxObjects_SelectedIndexChanged(object sender,EventArgs e)
{
pictureBoxCollection.Image =
_storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowArmoredTransports();
@ -82,10 +81,19 @@ namespace ProjectTank
{
return;
}
if (MessageBox.Show($"Удалить объект{listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes){
_storage.DelSet(listBoxStorages.SelectedItem.ToString()??string.Empty);
ReloadObjects();
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
pictureBoxCollection.Image = obj.ShowArmoredTransports();
}
}
/// <summary>
@ -129,12 +137,13 @@ namespace ProjectTank
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
var obj = _storage[listBoxStorages.SelectedItem.ToString()??string.Empty];
if (obj == null)
{
return;
}
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
@ -154,8 +163,7 @@ namespace ProjectTank
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonRefreshCollection_Click(object sender, EventArgs
e)
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
{

View File

@ -123,7 +123,6 @@ namespace ProjectTank.Generics
}
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth,
_pictureHeight / _placeSizeHeight * _placeSizeHeight);
}
}
/// <summary>
@ -132,7 +131,7 @@ namespace ProjectTank.Generics
/// <param name="g"></param>
private void DrawObjects(Graphics g)
{
int width = (_pictureWidth / _placeSizeWidth) / 2;
int width = (_pictureWidth / _placeSizeWidth);
int height = _pictureHeight / _placeSizeHeight;
int i = 0;
foreach (var armoredTransport in _collection.GetArmoredTrasports())

View File

@ -12,7 +12,8 @@ namespace ProjectTank.Generics
/// <summary>
/// Словарь (хранилище)
/// </summary>
readonly Dictionary<string, ArmoredTransportsGenericCollection<DrawningArmoredTransport, DrawningObjectArmoredTransport>> _armoredTransportStorages;
readonly Dictionary<string, ArmoredTransportsGenericCollection<DrawningArmoredTransport,
DrawningObjectArmoredTransport>> _armoredTransportStorages;
/// <summary>
/// Возвращение списка названий наборов
/// </summary>
@ -32,7 +33,8 @@ namespace ProjectTank.Generics
/// <param name="pictureHeight"></param>
public ArmoredTransportsGenericStorage(int pictureWidth, int pictureHeight)
{
_armoredTransportStorages = new Dictionary<string, ArmoredTransportsGenericCollection<DrawningArmoredTransport, DrawningObjectArmoredTransport>>();
_armoredTransportStorages = new Dictionary<string, ArmoredTransportsGenericCollection<DrawningArmoredTransport,
DrawningObjectArmoredTransport>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
@ -42,7 +44,9 @@ namespace ProjectTank.Generics
/// <param name="name">Название набора</param>
public void AddSet(string name)
{
_armoredTransportStorages.Add(name, new ArmoredTransportsGenericCollection<DrawningArmoredTransport, DrawningObjectArmoredTransport>(_pictureWidth, _pictureHeight));
_armoredTransportStorages.Add(name, new ArmoredTransportsGenericCollection<DrawningArmoredTransport,
DrawningObjectArmoredTransport>(_pictureWidth,
_pictureHeight));
}
/// <summary>
/// Удаление набора