2012-08-09 09:45:04 +00:00
|
|
|
#region Using Statements
|
2011-11-07 21:19:15 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
2012-10-13 10:51:27 +00:00
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using ANX.Framework.NonXNA.Development;
|
2011-11-07 21:19:15 +00:00
|
|
|
|
|
|
|
#endregion // Using Statements
|
|
|
|
|
2012-08-09 09:45:04 +00:00
|
|
|
// This file is part of the ANX.Framework created by the
|
|
|
|
// "ANX.Framework developer group" and released under the Ms-PL license.
|
|
|
|
// For details see: http://anxframework.codeplex.com/license
|
2011-11-07 21:19:15 +00:00
|
|
|
|
|
|
|
namespace ANX.Framework.Graphics
|
|
|
|
{
|
2012-10-13 10:51:27 +00:00
|
|
|
[PercentageComplete(100)]
|
|
|
|
[Developer("???, AstrorEnales")]
|
|
|
|
[TestState(TestStateAttribute.TestState.Untested)]
|
2011-11-07 21:19:15 +00:00
|
|
|
public sealed class ModelBoneCollection : ReadOnlyCollection<ModelBone>
|
|
|
|
{
|
2012-10-13 10:51:27 +00:00
|
|
|
private readonly ModelBone[] modelBones;
|
2011-11-07 21:19:15 +00:00
|
|
|
|
|
|
|
internal ModelBoneCollection(ModelBone[] modelBones)
|
|
|
|
: base(modelBones)
|
|
|
|
{
|
|
|
|
this.modelBones = modelBones;
|
|
|
|
}
|
|
|
|
|
|
|
|
public new Enumerator GetEnumerator()
|
|
|
|
{
|
|
|
|
return new Enumerator(this.modelBones);
|
|
|
|
}
|
|
|
|
|
|
|
|
public struct Enumerator : IEnumerator<ModelBone>, IDisposable, IEnumerator
|
|
|
|
{
|
2012-10-13 10:51:27 +00:00
|
|
|
private readonly ModelBone[] wrappedArray;
|
2011-11-07 21:19:15 +00:00
|
|
|
private int position;
|
|
|
|
|
2012-10-13 10:51:27 +00:00
|
|
|
public ModelBone Current
|
2011-11-07 21:19:15 +00:00
|
|
|
{
|
2012-10-13 10:51:27 +00:00
|
|
|
get { return this.wrappedArray[this.position]; }
|
2011-11-07 21:19:15 +00:00
|
|
|
}
|
|
|
|
|
2012-10-13 10:51:27 +00:00
|
|
|
object IEnumerator.Current
|
2011-11-07 21:19:15 +00:00
|
|
|
{
|
2012-10-13 10:51:27 +00:00
|
|
|
get { return this.Current; }
|
|
|
|
}
|
|
|
|
|
|
|
|
internal Enumerator(ModelBone[] wrappedArray)
|
|
|
|
{
|
|
|
|
this.wrappedArray = wrappedArray;
|
|
|
|
this.position = -1;
|
2011-11-07 21:19:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public bool MoveNext()
|
|
|
|
{
|
|
|
|
this.position++;
|
|
|
|
if (this.position >= this.wrappedArray.Length)
|
|
|
|
{
|
|
|
|
this.position = this.wrappedArray.Length;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void IEnumerator.Reset()
|
|
|
|
{
|
|
|
|
this.position = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
}
|
2012-10-13 10:51:27 +00:00
|
|
|
}
|
2011-11-07 21:19:15 +00:00
|
|
|
|
2012-10-13 10:51:27 +00:00
|
|
|
public bool TryGetValue(string boneName, out ModelBone value)
|
|
|
|
{
|
|
|
|
if (String.IsNullOrEmpty(boneName))
|
|
|
|
throw new ArgumentNullException("boneName");
|
|
|
|
|
|
|
|
for (int index = 0; index < Items.Count; index++)
|
2011-11-07 21:19:15 +00:00
|
|
|
{
|
2012-10-13 10:51:27 +00:00
|
|
|
ModelBone modelBone = Items[index];
|
|
|
|
if (String.Compare(modelBone.Name, boneName, StringComparison.Ordinal) == 0)
|
2011-11-07 21:19:15 +00:00
|
|
|
{
|
2012-10-13 10:51:27 +00:00
|
|
|
value = modelBone;
|
|
|
|
return true;
|
2011-11-07 21:19:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-13 10:51:27 +00:00
|
|
|
value = null;
|
|
|
|
return false;
|
2011-11-07 21:19:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public ModelBone this[string boneName]
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2012-10-13 10:51:27 +00:00
|
|
|
ModelBone result;
|
|
|
|
if (TryGetValue(boneName, out result) == false)
|
|
|
|
throw new KeyNotFoundException();
|
|
|
|
|
|
|
|
return result;
|
2011-11-07 21:19:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|