Provides search functionality for AvalonEdit. It is displayed in the top-right corner of the TextArea.
Inheritance: System.Windows.Controls.Control
Ejemplo n.º 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);
 }
Ejemplo n.º 2
0
 public void Attach(ITextEditor editor)
 {
     TextArea textArea = editor.GetService(typeof(TextArea)) as TextArea;
     if (textArea != null) {
         panel = SearchPanel.Install(textArea);
         panel.SearchOptionsChanged += SearchOptionsChanged;
     }
 }
Ejemplo n.º 3
0
 public void Detach()
 {
     if (panel != null) {
         panel.SearchOptionsChanged -= SearchOptionsChanged;
         panel.Uninstall();
         panel = null;
     }
 }
Ejemplo n.º 4
0
		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(); });
		}
Ejemplo n.º 5
0
 static void SearchPatternChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     if (d is SearchPanel)
     {
         SearchPanel panel = d as SearchPanel;
         panel.ValidateSearchText();
         panel.UpdateSearch();
     }
 }
Ejemplo n.º 6
0
        static void MarkerBrushChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            SearchPanel panel = d as SearchPanel;

            if (panel != null)
            {
                panel.renderer.MarkerBrush = (Brush)e.NewValue;
            }
        }
Ejemplo n.º 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(); });
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 9
0
 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();
   }
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 11
0
        static void SearchPatternChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            SearchPanel panel = d as SearchPanel;

            panel?.ValidateAndUpdateSearch();
        }
Ejemplo n.º 12
0
		public override void Detach()
		{
			base.Detach();
			if (panel != null) {
				panel.SearchOptionsChanged -= SearchOptionsChanged;
				panel.Uninstall();
				panel = null;
			}
		}
Ejemplo n.º 13
0
 internal SearchInputHandler(TextArea textArea, SearchPanel panel)
     : base(textArea)
 {
     RegisterCommands(this.CommandBindings);
     this.panel = panel;
 }
Ejemplo n.º 14
0
		void ExecuteCloseSearchPanel(object sender, ExecutedRoutedEventArgs e)
		{
			if (panel != null)
				panel.Close();
			panel = null;
		}
Ejemplo n.º 15
0
		public SearchPanelAdorner(TextArea textArea, SearchPanel panel)
			: base(textArea)
		{
			this.panel = panel;
			AddVisualChild(panel);
		}
Ejemplo n.º 16
0
 private void ExecuteCloseSearchPanel(object sender, ExecutedRoutedEventArgs e)
 {
   if (this.panel != null)
     this.panel.Close();
   this.panel = null;
 }
Ejemplo n.º 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();
		}
Ejemplo n.º 18
0
 public SearchPanelAdorner(TextArea textArea, SearchPanel panel)
     : base(textArea)
 {
     this.panel = panel;
     AddVisualChild(panel);
 }
Ejemplo n.º 19
0
		internal SearchInputHandler(TextArea textArea, SearchPanel panel)
			: base(textArea)
		{
			RegisterCommands(this.CommandBindings);
			this.panel = panel;
		}
Ejemplo n.º 20
0
 public SearchInputHandler(TextArea textArea)
     : base(textArea)
 {
     RegisterCommands(this.CommandBindings);
     panel = SearchPanel.Install(textArea);
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 22
0
 private void SearchButton_Click(object sender, RoutedEventArgs e)
 {
     SearchPanel sPanel = new SearchPanel();
     sPanel.Attach(SqlTextBox.TextArea);
 }
Ejemplo n.º 23
0
        public TextEditor()
        {
            InitializeComponent();

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

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