예제 #1
0
        private void RenderFlashObject(HtmlTextWriter writer)
        {
            switch (RenderMode)
            {
            case FlashRenderMode.ObjectTag:
                writer.AddAttribute("data", ResolveClientUrl(MovieUrl));

                writer.AddAttribute("classid", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000");
                writer.AddAttribute("codebase", "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + FlashVersion.Replace(".", ","));
                if (!Unit.Equals(ExpandedWidth, Unit.Empty))
                {
                    writer.AddAttribute("width", this.ExpandedWidth.ToString());
                }
                else
                {
                    writer.AddAttribute("width", this.Width.ToString());
                }
                if (!Unit.Equals(ExpandedHeight, Unit.Empty))
                {
                    writer.AddAttribute("height", this.ExpandedHeight.ToString());
                }
                else
                {
                    writer.AddAttribute("height", this.Height.ToString());
                }

                writer.AddAttribute("type", "application/x-shockwave-flash");
                writer.AddAttribute("viewastext", "viewastext");
                writer.RenderBeginTag(HtmlTextWriterTag.Object);
                RenderContents(writer);
                writer.RenderEndTag();
                break;



            case FlashRenderMode.ScriptTag:


                //Scripting attributes to the 'object' tag.

                if (!Unit.Equals(ExpandedWidth, Unit.Empty))
                {
                    _ScriptLine += ", \'" + this.ExpandedWidth.ToString() + "\'";
                }
                else
                {
                    _ScriptLine += ", \'" + this.Width.ToString() + "\'";
                }
                if (!Unit.Equals(ExpandedHeight, Unit.Empty))
                {
                    _ScriptLine += ", \'" + this.ExpandedHeight.ToString() + "\'";
                }
                else
                {
                    _ScriptLine += ", \'" + this.Height.ToString() + "\'";
                }

                _ScriptLine += ", \'" + ResolveClientUrl(MovieUrl) + "\'";
                // choose a wmode and a bgcolor based on BackColor value.
                if (BackColor == System.Drawing.Color.Transparent)
                {
                    _ScriptLine += ", \'#ffffff\'";
                    _ScriptLine += ", \'Transparent\'";
                }
                else if (BackColor.Equals(System.Drawing.Color.Empty))
                {
                    //TODO: why i'm setting a bgcolor? guess that we cant do nothing here.
                    _ScriptLine += ", \'#ffffff\'";
                    _ScriptLine += ", \'\'";
                }
                else
                {
                    //string color = Conversion.Hex(this.BackColor.ToArgb());
                    string color = this.BackColor.ToArgb().ToString("x2");
                    if (!color.Equals("0"))
                    {
                        _ScriptLine += ", \'#" + color.Substring(2) + "\'";
                        _ScriptLine += ", \'\'";
                    }
                }

                _ScriptLine += ", \'" + FlashVars + "\'";

                if (this.ScriptAccess == FlashScriptAccess.Default)
                {
                    _ScriptLine += ", null";
                }
                else
                {
                    _ScriptLine += ", \'" + ScriptAccess.ToString().ToLower() + "\'";
                }

                if (AllowFullScreen)
                {
                    _ScriptLine += ", true";
                }
                else
                {
                    _ScriptLine += ", false";
                }

                string scale = "null";
                if (this.Scale != FlashScale.ShowAll)
                {
                    scale = "\'" + this.Scale.ToString().ToLower() + "\'";
                }
                _ScriptLine += ", " + scale;



                string align = "null";

                if (this.Alignment != FlashAlign.Center)
                {
                    switch (Alignment)
                    {
                    case FlashAlign.Bottom:
                        align = "\'b\'";
                        break;

                    case FlashAlign.BottomLeft:
                        align = "\'bl\'";
                        break;

                    case FlashAlign.BottomRight:
                        align = "\'br\'";
                        break;

                    case FlashAlign.Left:
                        align = "\'l\'";
                        break;

                    case FlashAlign.Right:
                        align = "\'r\'";
                        break;

                    case FlashAlign.Top:
                        align = "\'t\'";
                        break;

                    case FlashAlign.TopLeft:
                        align = "\'tl\'";
                        break;

                    case FlashAlign.TopRight:
                        align = "\'tr\'";
                        break;
                    }
                }
                _ScriptLine += ", " + align;



                _ScriptLine += ");";
                writer.AddAttribute("type", "text/javascript");
                writer.RenderBeginTag(HtmlTextWriterTag.Script);
                writer.WriteLine(_ScriptLine);
                writer.RenderEndTag();
                break;
            }
        }
예제 #2
0
        protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
        {
            if (this.DesignMode)
            {
                //nothing to be done yet
            }
            else
            {
                WriteParam(writer, "movie", ResolveClientUrl(MovieUrl));
                // choose a wmode and a bgcolor based on BackColor value.
                if (BackColor == System.Drawing.Color.Transparent)
                {
                    WriteParam(writer, "wmode", "Transparent");
                }
                else if (BackColor.Equals(System.Drawing.Color.Empty))
                {
                    //nothing to be done.
                }
                else
                {
                    //Conversion.Hex
                    string color = this.BackColor.ToArgb().ToString("x2");
                    if (!color.Equals("0"))
                    {
                        WriteParam(writer, "bgcolor", "#" + color.Substring(2));
                    }
                }

                WriteParam(writer, "menu", ShowMenu.ToString().ToLower());

                if (!string.IsNullOrEmpty(FlashVars))
                {
                    WriteParam(writer, "flashVars", FlashVars);
                }

                if (this.Scale != FlashScale.ShowAll)
                {
                    WriteParam(writer, "scale", Scale.ToString().ToLower());
                }

                if (!Play)
                {
                    WriteParam(writer, "play", "false");
                }
                if (ScriptAccess != FlashScriptAccess.Default)
                {
                    WriteParam(writer, "allowScriptAccess", ScriptAccess.ToString().ToLower());
                }
                if (AllowFullScreen)
                {
                    WriteParam(writer, "allowFullscreen", AllowFullScreen.ToString().ToLower());
                }

                if (!@Loop)
                {
                    WriteParam(writer, "loop", "false");
                }

                WriteParam(writer, "quality", Quality.ToString().ToLower());

                if (this.Alignment != FlashAlign.Center)
                {
                    string align = "";
                    switch (Alignment)
                    {
                    case FlashAlign.Bottom:
                        align = "b";
                        break;

                    case FlashAlign.BottomLeft:
                        align = "bl";
                        break;

                    case FlashAlign.BottomRight:
                        align = "br";
                        break;

                    case FlashAlign.Left:
                        align = "l";
                        break;

                    case FlashAlign.Right:
                        align = "r";
                        break;

                    case FlashAlign.Top:
                        align = "t";
                        break;

                    case FlashAlign.TopLeft:
                        align = "tl";
                        break;

                    case FlashAlign.TopRight:
                        align = "tr";
                        break;
                    }
                    WriteParam(writer, "salign", align);
                }

                if (!Unit.Equals(ExpandedWidth, Unit.Empty))
                {
                    writer.AddAttribute("width", this.ExpandedWidth.ToString());
                }
                else
                {
                    writer.AddAttribute("width", this.Width.ToString());
                }
                if (!Unit.Equals(ExpandedHeight, Unit.Empty))
                {
                    writer.AddAttribute("height", this.ExpandedHeight.ToString());
                }
                else
                {
                    writer.AddAttribute("height", this.Height.ToString());
                }


                writer.AddAttribute(HtmlTextWriterAttribute.Type, "application/x-shockwave-flash");
                writer.AddAttribute("pluginspage", "http://www.macromedia.com/go/getflashplayer");
                writer.RenderBeginTag(HtmlTextWriterTag.Embed);
                writer.RenderEndTag();
            }
        }