Beispiel #1
0
        /// <summary>
        /// Create a DropDownList object at design time.
        /// </summary>
        /// <param name="output">Output stream that contains the HTML used to represent the control.</param>
        /// <param name="colorPicker"><see cref="ToolColorPicker"/> object to design.</param>
        ///
        public static void DesignColorPicker(ref HtmlTextWriter output, ToolColorPicker colorPicker)
        {
            IEnumerator enumerator = colorPicker.Style.Keys.GetEnumerator();

            while (enumerator.MoveNext())
            {
                output.AddStyleAttribute((string)enumerator.Current, colorPicker.Style[(string)enumerator.Current]);
            }
            colorPicker.ControlStyle.AddAttributesToRender(output);


            string backImage = string.Empty;

            if (colorPicker.BackImage != string.Empty)
            {
                if (colorPicker.Parent != null && colorPicker.Parent is ActiveUp.WebControls.Toolbar)
                {
                    backImage = "url(" + Utils.ConvertToImageDir(((Toolbar)colorPicker.Parent).ImagesDirectory, colorPicker.BackImage) + ")";
                }
                else
                {
                    backImage = "url(" + colorPicker.BackImage + ")";
                }
            }

            string style = "style=\"";

            if (colorPicker.BackColor != Color.Empty)
            {
                style += string.Format("background-color:{0};", Utils.Color2Hex(colorPicker.BackColor));
            }
            if (colorPicker.BorderColor != Color.Empty)
            {
                style += string.Format("border-color:{0};", Utils.Color2Hex(colorPicker.BorderColor));
            }
            style += string.Format("border-style:{0};", colorPicker.BorderStyle.ToString());
            if (colorPicker.BorderWidth != Unit.Empty)
            {
                style += string.Format("border-width:{0};", colorPicker.BorderWidth);
            }
            if (backImage != string.Empty)
            {
                style += string.Format("background-image:{0};", backImage);
            }
            style += "\"";

            string table = string.Empty;

            table += "<table";
            table += string.Format(" id={0}_ddl", colorPicker.ClientID);
            if (colorPicker.Width != Unit.Empty)
            {
                table += string.Format(" width={0}", colorPicker.Width.ToString());
            }
            if (colorPicker.Height != Unit.Empty)
            {
                table += string.Format(" height={0}", colorPicker.Height.ToString());
            }
            table += " cellpadding=0 cellspacing=0";
            table += string.Format(" {0}", style);
            table += ">";
            output.Write(table);
            output.RenderBeginTag(HtmlTextWriterTag.Tr);
            output.Write("\n");

            if (colorPicker.Width.IsEmpty == true)
            {
                output.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
            }
            else
            {
                output.AddAttribute(HtmlTextWriterAttribute.Width, colorPicker.Width.Value.ToString());
            }
            output.RenderBeginTag(HtmlTextWriterTag.Td);
            output.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
            output.AddAttribute(HtmlTextWriterAttribute.Height, "100%");
            output.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            output.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            output.AddAttribute(HtmlTextWriterAttribute.Border, "0");
            output.RenderBeginTag(HtmlTextWriterTag.Table);
            output.RenderBeginTag(HtmlTextWriterTag.Tr);
            output.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
            output.AddAttribute(HtmlTextWriterAttribute.Id, colorPicker.ClientID + "_text");
            if (colorPicker.UseSquareColor)
            {
                output.AddStyleAttribute("padding", "2px 2px 2px 2px");
            }
            else
            {
                output.AddStyleAttribute("padding", "0px 0px 0px 4px");
            }
            output.AddAttribute(HtmlTextWriterAttribute.Nowrap, null);
            if (colorPicker.ForeColor != Color.Empty)
            {
                output.AddStyleAttribute(HtmlTextWriterStyle.Color, Utils.Color2Hex(colorPicker.ForeColor));
            }
            Utils.AddStyleFontAttribute(output, colorPicker.Font);
            output.RenderBeginTag(HtmlTextWriterTag.Td);

            if (colorPicker.UseSquareColor)
            {
                output.AddAttribute(HtmlTextWriterAttribute.Id, colorPicker.ClientID + "_squareColor");
                output.AddAttribute(HtmlTextWriterAttribute.Width, "14px");
                output.AddAttribute(HtmlTextWriterAttribute.Height, "14px");
                output.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
                output.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
                output.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, Utils.Color2Hex(colorPicker.SelectedColor));
                output.AddStyleAttribute(HtmlTextWriterStyle.BorderColor, Utils.Color2Hex(Color.Silver));
                output.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "solid");
                output.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "1px");
                output.RenderBeginTag(HtmlTextWriterTag.Table);
                output.RenderBeginTag(HtmlTextWriterTag.Tr);
                output.RenderBeginTag(HtmlTextWriterTag.Td);
                output.RenderEndTag();
                output.RenderEndTag();
                output.RenderEndTag();
            }
            else
            {
                //output.Write(string.Format("<img src='{0}'>", Utils.ConvertToImageDir(((Toolbar)colorPicker.Parent).ImagesDirectory, colorPicker.Image,"color.gif",colorPicker.Page,colorPicker.GetType())));
                output.Write(string.Format("<img src='{0}'>", Utils.ConvertToImageDir(((Toolbar)colorPicker.Parent).ImagesDirectory, colorPicker.Image, "color.gif", colorPicker.Page, colorPicker.GetType())));
            }
            output.RenderEndTag();
            output.AddAttribute(HtmlTextWriterAttribute.Height, "100%");
            output.RenderBeginTag(HtmlTextWriterTag.Td);

            // drop down image

            output.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
            output.AddAttribute(HtmlTextWriterAttribute.Height, "100%");
            // Added by PMENGAL

            output.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
            output.AddAttribute(HtmlTextWriterAttribute.Height, "100%");
            output.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            output.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            output.RenderBeginTag(HtmlTextWriterTag.Table);
            output.RenderBeginTag(HtmlTextWriterTag.Tr);
            output.AddAttribute(HtmlTextWriterAttribute.Height, "100%");
            output.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            output.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            output.RenderBeginTag(HtmlTextWriterTag.Td);
            output.AddAttribute(HtmlTextWriterAttribute.Border, "0");
            if (colorPicker.DropDownImage != string.Empty)
            {
                if (colorPicker.Parent != null && colorPicker.Parent is ActiveUp.WebControls.Toolbar)
                {
                    output.AddAttribute(HtmlTextWriterAttribute.Src, Utils.ConvertToImageDir(((Toolbar)colorPicker.Parent).ImagesDirectory, colorPicker.DropDownImage, "down.gif", colorPicker.Page, colorPicker.GetType()));
                }
                else
                {
                    output.AddAttribute(HtmlTextWriterAttribute.Src, colorPicker.DropDownImage);
                }
            }
            else
            {
                if (colorPicker.Parent != null && colorPicker.Parent is ActiveUp.WebControls.Toolbar)
#if (!FX1_1)
                { output.AddAttribute(HtmlTextWriterAttribute.Src, Utils.ConvertToImageDir(((Toolbar)colorPicker.Parent).ImagesDirectory, "", "down.gif", colorPicker.Page, colorPicker.GetType())); }
#else
                { output.AddAttribute(HtmlTextWriterAttribute.Src, Utils.ConvertToImageDir(((Toolbar)colorPicker.Parent).ImagesDirectory, "down.gif")); }