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

View File

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

View File

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