224 lines
6.8 KiB
C#
224 lines
6.8 KiB
C#
using Egw.Window.Data;
|
|
using Microsoft.AspNetCore.Components;
|
|
using WebWindowTest.Models;
|
|
|
|
namespace WebWindowTest.Compo
|
|
{
|
|
public partial class CardFrame
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <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<DataUpdateRes> EC_ReqResetDict { get; set; }
|
|
|
|
/// <summary>
|
|
/// Evento per richiedere opzioni hardware
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<Frame> EC_ReqOptionHw { get; set; }
|
|
|
|
/// <summary>
|
|
/// Evento per richiesta calcolo preview
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<DataUpdateFrame> EC_UpdateFrame { get; set; }
|
|
|
|
/// <summary>
|
|
/// Frame corrente
|
|
/// </summary>
|
|
[CascadingParameter(Name = "CurrFrameWindow")]
|
|
public Frame CurrFrameWindow { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Lista di sash
|
|
/// </summary>
|
|
[CascadingParameter(Name = "SashList")]
|
|
public List<Sash> SashList { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Lista di split
|
|
/// </summary>
|
|
[CascadingParameter(Name = "SplitList")]
|
|
public List<Split> SplitList { get; set; } = null!;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Properties
|
|
|
|
/// <summary>
|
|
/// Metodo per selezionare shape
|
|
/// </summary>
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per selezionare threshold
|
|
/// </summary>
|
|
protected int SelThreshold
|
|
{
|
|
get => CurrFrameWindow.SelThresholdFromType;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Selezione quantità bottom rail
|
|
/// </summary>
|
|
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
|
|
|
|
/// <summary>
|
|
/// Metodo per cambiare tutti i joint
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
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);
|
|
}
|
|
|
|
/// <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 = 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);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiornamento joint
|
|
/// </summary>
|
|
/// <param name="updRec"></param>
|
|
/// <returns></returns>
|
|
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);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo per la visualizzazione dei pulsanti joint
|
|
/// </summary>
|
|
/// <param name="type"></param>
|
|
/// <returns></returns>
|
|
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
|
|
}
|
|
|
|
/// <summary>
|
|
/// Classe per raggruppare oggetti che servono per aggiornare frame
|
|
/// </summary>
|
|
public class DataUpdateFrame
|
|
{
|
|
#region Public Properties
|
|
|
|
public Frame currFrame { get; set; } = null!;
|
|
public bool svgNoHw { get; set; } = false;
|
|
|
|
#endregion Public Properties
|
|
}
|
|
} |