Files
webwindowconfigurator/WebWindowComplex/Compo/EditElement.razor.cs
T
2026-08-20 16:30:29 +02:00

143 lines
3.9 KiB
C#

using Microsoft.AspNetCore.Components;
using WebWindowComplex.Models;
namespace WebWindowComplex.Compo
{
public partial class EditElement
{
#region Public Properties
/// <summary>
/// Joint corrente
/// </summary>
[Parameter]
public ElementDimension CurrRec { get; set; } = null!;
/// <summary>
/// Vocabolario con traduzione lingua corrente
/// </summary>
[CascadingParameter(Name = "Vocabulary")]
public Dictionary<string, string> Vocabulary { get; set; } = null!;
[Parameter]
public EventCallback<ElementDimension> EC_Update { get; set; }
[Parameter]
public bool IsBottomRail { get; set; } = false;
/// <summary>
/// Livello di accesso (utente base)
/// </summary>
[CascadingParameter(Name = "User")]
public bool BaseUser { get; set; } = false!;
#endregion Public Properties
#region Protected Methods
protected override void OnParametersSet()
{
ElementDict = Vocabulary.Where(x => x.Key.Contains("CWElem_")).ToDictionary(x => x.Key, y => y.Value);
}
#endregion Protected Methods
#region Private Fields
private Dictionary<string, string> ElementDict = new();
#endregion Private Fields
#region Private Properties
/// <summary>
/// Metodo per aggiornare element corrente
/// </summary>
private double updateVal
{
get => CurrRec.dDimension;
set
{
if (CurrRec.dDimension != value)
{
CurrRec.dDimension = value;
_ = EC_Update.InvokeAsync(CurrRec);
}
}
}
#endregion Private Properties
#region Private Methods
private string GetImageElementPath(string fileName) => $"_content/Egw.Lux.WebWindowComplex/icone/element/{fileName}.svg";
/// <summary>
/// Metodo per aggiornare nome element corrente
/// </summary>
private string name()
{
if (IsBottomRail)
{
return CurrRec.nIndex.ToString();
}
else
{
int nElement = 0;
if (CurrRec.ParentArea is Frame frame)
nElement = frame.ElementDimensionList.Count;
else if (CurrRec.ParentArea is Sash sash)
nElement = sash.SashList.FirstOrDefault()!.ElementDimensionList.Count;
switch (CurrRec.nIndex)
{
case 1:
{
return "Bottom";
}
case 2:
{
return "Right";
}
case 3:
{
return "Top";
}
case 4:
case 5:
case 6:
{
return "Left";
}
}
}
return "";
}
/// <summary>
/// Metodo per determinare il titolo
/// </summary>
/// <returns></returns>
private string Title()
{
return "Min: " + CurrRec.dMinDim + ", Max: " + CurrRec.dMaxDim;
}
/// <summary>
/// Metodo per traduzione in lingua corrente
/// </summary>
/// <param name="lemma"></param>
/// <returns></returns>
private string Traduci(string lemma)
{
string ans = lemma;
if (ElementDict != null && ElementDict.ContainsKey(lemma))
{
ans = ElementDict.GetValueOrDefault(lemma) ?? "";
}
return ans;
}
#endregion Private Methods
}
}