Сравнительное объектно-ориентированное проектирование - 42 стр.

UptoLike

Составители: 

42
Sprite sprite;
try
{
sprite = (Sprite)Activator.CreateInstance(SpriteType,
new object[2] { SpriteRect, this });
}
catch (Exception e)
{
throw (e is System.Reflection.TargetInvocationException ?
e.InnerException : e);
}
sprite.Z = list.Add(sprite);
count = list.Count;
return sprite;
}
return null;
}
/// <summary>
/// Меняет z-слой положения спрайта.
/// </summary>
/// <param name="fromZ">
/// Исходный слой.
/// </param>
/// <param name="toZ">
/// Конечный слой.
/// </param>
public void MoveSprite(int fromZ, int toZ)
{
if (fromZ != toZ &&
fromZ > -1 && fromZ < count &&
toZ > -1 && toZ < count)
{
Sprite tempSprite;
int minZ = fromZ < toZ ? fromZ : toZ;
for (int i = count - 1; i >= minZ; i--)
if (this[i].Visible) this[i].Restore();
tempSprite = this[fromZ];
list.RemoveAt(fromZ);
list.Insert(toZ, tempSprite);
for (int i = minZ; i < count; i++)
{
this[i].Z = i;
if (this[i].Visible) this[i].Paint();
}
}
}
/// <summary>