Ejemplo n.º 1
0
        private IHmeResource ResourceToHmeResource(Events.ResourceInfo resourceInfo, Resource resource)
        {
            IHmeResource hmeResource = null;

            lock (_resourceManager)
            {
                if (_resourceManager.TryGetHmeResource(resourceInfo.ResourceId, out hmeResource))
                {
                    return(hmeResource);
                }
            }
            if (resource.IsMusic)
            {
                hmeResource = new StreamedMusic(this, resource.Name, resourceInfo.ResourceId);
            }
            else if (resource.IsResourceType(ResourceType.Image))
            {
                hmeResource = new ImageResource(this, resource.Name, resourceInfo.ResourceId);
            }
            else if (resource.IsResourceType(ResourceType.Sound))
            {
                hmeResource = new Sound(this, resource.Name, resourceInfo.ResourceId);
            }
            else if (resource.IsResourceType(ResourceType.TrueTypeFont))
            {
                hmeResource = new TrueTypeFontResource(this, resource.Name, resourceInfo.ResourceId);
            }
            else
            {
                hmeResource = new GenericResource(this, resource.Name, resourceInfo.ResourceId);
            }

            return(hmeResource);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Tests equality between two resources
        /// </summary>
        /// <param name="obj">Must be a TrueTypeFontResource.</param>
        /// <returns>true if the resources represent the same item; false otherwise.</returns>
        public override bool Equals(object obj)
        {
            TrueTypeFontResource ttfResource = obj as TrueTypeFontResource;

            if (ttfResource != null)
            {
                return(_resourceId == ttfResource._resourceId);
            }
            else
            {
                return(false);
            }
        }