/// <summary>
        /// Make the regular expression and execute a "Replace" operation
        /// </summary>
        private void RunReplace()
        {
            string replacedText =null;
            try
            {
                Regex r;

                _currentAction= RegexActionTypes.Replace;
                PrepareToRunMatch();

                if((r=MakeRegex())==null)
                {
                    this.Cursor=Cursors.Default;
                    TriggerFinishCallback(this,RegexActionTypes.Replace);
                    RegexProject.TriggerActionEnd(RegexActionTypes.Replace,null);
                    return;
                }

                PrepareToShowRegexMatches();
                TimeCounter timer = new TimeCounter();
                timer.Start();

                replacedText = r.Replace(txtInput.Text,txtReplaceWith.Text);;
                timer.Stop();
                ClearTreeNodes();
                DisplayPerformance(ActionType.Replaces,timer.DurationSeconds);
                SetResultText(replacedText);
                EnableRunButtonsOnDocument(true);
                //TODO: Trigget finished callback for replace,split and match event using control.Invoke

            }
            catch(Exception e)
            {
                SetErrorText(e.Message);

            }
            finally
            {
                EnableRunButtonsOnDocument(true);
                TriggerFinishCallback(this,RegexActionTypes.Replace);
                RegexProject.TriggerActionEnd(RegexActionTypes.Replace,replacedText);

            }
        }
        private void RunSplits()
        {
            Regex r;
            string[] found =null;

            _currentAction= RegexActionTypes.Split;
            PrepareToShowRegexMatches();
            PrepareToRunMatch();
            EnableRunButtonsOnDocument(false);
            if((r=MakeRegex())==null)
            {
                this.Cursor=Cursors.Default;
                TriggerFinishCallback(this,RegexActionTypes.Split);
                RegexProject.TriggerActionEnd(RegexActionTypes.Split,null);

                return;
            }

            // Store the results in the text box
            string text = txtInput.Text;
            TimeCounter timer = new TimeCounter();
            timer.Start();
            found = r.Split(text);

            timer.Stop();

            //----------------
            FillListWithSplits(found);
            ShowNumberOfCapturesInStatus(ActionType.Splits,timer.DurationSeconds);

            //DisplayPerformance(ActionType.Matches,timer.DurationSeconds);
            EnableRunButtonsOnDocument(true);
            TriggerFinishCallback(this,RegexActionTypes.Split);
            RegexProject.TriggerActionEnd(RegexActionTypes.Split,found);
        }
        /// <summary>
        /// Look for matches for the regular expression
        /// </summary>
        private void RunMatch()
        {
            MatchCollection  found =null;
            try
            {
                Regex r;
                _currentAction= RegexActionTypes.Match;
                PrepareToShowRegexMatches();
                PrepareToRunMatch();

                if((r=MakeRegex())==null)
                {
                    this.Cursor=Cursors.Default;
                    TriggerFinishCallback(this,RegexActionTypes.Match);
                    RegexProject.TriggerActionEnd(RegexActionTypes.Match,null);
                    return;
                }

                // Store the results in the text box
                string text = txtInput.Text;
                TimeCounter timer = new TimeCounter();
                timer.Start();
                found = r.Matches(text);
                timer.Stop();

                //----------------
                ShowNumberOfCapturesInStatus(ActionType.Matches,timer.DurationSeconds);

                FillTreeWithMatches(found,r);

                DisplayPerformance(ActionType.Matches,timer.DurationSeconds);
                EnableRunButtonsOnDocument(true);

            }
            catch(Exception e)
            {
                SetErrorText(e.Message);
            }
            finally
            {
                EnableRunButtonsOnDocument(true);
                TriggerFinishCallback(this,RegexActionTypes.Match);
                RegexProject.TriggerActionEnd(RegexActionTypes.Match,found);

                ;

            }
        }