Virtu/Library/Silverlight/FrameRateCounter.xaml.cs
Sean Fausett ae126d2552 Cosmetic changes.
Implemented video scanner and floating bus.

--HG--
extra : convert_revision : svn%3Affd33b8c-2492-42e0-bdc5-587b920b7d6d/trunk%4035682
2009-12-13 05:53:53 +00:00

43 lines
1.2 KiB
C#

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace Jellyfish.Library
{
public sealed partial class FrameRateCounter : UserControl
{
public FrameRateCounter()
{
InitializeComponent();
CompositionTarget.Rendering += OnCompositionTargetRendering;
}
private void OnCompositionTargetRendering(object sender, EventArgs e)
{
_frameCount++;
long time = DateTime.UtcNow.Ticks;
if (time - _lastTime >= TimeSpan.TicksPerSecond)
{
_lastTime = time;
FrameRate = _frameCount;
_frameCount = 0;
}
}
public static readonly DependencyProperty FrameRateProperty = DependencyProperty.Register("FrameRate", typeof(int), typeof(FrameRateCounter),
new PropertyMetadata(0));
public int FrameRate
{
get { return (int)GetValue(FrameRateProperty); }
set { SetValue(FrameRateProperty, value); }
}
private int _frameCount;
private long _lastTime;
}
}