Example #1
0
        public void AddDownloadLink(WikiPlex.Legacy.HtmlTextWriter writer)
        {
            writer.RenderBeginTag(WikiPlex.Legacy.HtmlTextWriterTag.P);

            writer.Write("You need to install Microsoft Silverlight to view this content. ");

            writer.AddAttribute(WikiPlex.Legacy.HtmlTextWriterAttribute.Href, DownloadUrl, false);
            writer.AddStyleAttribute(WikiPlex.Legacy.HtmlTextWriterStyle.TextDecoration, "none");
            writer.RenderBeginTag(WikiPlex.Legacy.HtmlTextWriterTag.A);

            writer.Write("Get Silverlight!<br />");

            writer.AddAttribute(WikiPlex.Legacy.HtmlTextWriterAttribute.Src,
                                "http://go.microsoft.com/fwlink/?LinkID=108181", false);
            writer.AddAttribute(WikiPlex.Legacy.HtmlTextWriterAttribute.Alt, "Get Microsoft Silverlight");
            writer.AddStyleAttribute(WikiPlex.Legacy.HtmlTextWriterStyle.BorderStyle, "none");
            writer.RenderBeginTag(WikiPlex.Legacy.HtmlTextWriterTag.Img);
            writer.RenderEndTag(); // img

            writer.RenderEndTag(); // a
            writer.RenderEndTag(); // p
        }
        /// <summary>
        /// Will expand the input into the appropriate content based on scope.
        /// </summary>
        /// <param name="scopeName">The scope name.</param>
        /// <param name="input">The input to be expanded.</param>
        /// <param name="htmlEncode">Function that will html encode the output.</param>
        /// <param name="attributeEncode">Function that will html attribute encode the output.</param>
        /// <returns>The expanded content.</returns>
        protected override string PerformExpand(string scopeName, string input
                                                , System.Func <string, string> htmlEncode
                                                , System.Func <string, string> attributeEncode)
        {
            string[] parameters = input.Split(new[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries);
            string   url        = WikiPlex.Common.Parameters.ExtractUrl(parameters);

            WikiPlex.Common.Dimensions dimensions = WikiPlex.Common.Parameters.ExtractDimensions(parameters, 200, 200);
            bool gpuAcceleration = WikiPlex.Common.Parameters.ExtractBool(parameters, "gpuAcceleration", false);

            string versionValue;
            int    version = 5;

            if (WikiPlex.Common.Parameters.TryGetValue(parameters, "version", out versionValue) && int.TryParse(versionValue, out version))
            {
                if (version < 2 || version > 5)
                {
                    version = 5;
                }
            }

            if (version == 2 && gpuAcceleration)
            {
                throw new WikiPlex.Common.RenderException("Cannot resolve silverlight macro, 'gpuAcceleration' cannot be enabled with version 2 of Silverlight.");
            }

            string[]             initParams = GetInitParams(parameters);
            ISilverlightRenderer renderer   = GetRenderer(version);

            System.Text.StringBuilder content = new System.Text.StringBuilder();
            using (var tw = new System.IO.StringWriter(content))
                using (var writer = new WikiPlex.Legacy.HtmlTextWriter(tw, string.Empty))
                {
                    writer.NewLine = string.Empty;

                    renderer.AddObjectTagAttributes(writer);
                    writer.AddStyleAttribute(WikiPlex.Legacy.HtmlTextWriterStyle.Height, dimensions.Height.ToString());
                    writer.AddStyleAttribute(WikiPlex.Legacy.HtmlTextWriterStyle.Width, dimensions.Width.ToString());
                    writer.RenderBeginTag(WikiPlex.Legacy.HtmlTextWriterTag.Object);

                    renderer.AddParameterTags(url, gpuAcceleration, initParams, writer);
                    renderer.AddDownloadLink(writer);

                    writer.RenderEndTag(); // object

                    writer.AddStyleAttribute(WikiPlex.Legacy.HtmlTextWriterStyle.Visibility, "hidden");
                    writer.AddStyleAttribute(WikiPlex.Legacy.HtmlTextWriterStyle.Height, "0");
                    writer.AddStyleAttribute(WikiPlex.Legacy.HtmlTextWriterStyle.Width, "0");
                    writer.AddStyleAttribute(WikiPlex.Legacy.HtmlTextWriterStyle.BorderWidth, "0");
                    writer.RenderBeginTag(WikiPlex.Legacy.HtmlTextWriterTag.Iframe);
                    writer.RenderEndTag();
                }

            return(content.ToString());
        }