Доработка

This commit is contained in:
Володя 2022-10-10 20:23:23 +03:00
parent 18c877f93b
commit 412fab79a2
4 changed files with 59 additions and 34 deletions

View File

@ -117,6 +117,8 @@ namespace AirPlaneWithRadar
{
return;
}
if (maskedTextBoxPosition.Text == null)
return;
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
if ((_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - (pos - 1)) != null)
{

View File

@ -113,44 +113,33 @@ namespace AirPlaneWithRadar
}
private void DrawPlains(Graphics g)
{
int CountWidth = _pictureWidth / _placeSizeWidth;
int x = _pictureWidth - _placeSizeWidth;
int y = _placeSizeHeight / 4;
int k = 0;
foreach(var plain in _setPlains.GetPlains())
{
for (int k = 0; k < _setPlains.Count; k++)
{
if (_setPlains[k] != null)
{
if ((k + 1) % CountWidth != 0 || k == 0)
{
_setPlains[k]?.SetObject(x, y, _pictureWidth, _pictureHeight);
_setPlains[k]?.DrawningObject(g);
plain?.SetObject(x, y, _pictureWidth, _pictureHeight);
plain?.DrawningObject(g);
x -= _placeSizeWidth;
}
else
{
_setPlains[k]?.SetObject(x, y, _pictureWidth, _pictureHeight);
_setPlains[k]?.DrawningObject(g);
x = _pictureWidth - _placeSizeWidth - _placeSizeWidth / 2 - _placeSizeWidth / 4;
plain?.SetObject(x, y, _pictureWidth, _pictureHeight);
plain?.DrawningObject(g);
x = _pictureWidth - _placeSizeWidth ;
y += _placeSizeHeight;
}
k++;
}
if (_setPlains[k] == null)
{
if ((k + 1) % CountWidth != 0 || k == 0)
x -= _placeSizeWidth;
else
{
x = _pictureWidth - _placeSizeWidth - _placeSizeWidth / 2 - _placeSizeWidth / 4;
y += _placeSizeHeight;
}
}
}
}
}

View File

@ -25,13 +25,19 @@ namespace AirPlaneWithRadar
public void AddMap(string name, AbstractMap map)
{
if (_mapStorages.ContainsKey(name))
return;
Keys.Add(name);
_mapStorages.Add(name, new MapWithSetPlainGeneric<DrawingObjectPlane, AbstractMap>(_pictureWidth, _pictureHeight, map));
}
public void DelMap(string name)
{
if (!_mapStorages.ContainsKey(name))
return;
Keys.Remove(name);
_mapStorages.Remove(name);
}
public MapWithSetPlainGeneric<DrawingObjectPlane, AbstractMap> this[string ind]
@ -39,7 +45,9 @@ namespace AirPlaneWithRadar
get
{
if (!_mapStorages.ContainsKey(ind))
return null;
else
return _mapStorages[ind];
}
}

View File

@ -20,31 +20,57 @@ namespace AirPlaneWithRadar
}
public int Insert(T plain)
{
return 1;
}
public bool Insert(T plain, int position)
if (_places.Count == _maxCount)
{
return -1;
}
_places.Insert(0, plain);
return true;
return _places.Count;
}
public int Insert(T plain, int position)
{
if (position < 0 || _places.Count < position||position > _maxCount)
return -1;
else if (plain == null)
return -1;
_places.Insert(position, plain);
return position;
}
public T Remove(int position)
{
return _places[position];
T mid;
if (position < 0 || _places.Count < position || position > _maxCount)
return null;
else if (_places[position] == null)
return null;
else
{
mid = _places[position];
_places.RemoveAt(position);
}
return mid;
}
public T this[int position]
{
get
{
if (position < 0 || _places.Count < position || position > _maxCount)
return null;
else if (_places[position] == null)
return null;
else
return _places[position];
}
set
{
if (position < 0 || _places.Count < position || position > _maxCount)
return;
else if (_places.Count == _maxCount)
return;
else
_places[position] = value;
}
}
public IEnumerable<T> GetPlains()