Exemplo n.º 1
0
        public static HtmlControl createDiv(string id, Pixel px, Size sz, string imgUrl, string position, 
            string border, string overflow, float opacity)
        {
            HtmlContainerControl div = new HtmlGenericControl("div");

            if (imgUrl != null)
                div.Style.Add("background-image", string.Format("url({0})", imgUrl));

            if (position == null)
                position = "absolute";

            modifyDOMElement(div, id, px, sz, position, border, overflow, opacity);

            return div;
        }
Exemplo n.º 2
0
        public static void modifyDOMElement(HtmlControl element, string id, Pixel px, Size sz, string position, string border,
            string overflow, float opacity)
        {
            if (id != null)
                element.ID = id;

            if (px != null)
            {
                element.Style["left"] = px.x + "px";
                element.Style["top"] = px.y + "px";
            }

            if (sz != Size.Empty)
            {
                element.Style["width"] = sz.Width + "px";
                element.Style["height"] = sz.Height + "px";
            }

            if (position != null)
            {
                element.Style["position"] = position;
            }

            if (border != null)
            {
                element.Style["border"] = border;
            }

            if (overflow != null)
            {
                element.Style["overflow"] = overflow;
            }

            if (opacity >= 0 && opacity < 1)
            {
                element.Style["filter"] = string.Format("alpha(opacity={0})", opacity * 100);
                element.Style["opacity"] = opacity.ToString();
            }
            else
                if (opacity == 1)
                {
                    element.Style["filter"] = "";
                    element.Style["opacity"] = "";
                }

        }