Files

183 lines
5.7 KiB
C#

using Microsoft.AspNetCore.Components;
namespace WebDoorCreator.UI.Components.SvgComp
{
public partial class HomeCard
{
#region Public Properties
[Parameter]
public bool isLogged { get; set; } = false;
[Parameter]
public string BodyStyle { get; set; } = "font-size: 2em;";
[Parameter]
public string BodyText { get; set; } = "Body Text";
[Parameter]
public string ButtonText { get; set; } = "Button Text";
[Parameter]
public List<ButtonData> ButtonsList { get; set; } = new List<ButtonData>();
[Parameter]
public EventCallback<string> EC_ExeFunct { get; set; }
[Parameter]
public string ImagePath { get; set; } = "images/DOORBG.png";
[Parameter]
public string LineColor { get; set; } = "#3989CC";
[Parameter]
public int LineWidth { get; set; } = 16;
[Parameter]
public int ObjH { get; set; } = 204;
[Parameter]
public int ObjId { get; set; } = 0;
[Parameter]
public int ObjW { get; set; } = 450;
[Parameter]
public int StartPoint { get; set; } = 220;
[Parameter]
public string TitleStyle { get; set; } = "font-size: 5.5em;";
[Parameter]
public string TitleText { get; set; } = "Title Text";
#endregion Public Properties
#region Protected Properties
protected List<PointData> PathClip { get; set; } = null!;
protected string PathClipData
{
get
{
//string path = $"{PathLineData} L1200,0 L1920,0 L1920,1080 L900,1080 Z";
string path = PathLineData;
if (pathClipCloseList.Count > 0)
{
for (int i = 0; i < pathClipCloseList.Count; i++)
{
path += $" L{pathClipCloseList[i].px},{pathClipCloseList[i].py}";
}
}
path += " Z";
return path;
}
}
public class ButtonData
{
public string Css { get; set; } = "btn btn-lg btn-primary rounded-pill p-3 px-4 text-uppercase";
public string Text { get; set; } = "Button";
public string Title { get; set; } = "Button Suggestion";
public string Descript { get; set; } = "...";
public string Icon { get; set; } = "fa fa-home";
public string RetPage { get; set; } = "home";
}
protected List<PointData> PathLine { get; set; } = null!;
protected string PathLineData
{
get
{
string path = "";
if (pathPointList.Count > 0)
{
path = $"M{pathPointList[0].px},{pathPointList[0].py} Q";
for (int i = 1; i < pathPointList.Count; i++)
{
path += $" {pathPointList[i].px},{pathPointList[i].py}";
}
}
return path;
}
}
#endregion Protected Properties
#region Protected Methods
protected void execFunc()
{
EC_ExeFunct.InvokeAsync("");
}
protected override void OnParametersSet()
{
setupGraphParams();
}
protected void setupGraphParams()
{
pathPointList = new List<PointData>();
pathClipCloseList = new List<PointData>();
// calcolo i dati necessari a disegnare
int deltaX = (ObjW / 2 - StartPoint);
int deltaY = ObjH / 3;
// inizio aggiungendo punti parametrici
pathPointList.Add(new PointData(StartPoint, ObjH + 5));
pathPointList.Add(new PointData((int)(StartPoint - deltaX * 0.19), ObjH - (deltaY / 2)));
pathPointList.Add(new PointData((int)(StartPoint + deltaX * 0.26), ObjH - deltaY));
pathPointList.Add(new PointData((int)(ObjW / 2 - deltaX * 0.48 ), (int)((ObjH / 2) + deltaY * 0.216)));
pathPointList.Add(new PointData(ObjW / 2, ObjH / 2));
pathPointList.Add(new PointData((int)(ObjW / 2 + deltaX * 0.48 ), (int)((ObjH / 2) - deltaY * 0.216)));
pathPointList.Add(new PointData((int)(ObjW - (StartPoint + deltaX * 0.26)), deltaY));
pathPointList.Add(new PointData((int)(ObjW - (StartPoint - deltaX * 0.19)), (deltaY / 2)));
pathPointList.Add(new PointData(ObjW - StartPoint, - 5));
// ora provvedo x la parte clip
pathClipCloseList.Add(new PointData(ObjW - StartPoint, 0));
pathClipCloseList.Add(new PointData(ObjW, 0));
pathClipCloseList.Add(new PointData(ObjW, ObjH));
pathClipCloseList.Add(new PointData(StartPoint, ObjH));
}
protected List<PointData> pathPointList = new List<PointData>();
protected List<PointData> pathClipCloseList = new List<PointData>();
#endregion Protected Methods
#region Protected Classes
protected class PointData
{
#region Public Constructors
public PointData(int valx, int valy)
{
px = valx;
py = valy;
}
#endregion Public Constructors
#region Public Properties
public int px { get; set; } = 0;
public int py { get; set; } = 0;
#endregion Public Properties
}
protected async Task raiseEvent(string? retPage)
{
retPage = retPage ?? "Home";
await EC_ExeFunct.InvokeAsync(retPage);
}
#endregion Protected Classes
}
}