Provides search functionality for AvalonEdit. It is displayed in the top-right corner of the TextArea.
Inheritance: System.Windows.Controls.Control
Exemple #1
0
 /// <summary>
 /// Creates a new SearchInputHandler and registers the search-related commands.
 /// </summary>
 public SearchInputHandler(TextArea textArea)
     : base(textArea)
 {
     RegisterCommands(this.CommandBindings);
     panel = new SearchPanel();
     panel.Attach(TextArea);
 }
 public void Attach(ITextEditor editor)
 {
     TextArea textArea = editor.GetService(typeof(TextArea)) as TextArea;
     if (textArea != null) {
         panel = SearchPanel.Install(textArea);
         panel.SearchOptionsChanged += SearchOptionsChanged;
     }
 }
 public void Detach()
 {
     if (panel != null) {
         panel.SearchOptionsChanged -= SearchOptionsChanged;
         panel.Uninstall();
         panel = null;
     }
 }
		void ExecuteFind(object sender, ExecutedRoutedEventArgs e)
		{
			if (panel == null || panel.IsClosed) {
				panel = new SearchPanel();
				panel.Attach(TextArea);
			}
			Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Input, (Action)delegate { panel.Reactivate(); });
		}
Exemple #5
0
 static void SearchPatternChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     if (d is SearchPanel)
     {
         SearchPanel panel = d as SearchPanel;
         panel.ValidateSearchText();
         panel.UpdateSearch();
     }
 }
Exemple #6
0
        static void MarkerBrushChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            SearchPanel panel = d as SearchPanel;

            if (panel != null)
            {
                panel.renderer.MarkerBrush = (Brush)e.NewValue;
            }
        }
Exemple #7
0
 void ExecuteFind(object sender, ExecutedRoutedEventArgs e)
 {
     if (panel == null || panel.IsClosed)
     {
         panel = new SearchPanel();
         panel.Attach(TextArea);
     }
     panel.SearchPattern = TextArea.Selection.GetText();
     Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Input, (Action) delegate { panel.Reactivate(); });
 }
Exemple #8
0
 /// <summary>
 /// Creates a SearchPanel and installs it to the TextArea.
 /// </summary>
 public static SearchPanel Install(TextArea textArea)
 {
     if (textArea == null)
     {
         throw new ArgumentNullException("textArea");
     }
                 #pragma warning disable 618
     SearchPanel panel = new SearchPanel();
     panel.AttachInternal(textArea);
     panel.handler = new SearchInputHandler(textArea, panel);
     textArea.DefaultInputHandler.NestedInputHandlers.Add(panel.handler);
     return(panel);
 }
 private void ExecuteFindImpl(string pattern, bool setFocusToSearchBox, bool isBackward)
 {
   if (this.panel == null || this.panel.IsClosed)
   {
     this.panel = new SearchPanel();
     this.panel.Attach(TextArea);
   }
   var currentPos = TextArea.Caret.Position;
   panel.SearchPattern = pattern;
   if (setFocusToSearchBox)
     Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Input, (Action) delegate { this.panel.Reactivate(); });
   if (isBackward)
   {
     TextArea.Caret.Position = currentPos;
     this.panel.FindPrevious();
   }
 }
Exemple #10
0
 private void SearchHandler(object sender, ExecutedRoutedEventArgs e)
 {
     var sp = new SearchPanel();
     sp.Attach(textEditor.TextArea);
     sp.Dispatcher.BeginInvoke(DispatcherPriority.Input, (Action)sp.Reactivate);
 }
Exemple #11
0
        static void SearchPatternChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            SearchPanel panel = d as SearchPanel;

            panel?.ValidateAndUpdateSearch();
        }
		public override void Detach()
		{
			base.Detach();
			if (panel != null) {
				panel.SearchOptionsChanged -= SearchOptionsChanged;
				panel.Uninstall();
				panel = null;
			}
		}
Exemple #13
0
 internal SearchInputHandler(TextArea textArea, SearchPanel panel)
     : base(textArea)
 {
     RegisterCommands(this.CommandBindings);
     this.panel = panel;
 }
Exemple #14
0
		void ExecuteCloseSearchPanel(object sender, ExecutedRoutedEventArgs e)
		{
			if (panel != null)
				panel.Close();
			panel = null;
		}
		public SearchPanelAdorner(TextArea textArea, SearchPanel panel)
			: base(textArea)
		{
			this.panel = panel;
			AddVisualChild(panel);
		}
Exemple #16
0
 private void ExecuteCloseSearchPanel(object sender, ExecutedRoutedEventArgs e)
 {
   if (this.panel != null)
     this.panel.Close();
   this.panel = null;
 }
Exemple #17
0
		public NewTextEditor(IThemeManager themeManager, ITextEditorSettings textEditorSettings) {
			this.themeManager = themeManager;
			this.textEditorSettings = textEditorSettings;
			this.textEditorSettings.PropertyChanged += TextEditorSettings_PropertyChanged;
			this.themeManager.ThemeChanged += ThemeManager_ThemeChanged;
			Options.AllowToggleOverstrikeMode = true;
			Options.RequireControlModifierForHyperlinkClick = false;
			UpdateColors(false);

			searchPanel = SearchPanel.Install(TextArea);
			searchPanel.RegisterCommands(this.CommandBindings);
			searchPanel.Localization = new AvalonEditSearchPanelLocalization();

			TextArea.SelectionCornerRadius = 0;
			TextArea.PreviewKeyDown += TextArea_PreviewKeyDown;
			TextArea.InputBindings.Add(new KeyBinding(new RelayCommand(a => PageUp()), Key.PageUp, ModifierKeys.Control));
			TextArea.InputBindings.Add(new KeyBinding(new RelayCommand(a => PageDown()), Key.PageDown, ModifierKeys.Control));
			TextArea.InputBindings.Add(new KeyBinding(new RelayCommand(a => UpDownLine(false)), Key.Down, ModifierKeys.Control));
			TextArea.InputBindings.Add(new KeyBinding(new RelayCommand(a => UpDownLine(true)), Key.Up, ModifierKeys.Control));
			this.AddHandler(GotKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(OnGotKeyboardFocus), true);
			this.AddHandler(LostKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(OnLostKeyboardFocus), true);

			TextArea.MouseRightButtonDown += (s, e) => GoToMousePosition();

			SetBinding(FontFamilyProperty, new Binding {
				Source = textEditorSettings,
				Path = new PropertyPath("FontFamily"),
				Mode = BindingMode.OneWay,
			});
			SetBinding(FontSizeProperty, new Binding {
				Source = textEditorSettings,
				Path = new PropertyPath("FontSize"),
				Mode = BindingMode.OneWay,
			});
			SetBinding(WordWrapProperty, new Binding {
				Source = textEditorSettings,
				Path = new PropertyPath("WordWrap"),
				Mode = BindingMode.OneWay,
			});

			OnHighlightCurrentLineChanged();
			OnShowLineNumbersChanged();
		}
Exemple #18
0
 public SearchPanelAdorner(TextArea textArea, SearchPanel panel)
     : base(textArea)
 {
     this.panel = panel;
     AddVisualChild(panel);
 }
Exemple #19
0
		internal SearchInputHandler(TextArea textArea, SearchPanel panel)
			: base(textArea)
		{
			RegisterCommands(this.CommandBindings);
			this.panel = panel;
		}
Exemple #20
0
 public SearchInputHandler(TextArea textArea)
     : base(textArea)
 {
     RegisterCommands(this.CommandBindings);
     panel = SearchPanel.Install(textArea);
 }
Exemple #21
0
 /// <summary>
 /// Creates a SearchPanel and installs it to the TextArea.
 /// </summary>
 public static SearchPanel Install(TextArea textArea)
 {
     if (textArea == null)
         throw new ArgumentNullException("textArea");
     #pragma warning disable 618
     SearchPanel panel = new SearchPanel();
     panel.AttachInternal(textArea);
     panel.handler = new SearchInputHandler(textArea, panel);
     textArea.DefaultInputHandler.NestedInputHandlers.Add(panel.handler);
     return panel;
 }
 private void SearchButton_Click(object sender, RoutedEventArgs e)
 {
     SearchPanel sPanel = new SearchPanel();
     sPanel.Attach(SqlTextBox.TextArea);
 }
        public TextEditor()
        {
            InitializeComponent();

            editor = new AvalonEditorWPF();
            attachWpfEditor(editor);

            ContextMenuStrip    = contextMenuEditor;
            foldingManager      = FoldingManager.Install(_.TextArea);
            searchPanel         = SearchPanel.Install(_.TextArea);
            init();
        }
Exemple #24
0
 void search_SearchOptionsChanged(object sender, SearchOptionsChangedEventArgs e)
 {
     searchPanel = sender as SearchPanel;
 }