Ooui-tws-port/Ooui.Forms/PlatformRenderer.cs

59 lines
1.6 KiB
C#
Raw Normal View History

2017-11-09 09:38:19 +00:00
using System;
using Xamarin.Forms;
namespace Ooui.Forms
{
public class PlatformRenderer : Ooui.Div, IDisposable
2017-11-09 09:38:19 +00:00
{
readonly Platform platform;
public Platform Platform => platform;
public override bool WantsFullScreen => true;
2017-11-09 09:38:19 +00:00
public PlatformRenderer (Platform platform)
{
this.platform = platform;
}
2017-12-11 03:02:41 +00:00
protected override bool TriggerEventFromMessage (Message message)
{
if (disposedValue)
return false;
2017-12-11 03:02:41 +00:00
if (message.TargetId == "window" && message.Key == "resize" && message.Value is Newtonsoft.Json.Linq.JObject j) {
var width = (double)j["width"];
var height = (double)j["height"];
Platform.Element.Style.Width = width;
Platform.Element.Style.Height = height;
return true;
}
else {
return base.TriggerEventFromMessage (message);
}
}
#region IDisposable Support
private bool disposedValue = false;
protected virtual void Dispose (bool disposing)
{
if (!disposedValue) {
if (disposing) {
// Disconnect any events we started
// Inform the page it's leaving
if (Platform.Page is IPageController pc) {
pc.SendDisappearing ();
}
}
disposedValue = true;
}
}
public void Dispose ()
{
Dispose (true);
}
#endregion
}
2017-11-09 09:38:19 +00:00
}