using Microsoft.AspNetCore.Components; namespace WebDoorCreator.UI.Components.SvgComp { public partial class HwSvgObj { #region Public Enums /// /// Enum delle azioni associate al controllo /// public enum ActionReq { Minus, Plus, Select } #endregion Public Enums #region Public Properties [Parameter] public EventCallback EC_ExeFunct { get; set; } /// /// Path img da mostrare /// [Parameter] public string ImagePath { get; set; } = ""; [Parameter] public int ItemCount { get; set; } = 0; [Parameter] public string ItemName { get; set; } = ""; [Parameter] public string LineColor { get; set; } = "#00838F"; [Parameter] public int LineWidth { get; set; } = 8; [Parameter] public int ObjH { get; set; } = 204; [Parameter] public string ObjId { get; set; } = "0"; [Parameter] public int ObjW { get; set; } = 450; [Parameter] public string PlusColor { get; set; } = "#69FF69"; [Parameter] public bool ShowPlus { get; set; } = false; [Parameter] public bool Disabled { get; set; } = false; [Parameter] public string TextStyle { get; set; } = "font-size: 2.5em;"; [Parameter] public string TextCss { get; set; } = ""; [Parameter] public string PlusOpacity { get; set; } = "30%"; [Parameter] public string BgColorFrom { get; set; } = "#AFCFD1"; [Parameter] public string BgColorTo { get; set; } = "#92B2C4"; [Parameter] public bool ImageBig { get; set; } = false; #endregion Public Properties #region Protected Properties protected string cardClass { get => ItemCount > 0 ? "bg-primary text-light" : "bg-inactive"; } protected CircleData CircleImg { get; set; } = null!; protected CircleData CircleLine { get; set; } = null!; protected int LineDist { get; set; } = 20; protected int TextAreaHeight { get => (ObjH / 2 * 110 / 100); } protected int TextAreaWidth { get => ObjW - (ObjH * 90 / 100); } #endregion Protected Properties #region Protected Methods /// /// Invia evento principale /// /// Azione richiesta /// /// se true manda sempre EC_ExeFunct, altrimenti NON invia se showPlus attivo... /// protected void doExecFunc(ActionReq action, bool forceSend) { // invia la chiamata richiesta secondo configurazione... if (forceSend || !ShowPlus) { EC_ExeFunct.InvokeAsync(action); } } protected override void OnParametersSet() { setupGraphParams(); } #endregion Protected Methods #region Protected Classes protected class CircleData { #region Public Constructors public CircleData(int px, int py, int radius) { cx = px; cy = py; rad = radius; } #endregion Public Constructors #region Public Properties public int cx { get; set; } = 0; public int cy { get; set; } = 0; public int rad { get; set; } = 100; #endregion Public Properties } protected class LineData { #region Public Constructors public LineData(PointData pA, PointData pB) { p1 = pA; p2 = pB; } #endregion Public Constructors #region Public Properties public PointData p1 { get; set; } public PointData p2 { get; set; } #endregion Public Properties } 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 } #endregion Protected Classes #region Private Methods private void setupGraphParams() { // calcolo i dati del cerchi... CircleLine = new CircleData(ObjW - LineWidth - (ObjH / 2), ObjH / 2, (ObjH - LineWidth) / 2); CircleImg = new CircleData(ObjW - LineWidth - (ObjH / 2), ObjH / 2, (ObjH - 2 * LineWidth) / 2); LineDist = ObjH / 4; } #endregion Private Methods } }