/*/// <summary>
  * ///  Gets the element with the specified Id in the category.
  * /// </summary>
  * /// <param name="id">The Id of the element to get.</param>
  * /// <returns>The element with the specified Id.</returns>
  * public ISpriteElement Get(object id) {
  *      ISpriteElement element = List.Find(e => e.Id.Equals(id));
  *      return element ?? throw new KeyNotFoundException($"Could not find the key \"{id}\"!");
  * }*/
 /// <summary>
 ///  Tries to get the element with the specified Id in the category.
 /// </summary>
 /// <param name="id">The Id of the element to get.</param>
 /// <param name="value">The output element if one was found, otherwise null.</param>
 /// <returns>True if an element with the Id was found, otherwise null.</returns>
 ///
 /// <exception cref="ArgumentNullException">
 ///  <paramref name="id"/> is null.
 /// </exception>
 public bool TryGetValue(object id, out ISpriteElement value)
 {
     if (id == null)
     {
         throw new ArgumentNullException(nameof(id));
     }
     value = List.Find(e => e.Id.Equals(id));
     return(value != null);
 }
 /*/// <summary>
  * ///  Gets the element at the specified index in the category.
  * /// </summary>
  * /// <param name="index">The index of the element to get.</param>
  * /// <returns>The element at the specified index.</returns>
  * public ISpriteElement this[int index] => List[index];*/
 /// <summary>
 ///  Gets the element with the specified Id in the category.
 /// </summary>
 /// <param name="id">The Id of the element to get.</param>
 ///
 /// <exception cref="ArgumentNullException">
 ///  <paramref name="id"/> is null.
 /// </exception>
 /// <exception cref="KeyNotFoundException">
 ///  The element with the <paramref name="id"/> was not found.
 /// </exception>
 public ISpriteElement this[object id] {
     get {
         if (id == null)
         {
             throw new ArgumentNullException(nameof(id));
         }
         ISpriteElement element = List.Find(e => e.Id.Equals(id));
         return(element ?? throw new KeyNotFoundException($"Could not find the key \"{id}\"!"));
     }
 }
Пример #3
0
 public XmlSpriteElement(ISpriteElement spriteElement)
 {
     if (spriteElement != null) {
         Name = spriteElement.Name;
         X = spriteElement.X;
         Y = spriteElement.Y;
         Height = spriteElement.Height;
         Width = spriteElement.Width;
         OriginX = spriteElement.OriginX;
         OriginY = spriteElement.OriginY;
     }
 }
        /*/// <summary>
         * ///  Creates a group part representing no selection.
         * /// </summary>
         * /// <returns>The created empty group part.</returns>
         * public ISpritePartGroupPart CreateNoneGroupPart() => SpritePartGroupPart.None;*/

        #endregion

        #region ISpriteCategoryBuilder Implementation

        /// <summary>
        ///  Adds the sprite element to the category.
        /// </summary>
        /// <param name="value">The sprite element to add with its Id.</param>
        public void Add(ISpriteElement value) => List.Add(value);