Simplified DispatcherTimer wrapper

This commit is contained in:
ClemensFischer 2025-01-28 17:52:40 +01:00
parent 4ec73292c3
commit d83493a498
7 changed files with 28 additions and 46 deletions

View file

@ -17,7 +17,6 @@
</ItemGroup>
<ItemGroup>
<Compile Remove="..\Shared\Timer.cs" />
<Compile Remove="..\Shared\TypeConverters.cs" />
</ItemGroup>

View file

@ -32,7 +32,10 @@ namespace MapControl
public double Width { get; }
public double Height { get; }
public bool Contains(Point p) => p.X >= X && p.X <= X + Width && p.Y >= Y && p.Y <= Y + Height;
public bool Contains(Point p)
{
return p.X >= X && p.X <= X + Width && p.Y >= Y && p.Y <= Y + Height;
}
public static implicit operator Windows.Foundation.Rect(Rect r)
{

View file

@ -1,33 +0,0 @@
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// Copyright © Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
using System;
namespace MapControl
{
internal static class Timer
{
public static DispatcherQueueTimer CreateTimer(this DependencyObject obj, TimeSpan interval)
{
var timer = obj.DispatcherQueue.CreateTimer();
timer.Interval = interval;
return timer;
}
public static void Run(this DispatcherQueueTimer timer, bool restart = false)
{
if (restart)
{
timer.Stop();
}
if (!timer.IsRunning)
{
timer.Start();
}
}
}
}