public static void DisplayCaretHighlightAnimation(TextArea textArea) { AdornerLayer layer = AdornerLayer.GetAdornerLayer(textArea.TextView); CaretHighlightAdorner adorner = new CaretHighlightAdorner(textArea); layer.Children.Add(adorner); DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(1); timer.Tick += delegate { timer.Stop(); layer.Children.Remove(adorner); }; timer.Start(); }
/// <summary> /// Jumps to the definition referred to by the <see cref="ReferenceSegment"/>. /// </summary> internal void JumpToReference(ReferenceSegment referenceSegment) { object reference = referenceSegment.Reference; if (referenceSegment.IsLocal) { ClearLocalReferenceMarks(); if (references != null) { foreach (var r in references) { if (reference.Equals(r.Reference)) { var mark = textMarkerService.Create(r.StartOffset, r.Length); mark.BackgroundColor = r.IsLocalTarget ? Colors.LightSeaGreen : Colors.GreenYellow; localReferenceMarks.Add(mark); } } } return; } if (definitionLookup != null) { int pos = definitionLookup.GetDefinitionPosition(reference); if (pos >= 0) { textEditor.TextArea.Focus(); textEditor.Select(pos, 0); textEditor.ScrollTo(textEditor.TextArea.Caret.Line, textEditor.TextArea.Caret.Column); Dispatcher.UIThread.InvokeAsync(new Action( delegate { CaretHighlightAdorner.DisplayCaretHighlightAnimation(textEditor.TextArea); }), DispatcherPriority.Background); return; } } MainWindow.Instance.JumpToReference(reference); }