| ofs | hex dump | ascii |
|---|
| 0000 | 00 00 01 00 01 00 30 30 00 00 01 00 20 00 a8 25 00 00 16 00 00 00 28 00 00 00 30 00 00 00 60 00 | ......00.......%......(...0...`. |
| 0020 | 00 00 01 00 20 00 00 00 00 00 80 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ...........%.................... |
| 0040 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 33 33 ee 0f 3c 34 | ..........................33..<4 |
| 0060 | f1 c3 3d 35 f0 ff 3d 35 f0 ff 3d 35 f0 ff 3d 35 f0 fb 3c 35 ee 88 00 00 ff 03 00 00 00 00 00 00 | ..=5..=5..=5..=5..<5............ |
| 0080 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................................ |
| 00a0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................................ |
| 00c0 | 00 00 00 00 ff 02 3c 35 ef 6e 3c 34 f0 f9 3d 35 f0 ff 3d 35 f0 ff 3d 35 f0 ff 3c 34 f0 cf 33 26 | ......<5.n<4..=5..=5..=5..<4..3& |
| 00e0 | e6 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................................ |
| 0100 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3c 35 f0 22 3d 35 | ..........................<5."=5 |
| 0120 | ef de 3d 35 f0 ff 3d 35 f0 ff 3d 35 f0 ff 3d 35 f0 ff 43 3c eb b2 8f 89 ae 29 a7 a7 97 20 a7 a7 | ..=5..=5..=5..=5..C<.....)...... |
| 0140 | 97 20 a7 a7 97 20 a7 a7 97 20 a7 a7 97 20 a7 a7 97 20 a7 a7 97 20 a7 a7 97 20 a7 a7 97 20 a7 a7 | ................................ |
| 0160 | 97 20 a7 a7 97 20 a7 a7 97 20 a7 a7 97 20 a7 a7 97 20 a7 a7 97 20 a7 a7 97 20 a7 a7 97 20 a7 a7 | ................................ |
| 0180 | 97 20 94 94 a8 26 46 3e e8 9c 3d 35 f0 ff 3d 35 f0 ff 3d 35 f0 ff 3d 35 f0 ff 3c 35 f0 e9 3a 34 | .....&F>..=5..=5..=5..=5..<5..:4 |
| 01a0 | ee 2c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Threading;
using Tango.Scripting.Editors.Rendering;
using Tango.Scripting.Editors.Utils;
namespace Tango.Scripting.Editors.Editing
{
sealed class CaretLayer : Layer
{
bool isVisible;
Rect caretRectangle;
DispatcherTimer caretBlinkTimer = new DispatcherTimer();
bool blink;
public CaretLayer(TextView textView) : base(textView, KnownLayer.Caret)
{
this.IsHitTestVisible = false;
caretBlinkTimer.Tick += new EventHandler(caretBlinkTimer_Tick);
}
void caretBlinkTimer_Tick(object sender, EventArgs e)
{
blink = !blink;
InvalidateVisual();
}
public void Show(Rect caretRectangle)
{
this.caretRectangle = caretRectangle;
this.isVisible = true;
StartBlinkAnimation();
InvalidateVisual();
}
public void Hide()
{
if (isVisible) {
isVisible = false;
StopBlinkAnimation();
InvalidateVisual();
}
}
void StartBlinkAnimation()
{
TimeSpan blinkTime = Win32.CaretBlinkTime;
blink = true; // the caret should visible initially
// This is important if blinking is disabled (system reports a negative blinkTime)
if (blinkTime.TotalMilliseconds > 0) {
caretBlinkTimer.Interval = blinkTime;
caretBlinkTimer.Start();
}
}
void StopBlinkAnimation()
{
caretBlinkTimer.Stop();
}
internal Brush CaretBrush;
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
if (isVisible && blink) {
Brush caretBrush = this.CaretBrush;
if (caretBrush == null)
caretBrush = (Brush)textView.GetValue(TextBlock.ForegroundProperty);
Rect r = new Rect(caretRectangle.X - textView.HorizontalOffset,
caretRectangle.Y - textView.VerticalOffset,
caretRectangle.Width,
caretRectangle.Height);
drawingContext.DrawRectangle(caretBrush, null, PixelSnapHelpers.Round(r, PixelSnapHelpers.GetPixelSize(this)));
}
}
}
}
|