Files
webwindowconfigurator/WebWindowComplex/Compo/EditJoint.razor.cs
T
Annamaria Sassi 809ff5a237 Aggiornamento
2026-08-13 14:48:23 +02:00

102 lines
2.8 KiB
C#

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
/// <summary>
/// Joint corrente
/// </summary>
[Parameter]
public Joint CurrRec { get; set; } = null!;
[Parameter]
public EventCallback<Joint> EC_Update { get; set; }
/// <summary>
/// Livello di accesso (utente base)
/// </summary>
[CascadingParameter(Name = "User")]
public bool BaseUser { 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";
/// <summary>
/// Metodo per aggiornare joint corrente
/// </summary>
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;
}
/// <summary>
/// Metodo per la visualizzazione dei pulsanti tipology
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
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
}
}