Example #1
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());
        }
Example #2
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());
        }
Example #3
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);
        }
        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);
                }
            }
        }
Example #6
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 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);
    }
Example #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;
        }
Example #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));
        }
Example #9
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;
    }
Example #10
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;
    }
Example #11
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);
    }