Example #1
0
 /// <summary>
 /// Gets a value indicating whether the specified animation name is valid for this sprite.
 /// </summary>
 /// <param name="name">The animation name to evaluate.</param>
 /// <returns><see langword="true"/> if the specified animation name is valid; otherwise, <see langword="false"/>.</returns>
 public Boolean IsValidAnimationName(SpriteAnimationName name)
 {
     if (name.IsName)
     {
         return(IsValidAnimationName((String)name));
     }
     else
     {
         return(IsValidAnimationIndex((Int32)name));
     }
 }
        /// <summary>
        /// Converts the string representation of a sprite animation name to an instance of
        /// the <see cref="SpriteAnimationName"/> structure.
        /// </summary>
        private static Boolean TryParseInternal(String s, out SpriteAnimationName name)
        {
            Int32 index;

            if (Int32.TryParse(s, out index))
            {
                name = new SpriteAnimationName(index);
                return(true);
            }

            name = new SpriteAnimationName(s);
            return(true);
        }
Example #3
0
 /// <summary>
 /// Retrieves the animation with the specified name.
 /// </summary>
 /// <param name="name">The name of the animation to retrieve.</param>
 /// <returns>The <see cref="SpriteAnimation"/> with the specified name, or <see langword="null"/> if no such animation exists.</returns>
 public SpriteAnimation this[SpriteAnimationName name]
 {
     get
     {
         if (name.IsIndex)
         {
             return(animations[(Int32)name]);
         }
         else
         {
             SpriteAnimation animation;
             animationCacheByName.TryGetValue((String)name, out animation);
             return(animation);
         }
     }
 }
 /// <inheritdoc/>
 public Boolean Equals(SpriteAnimationName other)
 {
     return
         (this.animationName == other.animationName &&
          this.animationIndex == other.animationIndex);
 }
        /// <summary>
        /// Converts the string representation of a <see cref="SpriteAnimationName"/> to an object instance.
        /// A return value indicates whether the conversion succeeded.
        /// </summary>
        /// <param name="s">The string to convert.</param>
        /// <param name="style">A set of <see cref="NumberStyles"/> values indicating which elements are present in <paramref name="s"/>.</param>
        /// <param name="provider">A format provider that provides culture-specific formatting information.</param>
        /// <param name="v">The converted value.</param>
        /// <returns><see langword="true"/> if the conversion succeeded; otherwise, <see langword="false"/>.</returns>
        public static Boolean TryParse(String s, NumberStyles style, IFormatProvider provider, out SpriteAnimationName v)
        {
            Contract.Require(s, nameof(s));

            return(TryParseInternal(s, out v));
        }
 /// <summary>
 /// Converts the string representation of a <see cref="SpriteAnimationName"/> to an object instance.
 /// A return value indicates whether the conversion succeeded.
 /// </summary>
 /// <param name="s">The string to convert.</param>
 /// <param name="v">The converted value.</param>
 /// <returns><see langword="true"/> if the conversion succeeded; otherwise, <see langword="false"/>.</returns>
 public static Boolean TryParse(String s, out SpriteAnimationName v)
 {
     return(TryParse(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out v));
 }