예제 #1
0
        /// <summary>
        /// Attaches this SearchPanel to a TextArea instance.
        /// </summary>
        public void Attach(TextArea textArea)
        {
            if (textArea == null)
            {
                throw new ArgumentNullException("textArea");
            }
            this.textArea = textArea;
            var layer = AdornerLayer.GetAdornerLayer(textArea);

            adorner = new SearchPanelAdorner(textArea, this);
            if (layer != null)
            {
                layer.Add(adorner);
            }
            DataContext = this;

            renderer = new SearchResultBackgroundRenderer();
            textArea.TextView.BackgroundRenderers.Add(renderer);
            currentDocument              = textArea.Document;
            currentDocument.TextChanged += textArea_Document_TextChanged;
            textArea.DocumentChanged    += textArea_DocumentChanged;
            KeyDown += SearchLayerKeyDown;

            this.CommandBindings.Add(new CommandBinding(SearchCommands.FindNext, (sender, e) => FindNext()));
            this.CommandBindings.Add(new CommandBinding(SearchCommands.FindPrevious, (sender, e) => FindPrevious()));
            this.CommandBindings.Add(new CommandBinding(SearchCommands.CloseSearchPanel, (sender, e) => Close()));
            IsClosed = true;
        }
예제 #2
0
        void AttachInternal(TextArea textArea)
        {
            this.textArea = textArea;
            adorner       = new SearchPanelAdorner(textArea, this);
            DataContext   = this;

            renderer        = new SearchResultBackgroundRenderer();
            currentDocument = textArea.Document;
            if (currentDocument != null)
            {
                currentDocument.TextChanged += textArea_Document_TextChanged;
            }
            textArea.DocumentChanged += textArea_DocumentChanged;
            KeyDown += SearchLayerKeyDown;

            this.CommandBindings.Add(new CommandBinding(SearchCommands.Find, (sender, e) => Open(false)));
            this.CommandBindings.Add(new CommandBinding(SearchCommands.Replace, (sender, e) => Open(true)));
            this.CommandBindings.Add(new CommandBinding(SearchCommands.FindNext, (sender, e) => FindNext()));
            this.CommandBindings.Add(new CommandBinding(SearchCommands.FindPrevious, (sender, e) => FindPrevious()));
            this.CommandBindings.Add(new CommandBinding(SearchCommands.ReplaceNext, (sender, e) => ReplaceNext()));
            this.CommandBindings.Add(new CommandBinding(SearchCommands.ReplaceAll, (sender, e) => ReplaceAll()));
            this.CommandBindings.Add(new CommandBinding(SearchCommands.CloseSearchPanel, (sender, e) => Close()));
            this.CommandBindings.Add(new CommandBinding(SearchCommands.CloseRegexNote, (sender, e) => HideRegexPopup()));
            IsClosed = true;
        }
예제 #3
0
		/// <summary>
		/// Creates a new SearchPanel and attaches it to a text area.
		/// </summary>
		public SearchPanel(TextArea textArea)
		{
			if (textArea == null)
				throw new ArgumentNullException("textArea");
			this.textArea = textArea;
			DataContext = this;
			InitializeComponent();
			
			textArea.TextView.Layers.Add(this);
			foldingManager = textArea.GetService(typeof(FoldingManager)) as FoldingManager;
			
			renderer = new SearchResultBackgroundRenderer();
			textArea.TextView.BackgroundRenderers.Add(renderer);
			textArea.Document.TextChanged += delegate { DoSearch(false); };
			this.Loaded += delegate { searchTextBox.Focus(); };
			
			useRegex.Checked     += ValidateSearchText;
			matchCase.Checked    += ValidateSearchText;
			wholeWords.Checked   += ValidateSearchText;
			
			useRegex.Unchecked   += ValidateSearchText;
			matchCase.Unchecked  += ValidateSearchText;
			wholeWords.Unchecked += ValidateSearchText;
		}
예제 #4
0
		/// <summary>
		/// Attaches this SearchPanel to a TextArea instance.
		/// </summary>
		public void Attach(TextArea textArea)
		{
			if (textArea == null)
				throw new ArgumentNullException("textArea");
			this.textArea = textArea;
			var layer = AdornerLayer.GetAdornerLayer(textArea);
			adorner = new SearchPanelAdorner(textArea, this);
			if (layer != null)
				layer.Add(adorner);
			DataContext = this;
			
			renderer = new SearchResultBackgroundRenderer();
			textArea.TextView.BackgroundRenderers.Add(renderer);
			currentDocument = textArea.Document;
			currentDocument.TextChanged += textArea_Document_TextChanged;
			textArea.DocumentChanged += textArea_DocumentChanged;
			KeyDown += SearchLayerKeyDown;
			
			this.CommandBindings.Add(new CommandBinding(SearchCommands.FindNext, (sender, e) => FindNext()));
			this.CommandBindings.Add(new CommandBinding(SearchCommands.FindPrevious, (sender, e) => FindPrevious()));
			this.CommandBindings.Add(new CommandBinding(SearchCommands.CloseSearchPanel, (sender, e) => Close()));
		}
예제 #5
0
        void AttachInternal(TextArea textArea)
        {
            this.textArea = textArea;
            adorner = new SearchPanelAdorner(textArea, this);
            DataContext = this;

            renderer = new SearchResultBackgroundRenderer();
            currentDocument = textArea.Document;
            if (currentDocument != null)
                currentDocument.TextChanged += textArea_Document_TextChanged;
            textArea.DocumentChanged += textArea_DocumentChanged;
            KeyDown += SearchLayerKeyDown;

            this.CommandBindings.Add(new CommandBinding(SearchCommands.FindNext, (sender, e) => FindNext()));
            this.CommandBindings.Add(new CommandBinding(SearchCommands.FindPrevious, (sender, e) => FindPrevious()));
            this.CommandBindings.Add(new CommandBinding(SearchCommands.CloseSearchPanel, (sender, e) => Close()));
            IsClosed = true;
        }
예제 #6
0
		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;
		}
예제 #7
0
        /// <summary>
        /// Attaches this SearchPanel to a TextArea instance.
        /// </summary>
        public void Attach(TextArea textArea)
        {
            if(textArea == null)
                throw new ArgumentNullException("textArea");

            this.textArea = textArea;
            adorner = new SearchPanelAdorner(textArea, this);
            DataContext = this;

            renderer = new SearchResultBackgroundRenderer();
            current_doc = textArea.Document;
            if(current_doc != null)
                current_doc.TextChanged += textArea_Document_TextChanged;

            textArea.DocumentChanged += textArea_DocumentChanged;
            KeyDown += SearchLayerKeyDown;

            this.CommandBindings.Add(new CommandBinding(SearchCommands.FindNext, (sender, e) => FindNext()));
            this.CommandBindings.Add(new CommandBinding(SearchCommands.FindPrevious, (sender, e) => FindPrevious()));
            this.CommandBindings.Add(new CommandBinding(SearchCommands.CloseSearchPanel, (sender, e) => Close()));
            IsClosed = true;
        }