using Microsoft.AspNetCore.Components; using Newtonsoft.Json.Linq; using WebWindowComplex.Json; using WebWindowComplex.Models; using static WebWindowComplex.LayoutConst; namespace WebWindowComplex.Compo { public partial class EditJoint { #region Public Properties /// /// Joint corrente /// [Parameter] public Joint CurrRec { get; set; } = null!; [Parameter] public EventCallback EC_Update { get; set; } /// /// Livello di accesso (utente base) /// [CascadingParameter(Name = "User")] public bool User { get; set; } = false!; #endregion Public Properties private bool isOpen = false; private bool isOpenDropdown = false; #region Private Properties private string GetImageJointPosPath(string fileName) => $"_content/Egw.Lux.WebWindowComplex/icone/joint/position/{fileName}.svg"; private string GetImageJointShapePath(string fileDir, string fileName) => $"_content/Egw.Lux.WebWindowComplex/icone/joint/shape/{fileDir}/{fileName}.svg"; /// /// Metodo per aggiornare joint corrente /// private int CurrJoint { get => CurrRec.SelJointTypeIndex; set { if (CurrRec.SelJointTypeIndex != value) { CurrRec.SelJointTypeIndex = value; _ = EC_Update.InvokeAsync(CurrRec); } } } private string CurrJointName { get => CurrRec.JointTypeList.FirstOrDefault(x=>x.Id == CurrRec.SelJointTypeIndex).Name; } private string CurrPosJointName { get => ((PositionJoints)(CurrRec.nIndex - 1)).ToString(); } private async Task HandleFocusOut() { // Un piccolo delay assicura che l'evento @onclick dell'item venga eseguito prima di chiudere il menu await Task.Delay(150); isOpen = false; } private void ToggleDropdownOpening() { isOpenDropdown = !isOpenDropdown; } /// /// Metodo per la visualizzazione dei pulsanti tipology /// /// /// private string ButtonOpeningCss(int index) { string ans = ""; if (CurrJoint == index) ans = "active"; return ans; } private async Task SelJoint(int index) { if (CurrRec.SelJointTypeIndex != index) { CurrRec.SelJointTypeIndex = index; await EC_Update.InvokeAsync(CurrRec); } } #endregion Private Properties } }