示例#1
0
        private void htmlToolStripMenuItem_Click(object sender, EventArgs e)
        {
            HtmlCssData hs = new HtmlCssData();

            document = hs.GetHtmlStructure;
            string filePath = Application.StartupPath;

            document.Save(filePath + "/tempHtml.txt");

            richTextBox1.LoadFile(filePath + "/tempHtml.txt", RichTextBoxStreamType.PlainText);
            using (Document d = Document.FromString(richTextBox1.Text))
            {
                d.IndentBlockElements = AutoBool.Yes;
                d.IndentSpaces        = 2;
                d.AddTidyMetaElement  = false;
                d.CleanAndRepair();
                d.Save(filePath + "/tempHtml.txt");
            }

            document.Load(filePath + "/tempHtml.txt");
            richTextBox1.Clear();
            richTextBox1.LoadFile(filePath + "/tempHtml.txt", RichTextBoxStreamType.PlainText);
            this.ColorHtmlTag();
            //view.NavigateToString(richTextBox1.Text);
            treeView1.Nodes.Clear();
            treeView1.Nodes.Add(document.DocumentNode.Name);
            TreeViewMethods.BindTreeView(document.DocumentNode, treeView1.Nodes[0]);
            htmlElementToolStripMenuItem1.Enabled = false;
            builder.Dispose();
            builder = new CssBulderControl1();
            //builder.Dock = DockStyle.Fill ;
            // this.Controls.Add(builder);
            //  builder.BringToFront();
        }
示例#2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            richTextBox1.LoadFile(Application.StartupPath + "/tempHtml.txt", RichTextBoxStreamType.PlainText);
            treeView1.Nodes.Clear();
            document.Load(Application.StartupPath + "/tempHtml.txt");
            HtmlNode node = document.DocumentNode;

            treeView1.Nodes.Add(node.Name);
            TreeViewMethods.BindTreeView(node, treeView1.Nodes[0]);

            ColorHtmlTag();
            HtmlNode       nd  = null;
            XPathNavigator nav = document.DocumentNode.CreateRootNavigator();

            if (nav.Evaluate("//head/link") != null)
            {
                nd = document.DocumentNode.SelectSingleNode("//head/link");
            }
            if (nd != null)
            {
                string cssfilePath = nd.GetAttributeValue("href", string.Empty);
                rtb1.LoadFile(cssfilePath, RichTextBoxStreamType.PlainText);
            }
            else
            {
                return;
            }
        }
示例#3
0
        private void htmlSourceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            splitContainer1.BringToFront();

            richTextBox1.Clear();
            richTextBox1.LoadFile(Application.StartupPath + "/tempHtml.txt", RichTextBoxStreamType.PlainText);
            ColorHtmlTag();
            treeView1.Nodes.Clear();
            document.Load(Application.StartupPath + "/tempHtml.txt");
            HtmlNode node = document.DocumentNode;

            treeView1.Nodes.Add(node.Name);
            TreeViewMethods.BindTreeView(node, treeView1.Nodes[0]);
            treeView1.ExpandAll();
            htmlElementToolStripMenuItem1.Enabled = false;
        }
示例#4
0
        private async void htmlToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter           = "Html File(.html)|*.html";
            openFileDialog1.RestoreDirectory = true;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                richTextBox1.LoadFile(openFileDialog1.FileName, RichTextBoxStreamType.PlainText);
                document.LoadHtml(richTextBox1.Text);
                document.Save(Application.StartupPath + "/tempHtml.txt");

                Thread.Sleep(1000);
                this.ColorHtmlTag();
                await view.EnsureCoreWebView2Async(null);

                view.CoreWebView2.NavigateToString(richTextBox1.Text);
                treeView1.Nodes.Clear();
                treeView1.Nodes.Add(document.DocumentNode.Name);
                TreeViewMethods.BindTreeView(document.DocumentNode, treeView1.Nodes[0]);
                htmlElementToolStripMenuItem1.Enabled = false;
                builder.Dispose();
                builder = new CssBulderControl1();
            }
        }