Files
webwindowconfigurator/WebWindowComplex/Compo/CardFrame.razor.cs
T
2025-11-07 10:36:56 +01:00

188 lines
5.4 KiB
C#

using Microsoft.AspNetCore.Components;
using WebWindowComplex.Models;
namespace WebWindowComplex.Compo
{
public partial class CardFrame
{
#region Public Properties
/// <summary>
/// Evento per aggiungere sash
/// </summary>
[Parameter]
public EventCallback<bool> EC_AddSash { get; set; }
/// <summary>
/// Evento per aggiungere split
/// </summary>
[Parameter]
public EventCallback<bool> EC_AddSplit { get; set; }
/// <summary>
/// Evento per cambiare tutti i Joints
/// </summary>
[Parameter]
public EventCallback<DataChangeJoints> EC_ChangeAllJoints { get; set; }
/// <summary>
/// Evento per tornare nella pagine Tree
/// </summary>
[Parameter]
public EventCallback<bool> EC_ReqClose { get; set; }
/// <summary>
/// Evento per richiedere reset dizionario Shape
/// </summary>
[Parameter]
public EventCallback<bool> EC_ReqResetDictShape { get; set; }
/// <summary>
/// Evento per aggiornare info frame (es cambaire tutti i Joints)
/// </summary>
[Parameter]
public EventCallback<Frame> EC_UpdateFrame { get; set; }
/// <summary>
/// Evento per richiesta calcolo Shape
/// </summary>
[Parameter]
public EventCallback<Frame> EC_UpdateShape { get; set; }
/// <summary>
/// Frame corrente
/// </summary>
[Parameter]
public Frame FrameWindow { get; set; } = null!;
/// <summary>
/// Lista di sash
/// </summary>
[Parameter]
public List<Sash> SashList { get; set; } = null!;
/// <summary>
/// Lista di split
/// </summary>
[Parameter]
public List<Split> SplitList { get; set; } = null!;
#endregion Public Properties
#region Protected Properties
protected int SelShapeIndex
{
get => FrameWindow.SelShapeIndex;
set
{
if (FrameWindow.SelShapeIndex != value)
{
FrameWindow.SelShapeIndex = value;
// richiesta reset dict shape
_ = EC_ReqResetDictShape.InvokeAsync(true);
foreach(var s in SashList)
{
s.SelHardwareFromId = "000000";
}
_ = EC_UpdateFrame.InvokeAsync(FrameWindow);
_ = EC_UpdateShape.InvokeAsync(FrameWindow);
}
}
}
#endregion Protected Properties
#region Private Methods
/// <summary>
/// Sollevo evento richiesta aggiunta sash
/// </summary>
/// <returns></returns>
private async Task AddSash()
{
//await EC_UpdateShape.InvokeAsync(FrameWindow);
await EC_AddSash.InvokeAsync(true);
}
/// <summary>
/// Sollevo evento richiesta aggiunta window
/// </summary>
/// <returns></returns>
private async Task AddSplit()
{
await EC_AddSplit.InvokeAsync(true);
}
/// <summary>
/// Sollevo evento richiesta copia sash
/// </summary>
/// <returns></returns>
private async Task ChangeAllJoints(Json.WindowConst.Joints JointType, Area a)
{
var Args = new DataChangeJoints
{
currJointType = JointType,
currArea = a,
};
await EC_ChangeAllJoints.InvokeAsync(Args);
}
/// <summary>
/// Sollevo evento per tornare alla pagina Tree
/// </summary>
private void ReqClose()
{
_ = EC_ReqClose.InvokeAsync(true);
}
/// <summary>
/// Aggiornamento dimensione editata
/// </summary>
/// <param name="updRec"></param>
private async Task UpdateDim(FrameDimension updRec)
{
// cerco il record
var currRec = FrameWindow.DimensionList.FirstOrDefault(x => x.ParentFrame == updRec.ParentFrame && x.nIndex == updRec.nIndex);
// lo aggiorno
if (updRec != null)
{
currRec = updRec;
await EC_UpdateShape.InvokeAsync(FrameWindow);
await EC_UpdateFrame.InvokeAsync(FrameWindow);
}
}
/// <summary>
/// Report aggiornamento joint
/// </summary>
/// <param name="updRec"></param>
/// <returns></returns>
private async Task UpdateJoint(Joint updRec)
{
// cerco il record
var currRec = FrameWindow.JointList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex);
// lo aggiorno
if (updRec != null)
{
currRec = updRec;
await EC_UpdateFrame.InvokeAsync(FrameWindow);
}
}
#endregion Private Methods
}
/// <summary>
/// Classe per raggruppare oggetti che servono per copiare Sash
/// </summary>
public class DataChangeJoints
{
#region Public Properties
public Area currArea { get; set; } = null!;
public Json.WindowConst.Joints currJointType { get; set; }
#endregion Public Properties
}
}