From 83161fd2c4ffd0be408b84024367aaf7a8889805 Mon Sep 17 00:00:00 2001 From: Annamaria Sassi Date: Mon, 16 Mar 2026 17:02:49 +0100 Subject: [PATCH 1/8] =?UTF-8?q?-=20Eliminazioni=20commenti=20-=20Eliminazi?= =?UTF-8?q?one=20funzioni=20non=20pi=C3=B9=20usate=20-=20Eliminazione=20pa?= =?UTF-8?q?gine=20razor=20sostituite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebWindowComplex/Compo/AreaFrame.razor | 2 +- WebWindowComplex/Compo/AreaFrame.razor.cs | 4 +- WebWindowComplex/Compo/AreaSash.razor.cs | 34 +- WebWindowComplex/Compo/AreaSplit.razor | 4 +- WebWindowComplex/Compo/AreaSplit.razor.cs | 4 +- WebWindowComplex/Compo/CardFrame.razor | 23 +- WebWindowComplex/Compo/CardFrame.razor.cs | 19 +- WebWindowComplex/Compo/CardSashGroup.razor | 2 +- WebWindowComplex/Compo/CardSashGroup.razor.cs | 6 +- WebWindowComplex/Compo/CardSplit.razor.cs | 14 +- WebWindowComplex/Compo/CardTree.razor | 8 +- WebWindowComplex/Compo/CardTree.razor.cs | 6 +- WebWindowComplex/Compo/FrameBottomRail.razor | 20 - .../Compo/FrameBottomRail.razor.cs | 42 -- WebWindowComplex/Compo/SashBottomRail.razor | 20 - .../Compo/SashBottomRail.razor.cs | 42 -- WebWindowComplex/Models/Area.cs | 139 +---- WebWindowComplex/Models/AreaDimension.cs | 5 +- WebWindowComplex/Models/ElementDimension.cs | 11 +- WebWindowComplex/Models/Fill.cs | 37 +- WebWindowComplex/Models/Frame.cs | 23 +- WebWindowComplex/Models/FrameDimension.cs | 31 -- WebWindowComplex/Models/Sash.cs | 111 ++-- WebWindowComplex/Models/SashDimension.cs | 138 ++--- WebWindowComplex/Models/Split.cs | 312 ++++++++--- WebWindowComplex/Models/SplitDimension.cs | 491 +++++++++--------- WebWindowComplex/TableComp.razor | 19 +- WebWindowComplex/TableComp.razor.cs | 120 ++--- WebWindowComplex/WebWindowComplex.csproj | 4 +- .../WebWindowConfigurator.csproj | 9 +- 30 files changed, 781 insertions(+), 919 deletions(-) delete mode 100644 WebWindowComplex/Compo/FrameBottomRail.razor delete mode 100644 WebWindowComplex/Compo/FrameBottomRail.razor.cs delete mode 100644 WebWindowComplex/Compo/SashBottomRail.razor delete mode 100644 WebWindowComplex/Compo/SashBottomRail.razor.cs diff --git a/WebWindowComplex/Compo/AreaFrame.razor b/WebWindowComplex/Compo/AreaFrame.razor index ccb0c97..38788d6 100644 --- a/WebWindowComplex/Compo/AreaFrame.razor +++ b/WebWindowComplex/Compo/AreaFrame.razor @@ -5,7 +5,7 @@
Area frame
- @if (SashList.Count == 0 && SplitList.Count == 0) + @if (SashGroupList.Count == 0 && SplitList.Count == 0) {
diff --git a/WebWindowComplex/Compo/AreaFrame.razor.cs b/WebWindowComplex/Compo/AreaFrame.razor.cs index 48180ac..5e39ecf 100644 --- a/WebWindowComplex/Compo/AreaFrame.razor.cs +++ b/WebWindowComplex/Compo/AreaFrame.razor.cs @@ -16,8 +16,8 @@ namespace WebWindowComplex.Compo /// /// Lista sash /// - [CascadingParameter(Name = "SashList")] - public List SashList { get; set; } = null!; + [CascadingParameter(Name = "SashGroupList")] + public List SashGroupList { get; set; } = null!; /// /// Lista split diff --git a/WebWindowComplex/Compo/AreaSash.razor.cs b/WebWindowComplex/Compo/AreaSash.razor.cs index baeef8f..37b6dcf 100644 --- a/WebWindowComplex/Compo/AreaSash.razor.cs +++ b/WebWindowComplex/Compo/AreaSash.razor.cs @@ -30,8 +30,8 @@ namespace WebWindowComplex.Compo /// /// Lista delle sash /// - [CascadingParameter(Name = "SashList")] - public List SashList { get; set; } = null!; + [CascadingParameter(Name = "SashGroupList")] + public List SashGroupList { get; set; } = null!; /// /// Livello di accesso (utente base) @@ -196,8 +196,32 @@ namespace WebWindowComplex.Compo /// private Task ChangeAllJoints(Json.WindowConst.Joints JointType) { - foreach (var item in CurrSashDim.JointList) - item.SelJointType = JointType; + for (int i = 0; i < CurrSashDim.JointList.Count; i++) + { + Frame? frame = CurrSashGroup.ParentWindow.AreaList.FirstOrDefault(); + if (frame != null && (frame.Shape is Json.WindowConst.Shapes.ARC || + frame.Shape is Json.WindowConst.Shapes.ARC_FULL || + frame.Shape is Json.WindowConst.Shapes.DOUBLEARC || + frame.Shape is Json.WindowConst.Shapes.THREECENTERARC)) + { + if(CurrSashGroup.SashList.Count == 1) + { + if(i == 2 || i == CurrSashDim.JointList.Count - 1) + CurrSashDim.JointList.ElementAt(i).SelJointType = Joints.ANGLED; + else + CurrSashDim.JointList.ElementAt(i).SelJointType = JointType; + } + else + { + if (IndexSash == 0 && i == CurrSashDim.JointList.Count - 1) + CurrSashDim.JointList.ElementAt(i).SelJointType = Joints.ANGLED; + else if(IndexSash == CurrSashGroup.SashList.Count - 1 && i == 2) + CurrSashDim.JointList.ElementAt(i).SelJointType = Joints.ANGLED; + else + CurrSashDim.JointList.ElementAt(i).SelJointType = JointType; + } + } + } return EC_UpdateSashDim.InvokeAsync(CurrSashDim); } @@ -242,7 +266,7 @@ namespace WebWindowComplex.Compo private Task ChangeHandle() { // Cerco la Sash che si sta considerando nella lista Sash - var s = SashList.Where(x => x.GroupId == CurrSashGroup.GroupId).FirstOrDefault(); + var s = SashGroupList.Where(x => x.GroupId == CurrSashGroup.GroupId).FirstOrDefault(); if (s != null) { // Setto la presenza o meno della maniglia per ogni anta diff --git a/WebWindowComplex/Compo/AreaSplit.razor b/WebWindowComplex/Compo/AreaSplit.razor index 2ec3b05..7d42284 100644 --- a/WebWindowComplex/Compo/AreaSplit.razor +++ b/WebWindowComplex/Compo/AreaSplit.razor @@ -10,11 +10,11 @@
- @for (int j = 0; j < SashList.Count; j++) + @for (int j = 0; j < SashGroupList.Count; j++) { int Index = j;
- +
}
diff --git a/WebWindowComplex/Compo/AreaSplit.razor.cs b/WebWindowComplex/Compo/AreaSplit.razor.cs index a272dfa..e8178e8 100644 --- a/WebWindowComplex/Compo/AreaSplit.razor.cs +++ b/WebWindowComplex/Compo/AreaSplit.razor.cs @@ -12,7 +12,7 @@ namespace WebWindowComplex.Compo /// Lista delle sash /// [Parameter] - public List SashList { get; set; } = null!; + public List SashGroupList { get; set; } = null!; /// /// Oggetto splitted corrente @@ -44,7 +44,7 @@ namespace WebWindowComplex.Compo private Task RaiseCopySash(int indexCurrSash) { CurrSplitted.AreaList.RemoveAll(i => i != null); - Area a = SashList[indexCurrSash].Copy(CurrSplitted); + Area a = SashGroupList[indexCurrSash].Copy(CurrSplitted); a.SetParentArea(CurrSplitted); CurrSplitted.AreaList.Add(a); return EC_UpdateSplitted.InvokeAsync(CurrSplitted); diff --git a/WebWindowComplex/Compo/CardFrame.razor b/WebWindowComplex/Compo/CardFrame.razor index d55f2c0..749aa48 100644 --- a/WebWindowComplex/Compo/CardFrame.razor +++ b/WebWindowComplex/Compo/CardFrame.razor @@ -73,7 +73,7 @@
- @if (SashList.Count == 0) + @if (SashGroupList.Count == 0) {
Bottom rail
@@ -112,25 +112,6 @@
- @*
- -
- @if (ForceChangeAll) - { -
-
- -
-
- -
-
- -
-
- } *@ @*
[Parameter] - public List SashList { get; set; } = null!; + public List SashGroupList { get; set; } = null!; /// /// Lista di split @@ -198,7 +198,7 @@ namespace WebWindowComplex.Compo svgNoHw = true }; await EC_ReqResetDict.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDictShape }); - if (SashList.Count > 0) + if (SashGroupList.Count > 0) await EC_ReqOptionHw.InvokeAsync(FrameWindow); await EC_ReqElement.InvokeAsync(FrameWindow); await EC_UpdateFrame.InvokeAsync(args); @@ -229,7 +229,7 @@ namespace WebWindowComplex.Compo if (currSplitted != null) { currSplitted.AreaList.RemoveAll(i => i != null); - Area a = SashList[indexCurrSash].Copy(currSplitted); + Area a = SashGroupList[indexCurrSash].Copy(currSplitted); a.SetParentArea(currSplitted); currSplitted.AreaList.Add(a); } diff --git a/WebWindowComplex/Compo/FrameBottomRail.razor b/WebWindowComplex/Compo/FrameBottomRail.razor deleted file mode 100644 index 41ea75c..0000000 --- a/WebWindowComplex/Compo/FrameBottomRail.razor +++ /dev/null @@ -1,20 +0,0 @@ - - - \ No newline at end of file diff --git a/WebWindowComplex/Compo/FrameBottomRail.razor.cs b/WebWindowComplex/Compo/FrameBottomRail.razor.cs deleted file mode 100644 index ff50155..0000000 --- a/WebWindowComplex/Compo/FrameBottomRail.razor.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Microsoft.AspNetCore.Components; -using WebWindowComplex.Models; - -namespace WebWindowComplex.Compo -{ - public partial class FrameBottomRail - { - #region Public Properties - - /// - /// Frame corrente - /// - [CascadingParameter(Name = "CurrFrameWindow")] - public Frame CurrFrame { get; set; } = null!; - - [Parameter] - public EventCallback EC_UpdateFrame { get; set; } - - #endregion Public Properties - - #region Private Properties - - /// - /// Aggiornamento element Bottom Rail - /// - /// - /// - private async Task UpdateElement(ElementDimension updRec) - { - // cerco il record - var currRec = CurrFrame.BottomRailElemDimList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex); - // lo aggiorno - if (updRec != null) - { - currRec = updRec; - await EC_UpdateFrame.InvokeAsync(CurrFrame); - } - } - - #endregion Private Properties - } -} \ No newline at end of file diff --git a/WebWindowComplex/Compo/SashBottomRail.razor b/WebWindowComplex/Compo/SashBottomRail.razor deleted file mode 100644 index de9ca4f..0000000 --- a/WebWindowComplex/Compo/SashBottomRail.razor +++ /dev/null @@ -1,20 +0,0 @@ - - - \ No newline at end of file diff --git a/WebWindowComplex/Compo/SashBottomRail.razor.cs b/WebWindowComplex/Compo/SashBottomRail.razor.cs deleted file mode 100644 index 4846335..0000000 --- a/WebWindowComplex/Compo/SashBottomRail.razor.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Microsoft.AspNetCore.Components; -using WebWindowComplex.Models; - -namespace WebWindowComplex.Compo -{ - public partial class SashBottomRail - { - #region Public Properties - - /// - /// Sash corrente rispetto alla lista Sash - /// - [CascadingParameter(Name = "CurrSashGroup")] - public Sash SashGroup { get; set; } = null!; - - [Parameter] - public EventCallback EC_UpdateSash { get; set; } - - #endregion Public Properties - - #region Private Properties - - /// - /// Aggiornamento element - /// - /// - /// - private async Task UpdateElement(ElementDimension updRec) - { - // cerco il record - var currRec = SashGroup.BottomRailElemDimList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex); - // lo aggiorno - if (updRec != null) - { - currRec = updRec; - await EC_UpdateSash.InvokeAsync(SashGroup); - } - } - - #endregion Private Properties - } -} \ No newline at end of file diff --git a/WebWindowComplex/Models/Area.cs b/WebWindowComplex/Models/Area.cs index 346afa0..835ce0e 100644 --- a/WebWindowComplex/Models/Area.cs +++ b/WebWindowComplex/Models/Area.cs @@ -131,12 +131,8 @@ namespace WebWindowComplex.Models { SashArea.SashList.LastOrDefault()!.JointList.ElementAt(2).SelJointTypeIndex = (int)Joints.ANGLED; } + // SashArea.SashArcElem = new SashArcElement(SashArea, ParentWindow, 10, true); } - //if (ParentWindow.AreaList.First().SelShapeIndex == (int)Shapes.ARC || - // ParentWindow.AreaList.First().SelShapeIndex == (int)Shapes.DOUBLEARC || - // ParentWindow.AreaList.First().SelShapeIndex == (int)Shapes.ARC_FULL || - // ParentWindow.AreaList.First().SelShapeIndex == (int)Shapes.THREECENTERARC) - // SashArea.SashArcElem = new SashArcElement(SashArea, ParentWindow, 10, true); //else // SashArea.SashArcElem = null; // Salvo gli oggetti già presenti e li cancello da AreaList @@ -188,7 +184,6 @@ namespace WebWindowComplex.Models Frame frame = ParentWindow.AreaList.First(); if(frame != null) { - //frame.SearchAreaList(frame, frame.AvailWidthArea(), "Width"); frame.SearchAreaList(frame, frame.AvailHeightArea(), "Height"); } } @@ -237,53 +232,32 @@ namespace WebWindowComplex.Models } } } + string heightName = "Height"; switch (frame.Shape) { - case Shapes.RECTANGLE: - case Shapes.ARC_FULL: - case Shapes.TRIANGLE: - { - SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Width")).First().dDimension, "Width"); - SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Height")).First().dDimension, "Height"); - break; - } - case Shapes.RIGHTCHAMFER: { - SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Width")).First().dDimension, "Width"); - SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Left Height")).First().dDimension, "Left Height"); + heightName = "Left Height"; break; } case Shapes.LEFTCHAMFER: { - SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Width")).First().dDimension, "Width"); - SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Right Height")).First().dDimension, "Right Height"); + heightName = "Right Height"; break; } case Shapes.DOUBLECHAMFER: case Shapes.ARC: - { - SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Width")).First().dDimension, "Width"); - SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Full Height")).First().dDimension, "Full Height"); - break; - } - case Shapes.DOUBLEARC: - { - SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Width")).First().dDimension, "Width"); - SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Full Height")).First().dDimension, "Full Height"); - break; - } - case Shapes.THREECENTERARC: { - SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Width")).First().dDimension, "Width"); - SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Full Height")).First().dDimension, "Full Height"); + heightName = "Full Height"; break; } } + SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals("Width")).First().dDimension, "Width"); + SearchAreaList(this, frame.DimensionList.Where(x => x.sName.Equals(heightName)).First().dDimension, heightName); } /// @@ -390,7 +364,7 @@ namespace WebWindowComplex.Models int countAbsolute = sash.SashList.Where(x => x.MeasureType.Equals(MeasureTypes.ABSOLUTE)).Count(); int countProportional = sash.SashList.Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).Count(); int countPercentage = sash.SashList.Where(x => x.MeasureType.Equals(MeasureTypes.PERCENTAGE)).Count(); - List dimList = new List(); + List dimList = new(); Split split = new Split(null, null); if (sash.ParentArea.ParentArea is Split) split = (Split)sash.ParentArea.ParentArea; @@ -413,12 +387,6 @@ namespace WebWindowComplex.Models double sum = sash.SashList.Sum(x => x.dDimension); if ((sash.ParentArea.ParentArea is Split && split.SplitHorizList.Count > 0)) { - //Frame? frame = sash.m_ParentWindow.AreaList.FirstOrDefault(); - //if (frame != null) - // dim = dim + frame.ElementDimensionList.ElementAt(1).dOverlap - // + frame.ElementDimensionList.Last().dOverlap; - //if(sash.SashList.Count == 1) - // dim = dim + sash.SashList.First().ElementDimensionList.ElementAt(1).dOverlap; for (int i = 1; i < sash.SashList.Count; i++) dim = dim + sash.SashList.ElementAt(i).ElementDimensionList.Last().dOverlap; } @@ -432,24 +400,18 @@ namespace WebWindowComplex.Models dim = dim - sash.SashList.First().ElementDimensionList.ElementAt(1).dDimension - sash.SashList.First().ElementDimensionList.Last().dDimension; for (int i = 1; i < sash.SashList.Count; i++) - { dim = dim - sash.SashList[i].ElementDimensionList.ElementAt(1).dDimension - sash.SashList[i].ElementDimensionList.Last().dDimension + sash.SashList[i].ElementDimensionList.Last().dOverlap; - } } else if (sash.SashList.Count > 1) { for (int i = 1; i < sash.SashList.Count; i++) - { dim = dim + sash.SashList[i].ElementDimensionList.Last().dOverlap; - } } double res = dim - sum; foreach (var sashDim in sash.SashList) - { sashDim.SetDimension(sashDim.dDimension + res / countAbsolute); - } } else if (countAbsolute < sash.SashList.Count && countPercentage != sash.SashList.Count && countProportional != sash.SashList.Count) { @@ -458,36 +420,30 @@ namespace WebWindowComplex.Models double sumAbsolute = sash.SashList.Where(x => x.MeasureType.Equals(MeasureTypes.ABSOLUTE)).Sum(x => x.dDimension); var percentageList = sash.SashList.Where(x => x.MeasureType.Equals(MeasureTypes.PERCENTAGE)).ToList(); foreach (var i in percentageList) - { - i.SetDimension(i.ConvertIn(dimList, (dim - sumAbsolute) / countPercentage, i.MeasureType, dim)); - } + i.SetDimension(i.ConvertAbsoluteIn(dimList, (dim - sumAbsolute) / countPercentage, i.MeasureType, dim)); } } } else if (area is Split split) { - List splitList = new List(); - List elemList = new List(); + List splitList = new(); + List elemList = new(); double sum = 0; if (nameDim.Equals("Width")) { splitList = split.SplitVertList; elemList = split.ElemDimVertList; - //foreach (var item in split.ElemDimVertList) - // sum = sum + item.dDimension; } else { splitList = split.SplitHorizList; elemList = split.ElemDimHorizList; - //foreach (var item in split.ElemDimHorizList) - // sum = sum + item.dDimension; } int countAbsolute = splitList.Where(x => x.MeasureType.Equals(MeasureTypes.ABSOLUTE)).Count(); if (countAbsolute != 0 && countAbsolute == splitList.Count) { sum = sum + splitList.Sum(x => x.dDimension); - List dimensionList = new List(); + List dimensionList = new(); foreach (var i in splitList) dimensionList.Add(new AreaDimension(i.dDimension, i.MeasureType, i.Parent)); double widthGlass = dim; @@ -517,75 +473,6 @@ namespace WebWindowComplex.Models m_ParentArea = ParentArea; } - - /// - /// Metodo per convertire da misura proporzionale a misura assoluta o percentuale - /// - /// - /// - internal double ConvertFromPropVal(Sash sashGroup, double sashDim, MeasureTypes newType, double widthTot) - { - double tot = widthTot; - List adList = new List(); - foreach (var it in sashGroup.SashList) - { - adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType, it.Parent)); - } - //Somma misura non proporzionali - double sumNotProp = sashGroup.SashList - .Where(m => m.MeasureType != MeasureTypes.PROPORTIONAL && !m.Equals(this)) - .Sum(m => m.CalculateAbsoluteValue(adList, tot)); - //Calcolo residuo - double res = tot - sumNotProp; - if (res < 0) res = 0; - //Misure proporzionali - var proportionalList = sashGroup.SashList - .Where(m => m.SelMeasureType == MeasureTypes.PROPORTIONAL) - .ToList(); - - double sumPesi = proportionalList.Sum(p => p.dDimension); - if (sumPesi == 0) sumPesi = 1; - if (newType.Equals(MeasureTypes.ABSOLUTE)) - { - return res / sumPesi * sashDim; - } - else - { - return (res / sumPesi * sashDim) / tot * 100; - } - } - - /// - /// Metodo per convertire da misura proporzionale a misura assoluta o percentuale - /// - /// - /// - internal double ConvertFromPropVal(List splitList, double splitDim, MeasureTypes newType, double widthTot) - { - double tot = widthTot; - List adList = new List(); - foreach (var it in splitList) - { - adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType, it.Parent)); - } - //Somma misura non proporzionali - double sumNotProp = splitList - .Where(m => m.MeasureType != MeasureTypes.PROPORTIONAL && !m.Equals(this)) - .Sum(m => m.CalculateAbsoluteValue(adList, tot)); - //Calcolo residuo - double res = tot - sumNotProp; - if (res < 0) res = 0; - //Misure proporzionali - var proportionalList = splitList - .Where(m => m.SelMeasureType == MeasureTypes.PROPORTIONAL) - .ToList(); - - double sumPesi = proportionalList.Sum(p => p.dDimension); - if (sumPesi == 0) - sumPesi = 1; - return res / sumPesi * splitDim; - } - #endregion Internal Methods #region Protected Fields @@ -607,7 +494,5 @@ namespace WebWindowComplex.Models private Area m_ParentArea; #endregion Private Fields - - } } \ No newline at end of file diff --git a/WebWindowComplex/Models/AreaDimension.cs b/WebWindowComplex/Models/AreaDimension.cs index 45135eb..f594617 100644 --- a/WebWindowComplex/Models/AreaDimension.cs +++ b/WebWindowComplex/Models/AreaDimension.cs @@ -190,7 +190,7 @@ namespace WebWindowComplex.Models /// Metodo per ricalcolare i valori proporzionali a causa della modifica di uno /// /// - internal List CalculatePropVal(List itemList, int indexArea, double widthTot) + internal List RicalculatePropVal(List itemList, int indexArea, double widthTot) { List ans = itemList; if (itemList.Where(m => m.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count == 0) @@ -309,7 +309,7 @@ namespace WebWindowComplex.Models /// Tipo di misura della dimensione /// Larghezza totale /// - internal double ConvertIn(List itemList, double absoluteVal, MeasureTypes type, double widthTot) + internal double ConvertAbsoluteIn(List itemList, double absoluteVal, MeasureTypes type, double widthTot) { switch (type) { @@ -379,7 +379,6 @@ namespace WebWindowComplex.Models if (sumPesi == 0) sumPesi = 1; return res / sumPesi * dimensionProp; } - #endregion Public Method } diff --git a/WebWindowComplex/Models/ElementDimension.cs b/WebWindowComplex/Models/ElementDimension.cs index 5dc8279..0e1647e 100644 --- a/WebWindowComplex/Models/ElementDimension.cs +++ b/WebWindowComplex/Models/ElementDimension.cs @@ -71,7 +71,10 @@ namespace WebWindowComplex.Models // Per calcolare larghezza split gorup mi basta una qualsiasi dimensione double height = 0; if (frame != null) - height =split.SplitHorizList.First().CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false)).m_Dimension; + { + height = split.CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false)).m_Dimension; + //height =split.SplitHorizList.First().CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false)).m_Dimension; + } //double height = ParentArea.CalculateWidthArea(ParentArea.ParentWindow.AreaList[0], ParentArea.ParentWindow.AreaList[0].AvailHeightArea()); List horizElemList = split.ElemDimHorizList.Where(x=>x.m_nIndex== 1).ToList(); foreach (var elem in horizElemList) @@ -96,7 +99,7 @@ namespace WebWindowComplex.Models // Per calcolare larghezza split gorup mi basta una qualsiasi dimensione double width = 0; if (frame != null) - width = split.SplitVertList.First().CalculateWidthSplitGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension; + width = split.CalculateWidthSplitGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension; //double width = ParentArea.CalculateWidthArea(ParentArea.ParentWindow.AreaList[0], ParentArea.ParentWindow.AreaList[0].AvailWidthArea()); List vertElemList = split.ElemDimVertList.Where(x => x.m_nIndex == 1).ToList(); foreach (var elem in vertElemList) @@ -262,8 +265,10 @@ namespace WebWindowComplex.Models return newElementDimension; } - public override bool Equals(object obj) + public override bool Equals(object? obj) { + if (obj is null) + return false; return Equals(obj as ElementDimension); } diff --git a/WebWindowComplex/Models/Fill.cs b/WebWindowComplex/Models/Fill.cs index 30beb75..83de8ac 100644 --- a/WebWindowComplex/Models/Fill.cs +++ b/WebWindowComplex/Models/Fill.cs @@ -6,7 +6,6 @@ namespace WebWindowComplex.Models public class Fill : Area { #region Public Constructors - public Fill(Area ParentArea, Window ParentWindow) : base(ParentArea, ParentWindow) { } @@ -23,13 +22,13 @@ namespace WebWindowComplex.Models } } - public List FillTypeList - { - get - { - return m_FillTypeList; - } - } + //public List FillTypeList + //{ + // get + // { + // return m_FillTypeList; + // } + //} public FillTypes SelFillType { @@ -43,17 +42,17 @@ namespace WebWindowComplex.Models } } - public int SelFillTypeIndex - { - get - { - return IdNameStruct.IndFromId((int)m_SelFillType, m_FillTypeList); - } - set - { - m_SelFillType = (FillTypes)IdNameStruct.IdFromInd(value, m_FillTypeList); - } - } + //public int SelFillTypeIndex + //{ + // get + // { + // return IdNameStruct.IndFromId((int)m_SelFillType, m_FillTypeList); + // } + // set + // { + // m_SelFillType = (FillTypes)IdNameStruct.IdFromInd(value, m_FillTypeList); + // } + //} #endregion Public Properties diff --git a/WebWindowComplex/Models/Frame.cs b/WebWindowComplex/Models/Frame.cs index a32c988..63f095e 100644 --- a/WebWindowComplex/Models/Frame.cs +++ b/WebWindowComplex/Models/Frame.cs @@ -397,15 +397,9 @@ namespace WebWindowComplex.Models if (node != null) { if (node.AreaType.Equals(AreaTypes.SASH)) - { sashList.Add((Sash)node); - //Sash s = (Sash)node; - //s.SashArcElem = null; - } foreach (var item in node.AreaList) - { SearchSash(sashList, item); - } } return sashList; } @@ -430,6 +424,11 @@ namespace WebWindowComplex.Models #region Public Methods + public override Frame Copy(Area ParentArea) + { + return new Frame(null, ParentWindow); + } + public void RefreshThresholdList() { m_ThresholdList.Clear(); @@ -478,11 +477,6 @@ namespace WebWindowComplex.Models overlap; } - public override Frame Copy(Area ParentArea) - { - return new Frame(null, ParentWindow); - } - /// /// Metodo per calcolare l'area disponibile /// @@ -496,12 +490,6 @@ namespace WebWindowComplex.Models if(AreaList.First() is Sash) overlap = ElementDimensionList.ElementAt(1).dOverlap + ElementDimensionList.Last().dOverlap; - //if (AreaList.First() is Split split) - //{ - // if(split.SplitHorizList.Count > 0) - // overlap = ElementDimensionList.ElementAt(1).dOverlap + - // ElementDimensionList.Last().dOverlap; - //} return dim - ElementDimensionList.ElementAt(1).dDimension - ElementDimensionList.Last().dDimension + overlap; @@ -638,7 +626,6 @@ namespace WebWindowComplex.Models } } // aggiungo Joint - //int nJointQty = 4; switch (Value) { case Shapes.RECTANGLE: diff --git a/WebWindowComplex/Models/FrameDimension.cs b/WebWindowComplex/Models/FrameDimension.cs index bf95728..ede159f 100644 --- a/WebWindowComplex/Models/FrameDimension.cs +++ b/WebWindowComplex/Models/FrameDimension.cs @@ -12,7 +12,6 @@ namespace WebWindowComplex.Models m_ParentFrame = ParentFrame; m_nIndex = nIndex; m_sName = sName; - m_bIsLen = bIsLen; } #endregion Public Constructors @@ -36,13 +35,9 @@ namespace WebWindowComplex.Models ParentFrame.SelShapeIndex == (int)Shapes.TRIANGLE) { if (value > MaxDim) - { m_dDimension = MaxDim; - } else if (value < MinDim && !m_sName.Equals("Radius") && !m_sName.Equals("Height projection")) - { m_dDimension = MinDim; - } else m_dDimension = value; } @@ -53,68 +48,44 @@ namespace WebWindowComplex.Models { var height = ParentFrame.DimensionList.First(x => x.sName.Equals("Height")).m_dDimension; if (sName.Equals("Height") && value > 0.5 * widthArea && value < MaxDim) - { m_dDimension = value; - } else if (sName.Equals("Width") && height > 0.5 * value && value > MinDim) - { m_dDimension = value; - } } else if (ParentFrame.SelShapeIndex == (int)Shapes.ARC) { var height = ParentFrame.DimensionList.First(x => x.sName.Equals("Height")).m_dDimension; var fullHeight = ParentFrame.DimensionList.First(x => x.sName.Equals("Full Height")).m_dDimension; if (sName.Equals("Full Height") && (value - height) < 0.5 * widthArea && value < MaxDim) - { m_dDimension = value; - } else if (sName.Equals("Height") && (fullHeight - value) < 0.5 * widthArea && value < MaxDim) - { m_dDimension = value; - } else if (sName.Equals("Width") && (fullHeight - height) < 0.5 * value && value < MaxDim) - { m_dDimension = value; - } } else if (ParentFrame.SelShapeIndex == (int)Shapes.THREECENTERARC) { var height = ParentFrame.DimensionList.First(x => x.sName.Equals("Height")).m_dDimension; var fullHeight = ParentFrame.DimensionList.First(x => x.sName.Equals("Full Height")).m_dDimension; if (sName.Equals("Full Height") && (value - height) < 0.5 * widthArea && value < MaxDim) - { m_dDimension = value; - } else if (sName.Equals("Height") && (fullHeight - value) < 0.5 * widthArea && value < MaxDim) - { m_dDimension = value; - } else if (sName.Equals("Width") && (fullHeight - height) < 0.5 * value) - { m_dDimension = value; - } else if (sName.Equals("Radius") && value < 0.5 * widthArea) - { m_dDimension = value; - } } else if (ParentFrame.SelShapeIndex == (int)Shapes.DOUBLEARC) { var height = ParentFrame.DimensionList.First(x => x.sName.Equals("Height")).m_dDimension; var fullHeight = ParentFrame.DimensionList.First(x => x.sName.Equals("Full Height")).m_dDimension; if (sName.Equals("Full Height") && (value - height) > 0.5 * widthArea && value < MaxDim) - { m_dDimension = value; - } else if (sName.Equals("Height") && (fullHeight - value) > 0.5 * widthArea && value < MaxDim) - { m_dDimension = value; - } else if (sName.Equals("Width") && (fullHeight - height) > 0.5 * value && value > MinDim) - { m_dDimension = value; - } } } if (ParentFrame.AreaList.Count > 0 && sName.Equals("Width") && ParentFrame != null) @@ -169,8 +140,6 @@ namespace WebWindowComplex.Models #region Private Fields - private bool m_bIsLen = false; - private int m_nIndex; private string m_sName; diff --git a/WebWindowComplex/Models/Sash.cs b/WebWindowComplex/Models/Sash.cs index 13fbe28..5bfe44d 100644 --- a/WebWindowComplex/Models/Sash.cs +++ b/WebWindowComplex/Models/Sash.cs @@ -642,6 +642,7 @@ namespace WebWindowComplex.Models #endregion Public Methods #region Internal Methods + internal void SetIsDimensionLight(bool DimensionLight) { m_IsbDimensionLight = DimensionLight; @@ -670,34 +671,34 @@ namespace WebWindowComplex.Models return newSash; } - internal OpeningSides GetOpeningSide(Openings OpeningType) - { - switch (OpeningType) - { - case Openings.TURNONLY_LEFT: - case Openings.TILTTURN_LEFT: - case Openings.TILTONLY_TOP: - case Openings.COMPLANARSLIDE_LEFT: - case Openings.LIFTSLIDE_LEFT: - { - return OpeningSides.LEFT; - } + //internal OpeningSides GetOpeningSide(Openings OpeningType) + //{ + // switch (OpeningType) + // { + // case Openings.TURNONLY_LEFT: + // case Openings.TILTTURN_LEFT: + // case Openings.TILTONLY_TOP: + // case Openings.COMPLANARSLIDE_LEFT: + // case Openings.LIFTSLIDE_LEFT: + // { + // return OpeningSides.LEFT; + // } - case Openings.TURNONLY_RIGHT: - case Openings.TILTTURN_RIGHT: - case Openings.TILTONLY_BOTTOM: - case Openings.COMPLANARSLIDE_RIGHT: - case Openings.LIFTSLIDE_RIGHT: - { - return OpeningSides.RIGHT; - } + // case Openings.TURNONLY_RIGHT: + // case Openings.TILTTURN_RIGHT: + // case Openings.TILTONLY_BOTTOM: + // case Openings.COMPLANARSLIDE_RIGHT: + // case Openings.LIFTSLIDE_RIGHT: + // { + // return OpeningSides.RIGHT; + // } - default: - { - return OpeningSides.NULL; - } - } - } + // default: + // { + // return OpeningSides.NULL; + // } + // } + //} internal Enums.OpeningTypes GetOpeningType(Openings OpeningType) { @@ -797,11 +798,6 @@ namespace WebWindowComplex.Models } } - internal void SetIsMeasureGlass(bool IsMeasureGlass) - { - m_bIsMeasureGlass = IsMeasureGlass; - } - internal void SetIsSashVertical(bool IsSashVertical) { m_bIsSashVertical = IsSashVertical; @@ -815,6 +811,10 @@ namespace WebWindowComplex.Models } } + /// + /// Metodo per impostare opzioni hardware da xml + /// + /// internal void SetHardwareOption(string OptionXml) { if (!string.IsNullOrEmpty(OptionXml)) @@ -928,10 +928,10 @@ namespace WebWindowComplex.Models } } - internal void SetSashType(SashTypes SashType) - { - m_SashType = SashType; - } + //internal void SetSashType(SashTypes SashType) + //{ + // m_SashType = SashType; + //} internal string SetSelFamilyHardwareFromIndex(string codHardware) { @@ -978,6 +978,11 @@ namespace WebWindowComplex.Models if (split.SplitVertList.Count > 0) { double dim = width; + double widthGlass = width; + foreach (var elem in split.ElemDimVertList) + { + widthGlass = widthGlass - elem.dDimension; + } switch (split.SplitVertList.ElementAt(i).SelMeasureType) { case MeasureTypes.ABSOLUTE: @@ -987,27 +992,19 @@ namespace WebWindowComplex.Models } case MeasureTypes.PROPORTIONAL: { - double widthGlass = width; + AreaDimension ad = new AreaDimension(split.SplitVertList.ElementAt(i).dDimension, split.SplitVertList.ElementAt(i).SelMeasureType, split.SplitVertList.ElementAt(i).Parent); List adList = new List(); foreach (var it in split.SplitVertList) { adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType, it.Parent)); } - foreach (var elem in split.ElemDimVertList) - { - widthGlass = widthGlass - elem.dDimension; - } dim = ad.ConvertFromPropVal(adList, MeasureTypes.ABSOLUTE, widthGlass); break; } case MeasureTypes.PERCENTAGE: { - foreach (var elem in split.ElemDimVertList) - { - dim = dim - elem.dDimension; - } - dim = split.SplitVertList.ElementAt(i).dDimension * dim / 100; + dim = split.SplitVertList.ElementAt(i).dDimension * widthGlass / 100; break; } } @@ -1094,6 +1091,12 @@ namespace WebWindowComplex.Models else { double dim = height; + double widthGlass = height; + int minSubArea = split.ElemDimHorizList.Min(x => x.nSubArea); + foreach (var elem in split.ElemDimHorizList.Where(x => x.nSubArea == minSubArea)) + { + widthGlass = widthGlass - elem.dDimension; + } switch (split.SplitHorizList.ElementAt(i).SelMeasureType) { case MeasureTypes.ABSOLUTE: @@ -1103,29 +1106,19 @@ namespace WebWindowComplex.Models } case MeasureTypes.PROPORTIONAL: { - double widthGlass = height; + AreaDimension ad = new AreaDimension(split.SplitHorizList.ElementAt(i).dDimension, split.SplitHorizList.ElementAt(i).SelMeasureType, split.SplitHorizList.ElementAt(i).Parent); List adList = new List(); foreach (var it in split.SplitHorizList) { adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType, it.Parent)); } - int minSubArea = split.ElemDimHorizList.Min(x=>x.nSubArea); - foreach (var elem in split.ElemDimHorizList.Where(x=>x.nSubArea == minSubArea)) - { - widthGlass = widthGlass - elem.dDimension; - } dim = ad.ConvertFromPropVal(adList, MeasureTypes.ABSOLUTE, widthGlass); break; } case MeasureTypes.PERCENTAGE: { - int minSubArea = split.ElemDimHorizList.Min(x => x.nSubArea); - foreach (var elem in split.ElemDimHorizList.Where(x => x.nSubArea == minSubArea)) - { - dim = dim - elem.dDimension; - } - dim = split.SplitHorizList.ElementAt(i).dDimension * dim / 100; + dim = split.SplitHorizList.ElementAt(i).dDimension * widthGlass / 100; break; } } @@ -1156,20 +1149,16 @@ namespace WebWindowComplex.Models /// private const string CustomHwId = "000000"; - private bool m_bIsMeasureGlass; - private bool m_bIsSashVertical; private bool m_bSashBottomRail; private string m_CurrShape = ""; private List m_HardwareList = new List(); - private List m_HwOptionList = new List(); private Dictionary m_SelHwOptionList = new Dictionary(); private int m_nSashBottomRailQty; - private List m_BottomRailElemDimList = new List(); private List m_OrientationSashTypeList = new List { diff --git a/WebWindowComplex/Models/SashDimension.cs b/WebWindowComplex/Models/SashDimension.cs index 0f4990d..3e29c06 100644 --- a/WebWindowComplex/Models/SashDimension.cs +++ b/WebWindowComplex/Models/SashDimension.cs @@ -24,23 +24,13 @@ namespace WebWindowComplex.Models switch (Parent.SashList[0].OpeningType) { case Openings.TURNONLY_LEFT: - { - SetOpeningType(Openings.TURNONLY_RIGHT); - break; - } - - case Openings.TURNONLY_RIGHT: - { - SetOpeningType(Openings.TURNONLY_LEFT); - break; - } - case Openings.TILTTURN_LEFT: { SetOpeningType(Openings.TURNONLY_RIGHT); break; } + case Openings.TURNONLY_RIGHT: case Openings.TILTTURN_RIGHT: { SetOpeningType(Openings.TURNONLY_LEFT); @@ -156,14 +146,12 @@ namespace WebWindowComplex.Models for (int i = 0; i < m_Parent.SashList.Count; i++) { if (i == 0) - widthTot = widthTot - - m_Parent.SashList.ElementAt(i).ElementDimensionList.ElementAt(1).dDimension - - m_Parent.SashList.ElementAt(i).ElementDimensionList.Last().dDimension; + widthTot = widthTot - m_Parent.SashList.ElementAt(i).ElementDimensionList.ElementAt(1).dDimension + - m_Parent.SashList.ElementAt(i).ElementDimensionList.Last().dDimension; else - widthTot = widthTot - - m_Parent.SashList.ElementAt(i).ElementDimensionList.ElementAt(1).dDimension - - m_Parent.SashList.ElementAt(i).ElementDimensionList.Last().dDimension - + m_Parent.SashList.ElementAt(i).ElementDimensionList.Last().dOverlap; + widthTot = widthTot - m_Parent.SashList.ElementAt(i).ElementDimensionList.ElementAt(1).dDimension + - m_Parent.SashList.ElementAt(i).ElementDimensionList.Last().dDimension + + m_Parent.SashList.ElementAt(i).ElementDimensionList.Last().dOverlap; } } double valMinAbsolute = 100; @@ -308,7 +296,7 @@ namespace WebWindowComplex.Models for (int i = 0; i < absoluteValList.Count; i++) { var item = m_Parent.SashList.ElementAt(i); - item.SetDimension(ad.ConvertIn(adList, absoluteValList[i], (MeasureTypes)item.SelMeasureTypeIndex, widthTot)); + item.SetDimension(ad.ConvertAbsoluteIn(adList, absoluteValList[i], (MeasureTypes)item.SelMeasureTypeIndex, widthTot)); } } foreach(var item in m_Parent.AreaList) @@ -430,28 +418,15 @@ namespace WebWindowComplex.Models else { for (int i = 0; i < m_Parent.SashList.Count - 1; i++) - { widthTot = widthTot + m_Parent.SashList.ElementAt(i).ElementDimensionList.ElementAt(1).dOverlap; - } } AreaDimension ad = new AreaDimension(m_dDimension, SelMeasureType, Parent); List newDimensions = new List(); foreach (var it in m_Parent.SashList) - { newDimensions.Add(new AreaDimension(it.m_dDimension, it.SelMeasureType, it.Parent)); - } - //double overlap = 0; - //if (!Parent.bIsDimensionLight) - //{ - // int index = m_Parent.SashList.IndexOf(this); - // if (index == 0) - // overlap = m_Parent.SashList.ElementAt(index).ElementDimensionList.ElementAt(1).dOverlap; - // else - // overlap = m_Parent.SashList.ElementAt(index).ElementDimensionList.Last().dOverlap; - //} if (newType is MeasureTypes.PROPORTIONAL) { - newDimensions = ad.CalculatePropVal(newDimensions, nSashId - 1, widthTot); + newDimensions = ad.RicalculatePropVal(newDimensions, nSashId - 1, widthTot); for (int i = 0; i < newDimensions.Count; i++) m_Parent.SashList.ElementAt(i).SetDimension(newDimensions.ElementAt(i).dDimension); } @@ -509,11 +484,6 @@ namespace WebWindowComplex.Models return JsonSashDimension; } - //internal void SetDimension(double dValue) - //{ - // m_dDimension = dValue; - //} - internal void SetHasHandle(bool value) { m_bHasHandle = value; @@ -529,57 +499,47 @@ namespace WebWindowComplex.Models SelMeasureType = value; } - internal void SetSelMeasureType(MeasureTypes value, int indexSash) - { - if (SelMeasureType != (MeasureTypes)value) - { - MeasureTypes newType = (MeasureTypes)value; - Frame? frame = m_Parent.ParentWindow.AreaList.FirstOrDefault(); - if (frame != null) - { - double widthTot = Parent.CalculateWidthSashGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension; - if (Parent.bIsDimensionLight) - { - for(int i = 0; i < Parent.SashList.Count; i++) - { - if (i == 0) - widthTot = widthTot - Parent.SashList.ElementAt(i).ElementDimensionList.ElementAt(1).dDimension - - Parent.SashList.ElementAt(i).ElementDimensionList.Last().dDimension; - else - widthTot = widthTot - Parent.SashList.ElementAt(i).ElementDimensionList.ElementAt(1).dDimension - - Parent.SashList.ElementAt(i).ElementDimensionList.Last().dDimension - + Parent.SashList.ElementAt(i).ElementDimensionList.Last().dOverlap; - } - } - else - { - for (int i = 0; i < m_Parent.SashList.Count - 1; i++) - { - widthTot = widthTot + m_Parent.SashList.ElementAt(i).ElementDimensionList.ElementAt(1).dOverlap; - } - } - AreaDimension ad = new AreaDimension(dDimension, SelMeasureType, Parent); - List newDimensions = new List(); - foreach(var item in m_Parent.SashList) - { - newDimensions.Add(new AreaDimension(item.dDimension, item.SelMeasureType, item.Parent)); - } - int index = m_Parent.SashList.IndexOf(this); - //double overlap = 0; - //if (index == 0) - // overlap = m_Parent.SashList.ElementAt(index).ElementDimensionList.ElementAt(1).dOverlap; - //else - // overlap = m_Parent.SashList.ElementAt(index).ElementDimensionList.Last().dOverlap; - m_dDimension = ad.ConvertDimension(newDimensions, SelMeasureType, newType, widthTot, indexSash); - //if (newType is MeasureTypes.PROPORTIONAL) - //{ - // for (int i = 0; i < newDimensions.Count; i++) - // m_Parent.SashList.ElementAt(i).SetDimension(newDimensions.ElementAt(i).dDimension); - //} - SelMeasureType = (MeasureTypes)value; - } - } - } + //internal void SetSelMeasureType(MeasureTypes value, int indexSash) + //{ + // if (SelMeasureType != (MeasureTypes)value) + // { + // MeasureTypes newType = (MeasureTypes)value; + // Frame? frame = m_Parent.ParentWindow.AreaList.FirstOrDefault(); + // if (frame != null) + // { + // double widthTot = Parent.CalculateWidthSashGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension; + // if (Parent.bIsDimensionLight) + // { + // for(int i = 0; i < Parent.SashList.Count; i++) + // { + // if (i == 0) + // widthTot = widthTot - Parent.SashList.ElementAt(i).ElementDimensionList.ElementAt(1).dDimension + // - Parent.SashList.ElementAt(i).ElementDimensionList.Last().dDimension; + // else + // widthTot = widthTot - Parent.SashList.ElementAt(i).ElementDimensionList.ElementAt(1).dDimension + // - Parent.SashList.ElementAt(i).ElementDimensionList.Last().dDimension + // + Parent.SashList.ElementAt(i).ElementDimensionList.Last().dOverlap; + // } + // } + // else + // { + // for (int i = 0; i < m_Parent.SashList.Count - 1; i++) + // { + // widthTot = widthTot + m_Parent.SashList.ElementAt(i).ElementDimensionList.ElementAt(1).dOverlap; + // } + // } + // AreaDimension ad = new AreaDimension(dDimension, SelMeasureType, Parent); + // List newDimensions = new List(); + // foreach(var item in m_Parent.SashList) + // { + // newDimensions.Add(new AreaDimension(item.dDimension, item.SelMeasureType, item.Parent)); + // } + // int index = m_Parent.SashList.IndexOf(this); + // m_dDimension = ad.ConvertDimension(newDimensions, SelMeasureType, newType, widthTot, indexSash); + // SelMeasureType = (MeasureTypes)value; + // } + // } + //} #endregion Internal Methods diff --git a/WebWindowComplex/Models/Split.cs b/WebWindowComplex/Models/Split.cs index 8b5aa61..c72e795 100644 --- a/WebWindowComplex/Models/Split.cs +++ b/WebWindowComplex/Models/Split.cs @@ -32,12 +32,12 @@ namespace WebWindowComplex.Models m_ElemDimHorizList.Clear(); double thickness = 78; if (ParentArea is Sash || ParentArea.ParentArea is Sash) - thickness = 60; + thickness = Window.m_ParameterList.GetValueOrDefault("Sash_Sash_Split_DimStd"); if (value) { for (int i = 0; i < nSplitQtyVert; i++) { - SplitElementDimension newVertElem= elemVertListOld.Where(x=>x.nSubArea==1 && x.nIndex==i+1).First().Copy(); + SplitElementDimension newVertElem = elemVertListOld.Where(x => x.nSubArea == 1 && x.nIndex == i + 1).First().Copy(); newVertElem.SetElement(i + 1, thickness, 0); m_ElemDimVertList.Add(newVertElem); //m_ElemDimVertList.Add(new SplitElementDimension(this, i + 1, thickness, 0)); @@ -46,7 +46,7 @@ namespace WebWindowComplex.Models { for (int index = 0; index < nSplitQtyHoriz; index++) { - SplitElementDimension newHorizElem = elemHorizListOld.Where(x => x.nIndex == index+1).First().Copy(); + SplitElementDimension newHorizElem = elemHorizListOld.Where(x => x.nIndex == index + 1).First().Copy(); newHorizElem.SetElement(index + 1, thickness, subArea + 1); m_ElemDimHorizList.Add(newHorizElem); //m_ElemDimHorizList.Add(new SplitElementDimension(this, index + 1, thickness, subArea + 1)); @@ -57,7 +57,7 @@ namespace WebWindowComplex.Models { for (int i = 0; i < nSplitQtyHoriz; i++) { - SplitElementDimension newHorizElem = elemHorizListOld.Where(x => x.nSubArea == 1 && x.nIndex == i+1).First().Copy(); + SplitElementDimension newHorizElem = elemHorizListOld.Where(x => x.nSubArea == 1 && x.nIndex == i + 1).First().Copy(); newHorizElem.SetElement(i + 1, thickness, 0); m_ElemDimHorizList.Add(newHorizElem); //m_ElemDimHorizList.Add(new SplitElementDimension(this, i + 1, thickness, 0)); @@ -66,7 +66,7 @@ namespace WebWindowComplex.Models { for (int index = 0; index < nSplitQtyVert; index++) { - SplitElementDimension newVertElem = elemVertListOld.Where(x => x.nIndex == index+1).First().Copy(); + SplitElementDimension newVertElem = elemVertListOld.Where(x => x.nIndex == index + 1).First().Copy(); newVertElem.SetElement(index + 1, thickness, subArea + 1); m_ElemDimVertList.Add(newVertElem); //m_ElemDimVertList.Add(new SplitElementDimension(this, index + 1, thickness, subArea + 1)); @@ -115,8 +115,8 @@ namespace WebWindowComplex.Models Frame? frame = ParentWindow.AreaList.FirstOrDefault(); if(frame != null) { - double heightTot = SplitHorizList.First().CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false)).m_Dimension; - //double heightTot = CalculateHeightArea(frame, frame.AvailHeightArea()); + double heightTot = CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false)).m_Dimension; + //double heightTot = SplitHorizList.First().CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false)).m_Dimension; // Ricalcolo dimensioni aggiungendo split if (value > m_SplitHorizList.Count - 1) { @@ -141,7 +141,7 @@ namespace WebWindowComplex.Models m_SplitHorizList.Add(new SplitDimension(dNewDimension, m_SplitHorizList[m_SplitHorizList.Count - 1].MeasureType, true, this, false)); double thickness = 78; if (ParentArea is Sash || ParentArea.ParentArea is Sash) - thickness = 60; + thickness = Window.m_ParameterList.GetValueOrDefault("Sash_Sash_Split_DimStd"); if (!m_bSplitStartVert) { //Aggiungo un elemento alla sottoarea principale @@ -287,7 +287,7 @@ namespace WebWindowComplex.Models Frame? frame = ParentWindow.AreaList.FirstOrDefault(); if (frame != null) { - double widthTot = SplitVertList.First().CalculateWidthSplitGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension; + double widthTot = CalculateWidthSplitGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension; //double widthTot = CalculateWidthArea(frame, frame.AvailWidthArea()); // Ricalcolo dimensioni aggiungendo split if (value > m_SplitVertList.Count - 1) @@ -313,7 +313,7 @@ namespace WebWindowComplex.Models m_SplitVertList.Add(new SplitDimension(dNewDimension, m_SplitVertList[m_SplitVertList.Count - 1].MeasureType, true, this, true)); double thickness = 78; if (ParentArea is Sash || ParentArea.ParentArea is Sash) - thickness = 60; + thickness = Window.m_ParameterList.GetValueOrDefault("Sash_Sash_Split_DimStd"); if (m_bSplitStartVert) { //Aggiungo un elemento alla sottoarea principale @@ -321,7 +321,7 @@ namespace WebWindowComplex.Models newElemDim.SetElement(ElemDimVertList.Max(x => x.nIndex) + 1, thickness, 0); ElemDimVertList.Add(newElemDim); //ElemDimVertList.Add(new SplitElementDimension(this, ElemDimVertList.Max(x => x.nIndex) + 1, 78, 0)); - if(nSplitQtyHoriz > 0) + if (nSplitQtyHoriz > 0) { // Aggiungo a tutte le sottoaree degli element int subArea = ElemDimHorizList.Max(x => x.nSubArea) + 1; @@ -546,12 +546,6 @@ namespace WebWindowComplex.Models newSplit.SplitVertList.Add(SplitVertList[i].Copy()); for (int i = 0; i < SplitHorizList.Count; i++) newSplit.SplitHorizList.Add(SplitHorizList[i].Copy()); - //newSplit.SetSplitQtyVert(nSplitQtyVert); - //for (int i = 0; i < SplitVertList.Count; i++) - // newSplit.SplitVertList.ElementAt(i).SetDimension(SplitVertList.ElementAt(i).dDimension); - //newSplit.SetSplitQtyHoriz(nSplitQtyHoriz); - //for (int i = 0; i < SplitHorizList.Count; i++) - // newSplit.SplitHorizList.ElementAt(i).SetDimension(SplitHorizList.ElementAt(i).dDimension); newSplit.SetSplitShape(SelSplitShape); newSplit.SetAreaType(AreaType); foreach (var item in ElemDimHorizList) @@ -627,13 +621,240 @@ namespace WebWindowComplex.Models return Split; } + /// + /// Metodo per calcolare altezza intero split group + /// + /// area di partenza + /// altezza di partenza + /// area di ritorno + /// + internal AreaFound CalculateHeightSplitGroup(Area area, double height, AreaFound res) + { + for (int i = 0; i < area.AreaList.Count; i++) + { + if (area.Equals(this)) + { + res.m_Dimension = height; + res.m_Found = true; + return res; + } + Area item = area.AreaList[i]; + if (area is Split split) + { + if (split.SplitHorizList.Count > 0) + { + double dim = height; + foreach (var elem in split.ElemDimHorizList) + dim = dim - elem.dDimension; + int index = i; + if (split.SelSplitShape is SplitShapes.GRID) + index = i % split.SplitHorizList.Count; + switch (split.SplitHorizList.ElementAt(index).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + dim = split.SplitHorizList.ElementAt(index).dDimension; + break; + } + case MeasureTypes.PROPORTIONAL: + { + AreaDimension ad = new AreaDimension(split.SplitHorizList.ElementAt(index).dDimension, split.SplitHorizList.ElementAt(index).SelMeasureType, split.SplitHorizList.ElementAt(index).Parent); + List adList = new List(); + foreach (var it in split.SplitHorizList) + adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType, it.Parent)); + dim = ad.ConvertFromPropVal(adList, MeasureTypes.ABSOLUTE, dim); + break; + } + case MeasureTypes.PERCENTAGE: + { + dim = split.SplitHorizList.ElementAt(index).dDimension * dim / 100; + break; + } + } + res = CalculateHeightSplitGroup(item, dim, res); + if (res.m_Dimension != -1 && res.m_Found) + return res; + } + else + { + double dim = height; + res = CalculateHeightSplitGroup(item, dim, res); + if (res.m_Dimension != -1 && res.m_Found) + return res; + } + } + else if (area is Sash sash) + { + double bottomRail = 0; + if (sash.SashBottomRailQty > 0) + { + foreach (var bottom in sash.BottomRailElemDimList) + bottomRail = bottomRail + bottom.dDimension + - bottom.dOverlap; + } + double dim = height - sash.SashList.First().ElementDimensionList.First().dDimension + - sash.SashList.First().ElementDimensionList.ElementAt(sash.SashList.First().ElementDimensionList.Count - 2).dDimension + - bottomRail; + res = CalculateHeightSplitGroup(item, dim, res); + if (res.m_Dimension != -1 && res.m_Found) + return res; + } + else if (area is Splitted splitted) + { + double dim = height; + if (splitted.ParentArea is Split sp && splitted.AreaList.First() is Sash sh) + { + if (sp.SplitHorizList.Count > 0) + { + dim = dim + sh.SashList.First().ElementDimensionList.First().dOverlap + + sh.SashList.First().ElementDimensionList.ElementAt(sh.SashList.First().ElementDimensionList.Count - 2).dOverlap; + } + } + res = CalculateHeightSplitGroup(item, dim, res); + if (res.m_Dimension != -1 && res.m_Found) + return res; + } + else + { + res = CalculateHeightSplitGroup(item, height, res); + if (res.m_Dimension != -1 && res.m_Found) + return res; + } + } + return res; + } + + /// + /// Metodo per calcolare larghezza intero split group + /// + /// area di partenza + /// larghezza di partenza + /// area di ritorno + /// + internal AreaFound CalculateWidthSplitGroup(Area area, double width, AreaFound res) + { + for (int i = 0; i < area.AreaList.Count; i++) + { + if (area.Equals(this)) + { + res.m_Dimension = width; + res.m_Found = true; + return res; + } + Area item = area.AreaList[i]; + if (area is Split split) + { + if (split.SplitVertList.Count > 0) + { + int index = i; + double dim = width; + foreach (var elem in split.ElemDimVertList) + dim = dim - elem.dDimension; + if (split.SelSplitShape is SplitShapes.GRID) + index = i % split.SplitHorizList.Count; + switch (split.SplitVertList.ElementAt(index).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + res = CalculateWidthSplitGroup(item, split.SplitVertList.ElementAt(index).dDimension, res); + break; + } + case MeasureTypes.PROPORTIONAL: + { + AreaDimension ad = new AreaDimension(split.SplitVertList.ElementAt(index).dDimension, split.SplitVertList.ElementAt(index).SelMeasureType, split.SplitVertList.ElementAt(index).Parent); + List adList = new List(); + foreach (var it in split.SplitVertList) + { + adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType, it.Parent)); + } + res = CalculateWidthSplitGroup(item, ad.ConvertFromPropVal(adList, MeasureTypes.ABSOLUTE, dim), res); + break; + } + case MeasureTypes.PERCENTAGE: + { + res = CalculateWidthSplitGroup(item, split.SplitVertList.ElementAt(index).dDimension * dim / 100, res); + break; + } + } + if (res.m_Dimension != -1 && res.m_Found) + return res; + } + else + { + res = CalculateWidthSplitGroup(item, width, res); + if (res.m_Dimension != -1 && res.m_Found) + return res; + } + } + else if (area is Sash sash) + { + double widthTot = width; + double dim = 0; + if (sash.ParentArea.ParentArea is Split) + widthTot = widthTot + sash.SashList.ElementAt(i).ElementDimensionList.ElementAt(1).dOverlap + + sash.SashList.ElementAt(i).ElementDimensionList.Last().dOverlap; + if (sash.bIsDimensionLight) + { + widthTot = widthTot - sash.SashList.First().ElementDimensionList.ElementAt(1).dDimension + - sash.SashList.First().ElementDimensionList.Last().dDimension; + for (int anta = 1; anta < sash.SashList.Count; anta++) + { + widthTot = widthTot - sash.SashList.ElementAt(anta).ElementDimensionList.ElementAt(1).dDimension + - sash.SashList.ElementAt(anta).ElementDimensionList.Last().dDimension + + sash.SashList.ElementAt(anta).ElementDimensionList.Last().dOverlap; + } + } + else + { + for (int anta = 1; anta < sash.SashList.Count; anta++) + { + widthTot = widthTot + sash.SashList.ElementAt(anta).ElementDimensionList.Last().dOverlap; + } + } + switch (sash.SashList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + dim = sash.SashList.ElementAt(i).dDimension; + break; + } + case MeasureTypes.PROPORTIONAL: + { + AreaDimension ad = new AreaDimension(sash.SashList.ElementAt(i).dDimension, sash.SashList.ElementAt(i).SelMeasureType, sash.SashList.ElementAt(i).Parent); + List adList = new List(); + foreach (var it in sash.SashList) + adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType, it.Parent)); + dim = ad.ConvertFromPropVal(adList, MeasureTypes.ABSOLUTE, widthTot); + break; + } + case MeasureTypes.PERCENTAGE: + { + dim = sash.SashList.ElementAt(i).dDimension * widthTot / 100; + break; + } + } + if (!sash.bIsDimensionLight) + dim = dim - sash.SashList.ElementAt(i).ElementDimensionList.ElementAt(1).dDimension + - sash.SashList.ElementAt(i).ElementDimensionList.Last().dDimension; + res = CalculateWidthSplitGroup(item, dim, res); + if (res.m_Dimension != -1 && res.m_Found) + return res; + } + else + { + res = CalculateWidthSplitGroup(item, width, res); + if (res.m_Dimension != -1 && res.m_Found) + return res; + } + } + return res; + } + internal override JsonArea Serialize(bool hideHw) { if (nCounterGroup < GroupId) Area.nCounterGroup = GroupId; JsonSplit JsonSplit = new JsonSplit(m_SelSplitShape, GroupId); - //foreach (var SplitPosition in m_SplitPositionList) - // JsonSplit.SplitPositionList.Add(SplitPosition.Serialize()); JsonSplit.SplitStartVert = bSplitStartVert; foreach (var SplitVert in m_SplitVertList) JsonSplit.SplitVertList.Add(SplitVert.Serialize()); @@ -690,11 +911,10 @@ namespace WebWindowComplex.Models { double thickness = 78; if (ParentArea is Sash || ParentArea.ParentArea is Sash) - thickness = 60; + thickness = Window.m_ParameterList.GetValueOrDefault("Sash_Sash_Split_DimStd"); // Un Elemento per ogni dimensione principale e per ogni sotto dimensione if (bSplitStartVert) { - for (int subArea = 0; subArea <= QtyVert; subArea++) { for (int i = 0; i < QtyHoriz; i++) @@ -741,7 +961,7 @@ namespace WebWindowComplex.Models { double thickness = 78; if (ParentArea is Sash || ParentArea.ParentArea is Sash) - thickness = 60; + thickness = Window.m_ParameterList.GetValueOrDefault("Sash_Sash_Split_DimStd"); // Un Elemento per ogni dimensione principale e per ogni sotto dimensione if (bSplitStartVert) { @@ -769,41 +989,6 @@ namespace WebWindowComplex.Models m_bSplitStartVert = SplitStartVert; } - internal double HeightFrame() - { - double dim = 0; - switch (ParentWindow.AreaList.First().SelShapeIndex) - { - case (int)Shapes.RECTANGLE: - case (int)Shapes.TRIANGLE: - case (int)Shapes.ARC_FULL: - { - dim = ParentWindow.AreaList.FirstOrDefault()!.DimensionList.Where(x => x.sName == "Height").First().dDimension; - break; - } - case (int)Shapes.RIGHTCHAMFER: - { - dim = ParentWindow.AreaList.FirstOrDefault()!.DimensionList.Where(x => x.sName == "Left Height").First().dDimension; - break; - } - case (int)Shapes.LEFTCHAMFER: - { - dim = ParentWindow.AreaList.FirstOrDefault()!.DimensionList.Where(x => x.sName == "Right Height").First().dDimension; - break; - } - default: - { - dim = ParentWindow.AreaList.FirstOrDefault()!.DimensionList.Where(x => x.sName == "Full Height").First().dDimension; - break; - } - } - foreach(var elem in ElemDimHorizList) - { - dim = dim - elem.dDimension; - } - return dim; - } - internal void UpdateSubAreaSplit() { if (SplitHorizList.Count > 0) @@ -816,16 +1001,16 @@ namespace WebWindowComplex.Models List dimList = new List(); foreach (var itemDim in SplitHorizList) dimList.Add(new AreaDimension(itemDim.dDimension, itemDim.MeasureType, itemDim.Parent)); - //double width = SplitHorizList.First().CalculateWidthSplitGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension; - ////double width = ParentArea.CalculateWidthArea(ParentArea.ParentWindow.AreaList[0], ParentArea.ParentWindow.AreaList[0].AvailWidthArea()); - //AreaList.ElementAt(i).SearchAreaList(AreaList.ElementAt(i), width, "Width"); double dim = currSplitDim.dDimension; double height = 0; if (!(currSplitDim.MeasureType.Equals(MeasureTypes.ABSOLUTE))) { Frame frame = ParentArea.ParentWindow.AreaList[0]; if (frame != null) - height = currSplitDim.CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false)).m_Dimension; + { + height = CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false)).m_Dimension; + //height = currSplitDim.CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false)).m_Dimension; + } foreach (var elem in ElemDimHorizList) height = height - elem.dDimension; dim = currSplitDim.ConvertDimension(dimList, currSplitDim.MeasureType, MeasureTypes.ABSOLUTE, height, -1); @@ -850,7 +1035,10 @@ namespace WebWindowComplex.Models { Frame frame = ParentArea.ParentWindow.AreaList[0]; if(frame != null) - width = currSplitDim.CalculateWidthSplitGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension; + { + width = CalculateWidthSplitGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension; + //width = currSplitDim.CalculateWidthSplitGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension; + } foreach (var elem in ElemDimVertList) width = width - elem.dDimension; dim = currSplitDim.ConvertDimension(dimList, currSplitDim.MeasureType, MeasureTypes.ABSOLUTE, width, -1); diff --git a/WebWindowComplex/Models/SplitDimension.cs b/WebWindowComplex/Models/SplitDimension.cs index caa9874..7ccad53 100644 --- a/WebWindowComplex/Models/SplitDimension.cs +++ b/WebWindowComplex/Models/SplitDimension.cs @@ -52,12 +52,14 @@ namespace WebWindowComplex.Models subAreaVert = m_Parent.ElemDimVertList.Min(x => x.nSubArea); if (m_Parent.ElemDimHorizList.Count > 0) subAreaHoriz = m_Parent.ElemDimHorizList.Min(x => x.nSubArea); - double width = CalculateWidthSplitGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension; + //double width = CalculateWidthSplitGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension; + double width = Parent.CalculateWidthSplitGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension; foreach (var item in m_Parent.ElemDimVertList.Where(x=>x.nSubArea == subAreaVert)) { width = width - item.dDimension; } - double height = (CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false))).m_Dimension; + double height = (Parent.CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false))).m_Dimension; + //double height = (CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false))).m_Dimension; foreach (var item in m_Parent.ElemDimHorizList.Where(x => x.nSubArea == subAreaHoriz)) { height = height - item.dDimension; @@ -225,7 +227,7 @@ namespace WebWindowComplex.Models for (int i = 0; i < absoluteValList.Count; i++) { var item = dimensions.ElementAt(i); - item.SetDimension(ad.ConvertIn(adList, absoluteValList[i], (MeasureTypes)item.SelMeasureTypeIndex, dimensionTot)); + item.SetDimension(ad.ConvertAbsoluteIn(adList, absoluteValList[i], (MeasureTypes)item.SelMeasureTypeIndex, dimensionTot)); } } for (int i = 0; i < m_Parent.AreaList.Count; i++) @@ -293,7 +295,8 @@ namespace WebWindowComplex.Models splitElemList = m_Parent.ElemDimVertList; else splitElemList = m_Parent.ElemDimVertList.Where(x => x.nSubArea == 1).ToList(); - dimSplitGroup = CalculateWidthSplitGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension; + //dimSplitGroup = CalculateWidthSplitGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension; + dimSplitGroup = Parent.CalculateWidthSplitGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension; } else { @@ -302,7 +305,8 @@ namespace WebWindowComplex.Models splitElemList = m_Parent.ElemDimHorizList.Where(x => x.nSubArea == 1).ToList(); else splitElemList = m_Parent.ElemDimHorizList; - dimSplitGroup = (CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false))).m_Dimension; + dimSplitGroup = (Parent.CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false))).m_Dimension; + //dimSplitGroup = (CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false))).m_Dimension; } AreaDimension ad = new AreaDimension(dDimension, SelMeasureType, Parent); List adList = new List(); @@ -316,7 +320,7 @@ namespace WebWindowComplex.Models } if (newType is MeasureTypes.PROPORTIONAL) { - adList = ad.CalculatePropVal(adList, splitList.IndexOf(this), dimSplitGroup); + adList = ad.RicalculatePropVal(adList, splitList.IndexOf(this), dimSplitGroup); for (int i = 0; i < adList.Count; i++) splitList.ElementAt(i).SetDimension(adList.ElementAt(i).dDimension); } @@ -342,247 +346,234 @@ namespace WebWindowComplex.Models #region Internal Methods - /// - /// Metodo per calcolare larghezza intero split group - /// - /// area di partenza - /// larghezza di partenza - /// area di ritorno - /// - internal AreaFound CalculateWidthSplitGroup(Area area, double width, AreaFound res) - { - for (int i = 0; i < area.AreaList.Count; i++) - { - if (area.Equals(m_Parent)) - { - res.m_Dimension = width; - res.m_Found = true; - return res; - } - Area item = area.AreaList[i]; - if (area is Split split) - { - if(split.SplitVertList.Count > 0) - { - int index = i; - double widthGlass = width; - foreach (var elem in split.ElemDimVertList) - widthGlass = widthGlass - elem.dDimension; - if (split.SelSplitShape is SplitShapes.GRID) - index = i % split.SplitHorizList.Count; - switch (split.SplitVertList.ElementAt(index).SelMeasureType) - { - case MeasureTypes.ABSOLUTE: - { - res = CalculateWidthSplitGroup(item, split.SplitVertList.ElementAt(index).dDimension, res); - break; - } - case MeasureTypes.PROPORTIONAL: - { - AreaDimension ad = new AreaDimension(split.SplitVertList.ElementAt(index).dDimension, split.SplitVertList.ElementAt(index).SelMeasureType, split.SplitVertList.ElementAt(index).Parent); - List adList = new List(); - foreach (var it in split.SplitVertList) - { - adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType, it.Parent)); - } - res = CalculateWidthSplitGroup(item, ad.ConvertFromPropVal(adList, MeasureTypes.ABSOLUTE, widthGlass), res); - break; - } - case MeasureTypes.PERCENTAGE: - { - res = CalculateWidthSplitGroup(item, split.SplitVertList.ElementAt(index).dDimension * widthGlass / 100, res); - break; - } - } - if (res.m_Dimension != -1 && res.m_Found) - return res; - } - else - { - res = CalculateWidthSplitGroup(item, width, res); - if (res.m_Dimension != -1 && res.m_Found) - return res; - } - } - else if (area is Sash sash) - { - double widthTot = width; - double dim = 0; - if (sash.ParentArea.ParentArea is Split) - widthTot = widthTot + sash.SashList.ElementAt(i).ElementDimensionList.ElementAt(1).dOverlap - + sash.SashList.ElementAt(i).ElementDimensionList.Last().dOverlap; - if (sash.bIsDimensionLight) - { - widthTot = widthTot - sash.SashList.First().ElementDimensionList.ElementAt(1).dDimension - - sash.SashList.First().ElementDimensionList.Last().dDimension; - for (int anta = 1; anta < sash.SashList.Count; anta++) - { - widthTot = widthTot - sash.SashList.ElementAt(anta).ElementDimensionList.ElementAt(1).dDimension - - sash.SashList.ElementAt(anta).ElementDimensionList.Last().dDimension - + sash.SashList.ElementAt(anta).ElementDimensionList.Last().dOverlap; - } - } - else - { - for (int anta = 1; anta < sash.SashList.Count; anta++) - { - widthTot = widthTot + sash.SashList.ElementAt(anta).ElementDimensionList.Last().dOverlap; - } - } - switch (sash.SashList.ElementAt(i).SelMeasureType) - { - case MeasureTypes.ABSOLUTE: - { - dim = sash.SashList.ElementAt(i).dDimension; - break; - } - case MeasureTypes.PROPORTIONAL: - { - AreaDimension ad = new AreaDimension(sash.SashList.ElementAt(i).dDimension, sash.SashList.ElementAt(i).SelMeasureType, sash.SashList.ElementAt(i).Parent); - List adList = new List(); - foreach (var it in sash.SashList) - adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType, it.Parent)); - dim = ad.ConvertFromPropVal(adList, MeasureTypes.ABSOLUTE, widthTot); - break; - } - case MeasureTypes.PERCENTAGE: - { - dim = sash.SashList.ElementAt(i).dDimension * widthTot / 100; - break; - } - } - if (!sash.bIsDimensionLight) - dim = dim - sash.SashList.ElementAt(i).ElementDimensionList.ElementAt(1).dDimension - - sash.SashList.ElementAt(i).ElementDimensionList.Last().dDimension; - res = CalculateWidthSplitGroup(item, dim, res); - if (res.m_Dimension != -1 && res.m_Found) - return res; - } - else - { - res = CalculateWidthSplitGroup(item, width, res); - if (res.m_Dimension != -1 && res.m_Found) - return res; - } - } - return res; - } + ///// + ///// Metodo per calcolare larghezza intero split group + ///// + ///// area di partenza + ///// larghezza di partenza + ///// area di ritorno + ///// + //internal AreaFound CalculateWidthSplitGroup(Area area, double width, AreaFound res) + //{ + // for (int i = 0; i < area.AreaList.Count; i++) + // { + // if (area.Equals(m_Parent)) + // { + // res.m_Dimension = width; + // res.m_Found = true; + // return res; + // } + // Area item = area.AreaList[i]; + // if (area is Split split) + // { + // if(split.SplitVertList.Count > 0) + // { + // int index = i; + // double dim = width; + // foreach (var elem in split.ElemDimVertList) + // dim = dim - elem.dDimension; + // if (split.SelSplitShape is SplitShapes.GRID) + // index = i % split.SplitHorizList.Count; + // switch (split.SplitVertList.ElementAt(index).SelMeasureType) + // { + // case MeasureTypes.ABSOLUTE: + // { + // res = CalculateWidthSplitGroup(item, split.SplitVertList.ElementAt(index).dDimension, res); + // break; + // } + // case MeasureTypes.PROPORTIONAL: + // { + // AreaDimension ad = new AreaDimension(split.SplitVertList.ElementAt(index).dDimension, split.SplitVertList.ElementAt(index).SelMeasureType, split.SplitVertList.ElementAt(index).Parent); + // List adList = new List(); + // foreach (var it in split.SplitVertList) + // { + // adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType, it.Parent)); + // } + // res = CalculateWidthSplitGroup(item, ad.ConvertFromPropVal(adList, MeasureTypes.ABSOLUTE, dim), res); + // break; + // } + // case MeasureTypes.PERCENTAGE: + // { + // res = CalculateWidthSplitGroup(item, split.SplitVertList.ElementAt(index).dDimension * dim / 100, res); + // break; + // } + // } + // if (res.m_Dimension != -1 && res.m_Found) + // return res; + // } + // else + // { + // res = CalculateWidthSplitGroup(item, width, res); + // if (res.m_Dimension != -1 && res.m_Found) + // return res; + // } + // } + // else if (area is Sash sash) + // { + // double widthTot = width; + // double dim = 0; + // if (sash.ParentArea.ParentArea is Split) + // widthTot = widthTot + sash.SashList.ElementAt(i).ElementDimensionList.ElementAt(1).dOverlap + // + sash.SashList.ElementAt(i).ElementDimensionList.Last().dOverlap; + // if (sash.bIsDimensionLight) + // { + // widthTot = widthTot - sash.SashList.First().ElementDimensionList.ElementAt(1).dDimension + // - sash.SashList.First().ElementDimensionList.Last().dDimension; + // for (int anta = 1; anta < sash.SashList.Count; anta++) + // { + // widthTot = widthTot - sash.SashList.ElementAt(anta).ElementDimensionList.ElementAt(1).dDimension + // - sash.SashList.ElementAt(anta).ElementDimensionList.Last().dDimension + // + sash.SashList.ElementAt(anta).ElementDimensionList.Last().dOverlap; + // } + // } + // else + // { + // for (int anta = 1; anta < sash.SashList.Count; anta++) + // { + // widthTot = widthTot + sash.SashList.ElementAt(anta).ElementDimensionList.Last().dOverlap; + // } + // } + // switch (sash.SashList.ElementAt(i).SelMeasureType) + // { + // case MeasureTypes.ABSOLUTE: + // { + // dim = sash.SashList.ElementAt(i).dDimension; + // break; + // } + // case MeasureTypes.PROPORTIONAL: + // { + // AreaDimension ad = new AreaDimension(sash.SashList.ElementAt(i).dDimension, sash.SashList.ElementAt(i).SelMeasureType, sash.SashList.ElementAt(i).Parent); + // List adList = new List(); + // foreach (var it in sash.SashList) + // adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType, it.Parent)); + // dim = ad.ConvertFromPropVal(adList, MeasureTypes.ABSOLUTE, widthTot); + // break; + // } + // case MeasureTypes.PERCENTAGE: + // { + // dim = sash.SashList.ElementAt(i).dDimension * widthTot / 100; + // break; + // } + // } + // if (!sash.bIsDimensionLight) + // dim = dim - sash.SashList.ElementAt(i).ElementDimensionList.ElementAt(1).dDimension + // - sash.SashList.ElementAt(i).ElementDimensionList.Last().dDimension; + // res = CalculateWidthSplitGroup(item, dim, res); + // if (res.m_Dimension != -1 && res.m_Found) + // return res; + // } + // else + // { + // res = CalculateWidthSplitGroup(item, width, res); + // if (res.m_Dimension != -1 && res.m_Found) + // return res; + // } + // } + // return res; + //} - /// - /// Metodo per calcolare altezza intero split group - /// - /// area di partenza - /// altezza di partenza - /// area di ritorno - /// - internal AreaFound CalculateHeightSplitGroup(Area area, double height, AreaFound res) - { - for (int i = 0; i < area.AreaList.Count; i++) - { - if (area.Equals(m_Parent)) - { - res.m_Dimension = height; - res.m_Found = true; - return res; - } - Area item = area.AreaList[i]; - if (area is Split split) - { - if (split.SplitHorizList.Count > 0) - { - double dim = height; - int index = i; - if (split.SelSplitShape is SplitShapes.GRID) - index = i % split.SplitHorizList.Count; - switch (split.SplitHorizList.ElementAt(index).SelMeasureType) - { - case MeasureTypes.ABSOLUTE: - { - dim = split.SplitHorizList.ElementAt(index).dDimension; - break; - } - case MeasureTypes.PROPORTIONAL: - { - double heigthGlass = 0; - AreaDimension ad = new AreaDimension(split.SplitHorizList.ElementAt(index).dDimension, split.SplitHorizList.ElementAt(index).SelMeasureType, split.SplitHorizList.ElementAt(index).Parent); - List adList = new List(); - foreach (var it in split.SplitHorizList) - adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType, it.Parent)); - foreach (var elem in split.ElemDimHorizList) - heigthGlass = heigthGlass - elem.dDimension; - dim = ad.ConvertFromPropVal(adList, MeasureTypes.ABSOLUTE, heigthGlass); - break; - } - case MeasureTypes.PERCENTAGE: - { - foreach(var elem in split.ElemDimHorizList) - dim = dim - elem.dDimension; - dim = split.SplitHorizList.ElementAt(index).dDimension * dim / 100; - break; - } - } - //if (split.ParentArea is Frame frame && split.AreaList.ElementAt(i).AreaList.First() is Sash sash) - //{ - // dim = dim + sash.SashList.First().ElementDimensionList.First().dOverlap - // + sash.SashList.First().ElementDimensionList.ElementAt(sash.SashList.First().ElementDimensionList.Count - 2).dOverlap; - //} - res = CalculateHeightSplitGroup(item, dim, res); - if (res.m_Dimension != -1 && res.m_Found) - return res; - } - else - { - double dim = height; - //if (split.ParentArea is Frame frame && split.AreaList.ElementAt(i).AreaList.First() is Sash sash) - //{ - // dim = dim + sash.SashList.First().ElementDimensionList.First().dOverlap - // + sash.SashList.First().ElementDimensionList.ElementAt(sash.SashList.First().ElementDimensionList.Count - 2).dOverlap; - //} - res = CalculateHeightSplitGroup(item, dim, res); - if (res.m_Dimension != -1 && res.m_Found) - return res; - } - } - else if (area is Sash sash) - { - double bottomRail = 0; - if(sash.SashBottomRailQty > 0) - { - foreach (var bottom in sash.BottomRailElemDimList) - bottomRail = bottomRail + bottom.dDimension - - bottom.dOverlap; - } - double dim = height - sash.SashList.First().ElementDimensionList.First().dDimension - - sash.SashList.First().ElementDimensionList.ElementAt(sash.SashList.First().ElementDimensionList.Count - 2).dDimension - - bottomRail; - res = CalculateHeightSplitGroup(item, dim, res); - if (res.m_Dimension != -1 && res.m_Found) - return res; - } - else if (area is Splitted splitted) - { - double dim = height; - if (splitted.ParentArea is Split sp && splitted.AreaList.First() is Sash sh) - { - if (sp.SplitHorizList.Count > 0) - { - dim = dim + sh.SashList.First().ElementDimensionList.First().dOverlap - + sh.SashList.First().ElementDimensionList.ElementAt(sh.SashList.First().ElementDimensionList.Count - 2).dOverlap; - } - } - res = CalculateHeightSplitGroup(item, dim, res); - if (res.m_Dimension != -1 && res.m_Found) - return res; - } - else - { - res = CalculateHeightSplitGroup(item, height, res); - if (res.m_Dimension != -1 && res.m_Found) - return res; - } - } - return res; - } + ///// + ///// Metodo per calcolare altezza intero split group + ///// + ///// area di partenza + ///// altezza di partenza + ///// area di ritorno + ///// + //internal AreaFound CalculateHeightSplitGroup(Area area, double height, AreaFound res) + //{ + // for (int i = 0; i < area.AreaList.Count; i++) + // { + // if (area.Equals(m_Parent)) + // { + // res.m_Dimension = height; + // res.m_Found = true; + // return res; + // } + // Area item = area.AreaList[i]; + // if (area is Split split) + // { + // if (split.SplitHorizList.Count > 0) + // { + // double dim = height; + // foreach (var elem in split.ElemDimHorizList) + // dim = dim - elem.dDimension; + // int index = i; + // if (split.SelSplitShape is SplitShapes.GRID) + // index = i % split.SplitHorizList.Count; + // switch (split.SplitHorizList.ElementAt(index).SelMeasureType) + // { + // case MeasureTypes.ABSOLUTE: + // { + // dim = split.SplitHorizList.ElementAt(index).dDimension; + // break; + // } + // case MeasureTypes.PROPORTIONAL: + // { + // AreaDimension ad = new AreaDimension(split.SplitHorizList.ElementAt(index).dDimension, split.SplitHorizList.ElementAt(index).SelMeasureType, split.SplitHorizList.ElementAt(index).Parent); + // List adList = new List(); + // foreach (var it in split.SplitHorizList) + // adList.Add(new AreaDimension(it.dDimension, it.SelMeasureType, it.Parent)); + // dim = ad.ConvertFromPropVal(adList, MeasureTypes.ABSOLUTE, dim); + // break; + // } + // case MeasureTypes.PERCENTAGE: + // { + // dim = split.SplitHorizList.ElementAt(index).dDimension * dim / 100; + // break; + // } + // } + // res = CalculateHeightSplitGroup(item, dim, res); + // if (res.m_Dimension != -1 && res.m_Found) + // return res; + // } + // else + // { + // double dim = height; + // res = CalculateHeightSplitGroup(item, dim, res); + // if (res.m_Dimension != -1 && res.m_Found) + // return res; + // } + // } + // else if (area is Sash sash) + // { + // double bottomRail = 0; + // if(sash.SashBottomRailQty > 0) + // { + // foreach (var bottom in sash.BottomRailElemDimList) + // bottomRail = bottomRail + bottom.dDimension + // - bottom.dOverlap; + // } + // double dim = height - sash.SashList.First().ElementDimensionList.First().dDimension + // - sash.SashList.First().ElementDimensionList.ElementAt(sash.SashList.First().ElementDimensionList.Count - 2).dDimension + // - bottomRail; + // res = CalculateHeightSplitGroup(item, dim, res); + // if (res.m_Dimension != -1 && res.m_Found) + // return res; + // } + // else if (area is Splitted splitted) + // { + // double dim = height; + // if (splitted.ParentArea is Split sp && splitted.AreaList.First() is Sash sh) + // { + // if (sp.SplitHorizList.Count > 0) + // { + // dim = dim + sh.SashList.First().ElementDimensionList.First().dOverlap + // + sh.SashList.First().ElementDimensionList.ElementAt(sh.SashList.First().ElementDimensionList.Count - 2).dOverlap; + // } + // } + // res = CalculateHeightSplitGroup(item, dim, res); + // if (res.m_Dimension != -1 && res.m_Found) + // return res; + // } + // else + // { + // res = CalculateHeightSplitGroup(item, height, res); + // if (res.m_Dimension != -1 && res.m_Found) + // return res; + // } + // } + // return res; + //} internal JsonSplitDimension Serialize() { @@ -623,7 +614,8 @@ namespace WebWindowComplex.Models splitElemList = m_Parent.ElemDimVertList; else splitElemList = m_Parent.ElemDimVertList.Where(x => x.nSubArea == 1).ToList(); - dimSplitGroup = CalculateWidthSplitGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension; + //dimSplitGroup = CalculateWidthSplitGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension; + dimSplitGroup = Parent.CalculateWidthSplitGroup(frame, frame.AvailWidthArea(), new AreaFound(-1, false)).m_Dimension; } else { @@ -632,7 +624,8 @@ namespace WebWindowComplex.Models splitElemList = m_Parent.ElemDimHorizList.Where(x => x.nSubArea == 1).ToList(); else splitElemList = m_Parent.ElemDimHorizList; - dimSplitGroup = (CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false))).m_Dimension; + //dimSplitGroup = (CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false))).m_Dimension; + dimSplitGroup = (Parent.CalculateHeightSplitGroup(frame, frame.AvailHeightArea(), new AreaFound(-1, false))).m_Dimension; } AreaDimension ad = new AreaDimension(dDimension, SelMeasureType, Parent); List adList = new List(); @@ -646,7 +639,7 @@ namespace WebWindowComplex.Models } if (newType is MeasureTypes.PROPORTIONAL) { - adList = ad.CalculatePropVal(adList, splitList.IndexOf(this), dimSplitGroup); + adList = ad.RicalculatePropVal(adList, splitList.IndexOf(this), dimSplitGroup); for (int i = 0; i < adList.Count; i++) splitList.ElementAt(i).SetDimension(adList.ElementAt(i).dDimension); } diff --git a/WebWindowComplex/TableComp.razor b/WebWindowComplex/TableComp.razor index c3f7949..38ddee9 100644 --- a/WebWindowComplex/TableComp.razor +++ b/WebWindowComplex/TableComp.razor @@ -103,7 +103,7 @@ maxCol="m_maxCol" RowCollapsedDict="RowCollapsed" ChildDict="Child" - SashList="SashList" + SashGroupList="SashGroupList" SplitList="SplitList" SplittedList="SplittedList" FillList="FillList" @@ -126,8 +126,8 @@ } - - + + = SashList.Count || currSashIndex == -1) + @if (currSashIndex >= SashGroupList.Count || currSashIndex == -1) { currStep = CompileStep.Tree; } @@ -171,8 +171,8 @@ { - - + + x.AreaList.First().Equals(FillList[currFillIndex])).FirstOrDefault(); @if(currSplitted != null) { - @if (currSplitted.ParentArea != null && currSplitted.ParentWindow != null){ - diff --git a/WebWindowComplex/TableComp.razor.cs b/WebWindowComplex/TableComp.razor.cs index 3b12dce..ae72fd3 100644 --- a/WebWindowComplex/TableComp.razor.cs +++ b/WebWindowComplex/TableComp.razor.cs @@ -161,7 +161,7 @@ namespace WebWindowComplex } } - protected List SashList + protected List SashGroupList { get => m_SashList; } @@ -218,11 +218,11 @@ 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 < SashGroupList.Count; i++) { - if (SashList[i].Equals(node)) + if (SashGroupList[i].Equals(node)) { - nWIndow = SashList.Count == 1 ? "" : $"{i + 1}"; + nWIndow = SashGroupList.Count == 1 ? "" : $"{i + 1}"; // Se il nodo ha figli, salvo il numero nell'oggetto if (node.AreaList.Count >= 1) ItemTableList.Add(new ItemTable(AreaTypes.SASH, "SG" + nWIndow, maxRow, col, i, node.AreaList.Count)); @@ -527,7 +527,7 @@ namespace WebWindowComplex // verifico variazione JWD if (!prevJwd.Equals(CurrJwd) || prevReq != (int)DataReq.ReqElement) { - Log.Info("Richiesta Profili Elementi"); + Log.Info("Richiesta profili elementi"); prevJwd = CurrJwd; prevReq = (int)DataReq.ReqElement; Dictionary Args = new Dictionary(); @@ -637,7 +637,7 @@ namespace WebWindowComplex WindowFromJson = JsonConvert.DeserializeObject(LiveData.CurrJwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); if (WindowFromJson == null || WindowFromJson.AreaList == null || WindowFromJson.AreaList.Count == 0) { - WindowFromJson = BuildFrameDefault(); + WindowFromJson = BuildWindowDefault(); Log.Info("Ricostruito jwd"); } UpdateInputList(WindowFromJson); @@ -654,7 +654,7 @@ namespace WebWindowComplex listErrLink.Add("Window", $"Deserializing Error:{Environment.NewLine}{ex}"); Log.Error($"Errore nel deserializzare jwd: {ex.Message}"); // costruisco una finestra base - WindowFromJson = BuildFrameDefault(); + WindowFromJson = BuildWindowDefault(); await DoPreviewSvg(true); } } @@ -667,7 +667,7 @@ namespace WebWindowComplex if (m_CurrWindow != null && m_CurrWindow.AreaList != null && m_CurrWindow.AreaList.Count > 0) { checkWarnings(); - if (SashList.Count > 0) + if (SashGroupList.Count > 0) currAntaIndex = 0; if (updRequested) { @@ -682,7 +682,7 @@ namespace WebWindowComplex if (LiveData.ProfElementList.Count == 0) await UpdateElement(FrameWindow); } - List reqList = SashList.Select(x => x.GroupId).ToList(); + List reqList = SashGroupList.Select(x => x.GroupId).ToList(); if (reqList.Count > 0) { await DoReqShape(reqList); @@ -704,7 +704,7 @@ namespace WebWindowComplex else { JsonWindow WindowFromJson = new JsonWindow("", "", "", ""); - WindowFromJson = BuildFrameDefault(); + WindowFromJson = BuildWindowDefault(); await DoPreviewSvg(true); } } @@ -716,7 +716,11 @@ namespace WebWindowComplex isLoading = false; } - private JsonWindow BuildFrameDefault() + /// + /// Metodo per costruire una finestra con vetro fisso + /// + /// + private JsonWindow BuildWindowDefault() { // Costruisco window e setto i parametri Window window = new Window(); @@ -766,15 +770,12 @@ namespace WebWindowComplex protected bool CheckGroupId(Window window) { List groupIdList = new List(); - SearchInWindow(window.AreaList.First(), groupIdList); + AllGroupIdList(window.AreaList.First(), groupIdList); var duplicati = groupIdList.GroupBy(x => x) - .Where(g => g.Count() > 1) - .Select(g => g.Key) - .ToList(); - if (duplicati.Count > 0) - return false; - else - return true; + .Where(g => g.Count() > 1) + .Select(g => g.Key) + .ToList(); + return duplicati.Count > 0 ? false : true; } /// @@ -812,7 +813,7 @@ namespace WebWindowComplex // Aggiornamento liste sash, split, splitted, fill e itemTable UpdateLists(); } - if (SashList.Count > 0) + if (SashGroupList.Count > 0) currAntaIndex = 0; // Aggiorno window con dati shape e hw option UpdateDict(); @@ -830,8 +831,7 @@ namespace WebWindowComplex // Inserisco le forme ricevuto nei sash group foreach (var item in LiveData.DictShape) { - //Sash sashFromGroupId = SashList.First(x => x.GroupId == item.Key); - var sashFromGroupId = SashList.FirstOrDefault(x => x.GroupId == item.Key); + Sash? sashFromGroupId = SashGroupList.FirstOrDefault(x => x.GroupId == item.Key); if (sashFromGroupId != null) { sashFromGroupId.SashShape = item.Value; @@ -842,7 +842,7 @@ namespace WebWindowComplex { if (reqHwOpt > 0) { - List reqList = SashList.Select(x => x.GroupId).ToList(); + List reqList = SashGroupList.Select(x => x.GroupId).ToList(); if (reqList.Count > 0) { _ = DoReqOptHardware(reqList); @@ -854,7 +854,7 @@ namespace WebWindowComplex if (LiveData.DictOptionsXml.Count > 0) { loadListRem("LoadHwOpt"); - foreach (var item in SashList) + foreach (var item in SashGroupList) { if (LiveData.DictOptionsXml.ContainsKey(item.GroupId)) { @@ -864,7 +864,6 @@ namespace WebWindowComplex } if (LiveData.ProfElementList.Count > 0) { - //List OrderedListProf = LiveData.ProfElementList.OrderBy(x => x.GroupId).ToList(); // Inserisco i profili ricevuti nei rispettivi Element foreach (var item in LiveData.ProfElementList) { @@ -992,7 +991,6 @@ namespace WebWindowComplex #region Private Properties private Window? m_CurrWindow { get; set; } = null; - private Window? m_PreviousWindow { get; set; } = null; /// @@ -1098,7 +1096,7 @@ namespace WebWindowComplex } /// - /// Helper aggiunta elemento a lista caricamento + /// Helper aggiunta elemento a lista caricamento (per caricamento opzioni hw) /// /// private void loadListAdd(string loadCode) @@ -1216,9 +1214,7 @@ namespace WebWindowComplex { Area? found = SearchAreaFromGroupId(child, idSearch); if (found != null) - { return found; - } } return null; } @@ -1719,7 +1715,7 @@ namespace WebWindowComplex if (prevReq == (int)DataReq.ReqShape) { // richiesta calcolo opzioni hardware per la singola sash group - List reqList = SashList.Select(x => x.GroupId).ToList(); + List reqList = SashGroupList.Select(x => x.GroupId).ToList(); // chiamo con gruppo della nuova sash await DoReqOptHardware(reqList); } @@ -1792,19 +1788,24 @@ namespace WebWindowComplex m_SplitList = new List(); m_SplittedList = new List(); CreateWindowsList((m_CurrWindow!).AreaList.First(), false); - ReqListGroupId(FrameWindow, reqList); + ReqGroupIdList(FrameWindow, reqList); await DoReqElement(reqList); } } - private void ReqListGroupId(Area node, List groupId) + /// + /// Lista completa dei group id per le richieste + /// + /// nodo da controllare + /// Lista groupId + private void ReqGroupIdList(Area node, List groupId) { if (node.AreaList == null) return; if (node is Sash || node is Split) groupId.Add(node.GroupId); foreach (var child in node.AreaList) - ReqListGroupId(child, groupId); + ReqGroupIdList(child, groupId); } /// @@ -1820,13 +1821,11 @@ namespace WebWindowComplex var currRec = SearchAreaFromGroupId(FrameWindow, newSash.GroupId); // lo aggiorno currRec = newSash; - // resetto hw lst + // resetto hw list await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt); // richiesta calcolo opzioni hardware per la singola sash group - List reqList = SashList.Select(x => x.GroupId).ToList(); - // chiamo con gruppo della nuova sash + List reqList = SashGroupList.Select(x => x.GroupId).ToList(); await DoReqOptHardware(reqList); - //} } } @@ -1843,10 +1842,10 @@ namespace WebWindowComplex var currRec = SearchAreaFromGroupId(FrameWindow, newSash.GroupId); // lo aggiorno currRec = newSash; - // resetto hw lst + // resetto hw list await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt); // richiesta calcolo opzioni hardware per la singola sash group - List reqList = SashList.Select(x => x.GroupId).ToList(); + List reqList = SashGroupList.Select(x => x.GroupId).ToList(); // chiamo con gruppo della nuova sash await DoReqOptHardware(reqList); } @@ -1855,7 +1854,7 @@ namespace WebWindowComplex /// /// Aggiornamento Frame /// - /// nuovo frame + /// nuovo frame /// private async Task UpdatePreviewSplit(DataUpdateSplit args) { @@ -1881,7 +1880,7 @@ namespace WebWindowComplex /// /// Metodo per aggiornare Splitted /// - /// Splitted da aggiornare + /// Splitted da aggiornare /// private async Task UpdatePreviewSplitted(Splitted currSplitted) { @@ -1892,7 +1891,7 @@ namespace WebWindowComplex // ricalcolo liste UpdateLists(); // richiedo update shape - List reqList = SashList.Select(x => x.GroupId).ToList(); + List reqList = SashGroupList.Select(x => x.GroupId).ToList(); await DoPreviewSvg(); await UpdateElement(FrameWindow); await DoReqShape(reqList); @@ -1910,39 +1909,34 @@ namespace WebWindowComplex Sash newSash = args.currSash; bool svgNoHw = args.svgNoHw; bool noSvg = args.noSvg; - if (svgNoHw) + Sash? item = (Sash?)SearchAreaFromGroupId(FrameWindow, newSash.GroupId); + if (!noSvg && newSash != null && item != null) { - Sash? item = (Sash?)SearchAreaFromGroupId(FrameWindow, newSash.GroupId); - if (newSash != null && item != null) - { - item = newSash; + item = newSash; + if (svgNoHw) await DoPreviewSvg(true, true); - } - } - else - { - Sash? item = (Sash?)SearchAreaFromGroupId(FrameWindow, newSash.GroupId); - if (newSash != null && item != null) - { - item = newSash; - if (!noSvg) - await DoPreviewSvg(); - } + else + await DoPreviewSvg(); } } + /// + /// Rimozione area da frame corrente + /// + /// oggetto da rimuovere + /// private async Task RemoveArea(DataNextStep remove) { if (remove.currCompileStep is CompileStep.Sash) { - SashList.ElementAt(remove.index).Remove(); + SashGroupList.ElementAt(remove.index).Remove(); if (FrameWindow.SelThreshold.Name.Contains("Threshold") && remove.index == 0) { Threshold? updThreshold = FrameWindow.ThresholdList.FirstOrDefault(x => x.Name != "Threshold"); if (updThreshold != null) FrameWindow.SelThresholdFromName = updThreshold.Name; } - SashList.RemoveAt(remove.index); + SashGroupList.RemoveAt(remove.index); } else if(remove.currCompileStep is CompileStep.Split) { @@ -1968,18 +1962,18 @@ namespace WebWindowComplex } /// - /// Metodo per ottenere lista groupId + /// Metodo per ottenere lista di tutti i groupId appartenenti alla window /// /// Area da aggiungere alla lista groupId /// Lista group id - protected void SearchInWindow(Area node, List groupIdList) + protected void AllGroupIdList(Area node, List groupIdList) { if (node != null) { groupIdList.Add(node.GroupId); foreach (var item in node.AreaList) { - SearchInWindow(item, groupIdList); + AllGroupIdList(item, groupIdList); } } } diff --git a/WebWindowComplex/WebWindowComplex.csproj b/WebWindowComplex/WebWindowComplex.csproj index 36649d1..75cd3be 100644 --- a/WebWindowComplex/WebWindowComplex.csproj +++ b/WebWindowComplex/WebWindowComplex.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 3.1.3.1610 + 3.1.3.1617 Annamaria Sassi Egalware Componente gestione Configurazioni avanzate Window per LUX @@ -34,3 +34,5 @@ + + diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index 1763a3d..0eba16f 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 3.1.3.1610 + 3.1.3.1617 Annamaria Sassi Egalware Componente gestione JWD per LUX @@ -35,4 +35,9 @@ - \ No newline at end of file + + + + + + From 10e1a79b0a049a63bf90b18d8cd1cc59bdc2a538 Mon Sep 17 00:00:00 2001 From: Annamaria Sassi Date: Mon, 16 Mar 2026 18:28:59 +0100 Subject: [PATCH 2/8] Gestione joint sash con aggiunta split nel frame --- WebWindowComplex/Compo/AreaSash.razor.cs | 6 +++++- WebWindowComplex/Models/Area.cs | 12 ++++++++++++ WebWindowComplex/WebWindowComplex.csproj | 13 ++++++++++++- WebWindowConfigurator/WebWindowConfigurator.csproj | 7 ++++++- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/WebWindowComplex/Compo/AreaSash.razor.cs b/WebWindowComplex/Compo/AreaSash.razor.cs index 37b6dcf..62bef39 100644 --- a/WebWindowComplex/Compo/AreaSash.razor.cs +++ b/WebWindowComplex/Compo/AreaSash.razor.cs @@ -202,7 +202,9 @@ namespace WebWindowComplex.Compo if (frame != null && (frame.Shape is Json.WindowConst.Shapes.ARC || frame.Shape is Json.WindowConst.Shapes.ARC_FULL || frame.Shape is Json.WindowConst.Shapes.DOUBLEARC || - frame.Shape is Json.WindowConst.Shapes.THREECENTERARC)) + frame.Shape is Json.WindowConst.Shapes.THREECENTERARC) && + (CurrSashGroup.ParentArea.ParentArea is Split && + CurrSashGroup.ParentArea.ParentArea.AreaList.LastOrDefault().AreaList.FirstOrDefault().Equals(CurrSashGroup))) { if(CurrSashGroup.SashList.Count == 1) { @@ -221,6 +223,8 @@ namespace WebWindowComplex.Compo CurrSashDim.JointList.ElementAt(i).SelJointType = JointType; } } + else + CurrSashDim.JointList.ElementAt(i).SelJointType = JointType; } return EC_UpdateSashDim.InvokeAsync(CurrSashDim); } diff --git a/WebWindowComplex/Models/Area.cs b/WebWindowComplex/Models/Area.cs index 835ce0e..705b349 100644 --- a/WebWindowComplex/Models/Area.cs +++ b/WebWindowComplex/Models/Area.cs @@ -184,6 +184,18 @@ namespace WebWindowComplex.Models Frame frame = ParentWindow.AreaList.First(); if(frame != null) { + // Aggiorno joint di tutte le ante + if(AreaList.FirstOrDefault()!.AreaList.FirstOrDefault().AreaList.FirstOrDefault() is Sash) + { + Sash sash = (Sash)AreaList.FirstOrDefault()!.AreaList.FirstOrDefault().AreaList.FirstOrDefault(); + foreach(var anta in sash.SashList) + { + foreach (var j in anta.JointList) + j.SelJointType = anta.JointList.FirstOrDefault().SelJointType; + } + + } + // Aggiorno altezza sotto aree frame.SearchAreaList(frame, frame.AvailHeightArea(), "Height"); } } diff --git a/WebWindowComplex/WebWindowComplex.csproj b/WebWindowComplex/WebWindowComplex.csproj index 75cd3be..d5e75f9 100644 --- a/WebWindowComplex/WebWindowComplex.csproj +++ b/WebWindowComplex/WebWindowComplex.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 3.1.3.1617 + 3.1.3.1618 Annamaria Sassi Egalware Componente gestione Configurazioni avanzate Window per LUX @@ -36,3 +36,14 @@ + + + + + + + + + + + diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index 0eba16f..695abc4 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 3.1.3.1617 + 3.1.3.1618 Annamaria Sassi Egalware Componente gestione JWD per LUX @@ -41,3 +41,8 @@ + + + + + From ae45bd542959b282ee09f69bc03d54e859d4b804 Mon Sep 17 00:00:00 2001 From: Annamaria Sassi Date: Wed, 18 Mar 2026 11:25:47 +0100 Subject: [PATCH 3/8] Correzione gestione joint sash --- WebWindowComplex/Models/Area.cs | 4 +--- WebWindowComplex/WebWindowComplex.csproj | 5 ++++- WebWindowConfigurator/WebWindowConfigurator.csproj | 5 ++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/WebWindowComplex/Models/Area.cs b/WebWindowComplex/Models/Area.cs index 705b349..88f7b40 100644 --- a/WebWindowComplex/Models/Area.cs +++ b/WebWindowComplex/Models/Area.cs @@ -185,15 +185,13 @@ namespace WebWindowComplex.Models if(frame != null) { // Aggiorno joint di tutte le ante - if(AreaList.FirstOrDefault()!.AreaList.FirstOrDefault().AreaList.FirstOrDefault() is Sash) + if(AreaList.FirstOrDefault()!.AreaList.FirstOrDefault()!.AreaList.FirstOrDefault() is Sash sash && sash != null) { - Sash sash = (Sash)AreaList.FirstOrDefault()!.AreaList.FirstOrDefault().AreaList.FirstOrDefault(); foreach(var anta in sash.SashList) { foreach (var j in anta.JointList) j.SelJointType = anta.JointList.FirstOrDefault().SelJointType; } - } // Aggiorno altezza sotto aree frame.SearchAreaList(frame, frame.AvailHeightArea(), "Height"); diff --git a/WebWindowComplex/WebWindowComplex.csproj b/WebWindowComplex/WebWindowComplex.csproj index d5e75f9..6f15799 100644 --- a/WebWindowComplex/WebWindowComplex.csproj +++ b/WebWindowComplex/WebWindowComplex.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 3.1.3.1618 + 3.1.3.1811 Annamaria Sassi Egalware Componente gestione Configurazioni avanzate Window per LUX @@ -47,3 +47,6 @@ + + + diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index 695abc4..a663915 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 3.1.3.1618 + 3.1.3.1811 Annamaria Sassi Egalware Componente gestione JWD per LUX @@ -46,3 +46,6 @@ + + + From 1518005f0633f40600b0fdc23644778bc0b849d8 Mon Sep 17 00:00:00 2001 From: Annamaria Sassi Date: Wed, 18 Mar 2026 18:08:12 +0100 Subject: [PATCH 4/8] Aggiornati nuget EgwCoreLib --- Directory.Packages.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 8cbcbcc..8dc4cd3 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -9,8 +9,8 @@ all - - + + From 4f83692336c24cc41bcdfa12f9be5315fbbf0f8d Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 20 Mar 2026 10:00:35 +0100 Subject: [PATCH 5/8] Riorganizzazione metodi protected - private per separare logica implementata da derivata --- WebWindowComplex/TableComp.razor.cs | 1909 ++++++++++++++------------- 1 file changed, 964 insertions(+), 945 deletions(-) diff --git a/WebWindowComplex/TableComp.razor.cs b/WebWindowComplex/TableComp.razor.cs index ae72fd3..330397e 100644 --- a/WebWindowComplex/TableComp.razor.cs +++ b/WebWindowComplex/TableComp.razor.cs @@ -2,8 +2,6 @@ using Microsoft.AspNetCore.Components; using Newtonsoft.Json; using NLog; -using System.Collections.Generic; -using System.Threading.Tasks; using WebWindowComplex.Compo; using WebWindowComplex.DTO; using WebWindowComplex.Json; @@ -49,18 +47,18 @@ namespace WebWindowComplex #region Public Properties + /// + /// Livello di accesso (utente base) + /// + [Parameter] + public bool baseUser { get; set; } = false!; + /// /// Classe override css x SVG (x rescale) /// [Parameter] public string CssSvg { get; set; } = "responsive-svg"; - /// - /// Preselezione valori - /// - [Parameter] - public SelectPayload? SelectionData { get; set; } = null; - /// /// Richiesta azione al parent /// @@ -100,10 +98,10 @@ namespace WebWindowComplex public LivePayload LiveData { get; set; } = null!; /// - /// Livello di accesso (utente base) + /// Preselezione valori /// [Parameter] - public bool baseUser { get; set; } = false!; + public SelectPayload? SelectionData { get; set; } = null; #endregion Public Properties @@ -119,39 +117,262 @@ namespace WebWindowComplex #endregion Public Methods - #region Protected Fields + #region Protected Methods - protected List currLoading = new List(); + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (forceSvgUpdate) + { + firstDisplay = false; + forceSvgUpdate = false; + // preview SVG senza HW + await DoPreviewSvg(true, true); + if (LiveData.ProfElementList.Count == 0) + await UpdateElement(FrameWindow); + } + isRendered = true; + } + + /// + /// Primo init componente + /// + protected override void OnInitialized() + { + // reset editLock... + editLock = false; + listErrPre = new Dictionary(); + listErrLink = new Dictionary(); + listWarnings = new Dictionary(); + } + + /// + /// Gestione update post ricezione parametri da controllo chiamante + /// + protected override async Task OnParametersSetAsync() + { + isLoading = true; + // SOLO SE sono presenti... + listErrLink = new Dictionary(); + okParams = ListPayload.IsPopulated(); + okJwd = LiveData.IsValid(); + if (okParams && okJwd) + { + bool updRequested = false; + listErrPre = new Dictionary(); + listWarnings = new Dictionary(); + // controllo elenchi BasePayload siano validi... + if (ListPayload.IsValid()) + { + // SOLO SE modificato live data... + if (prevLiveData == null || !prevLiveData.Equals(LiveData)) + { + bool needDeser = prevLiveData == null || !prevLiveData.JwdEqual(LiveData); + updRequested = true; + prevLiveData = new LivePayload() + { + CurrJwd = LiveData.CurrJwd, + DictOptionsXml = LiveData.DictOptionsXml, + DictShape = LiveData.DictShape, + SvgPreview = LiveData.SvgPreview, + ProfElementList = LiveData.ProfElementList + }; + // Aggiornati parametri di ingresso selezionati + UpdateSelParameter(); + // provo a deserializzare SE necessario + if (needDeser) + { + JsonWindow WindowFromJson = new JsonWindow("", "", "", ""); + try + { + WindowFromJson = JsonConvert.DeserializeObject(LiveData.CurrJwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); + if (WindowFromJson == null || WindowFromJson.AreaList == null || WindowFromJson.AreaList.Count == 0) + { + WindowFromJson = BuildWindowDefault(); + Log.Info("Ricostruito jwd"); + } + UpdateInputList(WindowFromJson); + setCurrWindow(WindowFromJson); + //SOLO SE non sono in edit... + if (!editLock) + { + currStep = CompileStep.Tree; + } + } + // altrimenti errore! + catch (Exception ex) + { + listErrLink.Add("Window", $"Deserializing Error:{Environment.NewLine}{ex}"); + Log.Error($"Errore nel deserializzare jwd: {ex.Message}"); + // costruisco una finestra base + WindowFromJson = BuildWindowDefault(); + await DoPreviewSvg(true); + } + } + else + { + // usando m_currWindow (preesistente) impostare i parametri... + UpdateDict(); + } + } + if (m_CurrWindow != null && m_CurrWindow.AreaList != null && m_CurrWindow.AreaList.Count > 0) + { + checkWarnings(); + if (SashGroupList.Count > 0) + currAntaIndex = 0; + if (updRequested) + { + // se mancasse dizionario forme chiamo quello + if (LiveData.DictShape.Count == 0 && listErrLink.Count == 0) + { + if (firstDisplay && isRendered) + { + firstDisplay = false; + // preview SVG senza HW + await DoPreviewSvg(true, true); + if (LiveData.ProfElementList.Count == 0) + await UpdateElement(FrameWindow); + } + else + { + forceSvgUpdate = true; + } + List reqList = SashGroupList.Select(x => x.GroupId).ToList(); + if (reqList.Count > 0) + { + await DoReqShape(reqList); + } + } + else + { + // chiedo SVG + if (prevReq != (int)DataReq.ReqSvg || !prevLiveData.JwdEqual(LiveData.CurrJwd)) + { + if (prevReq != (int)DataReq.ReqHwOpt) + await DoPreviewSvg(true); + else if (LiveData.DictOptionsXml.Count > 0) + await DoPreviewSvg(true); + } + } + } + } + else + { + JsonWindow WindowFromJson = new JsonWindow("", "", "", ""); + WindowFromJson = BuildWindowDefault(); + await DoPreviewSvg(true); + } + } + else + { + checkErrorPre(); + } + } + isLoading = false; + } + + #endregion Protected Methods + + #region Private Fields + + private static Logger Log = LogManager.GetCurrentClassLogger(); + + private int currAntaIndex = 0; + + private int currFillIndex = -1; + + private List currLoading = new List(); + + private int currSashIndex = -1; + + private int currSplitIndex = -1; + + private CompileStep currStep; + + private bool editLock = false; + + private bool firstDisplay = true; + + private bool forceSvgUpdate = false; + + private bool groupIdOK = false; + + /// + /// Booleana fase loading + /// + private bool isLoading = false; + + private bool isRendered = false; + + /// + /// ELenco errori di coerenza/link dati (vanno risolti per disegnare/procedere) + /// + private Dictionary listErrLink = new Dictionary(); + + /// + /// Elenco errori preliminari (mancano elementi di base di validazione modello dati)) + /// + private Dictionary listErrPre = new Dictionary(); + + /// + /// Elenco warnings non bloccanti + /// + private Dictionary listWarnings = new Dictionary(); + + private List m_FillList = new List(); + + private Frame? m_Frame; + + private List m_ItemTableList = new List(); + + private int m_maxCol = 0; + + private int m_maxRow = 0; + + private List m_SashList = new List(); + + private List m_SplitList = new List(); + + private List m_SplittedList = new List(); + + private bool okJwd = false; + + private bool okParams = false; /// /// Dati live precedenti x comparazione /// - protected LivePayload? prevLiveData = null; + private LivePayload? prevLiveData = null; - #endregion Protected Fields + #endregion Private Fields - #region Protected Properties + #region Private Properties - protected List FillList + private Dictionary Child { get; set; } = new Dictionary(); + + private List FillList { get => m_FillList; } - protected Frame FrameWindow + private Frame FrameWindow { get => m_Frame!; set => m_Frame = value; } - protected List ItemTableList + private List ItemTableList { get => m_ItemTableList; } + private Window? m_CurrWindow { get; set; } = null; + + private Window? m_PreviousWindow { get; set; } = null; + /// /// Componente SVG da mostrare /// - protected MarkupString outSvg + private MarkupString outSvg { get { @@ -161,29 +382,255 @@ namespace WebWindowComplex } } - protected List SashGroupList + /// + /// Salvataggio JWD precedente x evitare loop su update (aggiornato dopo chiamate redis) + /// + private string prevJwd { get; set; } = ""; + + /// + /// Salvataggio tipo di domanda precedente + /// + private int prevReq { get; set; } = 0; + + private int reqHwOpt { get; set; } = 0; + + private Dictionary RowCollapsed { get; set; } = new Dictionary(); + + private List SashGroupList { get => m_SashList; } - protected List SplittedList - { - get => m_SplittedList; - } - protected List SplitList + private string SelColorMaterial { get; set; } = ""; + + private string SelFamilyHardware { get; set; } = ""; + + private string SelGlass { get; set; } = ""; + + private string SelMaterial { get; set; } = ""!; + + private string SelProfile { get; set; } = ""; + + private List SplitList { get => m_SplitList; } - protected string SelColorMaterial { get; set; } = ""; - protected string SelFamilyHardware { get; set; } = ""; - protected string SelGlass { get; set; } = ""; - protected string SelMaterial { get; set; } = ""!; - protected string SelProfile { get; set; } = ""; + private List SplittedList + { + get => m_SplittedList; + } - #endregion Protected Properties + #endregion Private Properties - #region Protected Methods + #region Private Methods + + /// + /// Metodo per andare allo step successivo + /// + /// step successivo + private void AdvStep(CompileStep newStep) + { + currStep = newStep; + currSashIndex = -1; + currFillIndex = -1; + currSplitIndex = -1; + } + + /// + /// Metodo per ottenere lista di tutti i groupId appartenenti alla window + /// + /// Area da aggiungere alla lista groupId + /// Lista group id + private void AllGroupIdList(Area node, List groupIdList) + { + if (node != null) + { + groupIdList.Add(node.GroupId); + foreach (var item in node.AreaList) + { + AllGroupIdList(item, groupIdList); + } + } + } + + /// + /// Metodo per costruire una finestra con vetro fisso + /// + /// + private JsonWindow BuildWindowDefault() + { + // Costruisco window e setto i parametri + Window window = new Window(); + window.sProfilePath = "Profilo78"; + window.sMaterial = "Pino"; + window.sGlass = "Vetro BE 2S 4T/16/4T"; + window.sColorMaterial = "Wood"; + // Costruisco frame e setto i parametri + Frame frame = new Frame(null, window); + frame.SetGroupId(1); + frame.SetAreaType(AreaTypes.FRAME); + frame.SetSelShape(Shapes.RECTANGLE); + frame.SetSelThresholdFromName("Bottom"); + frame.SetBottomRail(false); + frame.SetBottomRailQty(0); + window.AreaList.Add(frame); + List DimensionList = new List + { + new FrameDimension(frame, 1, "Width", 800, false), + new FrameDimension(frame, 1, "Height", 1200, true) + }; + List JointList = new List + { + new Joint(frame, 1, Joints.FULL_H), + new Joint(frame, 2, Joints.FULL_H), + new Joint(frame, 3, Joints.FULL_H), + new Joint(frame, 4, Joints.FULL_H) + }; + frame.JointList = JointList; + frame.DimensionList = DimensionList; + // Costruisco fill e setto i parametri + Fill fill = new Fill(frame, window); + fill.AreaType = AreaTypes.FILL; + fill.SelFillType = FillTypes.GLASS; + fill.GroupId = 2; + frame.AreaList.Add(fill); + JsonWindow jsonWindow = window.Serialize(); + string jwd = JsonConvert.SerializeObject(jsonWindow); + return JsonConvert.DeserializeObject(jwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); + } + + /// + /// Calcola bottone per tutti i Fill + /// + /// + private string buttonFillCss(FillTypes reqFillTypes) + { + foreach (var fill in FillList) + { + if (!fill.FillType.Equals(reqFillTypes)) + return "btn btn-outline-secondary btn-sm"; + } + return "btn btn-secondary btn-sm"; + } + + /// + /// Metodo per cambiare tutti i Fill e richiedere aggiornamento SVG + /// + /// tipo di fill richiesto + /// + private Task ChangeAllFill(FillTypes reqFillType) + { + updateAllFill(FrameWindow, reqFillType); + return DoPreviewSvg(); + } + + /// + /// Verifica errori prelimionari per mostrare dove sia il problema + /// + private void checkErrorPre() + { + // verifico 1:1 le liste e indico cosa manca + if (ListPayload.Hardware == null || ListPayload.Hardware.Count == 0) + { + listErrPre.Add("Hardware", "Missing Hardware List!"); + Log.Warn("Missing Hardware List"); + } + else + { + if (ListPayload.FamilyHardware == null || ListPayload.FamilyHardware.Count == 0) + { + listErrPre.Add("FamilyHardware", "Missing Family HW List!"); + Log.Warn(" Missing Family HW List"); + } + } + if (ListPayload.Glass == null || ListPayload.Glass.Count == 0) + { + listErrPre.Add("Glass", "Missing Glass List!"); + Log.Warn(" Missing Glass List"); + } + if (ListPayload.Material == null || ListPayload.Material.Count == 0) + { + listErrPre.Add("Material", "Missing Material List!"); + Log.Warn(" Missing Material List"); + } + if (ListPayload.ColorMaterial == null || ListPayload.ColorMaterial.Count == 0) + { + listErrPre.Add("ColorMaterial", "Missing ColorMaterial List!"); + Log.Warn("Missing ColorMaterial List"); + } + if (ListPayload.ProfileList == null || ListPayload.ProfileList.Count == 0) + { + listErrPre.Add("Profile", "Missing Profile data!"); + Log.Warn("Missing Profile data"); + } + } + + /// + /// Metodo per controllare che non ci siano duplicati di GroupId + /// + /// + /// + private bool CheckGroupId(Window window) + { + List groupIdList = new List(); + AllGroupIdList(window.AreaList.First(), groupIdList); + var duplicati = groupIdList.GroupBy(x => x) + .Where(g => g.Count() > 1) + .Select(g => g.Key) + .ToList(); + return duplicati.Count > 0 ? false : true; + } + + /// + /// Verifica warning minori (es coerenza colori...) + /// + private void checkWarnings() + { + // verifico 1:1 le liste e i valori siano coerenti... + if (ListPayload.ColorMaterial != null && ListPayload.ColorMaterial.Count > 0) + { + if (m_CurrWindow != null) + { + if (ListPayload.ColorMaterial == null || !ListPayload.ColorMaterial.Contains(m_CurrWindow.sColorMaterial)) + { + listWarnings.Add("ColorMaterial", $"Missing Color: {m_CurrWindow.sColorMaterial}"); + } + if (ListPayload.Glass == null || !ListPayload.Glass.Contains(m_CurrWindow.sGlass)) + { + listWarnings.Add("Glass", $"Missing Glass: {m_CurrWindow.sGlass}"); + } + if (ListPayload.Material == null || !ListPayload.Material.Contains(m_CurrWindow.sMaterial)) + { + listWarnings.Add("Material", $"Missing Material: {m_CurrWindow.sMaterial}"); + } + if (ListPayload.ProfileList == null || !ListPayload.ProfileList.Any(x => x.ProfileName.Contains(m_CurrWindow.sProfilePath))) + { + listWarnings.Add("Profile", $"Missing Profile: {m_CurrWindow.sProfilePath}"); + } + if (!groupIdOK) + { + listWarnings.Add("GroupId", "JWD not correct!"); + } + } + } + } + + /// + /// Metodo per aggiornare il valore collassato degli elementi della gerarchia + /// + /// + private void CollapsedRowTree(Dictionary Args) + { + foreach (var item in Args) + { + RowCollapsed[item.Key] = Args[item.Key] ? true : false; + if (m_ItemTableList.FirstOrDefault(x => x.Row == item.Key) != null) + { + Child[item.Key] = m_ItemTableList.FirstOrDefault(x => x.Row == item.Key)!.NumChild; + } + } + } /// /// Metodo per riempire la lista ItemTable in modo da poter rappresentarla come tabella @@ -193,7 +640,7 @@ namespace WebWindowComplex /// numero di colonna /// numero di riga massimo /// numero di colonna massimo - protected void CreateElementTable(Area node, int row, int col, int maxRow, int maxCol) + private void CreateElementTable(Area node, int row, int col, int maxRow, int maxCol) { if (node != null) { @@ -336,7 +783,7 @@ namespace WebWindowComplex /// /// Area da classificare /// Parametro per sapere se si è dentro un'anta - protected void CreateWindowsList(Area node, bool IntoSash) + private void CreateWindowsList(Area node, bool IntoSash) { if (node != null) { @@ -385,7 +832,7 @@ namespace WebWindowComplex /// /// /// - protected string cssValid(string fKey) + private string cssValid(string fKey) { return listWarnings.ContainsKey(fKey) ? "border border-danger" : ""; } @@ -394,7 +841,7 @@ namespace WebWindowComplex /// Richiesta chiusura SENZA salvataggio (= restore prev) /// /// - protected async Task DoClose() + private async Task DoClose() { editLock = false; Log.Info("Richiesta Chiusura"); @@ -422,7 +869,7 @@ namespace WebWindowComplex /// Forza richiesta anche con JWD invariato /// Nasconde hw (def. false) poiché senza è piu rapido /// - protected async Task DoPreviewSvg(bool doForce = false, bool hideHw = false) + private async Task DoPreviewSvg(bool doForce = false, bool hideHw = false) { if (m_CurrWindow != null) { @@ -447,12 +894,42 @@ namespace WebWindowComplex } } + /// + /// Richiesta Profili Element da JWD + /// + /// + private async Task DoReqElement(List groupIdList) + { + if (m_CurrWindow != null) + { +#if DEBUG + var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize(), Formatting.Indented); +#else + var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize()); +#endif + // verifico variazione JWD + if (!prevJwd.Equals(CurrJwd) || prevReq != (int)DataReq.ReqElement) + { + Log.Info("Richiesta profili elementi"); + prevJwd = CurrJwd; + prevReq = (int)DataReq.ReqElement; + Dictionary Args = new Dictionary(); + Args.Add("Mode", $"{(int)Enums.QuestionModes.HARDWARE}"); + Args.Add("SubMode", $"{(int)Enums.QuestionHwSubModes.PROFILEDATAFROMAREA}"); + Args.Add("SerializedData", CurrJwd); + string listGroupId = JsonConvert.SerializeObject(groupIdList); + Args.Add("GroupId", listGroupId); + await EC_DoUpdate.InvokeAsync(Args); + } + } + } + /// /// Richiesta calcolo Options HW /// /// Lista degli ID numerici dei gruppi da valutare /// - protected async Task DoReqOptHardware(List groupIdList, bool isFirst = false) + private async Task DoReqOptHardware(List groupIdList, bool isFirst = false) { if (m_CurrWindow != null) { @@ -484,7 +961,7 @@ namespace WebWindowComplex /// /// Lista degli ID numerici dei gruppi da valutare /// - protected async Task DoReqShape(List groupIdList) + private async Task DoReqShape(List groupIdList) { if (m_CurrWindow != null) { @@ -511,40 +988,10 @@ namespace WebWindowComplex } } - /// - /// Richiesta Profili Element da JWD - /// - /// - protected async Task DoReqElement(List groupIdList) - { - if (m_CurrWindow != null) - { -#if DEBUG - var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize(), Formatting.Indented); -#else - var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize()); -#endif - // verifico variazione JWD - if (!prevJwd.Equals(CurrJwd) || prevReq != (int)DataReq.ReqElement) - { - Log.Info("Richiesta profili elementi"); - prevJwd = CurrJwd; - prevReq = (int)DataReq.ReqElement; - Dictionary Args = new Dictionary(); - Args.Add("Mode", $"{(int)Enums.QuestionModes.HARDWARE}"); - Args.Add("SubMode", $"{(int)Enums.QuestionHwSubModes.PROFILEDATAFROMAREA}"); - Args.Add("SerializedData", CurrJwd); - string listGroupId = JsonConvert.SerializeObject(groupIdList); - Args.Add("GroupId", listGroupId); - await EC_DoUpdate.InvokeAsync(Args); - } - } - } - /// /// Metodo di reset /// - protected Task DoReset() + private Task DoReset() { Log.Info("Richiesta reset"); return Task.CompletedTask; @@ -555,7 +1002,7 @@ namespace WebWindowComplex /// Richiesta chiusura con salvataggio /// /// - protected Task DoSave() + private Task DoSave() { editLock = false; Log.Info("Richiesta Salvataggio"); @@ -578,523 +1025,6 @@ namespace WebWindowComplex return null; } - protected override void OnAfterRender(bool firstRender) - { - isRendered = true; - } - - /// - /// Primo init componente - /// - protected override void OnInitialized() - { - // reset editLock... - editLock = false; - listErrPre = new Dictionary(); - listErrLink = new Dictionary(); - listWarnings = new Dictionary(); - } - - /// - /// Gestione update post ricezione parametri da controllo chiamante - /// - protected override async Task OnParametersSetAsync() - { - isLoading = true; - // SOLO SE sono presenti... - listErrLink = new Dictionary(); - okParams = ListPayload.IsPopulated(); - okJwd = LiveData.IsValid(); - if (okParams && okJwd) - { - bool updRequested = false; - listErrPre = new Dictionary(); - listWarnings = new Dictionary(); - // controllo elenchi BasePayload siano validi... - if (ListPayload.IsValid()) - { - // SOLO SE modificato live data... - if (prevLiveData == null || !prevLiveData.Equals(LiveData)) - { - bool needDeser = prevLiveData == null || !prevLiveData.JwdEqual(LiveData); - updRequested = true; - prevLiveData = new LivePayload() - { - CurrJwd = LiveData.CurrJwd, - DictOptionsXml = LiveData.DictOptionsXml, - DictShape = LiveData.DictShape, - SvgPreview = LiveData.SvgPreview, - ProfElementList = LiveData.ProfElementList - }; - // Aggiornati parametri di ingresso selezionati - UpdateSelParameter(); - // provo a deserializzare SE necessario - if (needDeser) - { - JsonWindow WindowFromJson = new JsonWindow("", "", "", ""); - try - { - WindowFromJson = JsonConvert.DeserializeObject(LiveData.CurrJwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); - if (WindowFromJson == null || WindowFromJson.AreaList == null || WindowFromJson.AreaList.Count == 0) - { - WindowFromJson = BuildWindowDefault(); - Log.Info("Ricostruito jwd"); - } - UpdateInputList(WindowFromJson); - setCurrWindow(WindowFromJson); - //SOLO SE non sono in edit... - if (!editLock) - { - currStep = CompileStep.Tree; - } - } - // altrimenti errore! - catch (Exception ex) - { - listErrLink.Add("Window", $"Deserializing Error:{Environment.NewLine}{ex}"); - Log.Error($"Errore nel deserializzare jwd: {ex.Message}"); - // costruisco una finestra base - WindowFromJson = BuildWindowDefault(); - await DoPreviewSvg(true); - } - } - else - { - // usando m_currWindow (preesistente) impostare i parametri... - UpdateDict(); - } - } - if (m_CurrWindow != null && m_CurrWindow.AreaList != null && m_CurrWindow.AreaList.Count > 0) - { - checkWarnings(); - if (SashGroupList.Count > 0) - currAntaIndex = 0; - if (updRequested) - { - // se mancasse dizionario forme chiamo quello - if (LiveData.DictShape.Count == 0 && listErrLink.Count == 0) - { - if (firstDisplay && isRendered) - { - firstDisplay = false; - // preview SVG senza HW - await DoPreviewSvg(true, true); - if (LiveData.ProfElementList.Count == 0) - await UpdateElement(FrameWindow); - } - List reqList = SashGroupList.Select(x => x.GroupId).ToList(); - if (reqList.Count > 0) - { - await DoReqShape(reqList); - } - } - else - { - // chiedo SVG - if (prevReq != (int)DataReq.ReqSvg || !prevLiveData.JwdEqual(LiveData.CurrJwd)) - { - if (prevReq != (int)DataReq.ReqHwOpt) - await DoPreviewSvg(true); - else if (LiveData.DictOptionsXml.Count > 0) - await DoPreviewSvg(true); - } - } - } - } - else - { - JsonWindow WindowFromJson = new JsonWindow("", "", "", ""); - WindowFromJson = BuildWindowDefault(); - await DoPreviewSvg(true); - } - } - else - { - checkErrorPre(); - } - } - isLoading = false; - } - - /// - /// Metodo per costruire una finestra con vetro fisso - /// - /// - private JsonWindow BuildWindowDefault() - { - // Costruisco window e setto i parametri - Window window = new Window(); - window.sProfilePath = "Profilo78"; - window.sMaterial = "Pino"; - window.sGlass = "Vetro BE 2S 4T/16/4T"; - window.sColorMaterial = "Wood"; - // Costruisco frame e setto i parametri - Frame frame = new Frame(null, window); - frame.SetGroupId(1); - frame.SetAreaType(AreaTypes.FRAME); - frame.SetSelShape(Shapes.RECTANGLE); - frame.SetSelThresholdFromName("Bottom"); - frame.SetBottomRail(false); - frame.SetBottomRailQty(0); - window.AreaList.Add(frame); - List DimensionList = new List - { - new FrameDimension(frame, 1, "Width", 800, false), - new FrameDimension(frame, 1, "Height", 1200, true) - }; - List JointList = new List - { - new Joint(frame, 1, Joints.FULL_H), - new Joint(frame, 2, Joints.FULL_H), - new Joint(frame, 3, Joints.FULL_H), - new Joint(frame, 4, Joints.FULL_H) - }; - frame.JointList = JointList; - frame.DimensionList = DimensionList; - // Costruisco fill e setto i parametri - Fill fill = new Fill(frame, window); - fill.AreaType = AreaTypes.FILL; - fill.SelFillType = FillTypes.GLASS; - fill.GroupId = 2; - frame.AreaList.Add(fill); - JsonWindow jsonWindow = window.Serialize(); - string jwd = JsonConvert.SerializeObject(jsonWindow); - return JsonConvert.DeserializeObject(jwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); - } - - /// - /// Metodo per controllare che non ci siano duplicati di GroupId - /// - /// - /// - protected bool CheckGroupId(Window window) - { - List groupIdList = new List(); - AllGroupIdList(window.AreaList.First(), groupIdList); - var duplicati = groupIdList.GroupBy(x => x) - .Where(g => g.Count() > 1) - .Select(g => g.Key) - .ToList(); - return duplicati.Count > 0 ? false : true; - } - - /// - /// Metodo per costruire oggetti della Window - /// - /// - protected void setCurrWindow(JsonWindow WindowFromJson) - { - if (m_CurrWindow != null) - { - m_CurrWindow = null; - } - m_CurrWindow = WindowFromJson.Deserialize(); - groupIdOK = CheckGroupId(m_CurrWindow); - if (groupIdOK) - { - FrameWindow = m_CurrWindow.AreaList[0]; - if (m_PreviousWindow != null) - { - for (int i = 0; i < 2; i++) - m_CurrWindow.AreaList.First().DimensionList[i].dDimension = m_PreviousWindow.AreaList.First().DimensionList[i].dDimension; - if (m_CurrWindow.AreaList.First().Shape == Shapes.TRIANGLE) - { - for (int i = 0; i < 2; i++) - m_CurrWindow.AreaList.First().JointList[i].SelJointType = m_PreviousWindow.AreaList.First().JointList[i].SelJointType; - } - else - { - for (int i = 0; i < 4; i++) - m_CurrWindow.AreaList.First().JointList[i].SelJointType = m_PreviousWindow.AreaList.First().JointList[i].SelJointType; - } - } - if (m_CurrWindow != null) - { - // Aggiornamento liste sash, split, splitted, fill e itemTable - UpdateLists(); - } - if (SashGroupList.Count > 0) - currAntaIndex = 0; - // Aggiorno window con dati shape e hw option - UpdateDict(); - } - } - - /// - /// Aggiornamento dei dati con informazioni ricevute dai dizionari - /// - protected void UpdateDict() - { - // se ho i dizionari delle forme le aggiungo - if (LiveData.DictShape.Count > 0) - { - // Inserisco le forme ricevuto nei sash group - foreach (var item in LiveData.DictShape) - { - Sash? sashFromGroupId = SashGroupList.FirstOrDefault(x => x.GroupId == item.Key); - if (sashFromGroupId != null) - { - sashFromGroupId.SashShape = item.Value; - sashFromGroupId.UpdateShape(item.Value); - } - } - if (prevReq == (int)DataReq.ReqShape) - { - if (reqHwOpt > 0) - { - List reqList = SashGroupList.Select(x => x.GroupId).ToList(); - if (reqList.Count > 0) - { - _ = DoReqOptHardware(reqList); - } - } - } - } - // se ho le opzioni hw le aggiungo - if (LiveData.DictOptionsXml.Count > 0) - { - loadListRem("LoadHwOpt"); - foreach (var item in SashGroupList) - { - if (LiveData.DictOptionsXml.ContainsKey(item.GroupId)) - { - item.SetHardwareOption(LiveData.DictOptionsXml[item.GroupId]); - } - } - } - if (LiveData.ProfElementList.Count > 0) - { - // Inserisco i profili ricevuti nei rispettivi Element - foreach (var item in LiveData.ProfElementList) - { - UpdateProfileElement(item.Profiles, item.GroupId, item.EntId); - } - } - } - - /// - /// Metodo che resetta le liste (sash, split, splitted, fill e itemTable) e le crea nuovamente - /// - protected void UpdateLists() - { - m_maxCol = 0; - m_maxRow = 0; - m_FillList = new List(); - m_SashList = new List(); - m_SplitList = new List(); - m_SplittedList = new List(); - m_ItemTableList = new List(); - CreateWindowsList((m_CurrWindow!).AreaList.First(), false); - CreateElementTable(m_CurrWindow.AreaList.First(), 1, 1, 1, 1); - foreach (var item in ItemTableList) - { - if (item.NumChild > 3) - { - if (!RowCollapsed.ContainsKey(item.Row)) - { - RowCollapsed.Add(item.Row, false); - Child.Add(item.Row, item.NumChild); - } - } - else if (RowCollapsed.ContainsKey(item.Row)) - { - RowCollapsed.Remove(item.Row); - Child.Remove(item.Row); - } - } - } - - /// - /// Metodo per settare i paramteri di ingresso selezionati - /// - protected void UpdateInputList(JsonWindow WindowFromJson) - { - string profile = WindowFromJson.ProfilePath; - Window.m_ParameterList = ListPayload.ProfileList?.FirstOrDefault(x => x.ProfileName.Equals(profile))?.ParameterDict ?? new(); - Frame.m_AllThresholdList = ListPayload.ProfileList?.FirstOrDefault(x => x.ProfileName.Equals(profile))?.ThresholdList ?? new(); - Sash.m_HardwareCompleteList = ListPayload.Hardware; - Sash.s_FamilyHardwareList = ListPayload.FamilyHardware; - } - - /// - /// Metodo per settare i parmateri di ingresso selezionati - /// - protected void UpdateSelParameter() - { - if (SelectionData != null && SelectionData.IsValid()) - { - SelFamilyHardware = SelectionData.FamilyHardware ?? ""; - SelColorMaterial = SelectionData.ColorMaterial ?? ""; - SelMaterial = SelectionData.Material ?? ""; - SelGlass = SelectionData.Glass ?? ""; - SelProfile = SelectionData.Profile ?? ""; - } - } - - #endregion Protected Methods - - #region Private Fields - - private int currAntaIndex = 0; - private int currFillIndex = -1; - private int currSashIndex = -1; - private int currSplitIndex = -1; - private CompileStep currStep; - private bool editLock = false; - private bool firstDisplay = true; - private bool groupIdOK = false; - - /// - /// Booleana fase loading - /// - private bool isLoading = false; - private bool okParams = false; - private bool okJwd = false; - private bool isRendered = false; - - /// - /// ELenco errori di coerenza/link dati (vanno risolti per disegnare/procedere) - /// - private Dictionary listErrLink = new Dictionary(); - - /// - /// Elenco errori preliminari (mancano elementi di base di validazione modello dati)) - /// - private Dictionary listErrPre = new Dictionary(); - - /// - /// Elenco warnings non bloccanti - /// - private Dictionary listWarnings = new Dictionary(); - - - private Frame? m_Frame; - - private List m_ItemTableList = new List(); - - private int m_maxCol = 0; - - private int m_maxRow = 0; - - private List m_SashList = new List(); - private List m_SplitList = new List(); - private List m_FillList = new List(); - private List m_SplittedList = new List(); - - private Dictionary RowCollapsed { get; set; } = new Dictionary(); - private Dictionary Child { get; set; } = new Dictionary(); - - private static Logger Log = LogManager.GetCurrentClassLogger(); - - #endregion Private Fields - - #region Private Properties - - private Window? m_CurrWindow { get; set; } = null; - private Window? m_PreviousWindow { get; set; } = null; - - /// - /// Salvataggio JWD precedente x evitare loop su update (aggiornato dopo chiamate redis) - /// - private string prevJwd { get; set; } = ""; - - /// - /// Salvataggio tipo di domanda precedente - /// - private int prevReq { get; set; } = 0; - private int reqHwOpt { get; set; } = 0; - - #endregion Private Properties - - #region Private Methods - - /// - /// Metodo per andare allo step successivo - /// - /// step successivo - private void AdvStep(CompileStep newStep) - { - currStep = newStep; - currSashIndex = -1; - currFillIndex = -1; - currSplitIndex = -1; - } - - /// - /// Verifica errori prelimionari per mostrare dove sia il problema - /// - private void checkErrorPre() - { - // verifico 1:1 le liste e indico cosa manca - if (ListPayload.Hardware == null || ListPayload.Hardware.Count == 0) - { - listErrPre.Add("Hardware", "Missing Hardware List!"); - Log.Warn("Missing Hardware List"); - } - else - { - if (ListPayload.FamilyHardware == null || ListPayload.FamilyHardware.Count == 0) - { - listErrPre.Add("FamilyHardware", "Missing Family HW List!"); - Log.Warn(" Missing Family HW List"); - } - } - if (ListPayload.Glass == null || ListPayload.Glass.Count == 0) - { - listErrPre.Add("Glass", "Missing Glass List!"); - Log.Warn(" Missing Glass List"); - } - if (ListPayload.Material == null || ListPayload.Material.Count == 0) - { - listErrPre.Add("Material", "Missing Material List!"); - Log.Warn(" Missing Material List"); - } - if (ListPayload.ColorMaterial == null || ListPayload.ColorMaterial.Count == 0) - { - listErrPre.Add("ColorMaterial", "Missing ColorMaterial List!"); - Log.Warn("Missing ColorMaterial List"); - } - if (ListPayload.ProfileList == null || ListPayload.ProfileList.Count == 0) - { - listErrPre.Add("Profile", "Missing Profile data!"); - Log.Warn("Missing Profile data"); - } - } - - /// - /// Verifica warning minori (es coerenza colori...) - /// - private void checkWarnings() - { - // verifico 1:1 le liste e i valori siano coerenti... - if (ListPayload.ColorMaterial != null && ListPayload.ColorMaterial.Count > 0) - { - if (m_CurrWindow != null) - { - if (ListPayload.ColorMaterial == null || !ListPayload.ColorMaterial.Contains(m_CurrWindow.sColorMaterial)) - { - listWarnings.Add("ColorMaterial", $"Missing Color: {m_CurrWindow.sColorMaterial}"); - } - if (ListPayload.Glass == null || !ListPayload.Glass.Contains(m_CurrWindow.sGlass)) - { - listWarnings.Add("Glass", $"Missing Glass: {m_CurrWindow.sGlass}"); - } - if (ListPayload.Material == null || !ListPayload.Material.Contains(m_CurrWindow.sMaterial)) - { - listWarnings.Add("Material", $"Missing Material: {m_CurrWindow.sMaterial}"); - } - if (ListPayload.ProfileList == null || !ListPayload.ProfileList.Any(x => x.ProfileName.Contains(m_CurrWindow.sProfilePath))) - { - listWarnings.Add("Profile", $"Missing Profile: {m_CurrWindow.sProfilePath}"); - } - if (!groupIdOK) - { - listWarnings.Add("GroupId", "JWD not correct!"); - } - } - } - } - /// /// Helper aggiunta elemento a lista caricamento (per caricamento opzioni hw) /// @@ -1165,19 +1095,67 @@ namespace WebWindowComplex } /// - /// Metodo per aggiornare il valore collassato degli elementi della gerarchia + /// Rimozione area da frame corrente /// - /// - private void CollapsedRowTree(Dictionary Args) + /// oggetto da rimuovere + /// + private async Task RemoveArea(DataNextStep remove) { - foreach (var item in Args) + if (remove.currCompileStep is CompileStep.Sash) { - RowCollapsed[item.Key] = Args[item.Key] ? true : false; - if (m_ItemTableList.FirstOrDefault(x => x.Row == item.Key) != null) + SashGroupList.ElementAt(remove.index).Remove(); + if (FrameWindow.SelThreshold.Name.Contains("Threshold") && remove.index == 0) { - Child[item.Key] = m_ItemTableList.FirstOrDefault(x => x.Row == item.Key)!.NumChild; + Threshold? updThreshold = FrameWindow.ThresholdList.FirstOrDefault(x => x.Name != "Threshold"); + if (updThreshold != null) + FrameWindow.SelThresholdFromName = updThreshold.Name; } + SashGroupList.RemoveAt(remove.index); } + else if (remove.currCompileStep is CompileStep.Split) + { + SplitList.ElementAt(remove.index).Remove(); + SplitList.RemoveAt(remove.index); + } + await EC_ActionReq.InvokeAsync(DataAction.ResetDimElem); + await DoPreviewSvg(); + } + + /// + /// Richiesta opzioni hardware per la prima volta + /// + /// nuovo frame + /// + private async Task ReqFirstOptionHw(Sash newSash) + { + if (newSash != null) + { + // cerco il record + var currRec = SearchAreaFromGroupId(FrameWindow, newSash.GroupId); + // lo aggiorno + currRec = newSash; + // resetto hw list + await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt); + // richiesta calcolo opzioni hardware per la singola sash group + List reqList = SashGroupList.Select(x => x.GroupId).ToList(); + // chiamo con gruppo della nuova sash + await DoReqOptHardware(reqList); + } + } + + /// + /// Lista completa dei group id per le richieste + /// + /// nodo da controllare + /// Lista groupId + private void ReqGroupIdList(Area node, List groupId) + { + if (node.AreaList == null) + return; + if (node is Sash || node is Split) + groupId.Add(node.GroupId); + foreach (var child in node.AreaList) + ReqGroupIdList(child, groupId); } /// @@ -1220,114 +1198,44 @@ namespace WebWindowComplex } /// - /// Metodo per aggiornare i nomi dei profili degli elementi + /// Metodo per costruire oggetti della Window /// - /// Lista dei profili - /// Id Area che si sta cercando - /// Id dell'anta o dello split (se -1 non usare) - /// - private void UpdateProfileElement(List profileNameList, int GroupIdSearch, int EntityIdSearch) + /// + private void setCurrWindow(JsonWindow WindowFromJson) { - // Cerco area corrispondente al GroupId - Area? found = SearchAreaFromGroupId(FrameWindow, GroupIdSearch); - List elemList = new List(); - if (found != null) + if (m_CurrWindow != null) { - switch (found.AreaType) + m_CurrWindow = null; + } + m_CurrWindow = WindowFromJson.Deserialize(); + groupIdOK = CheckGroupId(m_CurrWindow); + if (groupIdOK) + { + FrameWindow = m_CurrWindow.AreaList[0]; + if (m_PreviousWindow != null) { - case AreaTypes.FRAME: - { - Frame frame = (Frame)found; - for (int index = frame.ElementDimensionList.Count; index < profileNameList.Count; index++) - { - double valStd = Window.m_ParameterList.GetValueOrDefault(profileNameList.ElementAt(index) + "_DimStd"); - frame.ElementDimensionList.Add(new ElementDimension(frame, index + 1, valStd)); - } - for (int i = 0; i < frame.ElementDimensionList.Count; i++) - { - frame.ElementDimensionList.ElementAt(i).SetNameElement(profileNameList.ElementAt(i)); - } - for (int index = profileNameList.Count; index < frame.ElementDimensionList.Count; index++) - frame.ElementDimensionList.RemoveAt(index); - elemList = frame.ElementDimensionList; - foreach (var item in elemList) - { - string overlapName = string.Join("_", item.sName.Split('_').Skip(1)); - item.SetOverlapElement(Window.m_ParameterList.GetValueOrDefault(overlapName + "_Overlap")); - } - foreach (var elem in frame.BottomRailElemDimList) - { - elem.SetOverlapElement(Window.m_ParameterList.GetValueOrDefault("Frame_BottomRail_Overlap")); - } - break; - } - case AreaTypes.SASH: - { - Sash sash = (Sash)found; - SashDimension anta = sash.SashList.ElementAt(EntityIdSearch - 1); - for (int index = anta.ElementDimensionList.Count; index < profileNameList.Count; index++) - { - double valStd = Window.m_ParameterList.GetValueOrDefault(profileNameList.ElementAt(index) + "_DimStd"); - anta.ElementDimensionList.Add(new ElementDimension(sash, index + 1, valStd)); - } - int numElemDelete = anta.ElementDimensionList.Count - profileNameList.Count; - for (int i = 0; i < numElemDelete; i++) - { - anta.ElementDimensionList.RemoveAt(anta.ElementDimensionList.Count - 1); - } - for (int index = profileNameList.Count; index < anta.ElementDimensionList.Count; index++) - anta.ElementDimensionList.RemoveAt(index); - for (int i = 0; i < anta.ElementDimensionList.Count; i++) - { - anta.ElementDimensionList.ElementAt(i).SetNameElement(profileNameList.ElementAt(i)); - } - SetOverlapSash(sash, anta, EntityIdSearch - 1, elemList); - break; - } - case AreaTypes.SPLIT: - { - Split split = (Split)found; - List SpElemList = split.searchElemFromSubArea(EntityIdSearch); - for (int i = 0; i < SpElemList.Count; i++) - { - SpElemList.ElementAt(i).SetNameElement(profileNameList.ElementAt(i)); - SpElemList.ElementAt(i).SetMinDimension(Window.m_ParameterList.GetValueOrDefault(SpElemList.ElementAt(i).sName + "_DimMin")); - SpElemList.ElementAt(i).SetMaxDimension(Window.m_ParameterList.GetValueOrDefault(SpElemList.ElementAt(i).sName + "_DimMax")); - if (SpElemList.ElementAt(i).dDimension > SpElemList.ElementAt(i).dMaxDim) - { - SpElemList.ElementAt(i).SetDimension(SpElemList.ElementAt(i).dMaxDim); - Frame frame = split.ParentWindow.AreaList.First(); - if (frame != null) - { - frame.SearchAreaList(frame, frame.AvailWidthArea(), "Width"); - frame.SearchAreaList(frame, frame.AvailHeightArea(), "Height"); - } - } - else if (SpElemList.ElementAt(i).dDimension < SpElemList.ElementAt(i).dMinDim) - { - SpElemList.ElementAt(i).SetDimension(SpElemList.ElementAt(i).dMinDim); - Frame frame = split.ParentWindow.AreaList.First(); - if (frame != null) - { - frame.SearchAreaList(frame, frame.AvailWidthArea(), "Width"); - frame.SearchAreaList(frame, frame.AvailHeightArea(), "Height"); - } - } - string overlapName = string.Join("_", SpElemList.ElementAt(i).sName.Split('_').Skip(1)); - SpElemList.ElementAt(i).SetOverlapElement(Window.m_ParameterList.GetValueOrDefault(overlapName + "_Overlap")); - } - break; - } + for (int i = 0; i < 2; i++) + m_CurrWindow.AreaList.First().DimensionList[i].dDimension = m_PreviousWindow.AreaList.First().DimensionList[i].dDimension; + if (m_CurrWindow.AreaList.First().Shape == Shapes.TRIANGLE) + { + for (int i = 0; i < 2; i++) + m_CurrWindow.AreaList.First().JointList[i].SelJointType = m_PreviousWindow.AreaList.First().JointList[i].SelJointType; + } + else + { + for (int i = 0; i < 4; i++) + m_CurrWindow.AreaList.First().JointList[i].SelJointType = m_PreviousWindow.AreaList.First().JointList[i].SelJointType; + } } - foreach (var item in elemList) + if (m_CurrWindow != null) { - item.SetMinDimension(Window.m_ParameterList.GetValueOrDefault(item.sName + "_DimMin")); - item.SetMaxDimension(Window.m_ParameterList.GetValueOrDefault(item.sName + "_DimMax")); - if (item.dDimension > item.dMaxDim) - item.SetDimension(item.dMaxDim); - else if (item.dMaxDim < item.dMinDim) - item.SetDimension(item.dMinDim); + // Aggiornamento liste sash, split, splitted, fill e itemTable + UpdateLists(); } + if (SashGroupList.Count > 0) + currAntaIndex = 0; + // Aggiorno window con dati shape e hw option + UpdateDict(); } } @@ -1567,30 +1475,6 @@ namespace WebWindowComplex //} } - /// - /// Metodo per aggiornare valori della sezione General - /// - /// - private void UpdatePreviewGeneral(DataUpdateGeneral args) - { - string Color = args.Color; - string Glass = args.Glass; - string Material = args.Material; - string Profile = args.Profile; - if (m_CurrWindow != null) - { - if (!string.IsNullOrEmpty(Color)) - m_CurrWindow.sColorMaterial = Color; - else if (!string.IsNullOrEmpty(Glass)) - m_CurrWindow.sGlass = Glass; - else if (!string.IsNullOrEmpty(Material)) - m_CurrWindow.sMaterial = Material; - else if (!string.IsNullOrEmpty(Profile)) - m_CurrWindow.sProfilePath = Profile; - _ = DoPreviewSvg(); - } - } - /// /// Calcola il css del tab selezionato /// @@ -1622,17 +1506,6 @@ namespace WebWindowComplex return (testStep == currStep) ? "nav-link active fw-bold" : "nav-link text-dark"; } - /// - /// Metodo per cambiare tutti i Fill e richiedere aggiornamento SVG - /// - /// tipo di fill richiesto - /// - protected Task ChangeAllFill(FillTypes reqFillType) - { - updateAllFill(FrameWindow, reqFillType); - return DoPreviewSvg(); - } - /// /// Metodo per aggiornare tutti i Fill al nuovo tipo /// @@ -1652,6 +1525,220 @@ namespace WebWindowComplex } } + /// + /// Aggiornamento dei dati con informazioni ricevute dai dizionari + /// + private void UpdateDict() + { + // se ho i dizionari delle forme le aggiungo + if (LiveData.DictShape.Count > 0) + { + // Inserisco le forme ricevuto nei sash group + foreach (var item in LiveData.DictShape) + { + Sash? sashFromGroupId = SashGroupList.FirstOrDefault(x => x.GroupId == item.Key); + if (sashFromGroupId != null) + { + sashFromGroupId.SashShape = item.Value; + sashFromGroupId.UpdateShape(item.Value); + } + } + if (prevReq == (int)DataReq.ReqShape) + { + if (reqHwOpt > 0) + { + List reqList = SashGroupList.Select(x => x.GroupId).ToList(); + if (reqList.Count > 0) + { + _ = DoReqOptHardware(reqList); + } + } + } + } + // se ho le opzioni hw le aggiungo + if (LiveData.DictOptionsXml.Count > 0) + { + loadListRem("LoadHwOpt"); + foreach (var item in SashGroupList) + { + if (LiveData.DictOptionsXml.ContainsKey(item.GroupId)) + { + item.SetHardwareOption(LiveData.DictOptionsXml[item.GroupId]); + } + } + } + if (LiveData.ProfElementList.Count > 0) + { + // Inserisco i profili ricevuti nei rispettivi Element + foreach (var item in LiveData.ProfElementList) + { + UpdateProfileElement(item.Profiles, item.GroupId, item.EntId); + } + } + } + + /// + /// Aggiornamento Element + /// + /// nuovo frame + /// + private async Task UpdateElement(Frame newFrame) + { + if (newFrame != null) + { + // richiedo update element del frame + List reqList = new List(); + reqList.Add(FrameWindow.GroupId); + // Aggiorno le liste sash, split + m_FillList = new List(); + m_SashList = new List(); + m_SplitList = new List(); + m_SplittedList = new List(); + CreateWindowsList((m_CurrWindow!).AreaList.First(), false); + ReqGroupIdList(FrameWindow, reqList); + await DoReqElement(reqList); + } + } + + /// + /// Aggiornamento Element a causa di un cambiamento nel frame + /// + /// nuovo frame + /// + private async Task UpdateElementFrame(Frame newFrame) + { + if (newFrame != null) + { + // cerco il record + var currRec = m_CurrWindow?.AreaList.FirstOrDefault(x => x.GroupId == newFrame.GroupId); + // lo aggiorno + currRec = newFrame; + // richiedo update element del frame + await UpdateElement(FrameWindow); + } + } + + /// + /// Aggiornamento Element a causa di un cambiamento nella sash + /// + /// + /// + private async Task UpdateElementSash(Sash newSash) + { + if (newSash != null) + { + Sash currRec = (Sash)SearchAreaFromGroupId(FrameWindow, newSash.GroupId)!; + currRec = newSash; + await UpdateElement(FrameWindow); + } + } + + /// + /// Aggiornamento Element a causa di un cambiamento nello split + /// + /// + /// + private async Task UpdateElementSplit(Split newSplit) + { + if (newSplit != null) + { + Split currRec = (Split)SearchAreaFromGroupId(FrameWindow, newSplit.GroupId)!; + currRec = newSplit; + await UpdateElement(FrameWindow); + } + } + + /// + /// Aggiornamento opzioni dato nuovo frame + /// + /// nuovo frame + /// + private async Task UpdateHwOptionsFrame(Frame newFrame) + { + if (newFrame != null) + { + // cerco il record + var currRec = m_CurrWindow?.AreaList.FirstOrDefault(x => x.GroupId == newFrame.GroupId); + // lo aggiorno + currRec = newFrame; + // resetto hw lst + await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt); + reqHwOpt++; + if (prevReq == (int)DataReq.ReqShape) + { + // richiesta calcolo opzioni hardware per la singola sash group + List reqList = SashGroupList.Select(x => x.GroupId).ToList(); + // chiamo con gruppo della nuova sash + await DoReqOptHardware(reqList); + } + } + } + + /// + /// Aggiornamento opzioni data nuova sash group + /// + /// nuovo frame + /// + private async Task UpdateHwOptionsSash(Sash newSash) + { + if (newSash != null) + { + // cerco il record + var currRec = SearchAreaFromGroupId(FrameWindow, newSash.GroupId); + // lo aggiorno + currRec = newSash; + // resetto hw list + await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt); + // richiesta calcolo opzioni hardware per la singola sash group + List reqList = SashGroupList.Select(x => x.GroupId).ToList(); + await DoReqOptHardware(reqList); + } + } + + /// + /// Metodo per settare i paramteri di ingresso selezionati + /// + private void UpdateInputList(JsonWindow WindowFromJson) + { + string profile = WindowFromJson.ProfilePath; + Window.m_ParameterList = ListPayload.ProfileList?.FirstOrDefault(x => x.ProfileName.Equals(profile))?.ParameterDict ?? new(); + Frame.m_AllThresholdList = ListPayload.ProfileList?.FirstOrDefault(x => x.ProfileName.Equals(profile))?.ThresholdList ?? new(); + Sash.m_HardwareCompleteList = ListPayload.Hardware; + Sash.s_FamilyHardwareList = ListPayload.FamilyHardware; + } + + /// + /// Metodo che resetta le liste (sash, split, splitted, fill e itemTable) e le crea nuovamente + /// + private void UpdateLists() + { + m_maxCol = 0; + m_maxRow = 0; + m_FillList = new List(); + m_SashList = new List(); + m_SplitList = new List(); + m_SplittedList = new List(); + m_ItemTableList = new List(); + CreateWindowsList((m_CurrWindow!).AreaList.First(), false); + CreateElementTable(m_CurrWindow.AreaList.First(), 1, 1, 1, 1); + foreach (var item in ItemTableList) + { + if (item.NumChild > 3) + { + if (!RowCollapsed.ContainsKey(item.Row)) + { + RowCollapsed.Add(item.Row, false); + Child.Add(item.Row, item.NumChild); + } + } + else if (RowCollapsed.ContainsKey(item.Row)) + { + RowCollapsed.Remove(item.Row); + Child.Remove(item.Row); + } + } + } + /// /// Aggiornamento Fill /// @@ -1697,157 +1784,47 @@ namespace WebWindowComplex } /// - /// Aggiornamento opzioni dato nuovo frame + /// Metodo per aggiornare valori della sezione General /// - /// nuovo frame - /// - private async Task UpdateHwOptionsFrame(Frame newFrame) + /// + private void UpdatePreviewGeneral(DataUpdateGeneral args) { - if (newFrame != null) + string Color = args.Color; + string Glass = args.Glass; + string Material = args.Material; + string Profile = args.Profile; + if (m_CurrWindow != null) { - // cerco il record - var currRec = m_CurrWindow?.AreaList.FirstOrDefault(x => x.GroupId == newFrame.GroupId); - // lo aggiorno - currRec = newFrame; - // resetto hw lst - await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt); - reqHwOpt++; - if (prevReq == (int)DataReq.ReqShape) - { - // richiesta calcolo opzioni hardware per la singola sash group - List reqList = SashGroupList.Select(x => x.GroupId).ToList(); - // chiamo con gruppo della nuova sash - await DoReqOptHardware(reqList); - } + if (!string.IsNullOrEmpty(Color)) + m_CurrWindow.sColorMaterial = Color; + else if (!string.IsNullOrEmpty(Glass)) + m_CurrWindow.sGlass = Glass; + else if (!string.IsNullOrEmpty(Material)) + m_CurrWindow.sMaterial = Material; + else if (!string.IsNullOrEmpty(Profile)) + m_CurrWindow.sProfilePath = Profile; + _ = DoPreviewSvg(); } } /// - /// Aggiornamento Element a causa di un cambiamento nella sash + /// Aggiornamento opzioni dato update sash /// - /// + /// nuova sash /// - private async Task UpdateElementSash(Sash newSash) + private async Task UpdatePreviewSashGroup(DataUpdateSash args) { - if (newSash != null) + Sash newSash = args.currSash; + bool svgNoHw = args.svgNoHw; + bool noSvg = args.noSvg; + Sash? item = (Sash?)SearchAreaFromGroupId(FrameWindow, newSash.GroupId); + if (!noSvg && newSash != null && item != null) { - Sash currRec = (Sash)SearchAreaFromGroupId(FrameWindow, newSash.GroupId)!; - currRec = newSash; - await UpdateElement(FrameWindow); - } - } - - /// - /// Aggiornamento Element a causa di un cambiamento nello split - /// - /// - /// - private async Task UpdateElementSplit(Split newSplit) - { - if (newSplit != null) - { - Split currRec = (Split)SearchAreaFromGroupId(FrameWindow, newSplit.GroupId)!; - currRec = newSplit; - await UpdateElement(FrameWindow); - } - } - - /// - /// Aggiornamento Element a causa di un cambiamento nel frame - /// - /// nuovo frame - /// - private async Task UpdateElementFrame(Frame newFrame) - { - if (newFrame != null) - { - // cerco il record - var currRec = m_CurrWindow?.AreaList.FirstOrDefault(x => x.GroupId == newFrame.GroupId); - // lo aggiorno - currRec = newFrame; - // richiedo update element del frame - await UpdateElement(FrameWindow); - } - } - - /// - /// Aggiornamento Element - /// - /// nuovo frame - /// - private async Task UpdateElement(Frame newFrame) - { - if (newFrame != null) - { - // richiedo update element del frame - List reqList = new List(); - reqList.Add(FrameWindow.GroupId); - // Aggiorno le liste sash, split - m_FillList = new List(); - m_SashList = new List(); - m_SplitList = new List(); - m_SplittedList = new List(); - CreateWindowsList((m_CurrWindow!).AreaList.First(), false); - ReqGroupIdList(FrameWindow, reqList); - await DoReqElement(reqList); - } - } - - /// - /// Lista completa dei group id per le richieste - /// - /// nodo da controllare - /// Lista groupId - private void ReqGroupIdList(Area node, List groupId) - { - if (node.AreaList == null) - return; - if (node is Sash || node is Split) - groupId.Add(node.GroupId); - foreach (var child in node.AreaList) - ReqGroupIdList(child, groupId); - } - - /// - /// Aggiornamento opzioni data nuova sash group - /// - /// nuovo frame - /// - private async Task UpdateHwOptionsSash(Sash newSash) - { - if (newSash != null) - { - // cerco il record - var currRec = SearchAreaFromGroupId(FrameWindow, newSash.GroupId); - // lo aggiorno - currRec = newSash; - // resetto hw list - await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt); - // richiesta calcolo opzioni hardware per la singola sash group - List reqList = SashGroupList.Select(x => x.GroupId).ToList(); - await DoReqOptHardware(reqList); - } - } - - /// - /// Richiesta opzioni hardware per la prima volta - /// - /// nuovo frame - /// - private async Task ReqFirstOptionHw(Sash newSash) - { - if (newSash != null) - { - // cerco il record - var currRec = SearchAreaFromGroupId(FrameWindow, newSash.GroupId); - // lo aggiorno - currRec = newSash; - // resetto hw list - await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt); - // richiesta calcolo opzioni hardware per la singola sash group - List reqList = SashGroupList.Select(x => x.GroupId).ToList(); - // chiamo con gruppo della nuova sash - await DoReqOptHardware(reqList); + item = newSash; + if (svgNoHw) + await DoPreviewSvg(true, true); + else + await DoPreviewSvg(); } } @@ -1896,93 +1873,135 @@ namespace WebWindowComplex await UpdateElement(FrameWindow); await DoReqShape(reqList); } - } /// - /// Aggiornamento opzioni dato update sash + /// Metodo per aggiornare i nomi dei profili degli elementi /// - /// nuova sash + /// Lista dei profili + /// Id Area che si sta cercando + /// Id dell'anta o dello split (se -1 non usare) /// - private async Task UpdatePreviewSashGroup(DataUpdateSash args) + private void UpdateProfileElement(List profileNameList, int GroupIdSearch, int EntityIdSearch) { - Sash newSash = args.currSash; - bool svgNoHw = args.svgNoHw; - bool noSvg = args.noSvg; - Sash? item = (Sash?)SearchAreaFromGroupId(FrameWindow, newSash.GroupId); - if (!noSvg && newSash != null && item != null) + // Cerco area corrispondente al GroupId + Area? found = SearchAreaFromGroupId(FrameWindow, GroupIdSearch); + List elemList = new List(); + if (found != null) { - item = newSash; - if (svgNoHw) - await DoPreviewSvg(true, true); - else - await DoPreviewSvg(); - } - } - - /// - /// Rimozione area da frame corrente - /// - /// oggetto da rimuovere - /// - private async Task RemoveArea(DataNextStep remove) - { - if (remove.currCompileStep is CompileStep.Sash) - { - SashGroupList.ElementAt(remove.index).Remove(); - if (FrameWindow.SelThreshold.Name.Contains("Threshold") && remove.index == 0) + switch (found.AreaType) { - Threshold? updThreshold = FrameWindow.ThresholdList.FirstOrDefault(x => x.Name != "Threshold"); - if (updThreshold != null) - FrameWindow.SelThresholdFromName = updThreshold.Name; + case AreaTypes.FRAME: + { + Frame frame = (Frame)found; + for (int index = frame.ElementDimensionList.Count; index < profileNameList.Count; index++) + { + double valStd = Window.m_ParameterList.GetValueOrDefault(profileNameList.ElementAt(index) + "_DimStd"); + frame.ElementDimensionList.Add(new ElementDimension(frame, index + 1, valStd)); + } + for (int i = 0; i < frame.ElementDimensionList.Count; i++) + { + frame.ElementDimensionList.ElementAt(i).SetNameElement(profileNameList.ElementAt(i)); + } + for (int index = profileNameList.Count; index < frame.ElementDimensionList.Count; index++) + frame.ElementDimensionList.RemoveAt(index); + elemList = frame.ElementDimensionList; + foreach (var item in elemList) + { + string overlapName = string.Join("_", item.sName.Split('_').Skip(1)); + item.SetOverlapElement(Window.m_ParameterList.GetValueOrDefault(overlapName + "_Overlap")); + } + foreach (var elem in frame.BottomRailElemDimList) + { + elem.SetOverlapElement(Window.m_ParameterList.GetValueOrDefault("Frame_BottomRail_Overlap")); + } + break; + } + case AreaTypes.SASH: + { + Sash sash = (Sash)found; + SashDimension anta = sash.SashList.ElementAt(EntityIdSearch - 1); + for (int index = anta.ElementDimensionList.Count; index < profileNameList.Count; index++) + { + double valStd = Window.m_ParameterList.GetValueOrDefault(profileNameList.ElementAt(index) + "_DimStd"); + anta.ElementDimensionList.Add(new ElementDimension(sash, index + 1, valStd)); + } + int numElemDelete = anta.ElementDimensionList.Count - profileNameList.Count; + for (int i = 0; i < numElemDelete; i++) + { + anta.ElementDimensionList.RemoveAt(anta.ElementDimensionList.Count - 1); + } + for (int index = profileNameList.Count; index < anta.ElementDimensionList.Count; index++) + anta.ElementDimensionList.RemoveAt(index); + for (int i = 0; i < anta.ElementDimensionList.Count; i++) + { + anta.ElementDimensionList.ElementAt(i).SetNameElement(profileNameList.ElementAt(i)); + } + SetOverlapSash(sash, anta, EntityIdSearch - 1, elemList); + break; + } + case AreaTypes.SPLIT: + { + Split split = (Split)found; + List SpElemList = split.searchElemFromSubArea(EntityIdSearch); + for (int i = 0; i < SpElemList.Count; i++) + { + SpElemList.ElementAt(i).SetNameElement(profileNameList.ElementAt(i)); + SpElemList.ElementAt(i).SetMinDimension(Window.m_ParameterList.GetValueOrDefault(SpElemList.ElementAt(i).sName + "_DimMin")); + SpElemList.ElementAt(i).SetMaxDimension(Window.m_ParameterList.GetValueOrDefault(SpElemList.ElementAt(i).sName + "_DimMax")); + if (SpElemList.ElementAt(i).dDimension > SpElemList.ElementAt(i).dMaxDim) + { + SpElemList.ElementAt(i).SetDimension(SpElemList.ElementAt(i).dMaxDim); + Frame frame = split.ParentWindow.AreaList.First(); + if (frame != null) + { + frame.SearchAreaList(frame, frame.AvailWidthArea(), "Width"); + frame.SearchAreaList(frame, frame.AvailHeightArea(), "Height"); + } + } + else if (SpElemList.ElementAt(i).dDimension < SpElemList.ElementAt(i).dMinDim) + { + SpElemList.ElementAt(i).SetDimension(SpElemList.ElementAt(i).dMinDim); + Frame frame = split.ParentWindow.AreaList.First(); + if (frame != null) + { + frame.SearchAreaList(frame, frame.AvailWidthArea(), "Width"); + frame.SearchAreaList(frame, frame.AvailHeightArea(), "Height"); + } + } + string overlapName = string.Join("_", SpElemList.ElementAt(i).sName.Split('_').Skip(1)); + SpElemList.ElementAt(i).SetOverlapElement(Window.m_ParameterList.GetValueOrDefault(overlapName + "_Overlap")); + } + break; + } } - SashGroupList.RemoveAt(remove.index); - } - else if(remove.currCompileStep is CompileStep.Split) - { - SplitList.ElementAt(remove.index).Remove(); - SplitList.RemoveAt(remove.index); - } - await EC_ActionReq.InvokeAsync(DataAction.ResetDimElem); - await DoPreviewSvg(); - } - - /// - /// Calcola bottone per tutti i Fill - /// - /// - private string buttonFillCss(FillTypes reqFillTypes) - { - foreach (var fill in FillList) - { - if (!fill.FillType.Equals(reqFillTypes)) - return "btn btn-outline-secondary btn-sm"; - } - return "btn btn-secondary btn-sm"; - } - - /// - /// Metodo per ottenere lista di tutti i groupId appartenenti alla window - /// - /// Area da aggiungere alla lista groupId - /// Lista group id - protected void AllGroupIdList(Area node, List groupIdList) - { - if (node != null) - { - groupIdList.Add(node.GroupId); - foreach (var item in node.AreaList) + foreach (var item in elemList) { - AllGroupIdList(item, groupIdList); + item.SetMinDimension(Window.m_ParameterList.GetValueOrDefault(item.sName + "_DimMin")); + item.SetMaxDimension(Window.m_ParameterList.GetValueOrDefault(item.sName + "_DimMax")); + if (item.dDimension > item.dMaxDim) + item.SetDimension(item.dMaxDim); + else if (item.dMaxDim < item.dMinDim) + item.SetDimension(item.dMinDim); } } } + /// + /// Metodo per settare i parmateri di ingresso selezionati + /// + private void UpdateSelParameter() + { + if (SelectionData != null && SelectionData.IsValid()) + { + SelFamilyHardware = SelectionData.FamilyHardware ?? ""; + SelColorMaterial = SelectionData.ColorMaterial ?? ""; + SelMaterial = SelectionData.Material ?? ""; + SelGlass = SelectionData.Glass ?? ""; + SelProfile = SelectionData.Profile ?? ""; + } + } + #endregion Private Methods } - public class DataSave - { - public string currJwd { get; set; } = ""; - public bool ForceSave { get; set; } = true; - } -} +} \ No newline at end of file From 5cbd973c2220822f4f4871948ed648ec7f9aa97f Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 20 Mar 2026 10:00:51 +0100 Subject: [PATCH 6/8] Update logica gestione aggiornamento sul primo render con JWD vuoti --- Test.UI/Components/Pages/EditJWD.razor.cs | 3 ++- Test.UI/appsettings.json | 4 +++- WebWindowComplex/DTO/DataSave.cs | 12 ++++++++++++ WebWindowComplex/WebWindowComplex.csproj | 15 ++++++++++++++- .../WebWindowConfigurator.csproj | 15 ++++++++++++++- 5 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 WebWindowComplex/DTO/DataSave.cs diff --git a/Test.UI/Components/Pages/EditJWD.razor.cs b/Test.UI/Components/Pages/EditJWD.razor.cs index 06a5af7..089a306 100644 --- a/Test.UI/Components/Pages/EditJWD.razor.cs +++ b/Test.UI/Components/Pages/EditJWD.razor.cs @@ -147,8 +147,9 @@ namespace Test.UI.Components.Pages //InitialJwd = File.ReadAllText("Data\\AntaDoppiaInglesine.jwd"); #if false InitialJwd = File.ReadAllText("Data\\AntaDoppia.jwd"); -#endif +#else InitialJwd = "{}"; +#endif currJwd = InitialJwd; // rileggo altri dati await ReloadData(); diff --git a/Test.UI/appsettings.json b/Test.UI/appsettings.json index 8c5f5d9..ed1df57 100644 --- a/Test.UI/appsettings.json +++ b/Test.UI/appsettings.json @@ -52,7 +52,9 @@ }, "AllowedHosts": "*", "ConnectionStrings": { - "Redis": "redis.ufficio:26379, serviceName=devel, DefaultDatabase=6, keepAlive=180, connectTimeout=15000, syncTimeout=15000, asyncTimeout=15000, abortConnect=false, ssl=false, allowAdmin=true" + "Redis": "redis.ufficio:26379, serviceName=devel, DefaultDatabase=6, keepAlive=180, connectTimeout=15000, syncTimeout=15000, asyncTimeout=15000, abortConnect=false, ssl=false, allowAdmin=true", + "DefaultConnection": "Server=mdb.ufficio;port=3306;database=Lux_000;uid=lux_user;pwd=Egal_pwd!;sslmode=None;", + "Lux.All": "Server=mdb.ufficio;port=3306;database=Lux_000;uid=lux_user;pwd=Egal_pwd!;sslmode=None;" }, "ServerConf": { "BaseUrl": "/lux/test/", diff --git a/WebWindowComplex/DTO/DataSave.cs b/WebWindowComplex/DTO/DataSave.cs new file mode 100644 index 0000000..d4ff31b --- /dev/null +++ b/WebWindowComplex/DTO/DataSave.cs @@ -0,0 +1,12 @@ +namespace WebWindowComplex.DTO +{ + public class DataSave + { + #region Public Properties + + public string currJwd { get; set; } = ""; + public bool ForceSave { get; set; } = true; + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/WebWindowComplex/WebWindowComplex.csproj b/WebWindowComplex/WebWindowComplex.csproj index dd170d3..6e7997c 100644 --- a/WebWindowComplex/WebWindowComplex.csproj +++ b/WebWindowComplex/WebWindowComplex.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 3.1.3.1815 + 3.1.3.2009 Annamaria Sassi Egalware Componente gestione Configurazioni avanzate Window per LUX @@ -37,3 +37,16 @@ + + + + + + + + + + + + + diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index 2b3c764..626c441 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 3.1.3.1815 + 3.1.3.2009 Annamaria Sassi Egalware Componente gestione JWD per LUX @@ -38,3 +38,16 @@ + + + + + + + + + + + + + From b1fe7dc02e61989e540ed70e4751d377fceca323 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 20 Mar 2026 10:24:08 +0100 Subject: [PATCH 7/8] Fix comportamento apgina test x partenza vuota/piena JWD + da nascosto a mostrato --- Test.UI/Components/Pages/BaseEdit.razor.cs | 4 +- Test.UI/Components/Pages/EditJWD.razor | 30 ++++++---- Test.UI/Components/Pages/EditJWD.razor.cs | 57 +++++++++++++------ .../Components/Pages/SimpleEditOld.razor.cs | 2 +- Test.UI/Components/Pages/TestError.razor.cs | 6 +- WebWindowComplex/WebWindowComplex.csproj | 13 ++++- .../WebWindowConfigurator.csproj | 13 ++++- 7 files changed, 89 insertions(+), 36 deletions(-) diff --git a/Test.UI/Components/Pages/BaseEdit.razor.cs b/Test.UI/Components/Pages/BaseEdit.razor.cs index 878e010..3f03d14 100644 --- a/Test.UI/Components/Pages/BaseEdit.razor.cs +++ b/Test.UI/Components/Pages/BaseEdit.razor.cs @@ -296,9 +296,9 @@ namespace Test.UI.Components.Pages Random random = new Random(); CalcUid = Convert.ToString(random.Next(1000, 10000)); windowUid = CalcUid; - //InitialJwd = File.ReadAllText("Data\\FinestraSplitGrid.jwd"); + //initialJwd = File.ReadAllText("Data\\FinestraSplitGrid.jwd"); InitialJwd = File.ReadAllText("Data\\AntaDoppia.jwd"); - //InitialJwd = File.ReadAllText("Data\\ArcoAntaDoppia.jwd"); + //initialJwd = File.ReadAllText("Data\\ArcoAntaDoppia.jwd"); currJwd = InitialJwd; // rileggo altri dati await ReloadData(); diff --git a/Test.UI/Components/Pages/EditJWD.razor b/Test.UI/Components/Pages/EditJWD.razor index 693c30f..6a95742 100644 --- a/Test.UI/Components/Pages/EditJWD.razor +++ b/Test.UI/Components/Pages/EditJWD.razor @@ -66,20 +66,28 @@ *@ - @if(doEdit) -{ - - +@if (doEdit) +{ + + } else { - +
+
+ +
+
+ @txtEmpty + +
+
} @if (!string.IsNullOrEmpty(outClose)) diff --git a/Test.UI/Components/Pages/EditJWD.razor.cs b/Test.UI/Components/Pages/EditJWD.razor.cs index 089a306..8e4ae25 100644 --- a/Test.UI/Components/Pages/EditJWD.razor.cs +++ b/Test.UI/Components/Pages/EditJWD.razor.cs @@ -12,12 +12,6 @@ namespace Test.UI.Components.Pages { public partial class EditJWD : IDisposable { - #region Public Fields - - public string InitialJwd = ""; - - #endregion Public Fields - #region Public Methods public void Dispose() @@ -144,13 +138,9 @@ namespace Test.UI.Components.Pages Random random = new Random(); CalcUid = Convert.ToString(random.Next(1000, 10000)); windowUid = CalcUid; - //InitialJwd = File.ReadAllText("Data\\AntaDoppiaInglesine.jwd"); -#if false - InitialJwd = File.ReadAllText("Data\\AntaDoppia.jwd"); -#else - InitialJwd = "{}"; -#endif - currJwd = InitialJwd; + //initialJwd = File.ReadAllText("Data\\AntaDoppiaInglesine.jwd"); + //initialJwd = File.ReadAllText("Data\\AntaDoppia.jwd"); + currJwd = initialJwd; // rileggo altri dati await ReloadData(); // costruisco lista profili @@ -179,7 +169,7 @@ namespace Test.UI.Components.Pages }; CurrData = new LivePayload() { - CurrJwd = InitialJwd, + CurrJwd = currJwd, SvgPreview = currSvg, DictShape = currGroupShape, DictOptionsXml = currHwOption @@ -419,6 +409,8 @@ namespace Test.UI.Components.Pages {"Frame_Rail_Bottom_DimMax", 80} }; + private bool startEmpty = true; + private List ThresholdProfilo78 = new List() { { new Threshold(3, "Bottom") }, @@ -436,6 +428,26 @@ namespace Test.UI.Components.Pages #endregion Private Fields + #region Private Properties + + private string initialJwd + { + get + { + if (startEmpty) + { + return "{}"; + } + else + { + return File.ReadAllText("Data\\AntaDoppiaInglesine.jwd"); + //return File.ReadAllText("Data\\AntaDoppia.jwd"); + } + } + } + + #endregion Private Properties + #region Private Methods /// @@ -444,9 +456,10 @@ namespace Test.UI.Components.Pages /// private void CloseObj(DataSave reqSave) { - currJwd = reqSave.currJwd; - outClose = !reqSave.ForceSave ? "Richiesto chiusura!" : ""; - outSave = reqSave.ForceSave ? "Richiesto salvataggio!" : ""; + currJwd = reqSave.ForceSave ? reqSave.currJwd : initialJwd; + outClose = !reqSave.ForceSave ? "Richiesto Close!" : ""; + outSave = reqSave.ForceSave ? "Richiesto Close + Save!" : ""; + doEdit = false; } private void ConfInit() @@ -625,6 +638,16 @@ namespace Test.UI.Components.Pages doEdit = true; } + private Task ToggleJwd() + { + startEmpty = !startEmpty; + currJwd = initialJwd; + currSvg = ""; + CurrData.CurrJwd = currJwd; + CurrData.SvgPreview = currSvg; + return InvokeAsync(StateHasChanged); + } + private void updateInfoJwd(string currSer, string? newFamilyHardware, Hardware? newHardware, string? newColorMaterial, string? newMaterial, string? newGlass, string? newProfile) { var newJwd = SerialMan.MassUpdate(currSer, newFamilyHardware, newHardware, newColorMaterial, newMaterial, newGlass, newProfile); diff --git a/Test.UI/Components/Pages/SimpleEditOld.razor.cs b/Test.UI/Components/Pages/SimpleEditOld.razor.cs index 292c672..b0d1169 100644 --- a/Test.UI/Components/Pages/SimpleEditOld.razor.cs +++ b/Test.UI/Components/Pages/SimpleEditOld.razor.cs @@ -133,7 +133,7 @@ namespace Test.UI.Components.Pages CalcUid = Convert.ToString(random.Next(1000, 10000)); windowUid = CalcUid; InitialJwd = File.ReadAllText("Data\\FinestraSplitGrid.jwd"); - //InitialJwd = File.ReadAllText("Data\\AntaDoppia.jwd"); + //initialJwd = File.ReadAllText("Data\\AntaDoppia.jwd"); currJwd = InitialJwd; // rileggo altri dati await ReloadData(); diff --git a/Test.UI/Components/Pages/TestError.razor.cs b/Test.UI/Components/Pages/TestError.razor.cs index 4eb0b6e..a458773 100644 --- a/Test.UI/Components/Pages/TestError.razor.cs +++ b/Test.UI/Components/Pages/TestError.razor.cs @@ -335,7 +335,7 @@ namespace Test.UI.Components.Pages Random random = new Random(); CalcUid = Convert.ToString(random.Next(1000, 10000)); windowUid = CalcUid; - //InitialJwd = File.ReadAllText("Data\\AntaDoppiaInglesine.jwd"); + //initialJwd = File.ReadAllText("Data\\AntaDoppiaInglesine.jwd"); InitialJwd = File.ReadAllText("Data\\AntaDoppia.jwd"); currJwd = InitialJwd; // rileggo altri dati @@ -611,8 +611,8 @@ namespace Test.UI.Components.Pages } private Task RemoveJwd() { - //InitialJwd = "{}"; - //currJwd = InitialJwd; + //initialJwd = "{}"; + //currJwd = initialJwd; CurrData.CurrJwd = "{}"; // rileggo altri dati return ReloadData(); diff --git a/WebWindowComplex/WebWindowComplex.csproj b/WebWindowComplex/WebWindowComplex.csproj index 6e7997c..35f67f3 100644 --- a/WebWindowComplex/WebWindowComplex.csproj +++ b/WebWindowComplex/WebWindowComplex.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 3.1.3.2009 + 3.1.3.2010 Annamaria Sassi Egalware Componente gestione Configurazioni avanzate Window per LUX @@ -43,6 +43,17 @@ + + + + + + + + + + + diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index 626c441..e3899b2 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 3.1.3.2009 + 3.1.3.2010 Annamaria Sassi Egalware Componente gestione JWD per LUX @@ -45,6 +45,17 @@ + + + + + + + + + + + From d031563e699d608c7ad095f41b9c1dccf5007118 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 20 Mar 2026 10:27:26 +0100 Subject: [PATCH 8/8] Fix componente x corretto display su cambio --- Test.UI/Components/Pages/EditJWD.razor | 1 - WebWindowComplex/TableComp.razor | 40 +++++++++++-------- WebWindowComplex/WebWindowComplex.csproj | 1 + .../WebWindowConfigurator.csproj | 1 + 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Test.UI/Components/Pages/EditJWD.razor b/Test.UI/Components/Pages/EditJWD.razor index 6a95742..177c798 100644 --- a/Test.UI/Components/Pages/EditJWD.razor +++ b/Test.UI/Components/Pages/EditJWD.razor @@ -84,7 +84,6 @@ else
- @txtEmpty
diff --git a/WebWindowComplex/TableComp.razor b/WebWindowComplex/TableComp.razor index 38ddee9..39451b7 100644 --- a/WebWindowComplex/TableComp.razor +++ b/WebWindowComplex/TableComp.razor @@ -1,4 +1,5 @@ -@using static WebWindowComplex.LayoutConst +@using EgwCoreLib.Razor +@using static WebWindowComplex.LayoutConst
@if (isLoading) { @@ -7,27 +8,27 @@ else if (!okParams) {
-
+
Parametri Mancanti!
-
+
} else if (!okJwd) {
-
+
JWD Mancante!
-
+
} @@ -99,8 +100,8 @@
@if (currStep == CompileStep.Tree) { - @@ -186,7 +187,7 @@ - } + } } else if (currStep == CompileStep.Fill) { @@ -196,8 +197,8 @@ } else { - @@ -231,10 +232,10 @@
- @if(!baseUser && SplittedList != null && SplittedList.Count > 0) + @if (!baseUser && SplittedList != null && SplittedList.Count > 0) { Splitted? currSplitted = SplittedList.Where(x => x.AreaList.First().Equals(FillList[currFillIndex])).FirstOrDefault(); - @if(currSplitted != null) + @if (currSplitted != null) { @if (currSplitted.ParentArea != null && currSplitted.ParentWindow != null) { @@ -251,8 +252,8 @@ else if (currStep == CompileStep.General) { @@ -268,7 +269,14 @@ } *@
- @outSvg + @if (string.IsNullOrWhiteSpace(LiveData.SvgPreview)) + { + + } + else + { + @outSvg + }
diff --git a/WebWindowComplex/WebWindowComplex.csproj b/WebWindowComplex/WebWindowComplex.csproj index 35f67f3..8b02bb2 100644 --- a/WebWindowComplex/WebWindowComplex.csproj +++ b/WebWindowComplex/WebWindowComplex.csproj @@ -59,5 +59,6 @@ + diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index e3899b2..9d35a03 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -60,5 +60,6 @@ +