Пример #1
0
        protected virtual void OnFormClosing(object sender, FormClosingEventArgs e)
        {
            _searchOptonsUpdate?.Invoke(this.SearchText, _isMatchCase, _isMatchWholeWord);

            if (_highlightGroups.ContainsKey(_editor))
            {
                HighlightGroup group = _highlightGroups[_editor];
                if (group.HasMarkers)
                {
                    // Clear highlights
                    group.ClearMarkers();
                    _editor.Refresh();
                }
            }

            // Prevent dispose, as this form can be re-used
            if (e.CloseReason != CloseReason.FormOwnerClosing)
            {
                if (this.Owner != null)
                {
                    this.Owner.Select(); // prevent another app from being activated instead
                }
                _panelIsHidden = true;

                e.Cancel = true;
                this.Hide();

                // Discard search region
                _searchHandler.ClearScanRegion();
                _editor.Refresh(); // must repaint manually
            }
        }
Пример #2
0
        private void HighlightAll()
        {
            if (this.DesignMode)
            {
                return;
            }

            if (!_highlightGroups.ContainsKey(_editor))
            {
                _highlightGroups[_editor] = new HighlightGroup(_editor);
            }

            HighlightGroup group = _highlightGroups[_editor];

            if (!string.IsNullOrWhiteSpace(this.SearchText))
            {
                _searchHandler.SearchText         = this.SearchText;
                _searchHandler.MatchCase          = _isMatchCase;
                _searchHandler.MatchWholeWordOnly = _isMatchWholeWord;

                bool looped = false;
                int  offset = 0, count = 0;
                for (; ;)
                {
                    TextRange range = _searchHandler.FindNext(offset, false, out looped);
                    if (range == null || looped)
                    {
                        break;
                    }
                    offset = range.Offset + range.Length;
                    count++;

                    var m = new TextMarker(range.Offset, range.Length,
                                           TextMarkerType.SolidBlock, Color.LightGoldenrodYellow, Color.Black);
                    group.AddMarker(m);
                }

                if (group.HasMarkers)
                {
                    _editor.Refresh();
                }
            }
            else
            {
                if (_searchHandler.HasScanRegion || group.HasMarkers)
                {
                    // Clear highlights
                    group.ClearMarkers();
                }
            }
        }
Пример #3
0
        private void OnSearchTextChanged(object sender, EventArgs e)
        {
            if (_isInitialized)
            {
                _searchCount = 0;

                if (_highlightGroups.Count != 0 && _highlightGroups.ContainsKey(_editor))
                {
                    HighlightGroup group = _highlightGroups[_editor];
                    if (group.HasMarkers)
                    {
                        // Clear highlights
                        group.ClearMarkers();
                        _editor.Refresh();
                    }
                }
            }
        }