2017-12-10 06:37:25 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using Xamarin.Forms;
|
|
|
|
|
using Ooui.Forms.Extensions;
|
|
|
|
|
|
|
|
|
|
namespace Ooui.Forms.Renderers
|
|
|
|
|
{
|
|
|
|
|
public class FrameRenderer : VisualElementRenderer<Frame>
|
|
|
|
|
{
|
|
|
|
|
protected override void OnElementChanged (ElementChangedEventArgs<Frame> e)
|
|
|
|
|
{
|
|
|
|
|
base.OnElementChanged (e);
|
|
|
|
|
|
|
|
|
|
if (e.NewElement != null)
|
|
|
|
|
SetupLayer ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnElementPropertyChanged (object sender, PropertyChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnElementPropertyChanged (sender, e);
|
|
|
|
|
|
|
|
|
|
if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName ||
|
2018-05-15 08:30:42 +00:00
|
|
|
|
e.PropertyName == Xamarin.Forms.Frame.BorderColorProperty.PropertyName ||
|
2017-12-10 06:37:25 +00:00
|
|
|
|
e.PropertyName == Xamarin.Forms.Frame.HasShadowProperty.PropertyName ||
|
|
|
|
|
e.PropertyName == Xamarin.Forms.Frame.CornerRadiusProperty.PropertyName)
|
|
|
|
|
SetupLayer ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetupLayer ()
|
|
|
|
|
{
|
|
|
|
|
float cornerRadius = Element.CornerRadius;
|
|
|
|
|
|
|
|
|
|
if (cornerRadius == -1f)
|
|
|
|
|
cornerRadius = 5f; // default corner radius
|
|
|
|
|
|
|
|
|
|
var Layer = this.Style;
|
|
|
|
|
|
|
|
|
|
Layer.BorderRadius = cornerRadius;
|
|
|
|
|
|
2018-04-26 05:23:26 +00:00
|
|
|
|
Layer.BackgroundColor = Element.BackgroundColor.ToOouiColor (OouiTheme.BackgroundColor);
|
2017-12-10 06:37:25 +00:00
|
|
|
|
|
|
|
|
|
if (Element.HasShadow) {
|
|
|
|
|
//Layer.ShadowRadius = 5;
|
|
|
|
|
//Layer.ShadowColor = "black";
|
|
|
|
|
//Layer.ShadowOpacity = 0.8f;
|
|
|
|
|
//Layer.ShadowOffset = new SizeF ();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
//Layer.ShadowOpacity = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-15 08:30:42 +00:00
|
|
|
|
if (Element.BorderColor == Xamarin.Forms.Color.Default) {
|
2017-12-10 06:37:25 +00:00
|
|
|
|
Layer.BorderColor = Colors.Clear;
|
2018-04-26 05:23:26 +00:00
|
|
|
|
Layer.BorderWidth = 1;
|
|
|
|
|
Layer.BorderStyle = "none";
|
|
|
|
|
}
|
2017-12-10 06:37:25 +00:00
|
|
|
|
else {
|
2018-05-15 08:30:42 +00:00
|
|
|
|
Layer.BorderColor = Element.BorderColor.ToOouiColor (Colors.Clear);
|
2017-12-10 06:37:25 +00:00
|
|
|
|
Layer.BorderWidth = 1;
|
|
|
|
|
Layer.BorderStyle = "solid";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|