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

114 lines
3.2 KiB
C#

using Microsoft.AspNetCore.Components;
using WebWindowComplex.Models;
namespace WebWindowComplex.Compo
{
public partial class BottomRail
{
#region Public Properties
[Parameter]
public Area CurrArea { get; set; } = null!;
/// <summary>
/// Vocabolario con traduzione lingua corrente
/// </summary>
[CascadingParameter(Name = "Vocabulary")]
public Dictionary<string, string> Vocabulary { get; set; } = null!;
[Parameter]
public EventCallback<DataBottomRail> EC_UpdateBottomRail { get; set; }
#endregion Public Properties
#region Protected Methods
protected override void OnParametersSet()
{
BottomRDict = Vocabulary.Where(x => x.Key.Contains("CWBottomR_")).ToDictionary(x => x.Key, y => y.Value);
}
#endregion Protected Methods
#region Private Fields
private Dictionary<string, string> BottomRDict = new();
#endregion Private Fields
#region Private Properties
/// <summary>
/// Aggiornamento element Bottom Rail
/// </summary>
/// <param name="updRec"></param>
/// <returns></returns>
private async Task UpdateElement(ElementDimension updRec)
{
if (updRec != null)
{
DataBottomRail ans = new();
ElementDimension? currRec = new(CurrArea, -1, 0);
if (CurrFrame() != null)
{
// cerco il record
currRec = CurrFrame()!.BottomRailElemDimList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex);
}
else if(CurrSash() != null)
{
// cerco il record
currRec = CurrSash()!.BottomRailElemDimList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex);
}
if (currRec != null)
{
currRec = updRec;
ans = new DataBottomRail
{
frame = CurrFrame(),
sash = CurrSash()
};
}
await EC_UpdateBottomRail.InvokeAsync(ans);
}
}
private Frame? CurrFrame()
{
if(CurrArea is Frame frame)
return frame;
else
return null;
}
private Sash? CurrSash()
{
if (CurrArea is Sash sash)
return sash;
else
return null;
}
/// <summary>
/// Metodo per traduzione in lingua corrente
/// </summary>
/// <param name="lemma"></param>
/// <returns></returns>
private string Traduci(string lemma)
{
string ans = lemma;
if (BottomRDict != null && BottomRDict.ContainsKey(lemma))
{
ans = BottomRDict.GetValueOrDefault(lemma) ?? "";
}
return ans;
}
#endregion Private Properties
}
public class DataBottomRail
{
public Sash? sash { get; set; }
public Frame? frame { get; set; }
}
}