2017-11-10 19:32:51 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using Ooui.Forms.Extensions;
|
|
|
|
|
using Xamarin.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Ooui.Forms.Renderers
|
|
|
|
|
{
|
|
|
|
|
public class BoxRenderer : VisualElementRenderer<BoxView>
|
|
|
|
|
{
|
|
|
|
|
Ooui.Color _colorToRenderer;
|
|
|
|
|
|
|
|
|
|
protected override void OnElementChanged (ElementChangedEventArgs<BoxView> e)
|
|
|
|
|
{
|
|
|
|
|
base.OnElementChanged (e);
|
|
|
|
|
|
|
|
|
|
if (Element != null)
|
|
|
|
|
SetBackgroundColor (Element.BackgroundColor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnElementPropertyChanged (object sender, PropertyChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnElementPropertyChanged (sender, e);
|
|
|
|
|
if (e.PropertyName == BoxView.ColorProperty.PropertyName)
|
|
|
|
|
SetBackgroundColor (Element.BackgroundColor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void SetBackgroundColor (Xamarin.Forms.Color color)
|
|
|
|
|
{
|
|
|
|
|
if (Element == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2018-04-26 05:23:26 +00:00
|
|
|
|
_colorToRenderer = Element.Color.ToOouiColor (Colors.Clear);
|
2017-11-10 19:32:51 +00:00
|
|
|
|
|
|
|
|
|
Style.BackgroundColor = _colorToRenderer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|