2026-03-09 20:05:21 +01:00
|
|
|
using System.Diagnostics;
|
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
|
|
2026-03-22 18:31:05 +01:00
|
|
|
namespace ONDClient.GUI;
|
2026-03-09 20:05:21 +01:00
|
|
|
|
|
|
|
|
public class TimerUIElement : TextUIElement{
|
|
|
|
|
private Stopwatch stopwatch = new();
|
|
|
|
|
|
2026-03-12 22:33:35 +01:00
|
|
|
public TimerUIElement(Point corner1, SpriteFont font) : base(corner1, font) {
|
2026-03-09 20:05:21 +01:00
|
|
|
Text = "00:00.000";
|
2026-03-12 22:33:35 +01:00
|
|
|
Bounds = (corner1, corner1 + new Point((int)Measure().X, (int)Measure().Y));
|
2026-03-09 20:05:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Update() {
|
|
|
|
|
if (stopwatch.IsRunning){
|
|
|
|
|
Text = stopwatch.Elapsed.ToString("mm\\:ss\\.fff");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Start() {
|
2026-03-21 21:23:33 +01:00
|
|
|
stopwatch.Restart();
|
2026-03-09 20:05:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Stop() {
|
|
|
|
|
stopwatch.Stop();
|
|
|
|
|
}
|
|
|
|
|
}
|