using System; using System.Collections.Generic; using System.Text; using System.Windows; using System.Windows.Documents; using System.Windows.Media; namespace Qrakhen.Qamp.Editor.Controls; public class Caret : Adorner { private readonly Pen _caretPen; private readonly double _lineHeight; private Point _cursorPosition; public Caret(UIElement adornedElement, double lineHeight) : base(adornedElement) { _lineHeight = lineHeight; _caretPen = new Pen(Brushes.LimeGreen, 1.5); IsHitTestVisible = false; } public void UpdatePosition(Point newPosition) { _cursorPosition = newPosition; InvalidateVisual(); } protected override void OnRender(DrawingContext drawingContext) { Point startPoint = new(_cursorPosition.X, _cursorPosition.Y); Point endPoint = new(_cursorPosition.X, _cursorPosition.Y + _lineHeight); drawingContext.DrawLine(_caretPen, startPoint, endPoint); } }