Implement the platform ticker

This commit is contained in:
Frank A. Krueger 2017-12-09 22:19:16 -08:00
parent 88a4798acb
commit 33e1a65f59
3 changed files with 34 additions and 9 deletions

View File

@ -30,9 +30,9 @@ namespace Xamarin.Forms
Registrar.RegisterAll (new[] {
typeof(ExportRendererAttribute),
//typeof(ExportCellAttribute),
//typeof(ExportImageSourceHandlerAttribute),
});
//typeof(ExportCellAttribute),
//typeof(ExportImageSourceHandlerAttribute),
});
}
public static event EventHandler<ViewInitializedEventArgs> ViewInitialized;
@ -62,11 +62,6 @@ namespace Xamarin.Forms
Task.Run (action);
}
public Ticker CreateTicker ()
{
throw new NotImplementedException ();
}
public Assembly[] GetAssemblies ()
{
return AppDomain.CurrentDomain.GetAssemblies ();
@ -119,6 +114,31 @@ namespace Xamarin.Forms
}
}), null, (int)interval.TotalMilliseconds, (int)interval.TotalMilliseconds);
}
public Ticker CreateTicker ()
{
return new OouiTicker ();
}
class OouiTicker : Ticker
{
Timer timer;
protected override void DisableTimer ()
{
var t = timer;
timer = null;
t?.Dispose ();
}
protected override void EnableTimer ()
{
if (timer != null)
return;
var interval = TimeSpan.FromSeconds (1.0 / Ooui.UI.Session.MaxFps);
timer = new Timer ((_ => {
this.SendSignals ();
}), null, (int)interval.TotalMilliseconds, (int)interval.TotalMilliseconds);
}
}
}
public class ViewInitializedEventArgs

View File

@ -74,6 +74,9 @@ namespace Ooui.Forms.Renderers
{
base.OnElementPropertyChanged (sender, e);
if (Control == null)
return;
if (e.PropertyName == Xamarin.Forms.Label.HorizontalTextAlignmentProperty.PropertyName)
UpdateAlignment ();
else if (e.PropertyName == Xamarin.Forms.Label.VerticalTextAlignmentProperty.PropertyName)

View File

@ -522,9 +522,11 @@ namespace Ooui
readonly HashSet<string> createdIds;
readonly List<Message> queuedMessages = new List<Message> ();
public const int MaxFps = 30;
readonly System.Timers.Timer sendThrottle;
DateTime lastTransmitTime = DateTime.MinValue;
readonly TimeSpan throttleInterval = TimeSpan.FromSeconds (1.0 / 30); // 30 FPS max
readonly TimeSpan throttleInterval = TimeSpan.FromSeconds (1.0 / MaxFps);
readonly double initialWidth;
readonly double initialHeight;