// Copyright © Selmo Technology GmbH. All Rights Reserved

namespace SelmoStudio.Hmi.Server.Shared.Components.BaseComponents
{
    public abstract class ShapeComponentBase : ComponentBase
    {
        protected string ShapeStyle => $@"
        fill: {BackgroundColor};
        stroke-width: {BorderWidth}px;
        stroke: {BorderColor};
        stroke-dasharray: {GetStrokeDashArray(BorderStyle)};
    ";

        protected string SvgStyle => $@"
        padding: {Padding}px;
        margin: {Margin}px;
    ";

        protected string ViewBox => $"-{BorderWidth / 2} -{BorderWidth / 2} {Width + BorderWidth} {Height + BorderWidth}";

        protected string GetStrokeDashArray(string style)
        {
            return style?.ToLower() switch
            {
                "solid" => "",
                "dashed" => "5,5",
                "dotted" => "1,5",
                _ => ""
            };
        }
    }
}