using Egw.Window.Data;
using Microsoft.AspNetCore.Components;
using WebWindowTest.Models;
namespace WebWindowTest.Compo
{
public partial class CardFrame
{
#region Public Properties
///
/// Evento per tornare nella pagine Tree
///
[Parameter]
public EventCallback EC_ReqClose { get; set; }
///
/// Evento per richiedere reset dizionario Shape
///
[Parameter]
public EventCallback EC_ReqResetDict { get; set; }
///
/// Evento per richiedere opzioni hardware
///
[Parameter]
public EventCallback EC_ReqOptionHw { get; set; }
///
/// Evento per richiesta calcolo preview
///
[Parameter]
public EventCallback EC_UpdateFrame { get; set; }
///
/// Frame corrente
///
[CascadingParameter(Name = "CurrFrameWindow")]
public Frame CurrFrameWindow { get; set; } = null!;
///
/// Lista di sash
///
[CascadingParameter(Name = "SashList")]
public List SashList { get; set; } = null!;
///
/// Lista di split
///
[CascadingParameter(Name = "SplitList")]
public List SplitList { get; set; } = null!;
#endregion Public Properties
#region Protected Properties
///
/// Metodo per selezionare shape
///
protected int SelShapeIndex
{
get => CurrFrameWindow.SelShapeIndex;
set
{
if (CurrFrameWindow.SelShapeIndex != value)
{
CurrFrameWindow.SelShapeIndex = value;
// richiesta reset dict shape
_ = EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDictShape});
foreach(var s in SashList)
{
s.SelHardwareFromId = "000000";
}
var args = new DataUpdateFrame()
{
currFrame = CurrFrameWindow,
svgNoHw = true
};
_ = EC_UpdateFrame.InvokeAsync(args);
}
}
}
///
/// Metodo per selezionare threshold
///
protected int SelThreshold
{
get => CurrFrameWindow.SelThresholdFromType;
}
///
/// Selezione quantità bottom rail
///
protected int FrameBottomRailQty
{
get => CurrFrameWindow.BottomRailQty;
set
{
if (CurrFrameWindow.BottomRailQty != value)
{
CurrFrameWindow.BottomRailQty = value;
if (CurrFrameWindow.BottomRailQty > 0)
CurrFrameWindow.SetBottomRail(true);
else
CurrFrameWindow.SetBottomRail(false);
var args = new DataUpdateFrame()
{
currFrame = CurrFrameWindow,
svgNoHw = false
};
_ = EC_UpdateFrame.InvokeAsync(args);
}
}
}
#endregion Protected Properties
#region Private Methods
///
/// Metodo per cambiare tutti i joint
///
///
private async Task ChangeAllJoints(Json.WindowConst.Joints JointType, Area a)
{
if (a is Frame)
{
foreach (Joint joint in CurrFrameWindow.JointList)
{
joint.SetSelJointType(JointType);
}
}
var args = new DataUpdateFrame()
{
currFrame = CurrFrameWindow,
svgNoHw = false
};
await EC_UpdateFrame.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 = CurrFrameWindow.DimensionList.FirstOrDefault(x => x.ParentFrame == updRec.ParentFrame && x.nIndex == updRec.nIndex);
// lo aggiorno
if (updRec != null)
{
currRec = updRec;
var args = new DataUpdateFrame()
{
currFrame = CurrFrameWindow,
svgNoHw = true
};
await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDictShape });
await EC_UpdateFrame.InvokeAsync(args);
}
}
///
/// Aggiornamento joint
///
///
///
private async Task UpdateJoint(Joint updRec)
{
// cerco il record
var currRec = CurrFrameWindow.JointList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex);
// lo aggiorno
if (updRec != null)
{
currRec = updRec;
var args = new DataUpdateFrame()
{
currFrame = CurrFrameWindow,
svgNoHw = false
};
await EC_UpdateFrame.InvokeAsync(args);
}
}
///
/// Metodo per la visualizzazione dei pulsanti joint
///
///
///
private string ButtonJointCss(WebWindowTest.Json.WindowConst.Joints type)
{
foreach (var item in CurrFrameWindow.JointList)
{
if (!item.SelJointType.Equals(type))
return "btn btn-outline-secondary btn-sm";
}
return "btn btn-secondary btn-sm";
}
#endregion Private Methods
}
///
/// Classe per raggruppare oggetti che servono per aggiornare frame
///
public class DataUpdateFrame
{
#region Public Properties
public Frame currFrame { get; set; } = null!;
public bool svgNoHw { get; set; } = false;
#endregion Public Properties
}
}