using Xamarin.Forms;

namespace Pixiview.UI
{
    public class CircleImage : Image { }

    public class RoundImage : Image
    {
        public static readonly BindableProperty CornerRadiusProperty = BindableProperty.Create(
            nameof(CornerRadius), typeof(float), typeof(RoundImage));
        public static readonly BindableProperty CornerMasksProperty = BindableProperty.Create(
            nameof(CornerMasks), typeof(CornerMask), typeof(RoundImage));

        public float CornerRadius
        {
            get => (float)GetValue(CornerRadiusProperty);
            set => SetValue(CornerRadiusProperty, value);
        }
        public CornerMask CornerMasks
        {
            get => (CornerMask)GetValue(CornerMasksProperty);
            set => SetValue(CornerMasksProperty, value);
        }
    }

    public enum CornerMask
    {
        None = 0,

        LeftTop = 1,
        RightTop = 2,
        LeftBottom = 4,
        RightBottom = 8,

        Top = LeftTop | RightTop,           // 3
        Left = LeftTop | LeftBottom,        // 5
        Slash = RightTop | LeftBottom,      // 6
        BackSlash = LeftTop | RightBottom,  // 9
        Right = RightTop | RightBottom,     // 10
        Bottom = LeftBottom | RightBottom,  // 12

        ExceptRightBottom = LeftTop | RightTop | LeftBottom,    // 7
        ExceptLeftBottom = LeftTop | RightTop | RightBottom,    // 11
        ExceptRightTop = LeftTop | LeftBottom | RightBottom,    // 13
        ExceptLeftTop = RightTop | LeftBottom | RightBottom,    // 14

        All = LeftTop | RightTop | LeftBottom | RightBottom     // 15
    }

    public class RoundLabel : Label
    {
        public static readonly BindableProperty CornerRadiusProperty = BindableProperty.Create(
            nameof(CornerRadius), typeof(float), typeof(RoundLabel));
        public static new readonly BindableProperty BackgroundColorProperty = BindableProperty.Create(
            nameof(BackgroundColor), typeof(Color), typeof(RoundLabel), Color.Transparent);

        public float CornerRadius
        {
            get => (float)GetValue(CornerRadiusProperty);
            set => SetValue(CornerRadiusProperty, value);
        }
        public new Color BackgroundColor
        {
            get => (Color)GetValue(BackgroundColorProperty);
            set => SetValue(BackgroundColorProperty, value);
        }
    }
}
