Доработка
This commit is contained in:
parent
18c877f93b
commit
412fab79a2
@ -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)
|
||||
{
|
||||
|
@ -113,44 +113,33 @@ namespace AirPlaneWithRadar
|
||||
}
|
||||
private void DrawPlains(Graphics g)
|
||||
{
|
||||
|
||||
|
||||
int CountWidth = _pictureWidth / _placeSizeWidth;
|
||||
|
||||
int x = _pictureWidth - _placeSizeWidth;
|
||||
int y = _placeSizeHeight / 4;
|
||||
|
||||
for (int k = 0; k < _setPlains.Count; k++)
|
||||
int k = 0;
|
||||
foreach(var plain in _setPlains.GetPlains())
|
||||
{
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
if (_setPlains[k] == null)
|
||||
{
|
||||
if ((k + 1) % CountWidth != 0 || k == 0)
|
||||
x -= _placeSizeWidth;
|
||||
else
|
||||
{
|
||||
x = _pictureWidth - _placeSizeWidth - _placeSizeWidth / 2 - _placeSizeWidth / 4;
|
||||
y += _placeSizeHeight;
|
||||
}
|
||||
}
|
||||
|
||||
k++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
@ -20,31 +20,57 @@ namespace AirPlaneWithRadar
|
||||
}
|
||||
public int Insert(T plain)
|
||||
{
|
||||
|
||||
if (_places.Count == _maxCount)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
_places.Insert(0, plain);
|
||||
|
||||
return 1;
|
||||
return _places.Count;
|
||||
}
|
||||
public bool Insert(T plain, int position)
|
||||
public int Insert(T plain, int position)
|
||||
{
|
||||
|
||||
return true;
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user