Implement the platform ticker
This commit is contained in:
parent
88a4798acb
commit
33e1a65f59
|
@ -30,9 +30,9 @@ namespace Xamarin.Forms
|
||||||
|
|
||||||
Registrar.RegisterAll (new[] {
|
Registrar.RegisterAll (new[] {
|
||||||
typeof(ExportRendererAttribute),
|
typeof(ExportRendererAttribute),
|
||||||
//typeof(ExportCellAttribute),
|
//typeof(ExportCellAttribute),
|
||||||
//typeof(ExportImageSourceHandlerAttribute),
|
//typeof(ExportImageSourceHandlerAttribute),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static event EventHandler<ViewInitializedEventArgs> ViewInitialized;
|
public static event EventHandler<ViewInitializedEventArgs> ViewInitialized;
|
||||||
|
@ -62,11 +62,6 @@ namespace Xamarin.Forms
|
||||||
Task.Run (action);
|
Task.Run (action);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ticker CreateTicker ()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException ();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Assembly[] GetAssemblies ()
|
public Assembly[] GetAssemblies ()
|
||||||
{
|
{
|
||||||
return AppDomain.CurrentDomain.GetAssemblies ();
|
return AppDomain.CurrentDomain.GetAssemblies ();
|
||||||
|
@ -119,6 +114,31 @@ namespace Xamarin.Forms
|
||||||
}
|
}
|
||||||
}), null, (int)interval.TotalMilliseconds, (int)interval.TotalMilliseconds);
|
}), 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
|
public class ViewInitializedEventArgs
|
||||||
|
|
|
@ -74,6 +74,9 @@ namespace Ooui.Forms.Renderers
|
||||||
{
|
{
|
||||||
base.OnElementPropertyChanged (sender, e);
|
base.OnElementPropertyChanged (sender, e);
|
||||||
|
|
||||||
|
if (Control == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (e.PropertyName == Xamarin.Forms.Label.HorizontalTextAlignmentProperty.PropertyName)
|
if (e.PropertyName == Xamarin.Forms.Label.HorizontalTextAlignmentProperty.PropertyName)
|
||||||
UpdateAlignment ();
|
UpdateAlignment ();
|
||||||
else if (e.PropertyName == Xamarin.Forms.Label.VerticalTextAlignmentProperty.PropertyName)
|
else if (e.PropertyName == Xamarin.Forms.Label.VerticalTextAlignmentProperty.PropertyName)
|
||||||
|
|
|
@ -522,9 +522,11 @@ namespace Ooui
|
||||||
readonly HashSet<string> createdIds;
|
readonly HashSet<string> createdIds;
|
||||||
readonly List<Message> queuedMessages = new List<Message> ();
|
readonly List<Message> queuedMessages = new List<Message> ();
|
||||||
|
|
||||||
|
public const int MaxFps = 30;
|
||||||
|
|
||||||
readonly System.Timers.Timer sendThrottle;
|
readonly System.Timers.Timer sendThrottle;
|
||||||
DateTime lastTransmitTime = DateTime.MinValue;
|
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 initialWidth;
|
||||||
readonly double initialHeight;
|
readonly double initialHeight;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue