本文整理汇总了C#中Microsoft.Xna.Framework.Rectangle.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Clone方法的具体用法?C# Rectangle.Clone怎么用?C# Rectangle.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Rectangle
的用法示例。
在下文中一共展示了Rectangle.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddSourceRectangle
/// <summary>
/// Add's a source rectangle into the timeline at a specified position.
/// </summary>
/// <param name="r">The source rectangle</param>
/// <param name="position"> the postion</param>
/// <param name="insert">Whether or not to insert or replace.</param>
public void AddSourceRectangle(Rectangle r, int position, bool insert)
{
if (insert)
{
//resize it
var copy = new Rectangle[_sourcerectangles.GetUpperBound(0) + 1];
for (int i = 0; i < _sourcerectangles.GetUpperBound(0); i++)
{
if (i >= position) i++;
copy[i] = _sourcerectangles[i];
}
//Copy over the new array
_sourcerectangles = (Rectangle[])copy.Clone();
//copy the rectangle
_sourcerectangles[position] = r;
}
else
{
//if the position is greater than the array size
if (position > _sourcerectangles.GetUpperBound(0))
{
//resize it
var copy = new Rectangle[position];
for (int i = 0; i < _sourcerectangles.GetUpperBound(0); i++)
{
copy[i] = _sourcerectangles[i];
}
//Copy over the new array
_sourcerectangles = (Rectangle[])copy.Clone();
}
//copy the rectangle
_sourcerectangles[position] = r;
}
}