private void highlightSelectionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string LookFor = string.Empty;

            LookFor = editor.ActiveTextAreaControl.TextArea.SelectionManager.SelectedText;

            // if there's text selected, highlight all!
            if (!_highlightGroups.ContainsKey(editor))
            {
                _highlightGroups[editor] = new HighlightGroup(editor);
            }
            HighlightGroup     group   = _highlightGroups[editor];
            TextEditorSearcher _search = new TextEditorSearcher();

            _search.Document = editor.Document;

            group.ClearMarkers();


            _search.LookFor            = LookFor;
            _search.MatchCase          = true;
            _search.MatchWholeWordOnly = true;

            bool looped = false;
            int  offset = 0, count = 0;

            for (; ;)
            {
                TextRange range = _search.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.Orange, Color.Black);
                group.AddMarker(m);
            }

            editor.Invalidate();
            editor.Refresh();
        }
示例#2
0
        private void btnSerch_Click(object sender, EventArgs e)
        {
            var _editor = txtSchemaXML;

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

            group.ClearMarkers();

            TextEditorSearcher _search = new TextEditorSearcher();

            _search.LookFor            = txtLookFor.Text;
            _search.MatchCase          = false;
            _search.MatchWholeWordOnly = false;
            _search.Document           = _editor.Document;

            bool looped = false;
            int  offset = 0, count = 0;

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

                TextMarker m = new TextMarker(range.Offset, range.Length, TextMarkerType.SolidBlock, Color.Yellow, Color.Black);
                group.AddMarker(m);
            }
            if (count == 0)
            {
                MessageBox.Show("没有找到你要查找的内容", "提示");
            }

            Folding();
        }