Implement the platform ticker
This commit is contained in:
parent
88a4798acb
commit
33e1a65f59
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue