Пример #1
0
        public static void InitializeFrom(this UIView nativeControl, Controls.RoundedBoxView.RoundedBoxView formsControl)
        {
            if (nativeControl == null || formsControl == null)
            {
                return;
            }

            nativeControl.Layer.MasksToBounds = true;
            nativeControl.Layer.CornerRadius  = (float)formsControl.CornerRadius;
            nativeControl.UpdateBorder(formsControl.BorderColor, formsControl.BorderThickness);
        }
Пример #2
0
        public static void UpdateFrom(this View nativeControl, Controls.RoundedBoxView.RoundedBoxView formsControl,
                                      string propertyChanged)
        {
            if (nativeControl == null || formsControl == null)
            {
                return;
            }

            if (propertyChanged == Controls.RoundedBoxView.RoundedBoxView.CornerRadiusProperty.PropertyName)
            {
                nativeControl.UpdateCornerRadius(formsControl.CornerRadius);
            }
            if (propertyChanged == VisualElement.BackgroundColorProperty.PropertyName)
            {
                var background = nativeControl.Background as GradientDrawable;

                if (background != null)
                {
                    background.SetColor(formsControl.BackgroundColor.ToAndroid());
                }
                else
                {
                    var grad = new GradientDrawable();
                    grad.SetOrientation(GradientDrawable.Orientation.TopBottom);
                    grad.SetColors(new[]
                    {
                        formsControl.BackgroundColor.ToAndroid().ToArgb(),
                        formsControl.BackgroundColor.ToAndroid().ToArgb()
                    });

                    nativeControl.Background = grad;
                }

                nativeControl.UpdateCornerRadius(formsControl.CornerRadius);
                nativeControl.UpdateBorder(formsControl.BorderColor, formsControl.BorderThickness);
            }

            if (propertyChanged == Controls.RoundedBoxView.RoundedBoxView.BorderColorProperty.PropertyName)
            {
                nativeControl.UpdateBorder(formsControl.BorderColor, formsControl.BorderThickness);
            }

            if (propertyChanged == Controls.RoundedBoxView.RoundedBoxView.BorderThicknessProperty.PropertyName)
            {
                nativeControl.UpdateBorder(formsControl.BorderColor, formsControl.BorderThickness);
            }
        }
Пример #3
0
        public static void InitializeFrom(this View nativeControl, Controls.RoundedBoxView.RoundedBoxView formsControl)
        {
            if (nativeControl == null || formsControl == null)
            {
                return;
            }

            var background = new GradientDrawable();

            background.SetColor(formsControl.BackgroundColor.ToAndroid());

            if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean)
            {
                nativeControl.Background = background;
            }
            else
            {
                nativeControl.SetBackgroundDrawable(background);
            }

            nativeControl.UpdateCornerRadius(formsControl.CornerRadius);
            nativeControl.UpdateBorder(formsControl.BorderColor, formsControl.BorderThickness);
        }
Пример #4
0
        public static void UpdateFrom(this UIView nativeControl, Controls.RoundedBoxView.RoundedBoxView formsControl,
                                      string propertyChanged)
        {
            if (nativeControl == null || formsControl == null)
            {
                return;
            }

            if (propertyChanged == Controls.RoundedBoxView.RoundedBoxView.CornerRadiusProperty.PropertyName)
            {
                nativeControl.Layer.CornerRadius = (float)formsControl.CornerRadius;
            }

            if (propertyChanged == Controls.RoundedBoxView.RoundedBoxView.BorderColorProperty.PropertyName)
            {
                nativeControl.UpdateBorder(formsControl.BorderColor, formsControl.BorderThickness);
            }

            if (propertyChanged == Controls.RoundedBoxView.RoundedBoxView.BorderThicknessProperty.PropertyName)
            {
                nativeControl.UpdateBorder(formsControl.BorderColor, formsControl.BorderThickness);
            }
        }