Доработка
This commit is contained in:
parent
18c877f93b
commit
412fab79a2
@ -117,6 +117,8 @@ namespace AirPlaneWithRadar
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (maskedTextBoxPosition.Text == null)
|
||||||
|
return;
|
||||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||||
if ((_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - (pos - 1)) != null)
|
if ((_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - (pos - 1)) != null)
|
||||||
{
|
{
|
||||||
|
@ -113,44 +113,33 @@ namespace AirPlaneWithRadar
|
|||||||
}
|
}
|
||||||
private void DrawPlains(Graphics g)
|
private void DrawPlains(Graphics g)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
int CountWidth = _pictureWidth / _placeSizeWidth;
|
int CountWidth = _pictureWidth / _placeSizeWidth;
|
||||||
|
|
||||||
int x = _pictureWidth - _placeSizeWidth;
|
int x = _pictureWidth - _placeSizeWidth;
|
||||||
int y = _placeSizeHeight / 4;
|
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)
|
if ((k + 1) % CountWidth != 0 || k == 0)
|
||||||
{
|
{
|
||||||
_setPlains[k]?.SetObject(x, y, _pictureWidth, _pictureHeight);
|
plain?.SetObject(x, y, _pictureWidth, _pictureHeight);
|
||||||
_setPlains[k]?.DrawningObject(g);
|
plain?.DrawningObject(g);
|
||||||
x -= _placeSizeWidth;
|
x -= _placeSizeWidth;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
_setPlains[k]?.SetObject(x, y, _pictureWidth, _pictureHeight);
|
plain?.SetObject(x, y, _pictureWidth, _pictureHeight);
|
||||||
_setPlains[k]?.DrawningObject(g);
|
plain?.DrawningObject(g);
|
||||||
x = _pictureWidth - _placeSizeWidth - _placeSizeWidth / 2 - _placeSizeWidth / 4;
|
x = _pictureWidth - _placeSizeWidth ;
|
||||||
y += _placeSizeHeight;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,19 @@ namespace AirPlaneWithRadar
|
|||||||
|
|
||||||
public void AddMap(string name, AbstractMap map)
|
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)
|
public void DelMap(string name)
|
||||||
{
|
{
|
||||||
|
if (!_mapStorages.ContainsKey(name))
|
||||||
|
return;
|
||||||
|
Keys.Remove(name);
|
||||||
|
_mapStorages.Remove(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapWithSetPlainGeneric<DrawingObjectPlane, AbstractMap> this[string ind]
|
public MapWithSetPlainGeneric<DrawingObjectPlane, AbstractMap> this[string ind]
|
||||||
@ -39,7 +45,9 @@ namespace AirPlaneWithRadar
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (!_mapStorages.ContainsKey(ind))
|
||||||
|
return null;
|
||||||
|
else
|
||||||
return _mapStorages[ind];
|
return _mapStorages[ind];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,31 +20,57 @@ namespace AirPlaneWithRadar
|
|||||||
}
|
}
|
||||||
public int Insert(T plain)
|
public int Insert(T plain)
|
||||||
{
|
{
|
||||||
|
if (_places.Count == _maxCount)
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
public bool Insert(T plain, int position)
|
|
||||||
{
|
{
|
||||||
|
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)
|
public T Remove(int position)
|
||||||
{
|
{
|
||||||
|
T mid;
|
||||||
return _places[position];
|
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]
|
public T this[int position]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
if (position < 0 || _places.Count < position || position > _maxCount)
|
||||||
|
return null;
|
||||||
|
else if (_places[position] == null)
|
||||||
|
return null;
|
||||||
|
else
|
||||||
return _places[position];
|
return _places[position];
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
if (position < 0 || _places.Count < position || position > _maxCount)
|
||||||
|
return;
|
||||||
|
else if (_places.Count == _maxCount)
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
_places[position] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public IEnumerable<T> GetPlains()
|
public IEnumerable<T> GetPlains()
|
||||||
|
Loading…
Reference in New Issue
Block a user