using Microsoft.AspNetCore.Components;
using WebWindowComplex.Models;
namespace WebWindowComplex.Compo
{
public partial class CardFrame
{
#region Public Properties
///
/// Evento per aggiungere sash
///
[Parameter]
public EventCallback EC_AddSash { get; set; }
///
/// Evento per aggiungere split
///
[Parameter]
public EventCallback EC_AddSplit { get; set; }
///
/// Evento per cambiare tutti i Joints
///
[Parameter]
public EventCallback EC_ChangeAllJoints { get; set; }
///
/// Evento per tornare nella pagine Tree
///
[Parameter]
public EventCallback EC_ReqClose { get; set; }
///
/// Evento per richiedere reset dizionario Shape
///
[Parameter]
public EventCallback EC_ReqResetDictShape { get; set; }
///
/// Evento per aggiornare info frame (es cambaire tutti i Joints)
///
[Parameter]
public EventCallback EC_UpdateFrame { get; set; }
///
/// Evento per richiesta calcolo Shape
///
[Parameter]
public EventCallback EC_UpdateShape { get; set; }
///
/// Frame corrente
///
[Parameter]
public Frame FrameWindow { get; set; } = null!;
///
/// Lista di sash
///
[Parameter]
public List SashList { get; set; } = null!;
///
/// Lista di split
///
[Parameter]
public List 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
///
/// Sollevo evento richiesta aggiunta sash
///
///
private async Task AddSash()
{
//await EC_UpdateShape.InvokeAsync(FrameWindow);
await EC_AddSash.InvokeAsync(true);
}
///
/// Sollevo evento richiesta aggiunta window
///
///
private async Task AddSplit()
{
await EC_AddSplit.InvokeAsync(true);
}
///
/// Sollevo evento richiesta copia sash
///
///
private async Task ChangeAllJoints(Json.WindowConst.Joints JointType, Area a)
{
var Args = new DataChangeJoints
{
currJointType = JointType,
currArea = a,
};
await EC_ChangeAllJoints.InvokeAsync(Args);
}
///
/// Sollevo evento per tornare alla pagina Tree
///
private void ReqClose()
{
_ = EC_ReqClose.InvokeAsync(true);
}
///
/// Aggiornamento dimensione editata
///
///
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);
}
}
///
/// Report aggiornamento joint
///
///
///
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
}
///
/// Classe per raggruppare oggetti che servono per copiare Sash
///
public class DataChangeJoints
{
#region Public Properties
public Area currArea { get; set; } = null!;
public Json.WindowConst.Joints currJointType { get; set; }
#endregion Public Properties
}
}