using System; using ElmSharp; using EBox = ElmSharp.Box; namespace Xamarin.Forms.Platform.Tizen.Native { /// /// Extends the ElmSharp.Box class with functionality useful to Xamarin.Forms renderer. /// /// /// This class overrides the layout mechanism. Instead of using the native layout, /// LayoutUpdated event is sent. /// public class Box : EBox { /// /// The last processed geometry of the Box which was reported from the native layer. /// Rect _previousGeometry; /// /// Initializes a new instance of the class. /// /// The parent EvasObject. public Box(EvasObject parent) : base(parent) { SetLayoutCallback(() => { NotifyOnLayout(); }); } /// /// Notifies that the layout has been updated. /// public event EventHandler LayoutUpdated; /// /// Triggers the LayoutUpdated event. /// /// /// This method is called whenever there is a possibility that the size and/or position has been changed. /// void NotifyOnLayout() { if (null != LayoutUpdated) { var g = Geometry; if (0 == g.Width || 0 == g.Height || g == _previousGeometry) { // ignore irrelevant dimensions return; } LayoutUpdated(this, new LayoutEventArgs() { Geometry = g, } ); _previousGeometry = g; } } } }