void AttachInternal(TextArea textArea) { this.textArea = textArea; renderer = new SearchResultBackgroundRenderer(); currentDocument = textArea.Document; if (currentDocument != null) { currentDocument.TextChanged += textArea_Document_TextChanged; } textArea.DocumentChanged += textArea_DocumentChanged; }
public void Attach(TextArea textArea, TextEditor editor) { if (textArea == null) { throw new ArgumentNullException("textArea"); } _editor = editor; _textArea = textArea; _currentDocument = textArea.Document; _renderer = new SearchResultBackgroundRenderer { MarkerBrush = new SolidColorBrush(Colors.Yellow) }; _searchTextBox.TextChanged += new TextChangedEventHandler(_searchTextBox_TextChanged); _adorner = new SearchPanelAdorner(textArea, this); if (_currentDocument != null) { _currentDocument.TextChanged += new EventHandler(_currentDocument_TextChanged); } _textArea.DocumentChanged += new EventHandler(_textArea_DocumentChanged); _textArea.PreviewKeyDown += new KeyEventHandler(_textArea_PreviewKeyDown); _searchTextBox.LostFocus += new RoutedEventHandler(_searchTextBox_LostFocus); _replaceTextBox.LostFocus += new RoutedEventHandler(_replaceTextBox_LostFocus); _searchTextBox.GotFocus += new RoutedEventHandler(_searchTextBox_GotFocus); _replaceTextBox.GotFocus += new RoutedEventHandler(_replaceTextBox_GotFocus); KeyDown += new KeyEventHandler(_searchPanel_KeyDown); CommandBindings.Add(new CommandBinding(Find, (sender, e) => Open())); CommandBindings.Add(new CommandBinding(SearchCommands.FindNext, (sender, e) => FindNext())); CommandBindings.Add(new CommandBinding(SearchCommands.FindPrevious, (sender, e) => FindPrevious())); CommandBindings.Add(new CommandBinding(SearchCommands.CloseSearchPanel, (sender, e) => Close())); textArea.CommandBindings.Add(new CommandBinding(SearchCommands.FindNext, (sender, e) => FindNext())); textArea.CommandBindings.Add(new CommandBinding(SearchCommands.FindPrevious, (sender, e) => FindPrevious())); textArea.CommandBindings.Add(new CommandBinding(SearchCommands.CloseSearchPanel, (sender, e) => Close())); IsClosed = true; }
public FullEditor() { InitializeComponent(); _renderer = new SearchResultBackgroundRenderer(); editor.Editor.TextArea.TextView.BackgroundRenderers.Add(_renderer); editor.KeyDown += editor_KeyDown; editor.RunRequested += editor_RunRequested; editor.SelectionChanged += editor_SelectionChanged; editor.TextChanged += editor_TextChanged; txtFind.SingleLine = true; txtFind.TextChanged += txtFind_TextChanged; txtFind.RunRequested += txtFind_RunRequested; txtFind.KeyDown += textbox_KeyDown; txtReplace.SingleLine = true; txtReplace.RunRequested += txtReplace_RunRequested; txtReplace.KeyDown += textbox_KeyDown; FindReplaceMode = FindReplaceState.None; }