示例#1
0
        protected override void Parse([NotNull] XmlNode node)
        {
            base.Parse(node);
            HtmlSerializeHelper <HtmlHighlightedCode> .ReadRootElementAttributes(node, this);

            node         = node.SelectSingleNode("pre");
            Control.Text = node.InnerText.HttpDecode();
            node         = node.SelectSingleNode("code");
            Language     = (LANGUAGE)Enum.Parse(typeof(LANGUAGE), node.Attributes["class"].Value, true);
        }
示例#2
0
        public override void WriteHtml([NotNull] HtmlWriter w)
        {
            base.WriteHtml(w);
            HtmlSerializeHelper <HtmlHighlightedCode> .WriteRootElementAttributes(w, this);

            var ls = Language.ToString().ToLower();

            w.AddAttribute(HtmlAttribute.Name, "code");
            w.AddStyleAttribute(HtmlStyleAttribute.Overflow, "auto");
            w.RenderBeginTag(HtmlTag.Span);
            w.AddAttribute(HtmlAttribute.Class, ls);
            w.WriteFullBeginTag(string.Concat("pre><code class=\"", ls, "\""));
            w.Write(Control.Text.HttpEncode());
            w.WriteFullBeginTag("/code></pre");
            w.RenderEndTag();
        }
示例#3
0
        public override void WriteHtml(System.Web.UI.HtmlTextWriter w)
        {
            /*
             * //set code language
             * if (Language == CompiledQuestion.LANGUAGE.CPP)
             * {
             * LanguageToHighlight = HtmlHighlightedCode.LANGUAGE.Cpp;
             * }
             * else if (Language == CompiledQuestion.LANGUAGE.CS)
             * {
             * LanguageToHighlight = HtmlHighlightedCode.LANGUAGE.Cpp;
             * }
             * else if (Language == CompiledQuestion.LANGUAGE.Delphi)
             * {
             * LanguageToHighlight = HtmlHighlightedCode.LANGUAGE.Delphi;
             * }
             * else if (Language == CompiledQuestion.LANGUAGE.Java)
             * {
             * LanguageToHighlight = HtmlHighlightedCode.LANGUAGE.Java;
             * }
             * */

            //<div>
            w.AddAttribute(HtmlAttribute.Id, Name);
            w.AddAttribute(HtmlAttribute.Name, "advancedCompiledTest");
            w.AddStyleAttribute(HtmlStyleAttribute.Position, "absolute");
            HtmlSerializeHelper <HtmlCompiledTest> .WriteRootElementAttributes(w, this);

            w.RenderBeginTag(HtmlTag.Div);

            //var ls = LanguageToHighlight.ToString().ToLower();

            //<span name="BeforeCode">//there will be lector code
            w.AddAttribute(HtmlAttribute.Id, "TextBoxBefore");
            w.AddStyleAttribute(HtmlStyleAttribute.Overflow, "scroll");
            w.AddStyleAttribute(HtmlStyleAttribute.Height, (Control as AdvancedCompiledTest).TextBoxBefore.Height.ToString());
            w.AddStyleAttribute(HtmlStyleAttribute.Width, (Control as AdvancedCompiledTest).TextBoxBefore.Width.ToString());
            w.RenderBeginTag(HtmlTag.Span);
            //w.AddAttribute(HtmlAttribute.Class, ls);
            //w.WriteFullBeginTag(string.Concat("pre><code class=\"", ls, "\""));
            w.WriteFullBeginTag(string.Concat("pre><code"));
            w.Write((Control as AdvancedCompiledTest).TextBoxBefore.Text.HttpEncode());
            w.WriteFullBeginTag("/code></pre");
            w.RenderEndTag();
            //</span>

            //<textarea>//there will be user code
            w.AddAttribute(HtmlAttribute.Id, "TextBoxUserCode");
            w.AddStyleAttribute(HtmlStyleAttribute.Width, (Control as AdvancedCompiledTest).TextBoxUserCode.Width.ToString());
            w.AddStyleAttribute(HtmlStyleAttribute.Height, (Control as AdvancedCompiledTest).TextBoxUserCode.Height.ToString());
            w.RenderBeginTag(HtmlTextWriterTag.Textarea);
            w.RenderEndTag();
            //</textarea>

            //<span name="AfterCode">//there will be lector code
            w.AddAttribute(HtmlAttribute.Id, "TextBoxAfter");
            w.AddStyleAttribute(HtmlStyleAttribute.Overflow, "scroll");
            w.AddStyleAttribute(HtmlStyleAttribute.Height, (Control as AdvancedCompiledTest).TextBoxAfter.Height.ToString());
            w.AddStyleAttribute(HtmlStyleAttribute.Width, (Control as AdvancedCompiledTest).TextBoxAfter.Width.ToString());
            w.RenderBeginTag(HtmlTag.Span);
            //w.AddAttribute(HtmlAttribute.Class, ls);
            //w.WriteFullBeginTag(string.Concat("pre><code class=\"", ls, "\""));
            w.WriteFullBeginTag(string.Concat("pre><code"));
            w.Write((Control as AdvancedCompiledTest).TextBoxAfter.Text.HttpEncode());
            w.WriteFullBeginTag("/code></pre");
            w.RenderEndTag();
            //</span>

            w.RenderEndTag();
            //</div>
        }