public ActionResult Index()
        {
            StringWriter stringWriter = new StringWriter();

            using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter))
            {
                string classValue = "className";
                writer.RenderBeginTag(HtmlTextWriterTag.Html);

                writer.AddAttribute(HtmlTextWriterAttribute.Class, classValue);
                writer.AddStyleAttribute(HtmlTextWriterStyle.Color, "#db4141");
                writer.Write("Huy");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                writer.RenderEndTag();

                writer.RenderEndTag();
                GridView grid = new GridView();
                grid.AllowPaging = false;
                grid.RenderControl(writer);
                //Change the Header Row back to white color
                DataTable[] dt = new DataTable[2];

                for (int i = 0; i <= 1; i++)
                {
                    dt[i] = new DataTable();
                    dt[i].Columns.Add("id");
                    dt[i].Columns.Add("name");
                }

                IHTMLBuilder htmlBuilder = new HTMLBuilder();
                htmlBuilder.Build();

                grid.DataSource = dt;
                grid.DataBind();
                //Apply style to Individual Cells
                grid.HeaderRow.Cells[0].Text = "harrison";
                grid.HeaderRow.Cells[0].Style.Add("background-color", "green");

                Response.Clear();
                Response.Buffer = true;
                Response.AddHeader("content-disposition",
                 "attachment;filename=GridViewExport.xls");
                Response.Charset = "";
                Response.ContentType = "application/vnd.ms-excel";
                Dictionary<string, IdentityModels> test = new Dictionary<string, IdentityModels>();
                test.Add("huy", new IdentityModels());
                var testModel =  test["huy"];

            }
            Response.Output.Write(stringWriter.ToString());
            Response.Flush();
            Response.End();
            return View();
        }
Example #2
0
        public void CreateTableFromDataTable()
        {
            var builder = new HTMLBuilder();

            builder.Table(TestRecordData.TableRecords(), "Test", "Test data", new HTMLAttribute[] { new HTMLAttribute("style", "width:100%") });
            Debug.WriteLine(builder.ToString());
        }
Example #3
0
        public void DoNotPreserveCase()
        {
            var builder = new HTMLBuilder();

            builder.AddElement("DiV", new[] { new HTMLAttribute("CLASS", "Test") }, "Content");
            Assert.AreEqual(ConvertResourceStringToCurrentEnvironment(Test.Resources.AssertDoNotPreserveCase), builder.ToString());
        }
Example #4
0
        public void SingleLineComment()
        {
            var builder = new HTMLBuilder();

            builder.Document("en").Body().Comment("A comment for a div element").Div(content: "HTML comments test");
            Assert.AreEqual(ConvertResourceStringToCurrentEnvironment(Test.Resources.AssertEqualSingleLineComment), builder.ToString());
        }
Example #5
0
        static void Main(string[] args)
        {
            HTMLBuilder builder = new HTMLBuilder();


            string result = builder.contentTag("<!DOCTYPE html>")
                            .startTag("html")
                            .startTag("title")
                            .contentTag("Introduction to C#")
                            .endTag("title")
                            .meta("name=\"viewport\" content=\"width = device - width, initial - scale = 1\"")
                            .startTag("body")
                            .startTag("div class =\"Heder\"")
                            .startTag("h1")
                            .contentTag("What is C# used for?")
                            .endTag("h1")
                            .endTag("div")
                            .startTag("div class =\"container\"")
                            .startTag("p")
                            .contentTag("C# is a general-purpose, modern and object-oriented programming language pronounced as “C sharp”. It was developed by Microsoft led by Anders Hejlsberg and his team within the .Net initiative and was approved by the European Computer Manufacturers Association (ECMA) and International Standards Organization (ISO). C# is among the languages for Common Language Infrastructure and the current version of C# is version 7.2. C# is a lot similar to Java syntactically and is easy for the users who have knowledge of C, C++ or Java.")
                            .endTag("p")
                            .endTag("div")
                            .endTag("body")
                            .endTag("html")
                            .get();

            Console.WriteLine(result);
        }
 private BuffChartDataDto(BuffsGraphModel bgm, List <Segment> bChart, PhaseData phase)
 {
     Id      = bgm.Buff.ID;
     Visible = (bgm.Buff.Name == "Might" || bgm.Buff.Name == "Quickness" || bgm.Buff.Name == "Vulnerability");
     Color   = HTMLBuilder.GetLink("Color-" + bgm.Buff.Name);
     States  = Segment.ToObjectList(bChart, phase.Start, phase.End);
 }
        /// <summary>
        /// Updates the editor when the Editor tab is selected
        /// </summary>
        private void UpdateEditor()
        {
            if (!string.IsNullOrEmpty(builder.HTMLContent))
            {
                editor.Text = builder.HTMLContent;
            }
            else
            {
                editor.Text = HTMLBuilder.FormatHtml(browserDesign.DocumentText);
            }

            editMenuItem.Enabled   = false;
            insertMenuItem.Enabled = false;
            formatMenuItem.Enabled = false;
            tableMenuItem.Enabled  = false;
            formMenuItem.Enabled   = false;

            undoToolbarButton.Enabled      = false;
            redoToolbarButton.Enabled      = false;
            cutToolbarButton.Enabled       = false;
            copyToolbarButton.Enabled      = false;
            pasteToolbarButton.Enabled     = false;
            fontToolbarButton.Enabled      = false;
            fontColorToolbarButton.Enabled = false;
            hyperlinkToolbarButton.Enabled = false;
            imageToolbarButton.Enabled     = false;
            tableToolbarButton.Enabled     = false;
            listToolbarButton.Enabled      = false;
            formToolbarButton.Enabled      = false;
        }
Example #8
0
        static void Main(string[] args)
        {
            HTMLBuilder myHtmlPage = new HTMLBuilder();

            myHtmlPage.OpenTag("div").Body("Welcome to C#").ClosingTag("div");
            Console.WriteLine(myHtmlPage.Get());
        }
Example #9
0
        public void HelloWorld()
        {
            var builder = new HTMLBuilder();

            builder.Document().Body(content: "Hello world!");
            Assert.AreEqual(ConvertResourceStringToCurrentEnvironment(Test.Resources.AssertEqualHelloWorld), builder.ToString());
        }
Example #10
0
        public void SkipComments()
        {
            var builder = new HTMLBuilder();

            builder.Settings.WriteComments = false;
            builder.BeginComponent().Div("component").Child().A("http://www.google.com").EndComponent();
            Assert.AreEqual(ConvertResourceStringToCurrentEnvironment(Test.Resources.AssertSkipComments), builder.ToString());
        }
Example #11
0
        public void PreserveCase()
        {
            var builder = new HTMLBuilder();

            builder.AddElement("DiV", new[] { new HTMLAttribute("CLASS", "Test") }, "Content");
            builder.Settings.EnforceProperCase = false;
            Assert.AreEqual(ConvertResourceStringToCurrentEnvironment(Test.Resources.AssertEqualPreserveCase), builder.ToString());
        }
Example #12
0
        public void TabSize8()
        {
            var builder = new HTMLBuilder();

            builder.Document().Body(content: "Size 8");
            builder.Settings.TabSize = 8;
            Assert.AreEqual(ConvertResourceStringToCurrentEnvironment(Test.Resources.AssertEqualTabSize8), builder.ToString());
        }
Example #13
0
        public void CustomRootElement()
        {
            var builder = new HTMLBuilder(HTMLDocumentType.HTML5, new HTMLEmpty());

            builder.Settings.EnforceProperNesting = true;
            builder.AddElement("br", "");
            Assert.AreEqual(ConvertResourceStringToCurrentEnvironment(Test.Resources.AssertSelfClosing), builder.ToString());
        }
Example #14
0
        public void NoSelfClosing()
        {
            var builder = new HTMLBuilder();

            builder.Settings.EnforceProperNesting = false;
            builder.Empty();
            builder.AddElement("script", new[] { new HTMLAttribute("src", "test.js") }, "");
            Assert.AreEqual(ConvertResourceStringToCurrentEnvironment(Test.Resources.AssertNoSelfClosing), builder.ToString());
        }
Example #15
0
    public static string ReadBlockHTML(string fileName)
    {
        HTMLBuilder hb = new HTMLBuilder();

        fileName = HttpContext.Current.Server.MapPath("~/") + fileName;
        string html = hb.ReadHTML(fileName);

        return(html);
    }
 public GeradorRelatorioWindow()
 {
     InitializeComponent();
     a = new HTMLBuilder();
     //TODO V2-> Inserir um table sorter em Gastos.
     //TODO V2-> Gerar toda a documentacao em varios HTMLS (Index.html, gastos.html)
     //TODO V2-> Incluindo JavaScript, JQuery, Bootstrap, Cada um em um tipo de pasta(JS, CSS)
     //TODO V2-> Gerar um menu lateral para facil acesso a funcoes;
 }
Example #17
0
        public string HTMLScenario()
        {
            var      builder  = new HTMLBuilder();
            Director director = new Director(builder);

            //文書を作成
            director.Construct();
            //作成した文書
            return(builder.GetResult());
        }
        public static string HtmlString(ParsedEvtcLog log)
        {
            var ms      = new MemoryStream();
            var sw      = new StreamWriter(ms, NoBOMEncodingUTF8);
            var builder = new HTMLBuilder(log, htmlSettings, htmlAssets);

            builder.CreateHTML(sw, null);
            sw.Close();

            return(Encoding.UTF8.GetString(ms.ToArray()));
        }
Example #19
0
        public void DeeplyNested()
        {
            var builder = new HTMLBuilder();

            for (int i = 1; i <= 25; i++)
            {
                builder.Child().Div(className: "class" + i.ToString(), id: "element" + i.ToString());
            }

            Assert.AreEqual(ConvertResourceStringToCurrentEnvironment(Test.Resources.AssertEqualDeeplyNested), builder.ToString());
        }
        public static string HtmlString(ParsedLog log)
        {
            var ms      = new MemoryStream();
            var sw      = new StreamWriter(ms, GeneralHelper.NoBOMEncodingUTF8);
            var builder = new HTMLBuilder(log, null, false, false);

            builder.CreateHTML(sw, null);
            sw.Close();

            return(Encoding.UTF8.GetString(ms.ToArray()));
        }
        public static string HtmlString(ParsedLog log)
        {
            MemoryStream ms      = new MemoryStream();
            StreamWriter sw      = new StreamWriter(ms);
            HTMLBuilder  builder = new HTMLBuilder(log, null);

            builder.CreateHTML(sw, null);
            sw.Close();

            return(sw.ToString());
        }
        private void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            a = new HTMLBuilder();
            gerador();
            System.IO.FileStream fs = (System.IO.FileStream)saveFileDialog1.OpenFile();
            string toWrite          = a.toHTML();

            fs.Write(System.Text.Encoding.UTF8.GetBytes(toWrite), 0, toWrite.Length);
            fs.Close();
            MessageBox.Show(this, "Relatorio gerado com sucesso.");
            Dispose();
        }
Example #23
0
        public void LargeHTMLDocument()
        {
            var builder = new HTMLBuilder();

            builder.Settings.EnforceProperNesting = false;
            builder.Document().Body().P().Child().AddElement("div");
            for (int i = 1; i <= 1000; i++)
            {
                builder.AddElement("p", "List element " + i.ToString()).Child();
            }
            Assert.AreEqual(builder.ToString().Split('\n').Length, 3007);
        }
Example #24
0
        static void Main(string[] args)
        {
            Searchable str = new Searchable("Hey you! 4 Hey");


            Console.WriteLine("Number of words: {0}, the word \'Hey\' appeard {1} times, number of charachters: {2}, the char \'H\' appeard {3} times, last index of \'H\' is {4}", str.numOfWords(), str.numOfXWord("Hey")
                              , str.numOfChars(), str.numOfXChar('H'), str.lastIndexofChar('H'));

            //////////////
            ///
            Console.WriteLine("\n\n");
            swap("first(I'llBe2nd) second(I'llBe1st) third forth");
            ///////////////
            int[]  values = { 1, 2, 3, 4, 5 };
            int [] res    = rotate(values, 2, false);

            Console.WriteLine("\n\n");
            foreach (var num in res)
            {
                Console.Write("{0} ", num);
            }

            ///////////////
            ///

            string exposed = "Do not use your bag";

            using (SHA1 hash = SHA1.Create())
            {
                byte[] exposedBytes = Encoding.UTF8.GetBytes(exposed);
                byte[] hashBytes    = hash.ComputeHash(exposedBytes);
                string hashed       = BitConverter.ToString(hashBytes).Replace("-", String.Empty);
                Console.WriteLine("\n\nThe SHA1 hash of {0} is: {1}", exposed, hashed);
            }
            //////////////


            // method chaining & fluent interface
            HTMLBuilder html1    = new HTMLBuilder();
            string      htmlCode = html1.beginTag("p")
                                   .content("Welcome to HTML")
                                   .endTag("p").get();

            Console.WriteLine("\n\n" + htmlCode);

            ////////////
            ///
            Console.WriteLine("\n\nWhich part is: \nABCDENQRST@#$%%222");
            whichPart("ABnCamDENnQRdST@#$%%222");
        }
 public PlayerDto(Player player, ParsedEvtcLog log, ActorDetailsDto details) : base(player, log, details)
 {
     Group       = player.Group;
     Acc         = player.Account;
     Profession  = player.Prof;
     IsPoV       = log.LogData.PoV == player.AgentItem;
     IsCommander = player.HasCommanderTag;
     ColTarget   = HTMLBuilder.GetLink("Color-" + player.Prof);
     ColCleave   = HTMLBuilder.GetLink("Color-" + player.Prof + "-NonBoss");
     ColTotal    = HTMLBuilder.GetLink("Color-" + player.Prof + "-Total");
     IsDummy     = player.IsDummyActor;
     IsCustom    = player.IsCustomActor;
     BuildWeaponSets(player, log);
 }
Example #26
0
 public PlayerDto(AbstractSingleActor actor, ParsedEvtcLog log, ActorDetailsDto details) : base(actor, log, details)
 {
     Group       = actor.Group;
     Acc         = actor.Account;
     Profession  = actor.Spec.ToString();
     IsPoV       = log.LogData.PoV == actor.AgentItem;
     IsCommander = actor.HasCommanderTag;
     ColTarget   = HTMLBuilder.GetLink("Color-" + actor.Spec.ToString());
     ColCleave   = HTMLBuilder.GetLink("Color-" + actor.Spec.ToString() + "-NonBoss");
     ColTotal    = HTMLBuilder.GetLink("Color-" + actor.Spec.ToString() + "-Total");
     IsFake      = actor.IsFakeActor;
     NotInSquad  = !(actor is Player);
     BuildWeaponSets(actor, log);
 }
Example #27
0
        public void CreateAComponent()
        {
            var builder = new HTMLBuilder();

            builder.Document().Body()
            .H(1, "Component example")
            .BeginComponent("My Component")
            .Div("component")
            .Child()
            .AddElement("span", "Extra component content")
            .Parent()
            .EndComponent();
            Assert.AreEqual(ConvertResourceStringToCurrentEnvironment(Test.Resources.AssertCreateComponent), builder.ToString());
        }
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog dlgSaveFile = new SaveFileDialog();

            dlgSaveFile.Filter          = "HTML File (*.html, *.htm)|*.html, *.htm";
            dlgSaveFile.OverwritePrompt = true;
            dlgSaveFile.DefaultExt      = "*.html";
            dlgSaveFile.CheckPathExists = true;
            dlgSaveFile.AddExtension    = true;
            dlgSaveFile.ShowDialog();

            try
            {
                if (!string.IsNullOrEmpty(dlgSaveFile.FileName))
                {
                    builder.MakeImagePathsRelative();
                    if (!string.IsNullOrEmpty(builder.HTMLContent))
                    {
                        builder.SaveHtmlFile(dlgSaveFile.FileName);
                    }
                    else
                    {
                        File.WriteAllText(dlgSaveFile.FileName, HTMLBuilder.FormatHtml(browserDesign.DocumentText));
                    }

                    FileInfo savedFile = new FileInfo(dlgSaveFile.FileName);
                    builder.CopyImagesToFilePath(savedFile.DirectoryName);
                    builder.LoadHtmlFile(savedFile.FullName);
                    this.Text = savedFile.Name + " - Easy Web Page Builder";

                    modifiedDocument = false;
                    newFile          = false;
                }
            }
            catch (Exception ex)
            {
                //this exception does not make any sense
                if (ex.Message.Contains("URI formats"))
                {
                    builder.LoadHtmlFile(dlgSaveFile.FileName);
                    this.Text        = new FileInfo(dlgSaveFile.FileName).Name + " - Easy Web Page Builder";
                    modifiedDocument = false;
                    newFile          = false;
                    return;
                }

                MessageBox.Show(ex.Message + ex.StackTrace, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 internal PlayerDto(Player player, ParsedEvtcLog log, bool cr, ActorDetailsDto details) : base(player, log, cr, details)
 {
     Group       = player.Group;
     Acc         = player.Account;
     Profession  = player.Prof;
     Condi       = player.Condition;
     Conc        = player.Concentration;
     Heal        = player.Healing;
     IsPoV       = log.LogData.PoV == player.AgentItem;
     IsCommander = player.HasCommanderTag;
     ColTarget   = HTMLBuilder.GetLink("Color-" + player.Prof);
     ColCleave   = HTMLBuilder.GetLink("Color-" + player.Prof + "-NonBoss");
     ColTotal    = HTMLBuilder.GetLink("Color-" + player.Prof + "-Total");
     IsConjure   = player.IsFakeActor;
     BuildWeaponSets(player, log);
 }
Example #30
0
        public void InvalidTagForHTML401Strict()
        {
            var  builder         = new HTMLBuilder(HTMLDocumentType.HTML4_01_Strict);
            bool exceptionThrown = false;

            try
            {
                builder.AddElement("article", "Test");
            }
            catch (Exception ex)
            {
                exceptionThrown = true;
                Trace.WriteLine(ex.Message);
            }
            Assert.IsTrue(exceptionThrown);
        }
Example #31
0
        public void AddChildrenInLambda()
        {
            var builder = new HTMLBuilder();

            builder.AddElement("div", new HTMLAttribute[] { new HTMLAttribute("class", "parent") });
            builder.Child(() =>
            {
                builder.AddElement("div", "Child Level 1");
                builder.AddAttribute("class", "child");
                builder.Child(() =>
                {
                    builder.H(2, "Child Level 2");
                });
            });
            Debug.WriteLine(builder.ToString());
        }
        private void ShareCurrentPage_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
        {
            ResourceLoader resources = new ResourceLoader();
            HTMLBuilder builder = new HTMLBuilder();
            EventItemViewModel item = this.flipView.SelectedItem as EventItemViewModel;
            DataPackage data = args.Request.Data;

            data.Properties.Title = resources.GetString("AssociationName") + " " + item.Title;
            data.Properties.Description = item.Subtitle;

            List<string> content = new List<string>();
            content.Add(item.Title);
            content.Add(item.Subtitle);
            content.Add(item.RemotePictureURI);
            content.Add(item.Content);
            content.Add(item.ContactName);
            content.Add(item.ContactEmail);
            content.Add(item.PhoneNumber);
            content.Add(item.Address);
            content.Add(item.WebSiteURL);

            // Sharing text
            data.SetHtmlFormat(HtmlFormatHelper.CreateHtmlFormat(builder.ContentToHTML(content)));
        }
 public static string ReadBlockHTML(string fileName)
 {
     HTMLBuilder hb = new HTMLBuilder();
     fileName = HttpContext.Current.Server.MapPath("~/") + fileName;
     string html = hb.ReadHTML(fileName);
     return html;
 }