mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 06:26:41 +00:00
Simplified DispatcherTimer wrapper
This commit is contained in:
parent
4ec73292c3
commit
d83493a498
7 changed files with 28 additions and 46 deletions
|
|
@ -17,7 +17,6 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="..\Shared\Timer.cs" />
|
||||
<Compile Remove="..\Shared\TypeConverters.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue