Ejemplo n.º 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());
            }
        }
Ejemplo n.º 2
0
        public XPathTabPage()
        {
            InitializeComponent();
            hlFileContent = new HighLight(txtFileContent);

            txtFilePath.Text = Config.GetAppSettingValue("dest.file");
            LoadFileTree();
            LoadHistory();
        }
Ejemplo n.º 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++;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Do regex match, show the result on tree.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void btnMatch_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtInput.Text))
            {
                return;
            }
            if (string.IsNullOrEmpty(txtPattern.Text))
            {
                return;
            }

            HighLight hl = new HighLight(txtInput);

            hl.Reset2Default();
            treeMatch.Nodes.Clear();

            List <Match> matches = new List <Match>();

            Regex reg = new Regex(txtPattern.Text, RegexOptions);

            matches.AddRange(reg.Matches(txtInput.Text).Cast <Match>());
            BindMatchTree(matches, hl, reg, "Pattern");

            if (!string.IsNullOrEmpty(txtRangeFrom.Text))
            {
                Regex reg1 = new Regex(txtRangeFrom.Text, RegexOptions);
                matches.Clear();
                matches.AddRange(reg1.Matches(txtInput.Text).Cast <Match>());
                BindMatchTree(matches, hl, reg1, "RangeFrom", Color.Black, Color.LawnGreen);
            }
            if (!string.IsNullOrEmpty(txtRangeTo.Text))
            {
                Regex reg1 = new Regex(txtRangeTo.Text, RegexOptions);
                matches.Clear();
                matches.AddRange(reg1.Matches(txtInput.Text).Cast <Match>());
                BindMatchTree(matches, hl, reg1, "RangeTo", Color.Black, Color.LawnGreen);
            }

            tabResult.SelectedTab = tpMatch;
        }
Ejemplo n.º 5
0
 private void BindMatchTree(List <Match> matches, HighLight hl, Regex reg, string caption)
 {
     BindMatchTree(matches, hl, reg, caption, Color.Black, Color.Yellow);
 }