private void btnHighlightAll_Click(object sender, EventArgs e)
        {
            if (txtFind.Text == string.Empty)
            {
                return;
            }
            if (_scintilla == null)
            {
                return;
            }

            int foundCount = _findReplace.FindAll(txtFind.Text, false, true).Count;
        }
Ejemplo n.º 2
0
        private void btnFindAll_Click(object sender, EventArgs e)
        {
            if (txtFindF.Text == string.Empty)
            {
                return;
            }

            AddFindMru();

            lblStatus.Text = string.Empty;

            btnClear_Click(null, null);
            int foundCount = 0;

            #region RegEx

            if (rdoRegexF.Checked)
            {
                Regex rr = null;
                try
                {
                    rr = new Regex(txtFindF.Text, GetRegexOptions());
                }
                catch (ArgumentException ex)
                {
                    lblStatus.Text = "Error in Regular Expression: " + ex.Message;
                    return;
                }

                if (chkSearchSelectionF.Checked)
                {
                    if (_searchRange.cpMin == _searchRange.cpMax)
                    {
                        _searchRange = new CharacterRange(_scintilla.Selections[0].Start, _scintilla.Selections[0].End);
                    }

                    foundCount = FindReplace.FindAll(_searchRange, rr, chkMarkLine.Checked, chkHighlightMatches.Checked).Count;
                }
                else
                {
                    _searchRange = new CharacterRange();
                    foundCount   = FindReplace.FindAll(rr, chkMarkLine.Checked, chkHighlightMatches.Checked).Count;
                }
            }

            #endregion

            #region Non-RegEx

            if (!rdoRegexF.Checked)
            {
                if (chkSearchSelectionF.Checked)
                {
                    if (_searchRange.cpMin == _searchRange.cpMax)
                    {
                        _searchRange = new CharacterRange(_scintilla.Selections[0].Start, _scintilla.Selections[0].End);
                    }

                    string textToFind = rdoExtendedF.Checked ? FindReplace.Transform(txtFindF.Text) : txtFindF.Text;
                    foundCount = FindReplace.FindAll(_searchRange, textToFind, GetSearchFlags(), chkMarkLine.Checked, chkHighlightMatches.Checked).Count;
                }
                else
                {
                    _searchRange = new CharacterRange();
                    string textToFind = rdoExtendedF.Checked ? FindReplace.Transform(txtFindF.Text) : txtFindF.Text;
                    foundCount = FindReplace.FindAll(textToFind, GetSearchFlags(), chkMarkLine.Checked, chkHighlightMatches.Checked).Count;
                }
            }

            #endregion

            lblStatus.Text = "Total found: " + foundCount.ToString();
        }