public CaretHighlightAdorner(TextArea textArea) : base(textArea.TextView) { Rect min = textArea.Caret.CalculateCaretRectangle(); min.Offset(-textArea.TextView.ScrollOffset); Rect max = min; double size = Math.Max(min.Width, min.Height) * 0.25; max.Inflate(size, size); pen = new Pen(TextBlock.GetForeground(textArea.TextView).Clone(), 1); geometry = new RectangleGeometry(min, 2, 2); geometry.BeginAnimation(RectangleGeometry.RectProperty, new RectAnimation(min, max, new Duration(TimeSpan.FromMilliseconds(300))) { AutoReverse = true }); pen.Brush.BeginAnimation(Brush.OpacityProperty, new DoubleAnimation(1, 0, new Duration(TimeSpan.FromMilliseconds(200))) { BeginTime = TimeSpan.FromMilliseconds(450) }); }
public CaretHighlightAdorner(TextArea textArea) : base(textArea.TextView) { var rect = textArea.Caret.CalculateCaretRectangle(); rect.Offset(-textArea.TextView.ScrollOffset); var toValue = rect; var num = Math.Max(rect.Width, rect.Height)*0.25; toValue.Inflate(num, num); _pen = new Pen(TextBlock.GetForeground(textArea.TextView).Clone(), 1.0); _geometry = new RectangleGeometry(rect, 2.0, 2.0); _geometry.BeginAnimation(RectangleGeometry.RectProperty, new RectAnimation(rect, toValue, new Duration(TimeSpan.FromMilliseconds(300.0))) { AutoReverse = true }); _pen.Brush.BeginAnimation(Brush.OpacityProperty, new DoubleAnimation(1.0, 0.0, new Duration(TimeSpan.FromMilliseconds(200.0))) { BeginTime = TimeSpan.FromMilliseconds(450.0) }); }