2012-09-01 11:20:05 +00:00
#region Using Statements
using System ;
2012-08-12 20:00:19 +00:00
using System.Diagnostics ;
2012-09-08 09:07:23 +00:00
using ANX.Framework.NonXNA ;
2012-08-12 20:00:19 +00:00
using ANX.Framework.NonXNA.PlatformSystem ;
2012-09-01 11:20:05 +00:00
#endregion
2012-08-14 08:44:12 +00:00
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
2012-08-12 20:00:19 +00:00
namespace ANX.PlatformSystem.Metro
{
public class MetroGameTimer : INativeGameTimer
{
2012-09-01 11:20:05 +00:00
#region Using Statements
private Stopwatch stopwatch ;
private TimeSpan lastElapsed ;
#endregion
public MetroGameTimer ( )
{
if ( ! Stopwatch . IsHighResolution )
{
Logger . Warning ( "Created " + this . GetType ( ) . FullName + ", but it is not high resolution. Maybe the underlying platform doesn't support high resolution timers?" ) ;
}
stopwatch = Stopwatch . StartNew ( ) ;
Reset ( ) ;
}
public void Update ( )
{
TimeSpan elapsed = stopwatch . Elapsed ;
ElapsedTime = elapsed - lastElapsed ;
lastElapsed = elapsed ;
}
public void Reset ( )
{
stopwatch . Restart ( ) ;
lastElapsed = stopwatch . Elapsed ;
}
public void Suspend ( )
{
stopwatch . Stop ( ) ;
}
public void Resume ( )
{
stopwatch . Start ( ) ;
}
public TimeSpan ElapsedTime
{
get ;
internal set ;
}
public TimeSpan CurrentTime
{
get ;
internal set ;
}
2012-08-12 20:00:19 +00:00
public long Frequency
{
get
{
return Stopwatch . Frequency ;
}
}
public long Timestamp
{
get
{
return Stopwatch . GetTimestamp ( ) ;
}
}
2012-09-01 11:20:05 +00:00
}
2012-08-12 20:00:19 +00:00
}