Esempio n. 1
0
        /// <summary>
        /// Returns an Image that has been constructed taking in account
        /// the value of some attributes.
        /// </summary>
        /// <param name="attributes">Some attributes</param>
        /// <returns>an Image</returns>
        public static Image getInstance(Properties attributes)
        {
            string value = attributes.Remove(ElementTags.URL);

            if (value == null)
            {
                throw new Exception("The URL of the image is missing.");
            }
            Image image = Image.getInstance(value);
            int   align = Element.ALIGN_LEFT;

            if ((value = attributes.Remove(ElementTags.ALIGN)) != null)
            {
                if (ElementTags.ALIGN_LEFT.ToLower().Equals(value))
                {
                    align |= Image.LEFT;
                }
                else if (ElementTags.ALIGN_RIGHT.ToLower().Equals(value))
                {
                    align |= Image.RIGHT;
                }
                else if (ElementTags.ALIGN_MIDDLE.ToLower().Equals(value))
                {
                    align |= Image.MIDDLE;
                }
            }
            if ((value = attributes.Remove(ElementTags.UNDERLYING)) != null)
            {
                if (bool.Parse(value))
                {
                    align |= Image.UNDERLYING;
                }
            }
            if ((value = attributes.Remove(ElementTags.TEXTWRAP)) != null)
            {
                if (bool.Parse(value))
                {
                    align |= Image.TEXTWRAP;
                }
            }
            image.alignment = align;
            if ((value = attributes.Remove(ElementTags.ALT)) != null)
            {
                image.Alt = value;
            }
            string x;
            string y;

            if (((x = attributes.Remove(ElementTags.ABSOLUTEX)) != null) &&
                ((y = attributes.Remove(ElementTags.ABSOLUTEY)) != null))
            {
                image.setAbsolutePosition(float.Parse(x), float.Parse(y));
            }
            if ((value = attributes.Remove(ElementTags.PLAINWIDTH)) != null)
            {
                image.scaleAbsoluteWidth(float.Parse(value));
            }
            if ((value = attributes.Remove(ElementTags.PLAINHEIGHT)) != null)
            {
                image.scaleAbsoluteHeight(float.Parse(value));
            }
            if ((value = attributes.Remove(ElementTags.ROTATION)) != null)
            {
                image.setRotation(float.Parse(value));
            }
            if (attributes.Count > 0)
            {
                image.MarkupAttributes = attributes;
            }
            return(image);
        }