Beispiel #1
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
            {
                return(value);
            }

            String val = (String)value;

            CSharpFormat cSharpFormat = new CSharpFormat();
            FlowDocument doc          = new FlowDocument();
            Paragraph    p            = new Paragraph();

            p = cSharpFormat.FormatCode(val);
            doc.Blocks.Add(p);

            RichTextBox rtb = new RichTextBox();

            rtb.IsReadOnly                    = true;
            rtb.Document                      = doc;
            rtb.Document.PageWidth            = 2500.0;
            rtb.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            rtb.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            rtb.FontFamily                    = new FontFamily("Courier New");
            return(rtb);
        }
Beispiel #2
0
        public string GetTabContent(TabType LoadType, string Path, IWebHostEnvironment physicalPath)

        {
            EJ2CoreSampleBrowser.Helpers.BrowserClasses.TagBuilder tabContent = new EJ2CoreSampleBrowser.Helpers.BrowserClasses.TagBuilder("div");
            string            Filestream = "";
            CSharpFormat      csformat   = new CSharpFormat();
            HtmlFormat        format     = new HtmlFormat();
            JavaScriptFormat  jsformat   = new JavaScriptFormat();
            VisualBasicFormat vbformat   = new VisualBasicFormat();

            switch (LoadType)
            {
            case TabType.Description:
                Filestream           = ReadTabContent(physicalPath.ContentRootPath + "\\" + Path);
                tabContent.InnerHtml = WebUtility.HtmlDecode(Filestream);
                break;

            case TabType.PartialView:
                Filestream           = ReadTabContent(physicalPath.ContentRootPath + "\\" + @"\Views" + Path.Replace("/", "\\"));
                tabContent.InnerHtml = format.FormatCode(Filestream).ToString();
                break;

            case TabType.View:
                Filestream           = ReadTabContent(physicalPath.ContentRootPath + "\\" + Path);
                tabContent.InnerHtml = format.FormatCode(Filestream).ToString();
                break;

            case TabType.VB:
            case TabType.CS:
                Filestream           = ReadTabContent(physicalPath.ContentRootPath + "\\" + Path);
                tabContent.InnerHtml = csformat.FormatCode(Filestream).ToString();
                break;

            case TabType.CSS:
                Filestream           = ReadTabContent(physicalPath.ContentRootPath + "\\" + Path);
                tabContent.InnerHtml = format.FormatCode(Filestream).ToString();
                break;

            case TabType.XML:
                Filestream           = ReadTabContent(@"/Models" + Path);
                tabContent.InnerHtml = csformat.FormatCode(Filestream).ToString();
                break;

            case TabType.JavaScript:
                Filestream           = ReadTabContent(physicalPath.ContentRootPath + "\\" + @"\Scripts" + Path.Replace("/", "\\"));
                tabContent.InnerHtml = jsformat.FormatCode(Filestream).ToString();
                break;

            case TabType.Model:
                Filestream           = ReadTabContent(@"/Models" + Path).ToString();
                tabContent.InnerHtml = csformat.FormatCode(Filestream).ToString();
                break;

            default:
                break;
            }

            return(tabContent.ToString());
        }
Beispiel #3
0
        public string GetTabContent(TabType LoadType, string Path)
        {
            TagBuilder        tabContent = new TagBuilder("div");
            string            Filestream = "";
            CSharpFormat      csformat   = new CSharpFormat();
            HtmlFormat        format     = new HtmlFormat();
            JavaScriptFormat  jsformat   = new JavaScriptFormat();
            VisualBasicFormat vbformat   = new VisualBasicFormat();
            HttpContext       context    = System.Web.HttpContext.Current;

            switch (LoadType)
            {
            case TabType.Description:
                Filestream           = ReadTabContent(context.Request.PhysicalApplicationPath + Path);
                tabContent.InnerHtml = context.Server.HtmlDecode(Filestream);
                break;

            case TabType.PartialView:
                Filestream           = ReadTabContent(context.Request.PhysicalApplicationPath + @"\Views" + Path.Replace("/", "\\"));
                tabContent.InnerHtml = format.FormatCode(Filestream).ToString();
                break;

            case TabType.View:
                Filestream           = ReadTabContent(context.Request.PhysicalApplicationPath + Path);
                tabContent.InnerHtml = format.FormatCode(Filestream).ToString();
                break;

            case TabType.VB:
            case TabType.CS:
                Filestream           = ReadTabContent(context.Request.PhysicalApplicationPath + Path);
                tabContent.InnerHtml = csformat.FormatCode(Filestream).ToString();
                break;

            case TabType.CSS:
                Filestream           = ReadTabContent(context.Request.PhysicalApplicationPath + Path);
                tabContent.InnerHtml = format.FormatCode(Filestream).ToString();
                break;

            case TabType.XML:
                Filestream           = ReadTabContent(@"/Models" + Path);
                tabContent.InnerHtml = csformat.FormatCode(Filestream).ToString();
                break;

            case TabType.JavaScript:
                Filestream           = ReadTabContent(context.Request.PhysicalApplicationPath + @"\Scripts" + Path.Replace("/", "\\"));
                tabContent.InnerHtml = jsformat.FormatCode(Filestream).ToString();
                break;

            case TabType.Model:
                Filestream           = ReadTabContent(@"/Models" + Path).ToString();
                tabContent.InnerHtml = csformat.FormatCode(Filestream).ToString();
                break;

            default:
                break;
            }

            return(tabContent.ToString());
        }
        public void SetText(FlowDocument document, string text)
        {
            document.Blocks.Clear();
            //document.PageWidth = 2500;

            CSharpFormat cSharpFormat = new CSharpFormat();
            Paragraph    p            = cSharpFormat.FormatCode(text);

            document.Blocks.Add(p);
        }
        public void ProcessRequest()
        {
            foreach (KeyValuePair <string, string> pair in TabInfo)
            {
                string filePath = pair.Value;
                if (File.Exists(filePath))
                {
                    FileInfo file = new FileInfo(filePath);
                    System.Web.UI.HtmlControls.HtmlGenericControl divelemt = new System.Web.UI.HtmlControls.HtmlGenericControl("Div");
                    divelemt.ClientIDMode = ClientIDMode.Static;
                    divelemt.ID           = Convert.ToString(pair.Key.Replace('.', '_'));
                    divelemt.Attributes.Add("Name", Convert.ToString(pair.Key));
                    switch (file.Extension.ToLower())
                    {
                    case ".cs":
                        CSharpFormat cformat = new CSharpFormat();
                        cformat.EmbedStyleSheet = false;
                        divelemt.InnerHtml      = cformat.FormatCode(new FileStream(file.FullName, FileMode.Open));
                        break;

                    case ".css":
                        HtmlFormat htmlformat = new HtmlFormat();
                        htmlformat.EmbedStyleSheet = false;
                        FileInfo files = file;
                        if (files.Length > 0)
                        {
                            string       s1 = "";
                            StreamReader reader1;
                            FileStream   stra;
                            stra               = new FileStream(files.FullName, FileMode.Open);
                            reader1            = new StreamReader(stra);
                            s1                 = s1 + ("<b><i>" + files.Name + "</i></b>");
                            s1                 = s1 + htmlformat.FormatCode(stra);
                            divelemt.InnerHtml = s1;
                        }

                        break;

                    case ".js":
                        JavaScriptFormat jsformat = new JavaScriptFormat();
                        jsformat.EmbedStyleSheet = false;
                        divelemt.InnerHtml       = jsformat.FormatCode(new FileStream(file.FullName, FileMode.Open));
                        break;

                    default:
                        HtmlFormat htmlformat5 = new HtmlFormat();
                        htmlformat5.EmbedStyleSheet = false;
                        divelemt.InnerHtml          = htmlformat5.FormatCode(new FileStream(file.FullName, FileMode.Open));
                        break;
                    }

                    this.Controls.Add(divelemt);
                }
            }
        }
    /// <summary>
    /// Returns the formatted text.
    /// </summary>
    /// <param name="options">Whatever options were set in the regex groups.</param>
    /// <param name="text">Send the e.body so it can get formatted.</param>
    /// <returns>The formatted string of the match.</returns>
    private string Highlight(HighlightOptions options, string text)
    {
        switch (options.Language)
        {
        case "c#":
            CSharpFormat csf = new CSharpFormat();
            csf.LineNumbers = options.DisplayLineNumbers;
            csf.Alternate   = options.AlternateLineNumbers;
            return(HttpContext.Current.Server.HtmlDecode(csf.FormatCode(text)));

        case "vb":
            VisualBasicFormat vbf = new VisualBasicFormat();
            vbf.LineNumbers = options.DisplayLineNumbers;
            vbf.Alternate   = options.AlternateLineNumbers;
            return(HttpContext.Current.Server.HtmlDecode(vbf.FormatCode(text)));

        case "js":
            JavaScriptFormat jsf = new JavaScriptFormat();
            jsf.LineNumbers = options.DisplayLineNumbers;
            jsf.Alternate   = options.AlternateLineNumbers;
            return(HttpContext.Current.Server.HtmlDecode(jsf.FormatCode(text)));

        case "html":
            HtmlFormat htmlf = new HtmlFormat();
            htmlf.LineNumbers = options.DisplayLineNumbers;
            htmlf.Alternate   = options.AlternateLineNumbers;
            text = StripHtml(text).Trim();
            string code = htmlf.FormatCode(HttpContext.Current.Server.HtmlDecode(text)).Trim();
            return(code.Replace("\r\n", "<br />").Replace("\n", "<br />"));

        case "xml":
            HtmlFormat xmlf = new HtmlFormat();
            xmlf.LineNumbers = options.DisplayLineNumbers;
            xmlf.Alternate   = options.AlternateLineNumbers;
            text             = text.Replace("<br />", "\r\n");
            text             = StripHtml(text).Trim();
            string xml = xmlf.FormatCode(HttpContext.Current.Server.HtmlDecode(text)).Trim();
            return(xml.Replace("\r\n", "<br />").Replace("\n", "<br />"));

        case "tsql":
            TsqlFormat tsqlf = new TsqlFormat();
            tsqlf.LineNumbers = options.DisplayLineNumbers;
            tsqlf.Alternate   = options.AlternateLineNumbers;
            return(HttpContext.Current.Server.HtmlDecode(tsqlf.FormatCode(text)));

        case "msh":
            MshFormat mshf = new MshFormat();
            mshf.LineNumbers = options.DisplayLineNumbers;
            mshf.Alternate   = options.AlternateLineNumbers;
            return(HttpContext.Current.Server.HtmlDecode(mshf.FormatCode(text)));
        }

        return(string.Empty);
    }
Beispiel #7
0
        protected override void OnLoad(EventArgs e)
        {
            Assert.ArgumentNotNull(e, "e");
            base.OnLoad(e);
            UrlHandle handle = UrlHandle.Get();

            base.Header = handle["templatename"];
            var    cSharpFormat            = new CSharpFormat();
            string t4TemplateClassFormated = cSharpFormat.FormatCode(handle["class"]);

            OutputDiv.InnerHtml = t4TemplateClassFormated;
        }
Beispiel #8
0
        /// <summary>
        /// Generate code using the current template.
        /// </summary>
        /// <param name="baseUri">Base URI for container and authority.</param>
        /// <param name="tableName">Table name.</param>
        /// <param name="query">Query</param>
        /// <returns>Sample code.</returns>
        internal string GenerateCSharp(string baseUri, string tableName, string query)
        {
            // Create uri
            string uri = baseUri + "/" + tableName;

            Template = Template.Replace("{0}", uri);
            Template = Template.Replace("{1}", query);
            // Get the code in csharpformat
            var csharpFormat = new CSharpFormat();

            csharpFormat.Alternate       = true;
            csharpFormat.EmbedStyleSheet = false;
            csharpFormat.LineNumbers     = false;

            return(csharpFormat.FormatCode(Template));
        }
Beispiel #9
0
        public static string HighlightToHTML(string source, LangType type, bool customProtectionTags)
        {
            SourceFormat sf = null;

            switch (type)
            {
            case LangType.C:
            case LangType.CPP:
                sf = new CppFormat();
                break;

            case LangType.CS:
                sf = new CSharpFormat();
                break;

            case LangType.Html:
            case LangType.Xml:
            case LangType.Asp:
                sf = new HtmlFormat();
                break;

            case LangType.JS:
                sf = new JavaScriptFormat();
                break;

            case LangType.Msh:
                sf = new MshFormat();
                break;

            case LangType.TSql:
                sf = new TsqlFormat();
                break;

            case LangType.VB:
                sf = new VisualBasicFormat();
                break;
            }

            if (sf == null)
            {
                return(source);
            }

            sf.CustomProtectedTags = customProtectionTags;
            return(sf.FormatCode(source));
        }
Beispiel #10
0
        /// <summary>
        /// Handles the Click event of the btnCopy control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void btnCopy_Click(object sender, EventArgs e)
        {
            SourceFormat sf = null;

            if (rbCSharp.Checked)
            {
                sf = new CSharpFormat();
            }
            else if (rbVB.Checked)
            {
                sf = new VisualBasicFormat();
            }
            else if (rbtsql.Checked)
            {
                sf = new TsqlFormat();
            }
            else if (rbHtml.Checked)
            {
                sf = new HtmlFormat();
            }
            else if (rbJS.Checked)
            {
                sf = new JavaScriptFormat();
            }
            else if (rbMsh.Checked)
            {
                sf = new MshFormat();
            }
            else
            {
                return;
            }

            sf.TabSpaces       = 4;
            sf.LineNumbers     = cbLineNumbers.Checked;
            sf.EmbedStyleSheet = cbEmbedCss.Checked;
            sf.Alternate       = cbAlternate.Checked;
            string formatedCode = sf.FormatCode(CodeToFormat);

            //Clipboard.SetText(formatedCode, TextDataFormat.Html);
            Clipboard.SetText(formatedCode);
        }
Beispiel #11
0
        public override string GetReplaceResult(Match match)
        {
            string       lang      = match.Result("$1");
            string       body      = match.Result("$2");
            SourceFormat srcFormat = new HtmlFormat();

            if (lang.Equals("c#", StringComparison.OrdinalIgnoreCase) || lang.Equals("cs", StringComparison.OrdinalIgnoreCase) ||
                lang.Equals("csharp", StringComparison.OrdinalIgnoreCase))
            {
                srcFormat = new CSharpFormat();
            }

            if (lang.Equals("vb", StringComparison.OrdinalIgnoreCase) || lang.Equals("visualbasic", StringComparison.OrdinalIgnoreCase) ||
                lang.Equals("vbscript", StringComparison.OrdinalIgnoreCase))
            {
                srcFormat = new VisualBasicFormat();
            }

            if (lang.Equals("javascript", StringComparison.OrdinalIgnoreCase) || lang.Equals("js", StringComparison.OrdinalIgnoreCase) ||
                lang.Equals("jscript", StringComparison.OrdinalIgnoreCase))
            {
                srcFormat = new JavaScriptFormat();
            }

            if (lang.Equals("sql", StringComparison.OrdinalIgnoreCase))
            {
                srcFormat = new TsqlFormat();
            }

            if (lang.Equals("msh", StringComparison.OrdinalIgnoreCase))
            {
                srcFormat = new MshFormat();
            }

            srcFormat.Alternate       = Alternate;
            srcFormat.EmbedStyleSheet = EmbedStyleSheet;
            srcFormat.LineNumbers     = LineNumbers;
            return(srcFormat.FormatCode(body));
        }
Beispiel #12
0
        private static SourceFormat _GetSourceCodeFormat(string language, bool alternate, bool embedStyleSheet, bool lineNumbers)
        {
            SourceFormat srcFormat = new HtmlFormat();

            if (language.Equals("c#", StringComparison.OrdinalIgnoreCase) || language.Equals("cs", StringComparison.OrdinalIgnoreCase) ||
                language.Equals("csharp", StringComparison.OrdinalIgnoreCase))
            {
                srcFormat = new CSharpFormat();
            }

            if (language.Equals("vb", StringComparison.OrdinalIgnoreCase) || language.Equals("visualbasic", StringComparison.OrdinalIgnoreCase) ||
                language.Equals("vbscript", StringComparison.OrdinalIgnoreCase))
            {
                srcFormat = new VisualBasicFormat();
            }

            if (language.Equals("javascript", StringComparison.OrdinalIgnoreCase) || language.Equals("js", StringComparison.OrdinalIgnoreCase) ||
                language.Equals("jscript", StringComparison.OrdinalIgnoreCase))
            {
                srcFormat = new JavaScriptFormat();
            }

            if (language.Equals("sql", StringComparison.OrdinalIgnoreCase))
            {
                srcFormat = new TsqlFormat();
            }

            if (language.Equals("msh", StringComparison.OrdinalIgnoreCase))
            {
                srcFormat = new MshFormat();
            }

            srcFormat.Alternate       = alternate;
            srcFormat.EmbedStyleSheet = embedStyleSheet;
            srcFormat.LineNumbers     = lineNumbers;
            return(srcFormat);
        }
Beispiel #13
0
    //public MvcSampleBrowser.Models.Northwind SqlCE
    //{
    //    get
    //    {
    //        AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);
    //        string connectionString = @"Data Source=|DataDirectory|\Northwind.sdf";
    //        return new MvcSampleBrowser.Models.Northwind(connectionString);
    //    }
    //}
    //public MvcSampleBrowser.Models.EFModels.PUBSEntities EntitySQL
    //{
    //    get
    //    {
    //        return new MvcSampleBrowser.Models.EFModels.PUBSEntities();
    //    }
    //}
    //public MvcSampleBrowser.Models.PUBSEntities1 OutlookSQL
    //{
    //    get
    //    {
    //        return new MvcSampleBrowser.Models.PUBSEntities1();
    //    }
    //}
    ///// <summary>
    ///// Accordions this instance.
    ///// </summary>
    public void MainAccordion()
    {
        string DynamicUrl = System.Web.HttpContext.Current.Request.RawUrl.ToString();

        //    string order = "-1";
        string[] subURL       = { };
        string[] selectedItem = { };

        // Checks for query string format
        if (DynamicUrl.Contains('?'))
        {
            subURL       = DynamicUrl.Split('?');
            selectedItem = subURL[1].Split('=');
            DynamicUrl   = subURL[0];
        }


        AccordionModel accordionModel = new AccordionModel();
        DirectoryInfo  dir            = new DirectoryInfo(HttpContext.Request.PhysicalApplicationPath + "Views");

        FileInfo[] files = dir.GetFiles("Category.xml", SearchOption.AllDirectories);
        XDocument  doc   = new XDocument();
        XElement   root  = new XElement("root");

        // Reads the file
        foreach (FileInfo fileInfo in files)
        {
            root.Add(XDocument.Load(fileInfo.FullName).FirstNode);
        }

        // Gets the categories
        var catgories = from category in root.Elements("Category")
                        orderby category.Attribute("Order").Value
                        select new
        {
            categName  = category.Attribute("Name").Value,
            categOrder = category.Attribute("Order").Value,
            subItem    = category.Elements("Samples"),
            jQueryUI   = category.Attribute("jQueryUI")
        };

        foreach (var Categ in catgories)
        {
            string name = Categ.categName;


            var subItems = from category in Categ.subItem
                           orderby category.Attribute("order").Value
                           select new
            {
                subItemName = category.Attribute("displayname").Value,
                subItemUrl  = Url.Content(String.Format("~/{0}", category.Attribute("url").Value)),
                child       = category.FirstNode,
                filesList   = category.Elements("FilesList").Elements("File")
            };

            //Gets the sub categories
            foreach (var subCateg in subItems)
            {
                TagBuilder div    = new TagBuilder("div");
                HtmlA      anchor = new HtmlA("", subCateg.subItemName, subCateg.subItemUrl);

                if (DynamicUrl.ToLower() == subCateg.subItemUrl.ToLower())
                {
                    var OtherFilesList = from category in subCateg.filesList
                                         select new
                    {
                        subItemName = category.Attribute("displayname").Value,
                        subItemUrl  = category.Attribute("url").Value
                    };
                    foreach (var file in OtherFilesList)
                    {
                        string          FileContent = string.Empty;
                        ReadFileStreams MyStream    = new ReadFileStreams();
                        List <string>   Filestream  = new List <string>();
                        Filestream = MyStream.GetFileData(HttpContext.Request.PhysicalApplicationPath + file.subItemUrl);
                        foreach (string m in (IEnumerable)Filestream)
                        {
                            if (m != null)
                            {
                                FileContent += m.ToString();
                            }
                        }
                        FileContentList.Add(FileContent);
                        FileNametoDisplay.Add(file.subItemName);
                        int          ExtensionStart = (file.subItemUrl).LastIndexOf(".");
                        string       Extension      = file.subItemUrl.Substring(ExtensionStart + 1, file.subItemUrl.Length - ExtensionStart - 1);
                        CSharpFormat FileCSFormat   = new CSharpFormat();
                        HtmlFormat   FileHtmlFormat = new HtmlFormat();
                        string       FileFormatneed;
                        if (Extension == "cs")
                        {
                            FileFormatneed = FileCSFormat.FormatCode(FileContent);
                        }
                        else
                        {
                            FileFormatneed = FileHtmlFormat.FormatCode(FileContent);
                        }
                        FileFormatreq.Add(FileFormatneed);
                    }
                    description = ((System.Xml.Linq.XText)(subCateg.child)).Value;
                    ViewData["CurrentParent"] = Categ.categName;
                    ViewData["CurrentItem"]   = subCateg.subItemName;
                }
                div.InnerHtml = anchor.ToString();
            }
        }

        accordionModel.Collapsible = true;
        accordionModel.Navigation  = false;

        accordionModel.CustomCss = "MyAccordionStyle";


        accordionModel.AutoHeight = false;
        ViewData["Mainaccordion"] = accordionModel;
    }
Beispiel #14
0
    ///// <summary>
    ///// Tabses this instance.
    ///// </summary>
    public void MainTabs()
    {
        string        viewContent       = string.Empty;
        string        controllerContent = string.Empty;
        List <string> Filestream        = PlaceTabViewContent("View", HttpContext.Request.PhysicalApplicationPath + "Views");

        foreach (string m in (IEnumerable)Filestream)
        {
            if (m != null)
            {
                viewContent += m.ToString();
            }
        }

        controllerContent = PlaceTabContent("Controller", HttpContext.Request.PhysicalApplicationPath + "Controllers");


        // View
        HtmlFormat format    = new HtmlFormat();
        string     newFormat = format.FormatCode(viewContent);


        // controller
        CSharpFormat csFormat = new CSharpFormat();
        string       csForm   = csFormat.FormatCode(controllerContent);

        // Generating Source/Html tabs using JQuery Tabs
        TagBuilder tabDiv = new TagBuilder("div");

        tabDiv.GenerateId("main_Tab");
        tabDiv.MergeAttribute("style", "visibility:hidden");

        TagBuilder tabUL = new TagBuilder("ul");

        TagBuilder descriptionTab = new TagBuilder("li");
        TagBuilder descriptionRef = new TagBuilder("a");

        descriptionRef.MergeAttribute("href", "#tabs-1");
        descriptionRef.InnerHtml = "Description";
        descriptionTab.InnerHtml = descriptionRef.ToString();

        TagBuilder viewTab = new TagBuilder("li");
        TagBuilder viewRef = new TagBuilder("a");

        viewRef.MergeAttribute("href", "#tabs-2");
        viewRef.InnerHtml = "View";
        viewTab.InnerHtml = viewRef.ToString();

        string OtherFilesTab = string.Empty;

        for (int LoopCount = 0; LoopCount < FileContentList.Count; LoopCount++)
        {
            string     FileFormat     = string.Empty;
            TagBuilder PartialviewTab = new TagBuilder("li");
            TagBuilder PartialviewRef = new TagBuilder("a");
            if (FileContentList[LoopCount].ToString() != string.Empty)
            {
                PartialviewRef.MergeAttribute("href", "#tabs-" + (4 + LoopCount));
                PartialviewRef.InnerHtml = FileNametoDisplay[LoopCount].ToString();
                PartialviewTab.InnerHtml = PartialviewRef.ToString();
            }
            OtherFilesTab += PartialviewTab.ToString();
        }



        TagBuilder ControllerTab = new TagBuilder("li");
        TagBuilder ControllerRef = new TagBuilder("a");

        ControllerRef.MergeAttribute("href", "#tabs-3");
        ControllerRef.InnerHtml = "Controller";
        ControllerTab.InnerHtml = ControllerRef.ToString();

        tabUL.InnerHtml = descriptionTab.ToString() + viewTab.ToString();

        tabUL.InnerHtml += ControllerTab.ToString();
        if (OtherFilesTab != string.Empty)
        {
            tabUL.InnerHtml += OtherFilesTab;
        }
        tabDiv.InnerHtml += tabUL.ToString();

        TagBuilder tab1Div = new TagBuilder("div");

        tab1Div.AddCssClass("maintab");
        tab1Div.GenerateId("tabs-1");


        TagBuilder descriptionDiv = new TagBuilder("p");

        descriptionDiv.InnerHtml = description;
        tab1Div.InnerHtml        = descriptionDiv.ToString();

        TagBuilder tab2Div = new TagBuilder("div");

        tab2Div.GenerateId("tabs-2");
        tab2Div.AddCssClass("maintab");


        TagBuilder viewDiv = new TagBuilder("p");

        viewDiv.InnerHtml = newFormat.ToString();
        tab2Div.InnerHtml = viewDiv.ToString();

        string OtherFilesDiv = string.Empty;

        if (OtherFilesTab != string.Empty)
        {
            for (int LoopCount = 0; LoopCount < FileContentList.Count; LoopCount++)
            {
                TagBuilder tabPartialViewDiv = new TagBuilder("div");
                TagBuilder PartialViewDiv    = new TagBuilder("p");
                tabPartialViewDiv.GenerateId("tabs-" + (4 + LoopCount));
                tabPartialViewDiv.AddCssClass("maintab");

                PartialViewDiv.InnerHtml    = FileFormatreq[LoopCount].ToString();
                tabPartialViewDiv.InnerHtml = PartialViewDiv.ToString();
                OtherFilesDiv += tabPartialViewDiv.ToString();
            }
        }

        TagBuilder tab3Div = new TagBuilder("div");

        tab3Div.GenerateId("tabs-3");
        tab3Div.AddCssClass("maintab");


        TagBuilder controllerDiv = new TagBuilder("p");

        controllerDiv.InnerHtml = csForm.ToString();
        tab3Div.InnerHtml       = controllerDiv.ToString();

        tabDiv.InnerHtml += tab1Div.ToString();
        tabDiv.InnerHtml += tab2Div.ToString();
        tabDiv.InnerHtml += tab3Div.ToString();
        if (OtherFilesDiv != string.Empty)
        {
            tabDiv.InnerHtml += OtherFilesDiv;
        }
        ViewData["TabContent"] = tabDiv;


        TabModel tab = new TabModel();


        tab.CustomCss        = "Mytabstyle";
        ViewData["tabModel"] = tab;
    }
Beispiel #15
0
    /// <summary>
    /// Returns the formatted text.
    /// </summary>
    /// <param name="options">
    /// Whatever options were set in the regex groups.
    /// </param>
    /// <param name="text">
    /// Send the e.body so it can get formatted.
    /// </param>
    /// <returns>
    /// The formatted string of the match.
    /// </returns>
    private static string Highlight(HighlightOptions options, string text)
    {
        switch (options.Language)
        {
        case "c#":
            var csf = new CSharpFormat
            {
                LineNumbers = options.DisplayLineNumbers,
                Alternate   = options.AlternateLineNumbers
            };
            return(HttpContext.Current.Server.HtmlDecode(csf.FormatCode(text)));

        case "vb":
            var vbf = new VisualBasicFormat
            {
                LineNumbers = options.DisplayLineNumbers,
                Alternate   = options.AlternateLineNumbers
            };
            return(HttpContext.Current.Server.HtmlDecode(vbf.FormatCode(text)));

        case "js":
            var jsf = new JavaScriptFormat
            {
                LineNumbers = options.DisplayLineNumbers,
                Alternate   = options.AlternateLineNumbers
            };
            return(HttpContext.Current.Server.HtmlDecode(jsf.FormatCode(text)));

        case "html":
            var htmlf = new HtmlFormat
            {
                LineNumbers = options.DisplayLineNumbers,
                Alternate   = options.AlternateLineNumbers
            };
            text = Utils.StripHtml(text);
            var code = htmlf.FormatCode(HttpContext.Current.Server.HtmlDecode(text)).Trim();
            return(code.Replace("\r\n", "<br />").Replace("\n", "<br />"));

        case "xml":
            var xmlf = new HtmlFormat
            {
                LineNumbers = options.DisplayLineNumbers,
                Alternate   = options.AlternateLineNumbers
            };
            text = text.Replace("<br />", "\r\n");
            text = Utils.StripHtml(text);
            var xml = xmlf.FormatCode(HttpContext.Current.Server.HtmlDecode(text)).Trim();
            return(xml.Replace("\r\n", "<br />").Replace("\n", "<br />"));

        case "tsql":
            var tsqlf = new TsqlFormat
            {
                LineNumbers = options.DisplayLineNumbers,
                Alternate   = options.AlternateLineNumbers
            };
            return(HttpContext.Current.Server.HtmlDecode(tsqlf.FormatCode(text)));

        case "msh":
            var mshf = new MshFormat
            {
                LineNumbers = options.DisplayLineNumbers,
                Alternate   = options.AlternateLineNumbers
            };
            return(HttpContext.Current.Server.HtmlDecode(mshf.FormatCode(text)));
        }

        return(string.Empty);
    }
Beispiel #16
0
        static BbCodeProcessor()
        {
            _formatters.Add(new RegexFormatter("<(.|\\n)*?>", string.Empty));
            _formatters.Add(new LineBreaksFormatter(new string[7]
            {
                "html",
                "csharp",
                "code",
                "jscript",
                "sql",
                "vb",
                "php"
            }));
            _formatters.Add(new RegexFormatter("\\[b(?:\\s*)\\]((.|\\n)*?)\\[/b(?:\\s*)\\]", "<strong>$1</strong>"));
            _formatters.Add(new RegexFormatter("\\[chart(?:\\s*)\\]((.|\\n)*?)\\[/chart(?:\\s*)\\]", "<iframe src=\"/ShowChart/Charts/$1\"  border=\"0\" class=\"chartFrame\" > </iframe>"));

            _formatters.Add(new RegexFormatter("\\[tr(?:\\s*)\\]((.|\\n)*?)\\[/tr(?:\\s*)\\]", "<tr>$1</tr>"));
            _formatters.Add(new RegexFormatter("\\[td(?:\\s*)\\]((.|\\n)*?)\\[/td(?:\\s*)\\]", "<td>$1</td>"));
            _formatters.Add(new RegexFormatter("\\[table(?:\\s*)\\]((.|\\n)*?)\\[/table(?:\\s*)\\]", "<table>$1</table>"));
            _formatters.Add(new RegexFormatter("\\[chart(?:\\s*)\\]((.|\\n)*?)\\[/chart(?:\\s*)\\]", "<iframe src=\"/ShowChart/Charts/$1\" style=\"border:0 none;\" class=\"chartFrame\" > </iframe>"));

            _formatters.Add(new RegexFormatter("\\[i(?:\\s*)\\]((.|\\n)*?)\\[/i(?:\\s*)\\]", "<em>$1</em>"));
            _formatters.Add(new RegexFormatter("\\[s(?:\\s*)\\]((.|\\n)*?)\\[/s(?:\\s*)\\]", "<strike>$1</strike>"));
            _formatters.Add(new RegexFormatter("\\[u(?:\\s*)\\]((.|\\n)*?)\\[/u(?:\\s*)\\]", "<u>$1</u>"));
            _formatters.Add(new RegexFormatter("\\[left(?:\\s*)\\]((.|\\n)*?)\\[/left(?:\\s*)]", "<div style=\"text-align:left\">$1</div>"));
            _formatters.Add(new RegexFormatter("\\[center(?:\\s*)\\]((.|\\n)*?)\\[/center(?:\\s*)]", "<div style=\"text-align:center\">$1</div>"));
            _formatters.Add(new RegexFormatter("\\[right(?:\\s*)\\]((.|\\n)*?)\\[/right(?:\\s*)]", "<div style=\"text-align:right\">$1</div>"));
            _formatters.Add(new RegexFormatter("\\[rtl(?:\\s*)\\]((.|\\n)*?)\\[/rtl(?:\\s*)]", "<div style=\"text-align:right;direction:rtl\">$1</div>"));
            _formatters.Add(new RegexFormatter("\\[ltr(?:\\s*)\\]((.|\\n)*?)\\[/ltr(?:\\s*)]", "<div style=\"text-align:left;direction:ltr\">$1</div>"));
            _formatters.Add(new RegexFormatter("\\[code(?:\\s*)\\]((.|\\n)*?)\\[/code(?:\\s*)]", "<div class=\"bbc-codetitle\">Code:</div><div class=\"bbc-codecontent\"><pre>$1</pre></div>"));
            _formatters.Add(new RegexFormatter("\\[php(?:\\s*)\\]((.|\\n)*?)\\[/php(?:\\s*)]", "<div class=\"bbc-codetitle\">PHP Code:</div><div class=\"bbc-codecontent\"><pre>$1</pre></div>"));
            List <IHtmlFormatter> formatters1 = _formatters;
            HtmlFormat            htmlFormat  = new HtmlFormat();
            int num1 = 1;

            htmlFormat.EmbedStyleSheet = num1 != 0;
            string          pattern1         = "\\[html(?:\\s*)\\]((.|\\n)*?)\\[/html(?:\\s*)]";
            string          replace1         = "<div class=\"bbc-codetitle\">HTML Code:</div><div class=\"bbc-codecontent\">{0}</div>";
            SyntaxFormatter syntaxFormatter1 = new SyntaxFormatter(htmlFormat, pattern1, replace1);

            formatters1.Add(syntaxFormatter1);
            List <IHtmlFormatter> formatters2  = _formatters;
            CSharpFormat          csharpFormat = new CSharpFormat();
            int num2 = 1;

            csharpFormat.EmbedStyleSheet = num2 != 0;
            string          pattern2         = "\\[csharp(?:\\s*)\\]((.|\\n)*?)\\[/csharp(?:\\s*)]";
            string          replace2         = "<div class=\"bbc-codetitle\">C# Code:</div><div class=\"bbc-codecontent\">{0}</div>";
            SyntaxFormatter syntaxFormatter2 = new SyntaxFormatter(csharpFormat, pattern2, replace2);

            formatters2.Add(syntaxFormatter2);
            List <IHtmlFormatter> formatters3      = _formatters;
            JavaScriptFormat      javaScriptFormat = new JavaScriptFormat();
            int num3 = 1;

            javaScriptFormat.EmbedStyleSheet = num3 != 0;
            string          pattern3         = "\\[jscript(?:\\s*)\\]((.|\\n)*?)\\[/jscript(?:\\s*)]";
            string          replace3         = "<div class=\"bbc-codetitle\">JavaScript Code:</div><div class=\"bbc-codecontent\">{0}</div>";
            SyntaxFormatter syntaxFormatter3 = new SyntaxFormatter(javaScriptFormat, pattern3, replace3);

            formatters3.Add(syntaxFormatter3);
            List <IHtmlFormatter> formatters4 = _formatters;
            TsqlFormat            tsqlFormat  = new TsqlFormat();
            int num4 = 1;

            tsqlFormat.EmbedStyleSheet = num4 != 0;
            string          pattern4         = "\\[sql(?:\\s*)\\]((.|\\n)*?)\\[/sql(?:\\s*)]";
            string          replace4         = "<div class=\"bbc-codetitle\">SQL Code:</div><div class=\"bbc-codecontent\">{0}</div>";
            SyntaxFormatter syntaxFormatter4 = new SyntaxFormatter(tsqlFormat, pattern4, replace4);

            formatters4.Add(syntaxFormatter4);
            List <IHtmlFormatter> formatters5       = _formatters;
            VisualBasicFormat     visualBasicFormat = new VisualBasicFormat();
            int num5 = 1;

            visualBasicFormat.EmbedStyleSheet = num5 != 0;
            string          pattern5         = "\\[vb(?:\\s*)\\]((.|\\n)*?)\\[/vb(?:\\s*)]";
            string          replace5         = "<div class=\"bbc-codetitle\">Visual Basic Code:</div><div class=\"bbc-codecontent\">{0}</div>";
            SyntaxFormatter syntaxFormatter5 = new SyntaxFormatter(visualBasicFormat, pattern5, replace5);

            formatters5.Add(syntaxFormatter5);
            _formatters.Add(new RegexFormatter("\\[quote=((.|\\n)*?)(?:\\s*)\\]", "<div class=\"bbc-quotetitle\">$1 said:</div><div class=\"bbc-quotecontent\"><p>"));
            _formatters.Add(new RegexFormatter("\\[quote(?:\\s*)\\]", "<div class=\"bbc-quotecontent\"><p>"));
            _formatters.Add(new RegexFormatter("\\[/quote(?:\\s*)\\]", "</p></div>"));

            _formatters.Add(new RegexFormatter("\\[url(?:\\s*)\\]www\\.(.*?)\\[/url(?:\\s*)\\]", "<a href=\"http://www.$1\" target=\"_blank\" title=\"$1\">$1</a>"));

            _formatters.Add(new RegexFormatter("\\[url(?:\\s*)\\]((.|\\n)*?)\\[/url(?:\\s*)\\]", "<a href=\"$1\" target=\"_blank\" title=\"$1\">$1</a>"));
            _formatters.Add(new RegexFormatter("\\[url=\"((.|\\n)*?)(?:\\s*)\"\\]((.|\\n)*?)\\[/url(?:\\s*)\\]", "<a href=\"$1\" target=\"_blank\" title=\"$1\">$3</a>"));
            _formatters.Add(new RegexFormatter("\\[url=((.|\\n)*?)(?:\\s*)\\]((.|\\n)*?)\\[/url(?:\\s*)\\]", "<a href=\"$1\" target=\"_blank\" title=\"$1\">$3</a>"));
            _formatters.Add(new RegexFormatter("\\[link(?:\\s*)\\]((.|\\n)*?)\\[/link(?:\\s*)\\]", "<a href=\"$1\" target=\"_blank\" title=\"$1\">$1</a>"));
            _formatters.Add(new RegexFormatter("\\[link=((.|\\n)*?)(?:\\s*)\\]((.|\\n)*?)\\[/link(?:\\s*)\\]", "<a href=\"$1\" target=\"_blank\" title=\"$1\">$3</a>"));

            var rnd = new Random().Next(int.MaxValue);

            _formatters.Add(new RegexFormatter("\\[tree(?:\\s*)\\]((.|\\n)*?)\\[/tree(?:\\s*)\\]", "<div id='treegraph" + rnd + "'></div><script>   dTree.init(treeDataParcer('$1'), { target: '#treegraph" + rnd + "',width: document.getElementById('treegraph" + rnd + "').offsetWidth, height: 850}); </script>"));
            _formatters.Add(new RegexFormatter("\\[tree=((.|\\n)*?)(?:\\s*)\\]((.|\\n)*?)\\[/tree(?:\\s*)\\]", "<style>$1</style> <div id='treegraph" + rnd + "'></div> <script>   dTree.init(treeDataParcer('$3'), { target: '#treegraph" + rnd + "',width: document.getElementById('treegraph" + rnd + "').offsetWidth, height: 850 }); </script>"));


            _formatters.Add(new RegexFormatter("\\[img(?:\\s*)\\]((.|\\n)*?)\\[/img(?:\\s*)\\]", "<img src=\"$1\" border=\"0\" alt=\"\" />"));
            _formatters.Add(new RegexFormatter("\\[img align=((.|\\n)*?)(?:\\s*)\\]((.|\\n)*?)\\[/img(?:\\s*)\\]", "<img src=\"$3\" border=\"0\" align=\"$1\" alt=\"\" />"));
            _formatters.Add(new RegexFormatter("\\[img width=((.|\\n)*?),height=((.|\\n)*?)(?:\\s*)\\]((.|\\n)*?)\\[/img(?:\\s*)\\]", "<img width=\"$1\" height=\"$3\" src=\"$5\" border=\"0\" alt=\"\" />"));
            _formatters.Add(new RegexFormatter("\\[img=((.|\\n)*?)x((.|\\n)*?)(?:\\s*)\\]((.|\\n)*?)\\[/img(?:\\s*)\\]", "<img width=\"$1\" height=\"$3\" src=\"$5\" border=\"0\" alt=\"\" />"));
            _formatters.Add(new RegexFormatter("\\[color=((.|\\n)*?)(?:\\s*)\\]((.|\\n)*?)\\[/color(?:\\s*)\\]", "<span style=\"color:$1;\">$3</span>"));
            _formatters.Add(new RegexFormatter("\\[highlight(?:\\s*)\\]((.|\\n)*?)\\[/highlight(?:\\s*)]", "<span class=\"bbc-highlight\">$1</span>"));
            _formatters.Add(new RegexFormatter("\\[spoiler(?:\\s*)\\]((.|\\n)*?)\\[/spoiler(?:\\s*)]", "<span class=\"bbc-spoiler\">$1</span>"));
            _formatters.Add(new RegexFormatter("\\[indent(?:\\s*)\\]((.|\\n)*?)\\[/indent(?:\\s*)]", "<div class=\"bbc-indent\">$1</div>"));
            _formatters.Add(new RegexFormatter("\\[hr(?:\\s*)\\]", "<hr />"));
            _formatters.Add(new RegexFormatter("\\[rule=((.|\\n)*?)(?:\\s*)\\]((.|\\n)*?)\\[/rule(?:\\s*)\\]", "<div style=\"height: 0pt; border-top: 1px solid $3; margin: auto; width: $1;\"></div>"));
            _formatters.Add(new RegexFormatter("\\[email(?:\\s*)\\]((.|\\n)*?)\\[/email(?:\\s*)\\]", "<a href=\"mailto:$1\">$1</a>"));
            _formatters.Add(new RegexFormatter("\\[email=\"((.|\\n)*?)(?:\\s*)\"\\]((.|\\n)*?)\\[/email(?:\\s*)\\]", "<a href=\"mailto:$1\" title=\"$3\">$3</a>"));
            _formatters.Add(new RegexFormatter("\\[email=((.|\\n)*?)(?:\\s*)\\]((.|\\n)*?)\\[/email(?:\\s*)\\]", "<a href=\"mailto:$1\" title=\"$3\">$3</a>"));
            _formatters.Add(new RegexFormatter("\\[small(?:\\s*)\\]((.|\\n)*?)\\[/small(?:\\s*)]", "<small>$1</small>"));
            _formatters.Add(new RegexFormatter("\\[size=+((.|\\n)*?)(?:\\s*)\\]((.|\\n)*?)\\[/size(?:\\s*)\\]", "<span style=\"font-size:$1em\">$3</span>"));
            _formatters.Add(new RegexFormatter("\\[size=((.|\\n)*?)(?:\\s*)\\]((.|\\n)*?)\\[/size(?:\\s*)\\]", "<span style=\"font-size:$1\">$3</span>"));
            _formatters.Add(new RegexFormatter("\\[font=((.|\\n)*?)(?:\\s*)\\]((.|\\n)*?)\\[/font(?:\\s*)\\]", "<span style=\"font-family:$1;\">$3</span>"));
            _formatters.Add(new RegexFormatter("\\[align=((.|\\n)*?)(?:\\s*)\\]((.|\\n)*?)\\[/align(?:\\s*)\\]", "<span style=\"text-align:$1;\">$3</span>"));
            _formatters.Add(new RegexFormatter("\\[float=((.|\\n)*?)(?:\\s*)\\]((.|\\n)*?)\\[/float(?:\\s*)\\]", "<span style=\"float:$1;\">$3</div>"));
            string format = "<ol class=\"bbc-list\" style=\"list-style:{0};\">$1</ol>";

            _formatters.Add(new RegexFormatter("\\[\\*(?:\\s*)]\\s*([^\\[]*)", "<li>$1</li>"));
            _formatters.Add(new RegexFormatter("\\[list(?:\\s*)\\]((.|\\n)*?)\\[/list(?:\\s*)\\]", "<ul class=\"bbc-list\">$1</ul>"));
            _formatters.Add(new RegexFormatter("\\[list=1(?:\\s*)\\]((.|\\n)*?)\\[/list(?:\\s*)\\]", string.Format(format, "decimal"), false));
            _formatters.Add(new RegexFormatter("\\[list=i(?:\\s*)\\]((.|\\n)*?)\\[/list(?:\\s*)\\]", string.Format(format, "lower-roman"), false));
            _formatters.Add(new RegexFormatter("\\[list=I(?:\\s*)\\]((.|\\n)*?)\\[/list(?:\\s*)\\]", string.Format(format, "upper-roman"), false));
            _formatters.Add(new RegexFormatter("\\[list=a(?:\\s*)\\]((.|\\n)*?)\\[/list(?:\\s*)\\]", string.Format(format, "lower-alpha"), false));
            _formatters.Add(new RegexFormatter("\\[list=A(?:\\s*)\\]((.|\\n)*?)\\[/list(?:\\s*)\\]", string.Format(format, "upper-alpha"), false));
        }