Copiato codice da componente WebWindowTest a WebWindowComplex

This commit is contained in:
Annamaria Sassi
2025-09-19 13:16:15 +02:00
parent 51e6695079
commit 1dcb0ba15b
14 changed files with 819 additions and 504 deletions
+161 -69
View File
@@ -4,7 +4,7 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Reflection.Metadata;
using System.Runtime.InteropServices;
using WebWindow.Base;
using WebWindowComplex;
using WebWindowComplex.DTO;
using WebWindowComplex.Json;
using static WebWindowComplex.Json.WindowConst;
@@ -28,17 +28,19 @@ namespace WebWindowComplex
public EventCallback<Dictionary<string, string>> EC_OnUpdate { get; set; }
[Parameter]
public Template IN_SelTemplate
public string CurrJwd
{
get => m_SelTemplate;
get => m_CurrJwd;
set
{
// Se non ho ancora selezionato template oppure se cambio template di selezione
if (value != null && (m_SelTemplate == null || (m_SelTemplate != null && value.nIndex != m_SelTemplate.nIndex)) && !string.IsNullOrEmpty(value.JWD))
if (m_CurrJwd != value && value != "")
{
m_SelTemplate = value;
m_CurrJwd = value;
SelFamilyHardware = IN_SelFamilyHardware;
JsonWindow WindowFromJson = JsonConvert.DeserializeObject<JsonWindow>(m_SelTemplate.JWD, new PolymorphicJsonConverter()) ?? new JsonWindow("");
SelColorMaterial = IN_SelColorMaterial ?? "";
SelMaterial = IN_SelMaterial ?? "";
SelGlass = IN_SelGlass ?? "";
JsonWindow WindowFromJson = JsonConvert.DeserializeObject<JsonWindow>(m_CurrJwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", "");
if (m_CurrWindow != null)
{
m_CurrWindow.OnPreview -= M_CurrWindow_OnPreview;
@@ -65,7 +67,57 @@ namespace WebWindowComplex
m_FillList = new List<Fill>();
m_SashList = new List<Sash>();
m_SplitList = new List<Split>();
m_SplitParentList = new List<SplitParent>();
//m_SplitParentList = new List<SplitParent>();
m_SplittedList = new List<Splitted>();
m_ItemTableList = new List<ItemTable>();
CreateWindowsList(m_CurrWindow.AreaList[0], false);
CreateElementTable(m_CurrWindow.AreaList[0], 1, 1, 1, 1);
}
}
}
[Parameter]
public Template IN_SelTemplate
{
get => m_SelTemplate;
set
{
// Se non ho ancora selezionato template oppure se cambio template di selezione
if (value != null && (m_SelTemplate == null || (m_SelTemplate != null && value.nIndex != m_SelTemplate.nIndex)) && !string.IsNullOrEmpty(value.JWD))
{
m_SelTemplate = value;
SelFamilyHardware = IN_SelFamilyHardware;
SelColorMaterial = IN_SelColorMaterial ?? "";
SelMaterial = IN_SelMaterial ?? "";
SelGlass = IN_SelGlass ?? "";
JsonWindow WindowFromJson = JsonConvert.DeserializeObject<JsonWindow>(m_SelTemplate.JWD, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", "");
if (m_CurrWindow != null)
{
m_CurrWindow.OnPreview -= M_CurrWindow_OnPreview;
m_CurrWindow = null;
}
Sash.m_HardwareCompleteList = IN_HardwareList;
Sash.s_FamilyHardwareList = IN_FamilyHardwareList;
Sash.s_SelFamilyHW = IN_SelFamilyHardware;
m_CurrWindow = WindowFromJson.Deserialize();
m_CurrWindow.OnPreview += M_CurrWindow_OnPreview;
// recupero dimensioni Frame e Joint 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)
{
m_maxCol = 0;
m_maxRow = 0;
m_FillList = new List<Fill>();
m_SashList = new List<Sash>();
m_SplitList = new List<Split>();
//m_SplitParentList = new List<SplitParent>();
m_SplittedList = new List<Splitted>();
m_ItemTableList = new List<ItemTable>();
CreateWindowsList(m_CurrWindow.AreaList[0], false);
@@ -81,10 +133,28 @@ namespace WebWindowComplex
public List<string> IN_FamilyHardwareList { get; set; } = null!;
[Parameter]
public string? IN_SelFamilyHardware { get; set; } = null;
public string IN_SelFamilyHardware { get; set; } = null!;
[Parameter]
public List<Hardware>? IN_HardwareList { get; set; } = null;
public List<Hardware> IN_HardwareList { get; set; } = null!;
[Parameter]
public List<string> IN_ColorMaterialList { get; set; } = null!;
[Parameter]
public string? IN_SelColorMaterial { get; set; } = null;
[Parameter]
public List<string> IN_MaterialList { get; set; } = null!;
[Parameter]
public string? IN_SelMaterial { get; set; } = null;
[Parameter]
public List<string> IN_GlassList { get; set; } = null!;
[Parameter]
public string? IN_SelGlass { get; set; } = null;
[Parameter]
public string LiveSVG
@@ -121,16 +191,6 @@ namespace WebWindowComplex
General
}
protected enum ColorWindow
{
Bianco = 0,
Grigio = 1,
Tortora,
Blu,
Verde,
Nero
}
protected enum positionJoints
{
BL = 0, // Bottom Left
@@ -148,7 +208,7 @@ namespace WebWindowComplex
get => m_Frame;
set => m_Frame = value;
}
protected string m_CurrJwd { get; set; }
protected string m_SelSVG { get; set; } = "";
/// <summary>
@@ -180,10 +240,10 @@ namespace WebWindowComplex
{
get => m_SplittedList;
}
protected List<SplitParent> SplitParentList
{
get => m_SplitParentList;
}
//protected List<SplitParent> SplitParentList
//{
// get => m_SplitParentList;
//}
protected List<ItemTable> ItemTableList
{
get => m_ItemTableList;
@@ -213,20 +273,36 @@ namespace WebWindowComplex
}
}
}
protected string SelColorMaterial { get; set; } = null;
protected string SelMaterial { get; set; } = null;
protected string SelGlass { get; set; } = null;
#endregion Protected Properties
#region Protected Methods
protected override async Task OnInitializedAsync()
{
if (string.IsNullOrEmpty(CurrJwd))
{
currStep = CompileStep.Template;
}
else
{
currStep = CompileStep.Gerarchia;
}
await DoPreviewSvg();
}
/// <summary>
/// Metodo per la scelta della maniglia univoca
/// </summary>
/// <param name="sashDim"></param>
/// <returns></returns>
protected async Task changeHandle(SashDimension sashDim)
protected void changeHandle(SashDimension sashDim)
{
//if(m_SashList[0].AreaList.Count < 3)
//{
foreach (SashDimension item in SashList[0].SashList)
{
if (item.Equals(sashDim))
@@ -238,8 +314,6 @@ namespace WebWindowComplex
item.bHasHandle = false;
}
}
//}
await Task.Delay(1);
}
// Ancora da fare...
@@ -270,7 +344,14 @@ namespace WebWindowComplex
protected async Task DoReset()
{
SelFamilyHardware = IN_SelFamilyHardware;
JsonWindow WindowFromJson = JsonConvert.DeserializeObject<JsonWindow>(m_SelTemplate.JWD, new PolymorphicJsonConverter()) ?? new JsonWindow("");
SelColorMaterial = IN_SelColorMaterial ?? "";
SelMaterial = IN_SelMaterial ?? "";
SelGlass = IN_SelGlass ?? "";
JsonWindow WindowFromJson;
if (string.IsNullOrEmpty(CurrJwd))
WindowFromJson = JsonConvert.DeserializeObject<JsonWindow>(m_SelTemplate.JWD, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", "");
else
WindowFromJson = JsonConvert.DeserializeObject<JsonWindow>(m_CurrJwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", "");
if (m_CurrWindow != null)
{
m_CurrWindow.OnPreview -= M_CurrWindow_OnPreview;
@@ -282,7 +363,7 @@ namespace WebWindowComplex
m_SashList = new List<Sash>();
m_SplitList = new List<Split>();
m_SplittedList = new List<Splitted>();
m_SplitParentList = new List<SplitParent>();
//m_SplitParentList = new List<SplitParent>();
m_ItemTableList = new List<ItemTable>();
m_maxCol = 0;
m_maxRow = 0;
@@ -377,7 +458,7 @@ namespace WebWindowComplex
{
case AreaTypes.FRAME:
{
if(node.AreaList.Count >= 1)
if (node.AreaList.Count >= 1)
ItemTableList.Add(new ItemTable(AreaTypes.FRAME, "FR", row, col, -1, node.AreaList.Count));
else
ItemTableList.Add(new ItemTable(AreaTypes.FRAME, "FR", row, col, -1, 0));
@@ -393,12 +474,12 @@ namespace WebWindowComplex
if ((node.ParentArea.ParentArea != null && node.ParentArea.ParentArea.AreaList.Count > 1) ||
(node.ParentArea != null && node.ParentArea.AreaList.Count > 1))
{
for(int i = 0; i < SashList.Count; i++)
for (int i = 0; i < SashList.Count; i++)
{
if (SashList[i].Equals(node))
{
// Se il nodo ha figli, salvo il numero nell'oggetto
if(node.AreaList.Count >= 1)
if (node.AreaList.Count >= 1)
ItemTableList.Add(new ItemTable(AreaTypes.SASH, "SH", maxRow, col, i, node.AreaList.Count));
else
ItemTableList.Add(new ItemTable(AreaTypes.SASH, "SH", maxRow, col, i, 0));
@@ -422,7 +503,7 @@ namespace WebWindowComplex
}
case AreaTypes.FILL:
{
if((node.ParentArea.AreaList.Count > 1 && node.ParentArea.AreaList[0].Equals(node)) ||
if ((node.ParentArea.AreaList.Count > 1 && node.ParentArea.AreaList[0].Equals(node)) ||
(node.ParentArea.ParentArea != null && node.ParentArea.ParentArea.AreaList.Count > 1 && node.ParentArea.ParentArea.AreaList[0].AreaList[0].Equals(node)))
maxCol++;
ItemTableList.Add(new ItemTable(AreaTypes.FILL, "FL", maxRow, col, -1, 0));
@@ -436,7 +517,7 @@ namespace WebWindowComplex
if (node.ParentArea.AreaList.Count > 1 || (node.ParentArea.ParentArea != null && node.ParentArea.ParentArea.AreaList.Count > 1))
{
if (node.ParentArea.AreaList[0].Equals(node) || node.ParentArea.ParentArea.AreaList[0].Equals(node))
maxCol ++;
maxCol++;
if (node.AreaList.Count >= 1 || node.AreaList.Count >= 1)
ItemTableList.Add(new ItemTable(AreaTypes.SPLIT, "SP", maxRow, col, -1, node.AreaList.Count));
else
@@ -468,7 +549,7 @@ namespace WebWindowComplex
CreateElementTable(item, row, col, maxRow, maxCol);
}
}
if(maxCol> m_maxCol)
if (maxCol > m_maxCol)
{
m_maxCol = maxCol;
}
@@ -477,13 +558,13 @@ namespace WebWindowComplex
m_maxRow = maxRow;
}
}
private string fillTable(int row, int col)
{
List<ItemTable> itemSameCol = new List<ItemTable>();
for(int k = 0; k < row; k++)
for (int k = 0; k < row; k++)
{
if(ItemTableList[k].Col == col+1)
if (ItemTableList[k].Col == col + 1)
{
itemSameCol.Add(ItemTableList[k]);
}
@@ -509,10 +590,10 @@ namespace WebWindowComplex
if (itemSameCol.Count > 0)
{
// Sono alla riga successiva di un elemento e nella stessa colonna
if(itemSameCol.Last().Row == row)
if (itemSameCol.Last().Row == row)
{
// se ha un solo figlio
if(itemSameCol.Last().NumChild == 1)
if (itemSameCol.Last().NumChild == 1)
{
return "└";
}
@@ -529,7 +610,7 @@ namespace WebWindowComplex
else
{
// se ha un solo figlio
if(itemSameCol.Last().NumChild == 1)
if (itemSameCol.Last().NumChild == 1)
{
return " ";
}
@@ -561,9 +642,9 @@ namespace WebWindowComplex
/// Metodo per settare tutti i Joints di Frame o Sash come ANGLED o FULL_H o FULL_V
/// </summary>
/// <param name="n_type"> tipo di giunzione (ANGLED o FULL_H o FULL_V)</param>
/// <param name="n_place"> oggetto a cui essere applicato (Frame o Sash)</param>
/// <param name="area"> area su cui eseguire la funzione (Frame o Sash)</param>
/// <returns></returns>
private async Task AllJointsFrame(int n_type, int n_place)
private async Task AllJointsFrame(int n_type, Area area)
{
Joints type = Joints.ANGLED;
if (n_type == 2)
@@ -574,16 +655,17 @@ namespace WebWindowComplex
{
type = Joints.FULL_V;
}
if (n_place == 0)
if (area is Frame)
{
foreach (Joint joint in FrameWindow.JointList)
{
joint.SetSelJointType(type);
}
}
else if (n_place == 1)
else
{
foreach (Joint joint in m_SashList[0].JointList)
Sash s = (Sash)area;
foreach (Joint joint in s.JointList)
{
joint.SetSelJointType(type);
}
@@ -616,20 +698,26 @@ namespace WebWindowComplex
/// <param name="sashItem">Sash dove si torva anta </param>
/// <param name="IndexCopy">Indice dell'anta che si copia</param>
/// <param name="IndexModify">Indice dell'anta che si modifica</param>
private async Task CopyContent(Sash sashItem, int IndexCopy, int IndexModify)
private async Task CopyContentSash(Sash sashItem, int IndexCopy, int IndexModify)
{
// Anta selezionata
Area sashSplitted = sashItem.AreaList[IndexModify];
// Rimuovo riempimento da anta selezionata
sashSplitted.AreaList.RemoveAt(0);
// Creo la copia dell'anta scelta
Area a = sashItem.AreaList[IndexCopy-1].AreaList[0].Copy(sashSplitted);
Area a = sashItem.AreaList[IndexCopy - 1].AreaList[0].Copy(sashSplitted);
// Aggiungo copia all'anta selezionata
sashItem.AreaList[IndexModify].AreaList.Add(a);
await DoPreviewSvg();
}
private async Task CopySplitted(Splitted currSplitted, int numSash)
/// <summary>
/// Metodo per copiare una sash intera
/// </summary>
/// <param name="currSplitted"></param>
/// <param name="numSash"></param>
/// <returns></returns>
private async Task CopySash(Splitted currSplitted, int numSash)
{
//Rimuovo contenuto di Splitted
currSplitted.AreaList.RemoveAll(i => i != null);
@@ -650,13 +738,10 @@ namespace WebWindowComplex
#endregion Protected Methods
#region Private Fields
private CompileStep currStep = CompileStep.Template;
private CompileStep currStep;
private int currSash = -1;
private ColorWindow currColorWin = ColorWindow.Bianco;
private Frame m_Frame;
private List<Sash> m_SashList = new List<Sash>();
@@ -669,7 +754,7 @@ namespace WebWindowComplex
private List<ItemTable> m_ItemTableList = new List<ItemTable>();
private List<SplitParent> m_SplitParentList = new List<SplitParent>();
//private List<SplitParent> m_SplitParentList = new List<SplitParent>();
private int m_maxCol = 0;
private int m_maxRow = 0;
@@ -700,12 +785,6 @@ namespace WebWindowComplex
currSash = -1;
}
private void ChangeColorWindow(ColorWindow newColorWin)
{
currColorWin = newColorWin;
}
private void M_CurrWindow_OnPreview(object? sender, OnPreviewEventArgs e)
{
Dictionary<string, string> Args = new Dictionary<string, string>();
@@ -735,13 +814,8 @@ namespace WebWindowComplex
return (testStep == currStep) ? "nav-link active fw-bold" : "nav-link text-secondary";
}
private string buttonCss(ColorWindow testColor)
{
return testColor.Equals(currColorWin) ? "btn btn-outline-secondary active" : "btn btn-outline-secondary";
}
/// <summary>
/// Calcola larghezza colonna da mostrare
/// Calcola larghezza colonna contenente nav da mostrare
/// </summary>
/// <returns></returns>
private string mainCss()
@@ -749,6 +823,24 @@ namespace WebWindowComplex
return (currStep == CompileStep.Template) ? "col-12" : "col-6";
}
/// <summary>
/// Calcola larghezza colonna header nav
/// </summary>
/// <returns></returns>
private string headerCss()
{
return (currStep == CompileStep.Template) ? "col-10 d-grid gap-1 px-2 d-md-flex justify-content-md-start" : "col-8 d-grid gap-1 px-2 d-md-flex justify-content-md-start";
}
/// <summary>
/// Calcola larghezza colonna button nav
/// </summary>
/// <returns></returns>
private string buttonCss()
{
return (currStep == CompileStep.Template) ? "col-2 d-grid gap-1 d-md-flex justify-content-md-end" : "col-4 d-grid gap-1 d-md-flex justify-content-md-end";
}
#endregion Private Methods
}
}