using Egw.Window.Data;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.Net.Http.Headers;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Runtime.InteropServices;
using WebWindowComplex.DTO;
using WebWindowComplex.Json;
using static WebWindowComplex.Json.WindowConst;
namespace WebWindowComplex
{
public partial class TableComp : IDisposable
{
#region Public Properties
///
/// Classe override css x SVG (x rescale)
///
[Parameter]
public string CssSvg { get; set; } = "responsive-svg";
///
/// Preselezione valori
///
[Parameter]
public SelectPayload? CurrSelection { get; set; } = null;
///
/// Richiesta chiusura JWD (+ refresh)
/// se torna true --> richiesta salvataggio
/// se torna false --> richiesta revert
///
[Parameter]
public EventCallback EC_OnClose { get; set; }
///
/// Evento selezione template
///
[Parameter]
public EventCallback EC_OnSelectedTemplate { get; set; }
///
/// Richiesta refresh SVG da JWD
///
[Parameter]
public EventCallback> EC_OnUpdate { get; set; }
///
/// Elenco anagrafiche di base
///
[Parameter]
public BaseListPayload ListPayload { get; set; } = null!;
///
/// Dati live controllo (JWD, SVG, ...)
///
[Parameter]
public LivePayload LiveData { get; set; } = null!;
#endregion Public Properties
#if false
[Parameter]
public string CurrJwd
{
get => m_CurrJwd;
set
{
// Se viene passato un JWD
if (m_CurrJwd != value && value != "")
{
m_CurrJwd = value;
// Aggiornati parametri di ingresso selezionati
UpdateSelParameter();
JsonWindow WindowFromJson = JsonConvert.DeserializeObject(m_CurrJwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", "");
if (m_CurrWindow != null)
{
m_CurrWindow.OnPreview -= M_CurrWindow_OnPreview;
m_CurrWindow = null;
}
m_CurrWindow = WindowFromJson.Deserialize();
m_CurrWindow.OnPreview += M_CurrWindow_OnPreview;
// Recupero dimensioni Frame e Joint del frame della finestra precedente
if (m_PreviousWindow != null)
{
for (int i = 0; i < 2; i++)
m_CurrWindow.AreaList[0].DimensionList[i] = m_PreviousWindow.AreaList[0].DimensionList[i];
for (int i = 0; i < 4; i++)
m_CurrWindow.AreaList[0].JointList[i] = m_PreviousWindow.AreaList[0].JointList[i];
}
}
if (m_CurrWindow != null)
{
// Aggiornate liste di sash, split, splitted, fill e itemTable
UpdateLists();
}
}
}
[Parameter]
public string LiveSVG
{
get => m_SelSVG;
set => m_SelSVG = value;
}
#endif
#if false
[Parameter]
public Template IN_SelTemplate
{
get => m_SelTemplate;
set
{
// Se viene passato il template selezionato oppure se non è ancora stato selezionato un template oppure se si cambia template di selezione
if (value != null && (m_SelTemplate == null || (m_SelTemplate != null && value.nIndex != m_SelTemplate.nIndex)) && !string.IsNullOrEmpty(value.JWD))
{
m_SelTemplate = value;
// Aggiornamento parametri di ingresso selezionati
UpdateSelParameter();
JsonWindow WindowFromJson = JsonConvert.DeserializeObject(m_SelTemplate.JWD, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", "");
if (m_CurrWindow != null)
{
m_CurrWindow.OnPreview -= M_CurrWindow_OnPreview;
m_CurrWindow = null;
}
m_CurrWindow = WindowFromJson.Deserialize();
m_CurrWindow.OnPreview += M_CurrWindow_OnPreview;
// Recupero dimensioni Frame e Joint del frame della finestra precedente
if (m_PreviousWindow != null)
{
for (int i = 0; i < 2; i++)
m_CurrWindow.AreaList[0].DimensionList[i] = m_PreviousWindow.AreaList[0].DimensionList[i];
for (int i = 0; i < 4; i++)
m_CurrWindow.AreaList[0].JointList[i] = m_PreviousWindow.AreaList[0].JointList[i];
}
}
if (m_CurrWindow != null)
{
// Aggiornamento liste sash, split, splitted, fill e itemTable
UpdateLists();
}
}
}
[Parameter]
public List IN_TemplateDTOList { get; set; } = null!;
[Parameter]
public List IN_FamilyHardwareList { get; set; } = null!;
[Parameter]
public List IN_HardwareList { get; set; } = null!;
[Parameter]
public List IN_ColorMaterialList { get; set; } = null!;
[Parameter]
public List IN_MaterialList { get; set; } = null!;
[Parameter]
public List IN_GlassList { get; set; } = null!;
#endif
#if false
[Parameter]
public string IN_SelFamilyHardware { get; set; } = null!;
[Parameter]
public string? IN_SelColorMaterial { get; set; } = null;
[Parameter]
public string? IN_SelMaterial { get; set; } = null;
[Parameter]
public string? IN_SelGlass { get; set; } = null;
#endif
#region Public Methods
public void Dispose()
{
if (m_CurrWindow != null)
{
m_CurrWindow.OnPreview -= M_CurrWindow_OnPreview;
m_CurrWindow = null;
}
}
#endregion Public Methods
#region Protected Enums
protected enum CompileStep
{
Template = 0,
Tree = 1,
Frame,
Split,
Sash,
Fill,
General
}
protected enum PositionJoints
{
BL = 0, // Bottom Left
BR = 1, // Bottom Right
TR, // Top Right
TL // Top Left
}
#endregion Protected Enums
#region Protected Properties
protected List FillList
{
get => m_FillList;
}
protected Frame FrameWindow
{
get => m_Frame!;
set => m_Frame = value;
}
protected List ItemTableList
{
get => m_ItemTableList;
}
protected string? m_CurrJwd { get; set; }
protected string m_SelSVG { get; set; } = "";
///
/// Componente SVG da mostrare
///
protected MarkupString outSvg
{
get
{
// aggiunta gestione classe svg per posizionamento con costraints
var newSvg = LiveData.SvgPreview.Replace("