示例#1
0
        /// <summary>
        /// Do replace, show the result on replaced textbox.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void btnReplace_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtInput.Text))
            {
                return;
            }
            if (string.IsNullOrEmpty(txtReplacement.Text))
            {
                return;
            }
            //Match first
            btnMatch_Click(sender, e);

            UI2Data();

            txtReplaceResult.Text = ruleItem.replaceText(txtInput.Text);
            HighLight hl = new HighLight(txtReplaceResult);

            hl.Reset2Default();
            foreach (string result in ruleItem.Results)
            {
                string[] newV = Regex.Split(result, @"\t");
                hl.Highlight(newV.Last());
            }
        }
示例#2
0
        public void btnMatch_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(lblFilePath.Text))
            {
                return;
            }

            try
            {
                hlFileContent.Reset2Default();

                Dictionary <string, HtmlNodeCollection> kvNodes = HtmlParser.GetNodes(lblFilePath.Text, txtFilter.Text);
                treeResult.Nodes.Clear();
                foreach (KeyValuePair <string, HtmlNodeCollection> kv in kvNodes)
                {
                    TreeNode treeNode = treeResult.Nodes.Add(kv.Key, kv.Key);
                    foreach (HtmlNode n1 in kv.Value)
                    {
                        ConvertHtmlNode(treeNode, n1);
                        hlFileContent.Highlight(n1.StreamPosition, n1.OuterHtml.Length, Color.Black, Color.YellowGreen);
                    }
                }

                if (!rules.Contains(txtFilter.Text))
                {
                    rules.Add(txtFilter.Text);
                    listHistory.Items.Add(txtFilter.Text);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#3
0
        /// <summary>
        /// Show the match result on tree.
        /// </summary>
        /// <param name="matches"></param>
        private void BindMatchTree(List <Match> matches, HighLight hl, Regex reg, string caption, Color foreColor, Color backColor)
        {
            int index = 0;

            foreach (Match match in matches)
            {
                hl.Highlight(match, foreColor, backColor);

                TreeNode nodeMatch = treeMatch.Nodes.Add(string.Format("{0} Match[{1}]:{2}", caption, index, reg.ToString()));
                nodeMatch.Name = string.Format("{0}:{1}", match.Index, match.Length);
                BindGroup(nodeMatch, match, reg);
                index++;
            }
        }