From 1baeeb1b1e0593a66ae9c8700afa2003eaca49ad Mon Sep 17 00:00:00 2001 From: Annamaria Sassi Date: Mon, 8 Sep 2025 18:43:28 +0200 Subject: [PATCH] aggiunti bottoni per copiare singola anta --- WebWindowComplex/ItemTable.cs | 39 ++++- WebWindowComplex/TableComp.razor | 79 +++++++--- WebWindowComplex/TableComp.razor.cs | 155 ++++++++++++++++-- WebWindowComplex/TableComp.razor.css | 1 + WebWindowComplex/Window.cs | 225 +++++++++++++++++++++------ 5 files changed, 410 insertions(+), 89 deletions(-) create mode 100644 WebWindowComplex/TableComp.razor.css diff --git a/WebWindowComplex/ItemTable.cs b/WebWindowComplex/ItemTable.cs index 22fcb83..2a4692c 100644 --- a/WebWindowComplex/ItemTable.cs +++ b/WebWindowComplex/ItemTable.cs @@ -61,19 +61,48 @@ namespace WebWindowComplex } } - public ItemTable( string s_description, int n_row, int n_col) + /// + /// Indica l'indice rispetto al vettore delle sash + /// Se non è una sash vale -1 + /// + private int m_numSash; + public int NumSash { - m_desc = s_description; - Row = n_row; - Col = n_col; + get + { + return m_numSash; + } + set + { + m_numSash = value; + } } - public ItemTable(AreaTypes elementType, string s_description,int n_row, int n_col) + /// + /// Indica il numero di figli + /// Se non ha figli vale -1 + /// + private int m_numChild; + public int NumChild + { + get + { + return m_numChild; + } + set + { + m_numChild = value; + } + } + + public ItemTable(AreaTypes elementType, string s_description,int n_row, int n_col, int n_numSash, int n_numChild) { Type = elementType; m_desc = s_description; Row = n_row; Col = n_col; + NumSash = n_numSash; + NumChild = n_numChild; } } } diff --git a/WebWindowComplex/TableComp.razor b/WebWindowComplex/TableComp.razor index 42d9072..2243e46 100644 --- a/WebWindowComplex/TableComp.razor +++ b/WebWindowComplex/TableComp.razor @@ -90,29 +90,50 @@ } else if (currStep == CompileStep.Gerarchia) { - - - @for (int i = 0; i < ItemTableList.Count; i++) - { - - @for (int j = 0; j < m_maxCol; j++) - { - @if (j + 1 == ItemTableList[i].Col) +
+
+ + @for (int i = 0; i < ItemTableList.Count; i++) + { + + @for (int j = 0; j < m_maxCol; j++) { - + CompileStep cs = CompileStep.Frame; + int indSash = -1; + @if (j + 1 == ItemTableList[i].Col) + { + @if (ItemTableList[i].Type is Json.WindowConst.AreaTypes.FRAME) + { + cs = CompileStep.Frame; + } + else if (ItemTableList[i].Type is Json.WindowConst.AreaTypes.SPLIT) + { + cs = CompileStep.Split; + } + else if (ItemTableList[i].Type is Json.WindowConst.AreaTypes.SASH) + { + cs = CompileStep.Sash; + indSash = ItemTableList[i].NumSash; + } + else if (ItemTableList[i].Type is Json.WindowConst.AreaTypes.FILL) + { + cs = CompileStep.Fill; + } + + } + else + { + + } } - else - { - - } - } - - - } - -
- - + + @fillTable(i, j) 
+ + } + + + + } else if (currStep == CompileStep.Frame) { @@ -462,6 +483,10 @@ } else if (currStep == CompileStep.Sash) { + @if (currSash > SashList.Count) + { + currStep = CompileStep.Gerarchia; + } Sash item = SashList[currSash];
@@ -547,6 +572,18 @@
+
+ @for (int k = 1; k <= i*2+j; k++) + { + int IndexCopy = k; + int IndexModify = i * 2 + j; +
+
+ +
+
+ } +
diff --git a/WebWindowComplex/TableComp.razor.cs b/WebWindowComplex/TableComp.razor.cs index 5314d39..db781f6 100644 --- a/WebWindowComplex/TableComp.razor.cs +++ b/WebWindowComplex/TableComp.razor.cs @@ -56,6 +56,7 @@ namespace WebWindowComplex if (m_CurrWindow != null) { m_maxCol = 0; + m_maxRow = 0; m_FillList = new List(); m_SashList = new List(); m_SplitList = new List(); @@ -238,10 +239,11 @@ namespace WebWindowComplex m_SplitParentList = new List(); m_ItemTableList = new List(); m_maxCol = 0; + m_maxRow = 0; // popolo le liste Fill, Sash e Split CreateWindowsList(m_CurrWindow.AreaList[0], false); CreateElementTable(m_CurrWindow.AreaList[0], 1, 1, 1, 1); - currSash = -1; + //currSash = -1; await DoPreviewSvg(); } @@ -329,7 +331,10 @@ namespace WebWindowComplex { case AreaTypes.FRAME: { - ItemTableList.Add(new ItemTable(AreaTypes.FRAME, "FR",row, col)); + 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)); row++; col++; maxRow++; @@ -338,15 +343,30 @@ namespace WebWindowComplex } case AreaTypes.SASH: { - if (node.ParentArea.AreaList.Count > 1) + // Se ha fratelli + if ((node.ParentArea.ParentArea != null && node.ParentArea.ParentArea.AreaList.Count > 1) || + (node.ParentArea != null && node.ParentArea.AreaList.Count > 1)) { - if (node.ParentArea.AreaList[0].Equals(node)) - maxCol++; - ItemTableList.Add(new ItemTable(AreaTypes.SASH, "SH", maxRow, col)); + 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) + 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)); + } + } + maxCol++; } else { - ItemTableList.Add(new ItemTable(AreaTypes.SASH, "SH", row, col)); + // Se il nodo ha figli, salvo il numero nell'oggetto + if (node.AreaList.Count >= 1) + ItemTableList.Add(new ItemTable(AreaTypes.SASH, "SH", row, col, 0, node.AreaList.Count)); + else + ItemTableList.Add(new ItemTable(AreaTypes.SASH, "SH", row, col, 0, 0)); maxCol++; } row++; @@ -356,11 +376,10 @@ 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++; - if(node.ParentArea.AreaList.Count > 1) - maxCol++; - ItemTableList.Add(new ItemTable(AreaTypes.FILL, "FL", row, col)); + ItemTableList.Add(new ItemTable(AreaTypes.FILL, "FL", maxRow, col, -1, 0)); row++; col++; maxRow++; @@ -368,15 +387,21 @@ namespace WebWindowComplex } case AreaTypes.SPLIT: { - if (node.ParentArea.AreaList.Count > 1) + if (node.ParentArea.AreaList.Count > 1 || (node.ParentArea.ParentArea != null && node.ParentArea.ParentArea.AreaList.Count > 1)) { - if (node.ParentArea.AreaList[0].Equals(node)) + if (node.ParentArea.AreaList[0].Equals(node) || node.ParentArea.ParentArea.AreaList[0].Equals(node)) maxCol ++; - ItemTableList.Add(new ItemTable(AreaTypes.SPLIT, "SP", maxRow, col)); + if (node.AreaList.Count >= 1 || node.AreaList.Count >= 1) + ItemTableList.Add(new ItemTable(AreaTypes.SPLIT, "SP", maxRow, col, -1, node.AreaList.Count)); + else + ItemTableList.Add(new ItemTable(AreaTypes.SPLIT, "SP", maxRow, col, -1, 0)); } else { - ItemTableList.Add(new ItemTable(AreaTypes.SPLIT, "SP", row, col)); + if (node.AreaList.Count >= 1 || node.AreaList.Count >= 1) + ItemTableList.Add(new ItemTable(AreaTypes.SPLIT, "SP", row, col, -1, node.AreaList.Count)); + else + ItemTableList.Add(new ItemTable(AreaTypes.SPLIT, "SP", row, col, -1, 0)); maxCol++; } row++; @@ -391,15 +416,100 @@ namespace WebWindowComplex } foreach (var item in node.AreaList) { - CreateElementTable(item, row, col, maxRow, maxCol); + if (maxRow < m_maxRow) + CreateElementTable(item, row, col, m_maxRow, maxCol); + else + CreateElementTable(item, row, col, maxRow, maxCol); } } if(maxCol> m_maxCol) { m_maxCol = maxCol; } + if (maxRow > m_maxRow) + { + m_maxRow = maxRow; + } + } + + private string fillTable(int row, int col) + { + List itemSameCol = new List(); + for(int k = 0; k < row; k++) + { + if(ItemTableList[k].Col == col+1) + { + itemSameCol.Add(ItemTableList[k]); + } + continue; + } + int numItemNextCol = 0; + for (int k = 0; k < row; k++) + { + if (ItemTableList[k].Row <= row && ItemTableList[k].Col == col + 2) + { + numItemNextCol++; + } + continue; + } + if (itemSameCol.Count > 1) + { + for (int i = 0; i <= itemSameCol.Count - 2; i++) + { + if (itemSameCol[i].NumChild > 0) + numItemNextCol = numItemNextCol - itemSameCol[i].NumChild; + } + } + if (itemSameCol.Count > 0) + { + // Sono alla riga successiva di un elemento e nella stessa colonna + if(itemSameCol.Last().Row == row) + { + // se ha un solo figlio + if(itemSameCol.Last().NumChild == 1) + { + return "└"; + } + else if (itemSameCol.Last().NumChild == 0) + { + return " "; + } + else + { + return "├"; + } + } + // Non solo alla riga successiva + else + { + // se ha un solo figlio + if(itemSameCol.Last().NumChild == 1) + { + return " "; + } + else if (col + 2 <= m_maxCol && ItemTableList[row].Col == col + 2) + { + if (numItemNextCol < itemSameCol.Last().NumChild && numItemNextCol != (itemSameCol.Last().NumChild - 1)) + { + return "├"; + } + return "└"; + } + else if (numItemNextCol < itemSameCol.Last().NumChild) + { + return "│"; + } + else + { + return " "; + } + } + } + else + { + return " "; + } } - /// /// Metodo per settare tutti i Joints di Frame o Sash come ANGLED o FULL_H o FULL_V @@ -455,6 +565,16 @@ namespace WebWindowComplex await DoPreviewSvg(); } + private void CopyContent(Sash sashItem, int IndexCopy, int IndexModify) + { + // Rimuovo riempimento da anta selezionata + sashItem.AreaList[IndexModify].AreaList.RemoveAt(0); + // Creo la copia dell'anta scelta + Area a = sashItem.AreaList[IndexCopy-1].AreaList[0].Copy(); + // Aggiungo copia all'anta selezionata + sashItem.AreaList[IndexModify].AreaList.Add(a); + } + private async Task SwapTwoAree(Area currArea) { currArea.SwapAree(); @@ -487,6 +607,7 @@ namespace WebWindowComplex private List m_SplitParentList = new List(); private int m_maxCol = 0; + private int m_maxRow = 0; private enum positionJoints { diff --git a/WebWindowComplex/TableComp.razor.css b/WebWindowComplex/TableComp.razor.css new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/WebWindowComplex/TableComp.razor.css @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/WebWindowComplex/Window.cs b/WebWindowComplex/Window.cs index 3c4270f..fa52611 100644 --- a/WebWindowComplex/Window.cs +++ b/WebWindowComplex/Window.cs @@ -232,6 +232,8 @@ namespace WebWindowComplex AreaList[1] = tempArea; } } + + public abstract Area Copy(); } public class Frame : Area @@ -634,6 +636,11 @@ namespace WebWindowComplex } } + public override Frame Copy() + { + return null; + } + internal override JsonArea Serialize() { JsonFrame JsonFrame = new JsonFrame(m_Shape, m_bBottomRail, m_nBottomRailQty); @@ -693,14 +700,16 @@ namespace WebWindowComplex } else { + // Se tolgo singola anta, ma tengo split SashList.RemoveAt(0); + } } if(m_SashList.Count == 0) { Area child = AreaList[0]; // Se nella singola anta ho uno split - if(!(child is Fill)) + if (!(child is Fill)) { child = child.AreaList[0].AreaList[0]; } @@ -708,64 +717,110 @@ namespace WebWindowComplex this.ParentArea.AreaList.Remove(this); this.ParentArea.AreaList.Add(child); } + // Se ho singola anta else if (m_SashList.Count == 1) { + // Metto come padre dell'area nello splitted l'anta stessa List ContentArea = new List(); - while (AreaList.Count > 0) - { - if (AreaList.Count == 1 & AreaList[0].AreaList.Count > 0) - { - foreach (Area selArea in AreaList[0].AreaList) - { - ContentArea.Add(selArea); - } - } - AreaList.Remove(AreaList[AreaList.Count - 1]); - } - if (ContentArea.Count > 0) - { - AreaList = ContentArea; - } + ContentArea.Add(AreaList[0].AreaList[0]); + ContentArea[0].SetParentArea(this); + AreaList.Clear(); + AreaList.Add(ContentArea[0]); + + //while (AreaList.Count > 0) + //{ + // if (AreaList.Count == 1 & AreaList[0].AreaList.Count > 0) + // { + // foreach (Area selArea in AreaList[0].AreaList) + // { + // ContentArea.Add(selArea); + // } + // } + // AreaList.Remove(AreaList[AreaList.Count - 1]); + //} + //if (ContentArea.Count > 0) + //{ + // AreaList = ContentArea; + //} } else { - List ContentArea = new List(); - if (AreaList.Count == 1 & SashList.Count > AreaList.Count) + // Se aggiungo ante + if(SashList.Count > AreaList.Count) { - ContentArea.Add(AreaList.ElementAt(0)); - AreaList.Clear(); - } - for (int SplitIndex = AreaList.Count; SplitIndex <= SashList.Count - 1; SplitIndex++) - { - AreaList.Add(Splitted.CreateSplitted(this)); - } - for (int SplitIndex = SashList.Count; SplitIndex <= AreaList.Count() - 1; SplitIndex++) - { - AreaList.Remove(AreaList[AreaList.Count - 1]); - } - if (AreaList[AreaList.Count - 1].AreaList.Count == 0) - { - if (ContentArea.Count > 0) + List ContentArea = new List(); + // Salvo in ContentArea il sottoalbero delle singole aree che mantengo + if (AreaList.Count >= 1 & SashList.Count > AreaList.Count) { - for (int SplitIndex = 0; SplitIndex <= AreaList.Count() - 1; SplitIndex++) + foreach (Area area in AreaList) { - if (SplitIndex == 0) - { - AreaList[0].AreaList.Add(ContentArea[0]); - } + if (area is Splitted) + ContentArea.Add(area.AreaList[0]); else - { - Fill f1 = (Fill)ContentArea[0]; - AreaList[SplitIndex].AreaList.Add(Fill.CreateFill(AreaList[SplitIndex], f1.FillType)); - } + ContentArea.Add(area); } + AreaList.Clear(); } - else + for (int SplitIndex = AreaList.Count; SplitIndex <= SashList.Count - 1; SplitIndex++) { - Fill f1 = (Fill)AreaList[AreaList.Count - 2].AreaList[0]; - AreaList[AreaList.Count - 1].AreaList.Add(Fill.CreateFill(AreaList[AreaList.Count - 1], f1.FillType)); + AreaList.Add(Splitted.CreateSplitted(this)); + } + // Riaggiungo i sottoalberi che avevo salvato + for (int i = 0; i < AreaList.Count - 1; i++) + { + if (AreaList.Count == 2) + { + ContentArea[i].SetParentArea(AreaList[i]); + } + AreaList[i].AreaList.Add(ContentArea[i]); + + } + // Aggiungo all'ultimo Splitted l'area di vetro + Fill newFill = new Fill(AreaList[1], ParentWindow); + newFill.SetFillType(FillTypes.GLASS); + newFill.SetAreaType(AreaTypes.FILL); + AreaList[AreaList.Count - 1].AreaList.Add(newFill); + } + // Se tolgo anta + else + { + for (int SplitIndex = SashList.Count; SplitIndex <= AreaList.Count() - 1; SplitIndex++) + { + AreaList.Remove(AreaList[AreaList.Count - 1]); + break; } } + //if (AreaList[AreaList.Count - 1].AreaList.Count == 0) + //{ + // if (ContentArea.Count > 0) + // { + // if (ContentArea[0] is Fill) + // { + // for (int SplitIndex = 0; SplitIndex <= AreaList.Count() - 1; SplitIndex++) + // { + // if (SplitIndex == 0) + // { + // AreaList[0].AreaList.Add(ContentArea[0]); + // } + // else + // { + // Fill f1 = (Fill)ContentArea[0]; + // AreaList[SplitIndex].AreaList.Add(Fill.CreateFill(AreaList[SplitIndex], f1.FillType)); + // } + // } + // } + // else + // { + // AreaList[0].AreaList.Add(ContentArea[0]); + // AreaList[1].AreaList.Add(ContentArea[0]); + // } + // } + // else + // { + // Fill f1 = (Fill)AreaList[AreaList.Count - 2].AreaList[0]; + // AreaList[AreaList.Count - 1].AreaList.Add(Fill.CreateFill(AreaList[AreaList.Count - 1], f1.FillType)); + // } + //} } } //RefreshHardwareList(); @@ -858,7 +913,6 @@ namespace WebWindowComplex } } - private bool m_bIsSashVertical; public bool bIsSashVertical { @@ -1278,6 +1332,32 @@ namespace WebWindowComplex } } + public override Sash Copy() + { + Sash newSash = new Sash(ParentArea, m_ParentWindow); + newSash.SetAreaType(AreaType); + newSash.SetSashQty(nSashQty); + newSash.SetIsSashVertical(bIsSashVertical); + newSash.SetOrientationSashType(OrientationSashType); + newSash.SetSashBottomRailQty(SashBottomRailQty); + foreach (var item in SashList) + { + SashDimension dim = item.Copy(); + newSash.SashList.Add(dim); + } + foreach (var item in JointList) + { + Joint j = item.Copy(); + newSash.JointList.Add(j); + } + foreach (var item in AreaList) + { + Area a = item.Copy(); + newSash.AreaList.Add(a); + } + return newSash; + } + internal override JsonArea Serialize() { JsonSash JsonSash = new JsonSash(m_bIsSashVertical, m_SashType, m_bSashBottomRail, m_nSashBottomRailQty/*, m_SelHardware.sId*/); @@ -1479,6 +1559,20 @@ namespace WebWindowComplex return Split; } + public override Split Copy() + { + Split newSplit = new Split(ParentArea, ParentWindow); + newSplit.SetSplitQty(nSplitQty); + newSplit.SetSplitShape(SelSplitShape, true); + newSplit.SetAreaType(AreaType); + foreach(var item in AreaList) + { + Area a = item.Copy(); + newSplit.AreaList.Add(a); + } + return newSplit; + } + internal override JsonArea Serialize() { JsonSplit JsonSplit = new JsonSplit(m_SelSplitShape); @@ -1504,6 +1598,18 @@ namespace WebWindowComplex return Splitted; } + public override Splitted Copy() + { + Splitted newSplitted = new Splitted(ParentArea, ParentWindow); + newSplitted.SetAreaType(AreaType); + foreach (var item in AreaList) + { + Area a = item.Copy(); + newSplitted.AreaList.Add(a); + } + return newSplitted; + } + internal override JsonArea Serialize() { JsonSplitted JsonSplitted = new JsonSplitted(); @@ -1576,6 +1682,14 @@ namespace WebWindowComplex return Fill; } + public override Fill Copy() + { + Fill newFill = new Fill(ParentArea, m_ParentWindow); + newFill.SetFillType(SelFillType); + newFill.SetAreaType(AreaType); + return newFill; + } + internal override JsonArea Serialize() { JsonFill JsonFill = new JsonFill(FillType); @@ -1647,6 +1761,13 @@ namespace WebWindowComplex m_SelJointType = value; //NotifyPropertyChanged(nameof(SelJointTypeIndex)); } + + public Joint Copy() + { + Joint newJoint = new Joint(ParentArea,nIndex, SelJointType); + return newJoint; + } + public Joint(Area ParentArea, int nIndex, Joints SelJointType) { m_ParentArea = ParentArea; @@ -2006,7 +2127,6 @@ namespace WebWindowComplex //m_Parent.SetFirstHardware(); } } - public Openings OpeningType { get @@ -2132,6 +2252,14 @@ namespace WebWindowComplex m_dDimension = dValue; } + public SashDimension Copy() + { + SashDimension newSashDim = new SashDimension(dDimension, bIsRelative, m_Parent); + newSashDim.SetOpeningType(SelOpeningType); + newSashDim.SetHasHandle(bHasHandle); + return newSashDim; + } + public SashDimension(double dDimension, bool bIsRelative, Sash Parent) { m_dDimension = dDimension; @@ -2322,6 +2450,11 @@ namespace WebWindowComplex m_dDimension = dValue; } + public SplitDimension Copy() + { + SplitDimension newSplitDim = new SplitDimension(dDimension, bIsRelative, m_Parent); + return newSplitDim; + } public SplitDimension(double dDimension, bool bIsRelative, Split Parent) { m_dDimension = dDimension;