diff --git a/README.md b/README.md index 43838b6..abf39d1 100644 --- a/README.md +++ b/README.md @@ -7,23 +7,24 @@ Durante la configurazione ad ogni cambiamento viene aggiornata l'immagine del se ## Requisiti I requisiti per utilizzare il componente sono: - - JWD da modificare - - Lista delle famiglie hardware - - Lista hardware - - Lista dei materiali - - Lista dei colori dei materiali - - Lista dei vetri ammessi - - Lista dei profili gestiti + - JWD da modificare; + - Lista delle famiglie hardware; + - Lista hardware; + - Lista dei materiali; + - Lista dei colori dei materiali; + - Lista dei vetri ammessi; + - Lista dei profili gestiti. ## Funzionalità componente Il componente permette i seguenti comportamenti principali: - - Aggiungere un gruppo di ante al telaio, - - Aggiungere uno split al telaio o a un anta, - - Copiare il contenuto di un'anta in un'altra anta, - - Eliminare un gruppo di ante, - - Eliminare uno split + - Aggiungere un gruppo di ante al telaio; + - Aggiungere uno split al telaio o a un anta; + - Copiare il contenuto di un'anta in un'altra anta; + - Eliminare un gruppo di ante; + - Eliminare uno split; + - Cambiare le caratteristiche dei gruppi di ante, delle singole ante, degli split e del frame. ## JWD @@ -53,17 +54,17 @@ Al frame sono associate le seguenti caratteristiche: #### Forme Telaio Le forme ammesse per il telaio sono le seguenti: - - Rectangle - - Right Chamfer - - Left Chamfer - - Double Chamfer - - Arc - - Full Arc - - Fillet - - Double Arc - - Three Center Arc - - Triangle, - - Custom + - Rectangle; + - Right Chamfer; + - Left Chamfer; + - Double Chamfer; + - Arc; + - Full Arc; + - Fillet; + - Double Arc; + - Three Center Arc; + - Triangle; + - Custom. ### Divisione (Split) @@ -71,9 +72,9 @@ Uno split genera sempre almeno due sottoaree contenenti ognuna un riempimento (F Se ci sono solo due sottoaree generate da uno split, si possono scambiare tra di loro. Uno split può essere: - - Orizzontale, definisco il numero di split orizzontali e l'altezza delle nuove aree orizzontali formate; - - Verticale, definisco il numero di split verticali e la larghezza delle nuove aree verticali formate; - - A griglia, definisco il numero di split orizzontali e verticali e l'altezza delle aree orizzontali e la larghezza delle aree verticali. + - Orizzontale, viene definito il numero di split orizzontali e l'altezza delle nuove aree orizzontali formate; + - Verticale, viene definito il numero di split verticali e la larghezza delle nuove aree verticali formate; + - A griglia, viene definito il numero di split orizzontali e verticali e l'altezza delle aree orizzontali e la larghezza delle aree verticali; in questo caso si può scegliere se hanno la precedenza gli split orizzontali o verticali (cambia il modo in cui si esegue l'incrocio tra gli split). ### Gruppo di ante (Sash group) @@ -81,33 +82,22 @@ Al gruppo di ante sono associate le seguenti caratteristiche: - Numero di ante; - Orientamento; - Quantità bottom rail; - - Giunti; - Codice hardware. -#### Forme gruppo ante - -Le forme ammesse per il telaio sono le seguenti: - - Arc - - Circle - - Custom - - FullArc - - Rectangle - - SemiArc - - SemiFullArc - - Trapezoid - #### Singola anta La singola anta ha associate le seguenti caratteristiche: - Tipologia di apertura; - Dimensione; - - Presenza maniglia. + - Tipo di misura per la dimensione (assoluta, percentuale o proporzionale) + - Presenza maniglia; + - Giunti. #### Hardware Per calcolare la lista di hardware ammessi data una famiglia di hardware servono i seguenti dati: - Forma del gruppo di ante (tramite richiesta al programma di calcolo); - - Apertura dell'anta con la maniglia; + - Tipo di apertura dell'anta con la maniglia; - Numero di ante; - Posizione anta battente (nel caso di tre o più ante, bisogna sapere se l'anta con la maniglia è incernierata al telaio o a un'altra anta). @@ -115,6 +105,7 @@ La richiesta della forma del gruppo di ante viene trasmessa se si cambiano i seg - Forma del telaio; - Dimensioni del telaio; - Aggiunta di uno split nel frame se già presente un gruppo di ante; + - Se si effettua lo scambio delle aree di uno split e una delle aree contiene una sash - Eliminazione di uno split. La lista degli hardware viene aggiornata se si cambiano i seguenti parametri: @@ -135,8 +126,6 @@ Vengono richieste nei seguenti casi: Descrive il tipo di riempimento: vetro o pannello. - - ## Roadmap Mancano: diff --git a/Test.UI/Components/Pages/EditJWD.razor.cs b/Test.UI/Components/Pages/EditJWD.razor.cs index 3891743..bb5d928 100644 --- a/Test.UI/Components/Pages/EditJWD.razor.cs +++ b/Test.UI/Components/Pages/EditJWD.razor.cs @@ -9,6 +9,7 @@ using System.Diagnostics; using System.Security.AccessControl; using WebWindowComplex; using WebWindowComplex.DTO; +using static WebWindowComplex.LayoutConst; namespace Test.UI.Components.Pages { @@ -126,8 +127,9 @@ namespace Test.UI.Components.Pages protected override async Task OnInitializedAsync() { ConfInit(); - //InitialJwd = File.ReadAllText("Data\\FinestraDueAnteSeparate.jwd"); + //InitialJwd = File.ReadAllText("Data\\FinestraSplitVert.jwd"); InitialJwd = File.ReadAllText("Data\\AntaDoppia.jwd"); + //InitialJwd = File.ReadAllText("Data\\ArcoAntaDoppia.jwd"); currJwd = InitialJwd; // rileggo altri dati await ReloadData(); @@ -228,18 +230,18 @@ namespace Test.UI.Components.Pages /// Esecuzione azione richiesta /// /// Azione richiesta - private void DoAction(TableComp.DataAction actReq) + private void DoAction(DataAction actReq) { switch (actReq) { - case TableComp.DataAction.None: + case DataAction.None: break; - case TableComp.DataAction.ResetDictShape: + case DataAction.ResetDictShape: CurrData.DictShape = new Dictionary(); break; - case TableComp.DataAction.ResetHwOpt: + case DataAction.ResetHwOpt: CurrData.DictOptionsXml = new Dictionary(); break; diff --git a/Test.UI/Data/AntaDoppia.jwd b/Test.UI/Data/AntaDoppia.jwd index eeb3733..42f5692 100644 --- a/Test.UI/Data/AntaDoppia.jwd +++ b/Test.UI/Data/AntaDoppia.jwd @@ -29,11 +29,11 @@ }, { "Index": 3, - "JointType": "FULL_H" + "JointType": "FULL_V" }, { "Index": 4, - "JointType": "FULL_H" + "JointType": "FULL_V" } ], "BottomRail": false, @@ -47,34 +47,54 @@ "SashId": 1, "OpeningType": "TILTTURN_LEFT", "HasHandle": true, + "JointList": [ + { + "Index": 1, + "JointType": "FULL_V" + }, + { + "Index": 2, + "JointType": "FULL_V" + }, + { + "Index": 3, + "JointType": "FULL_V" + }, + { + "Index": 4, + "JointType": "FULL_V" + } + ], + "MeasureType": "PERCENTAGE", "Dimension": 50.0 }, { "SashId": 2, "OpeningType": "TURNONLY_RIGHT", "HasHandle": false, + "JointList": [ + { + "Index": 1, + "JointType": "FULL_V" + }, + { + "Index": 2, + "JointType": "FULL_V" + }, + { + "Index": 3, + "JointType": "FULL_V" + }, + { + "Index": 4, + "JointType": "FULL_V" + } + ], + "MeasureType": "PERCENTAGE", "Dimension": 50.0 } ], "SashType": "NULL", - "JointList": [ - { - "Index": 1, - "JointType": "FULL_H" - }, - { - "Index": 2, - "JointType": "FULL_H" - }, - { - "Index": 3, - "JointType": "FULL_H" - }, - { - "Index": 4, - "JointType": "FULL_H" - } - ], "BottomRail": false, "BottomRailQty": 0, "Hardware": "000633", diff --git a/Test.UI/Data/AntaSingola.jwd b/Test.UI/Data/AntaSingola.jwd index 4ccc9d1..f1c6dea 100644 --- a/Test.UI/Data/AntaSingola.jwd +++ b/Test.UI/Data/AntaSingola.jwd @@ -29,11 +29,11 @@ }, { "Index": 3, - "JointType": "FULL_H" + "JointType": "FULL_V" }, { "Index": 4, - "JointType": "FULL_H" + "JointType": "FULL_V" } ], "BottomRail": false, @@ -54,19 +54,19 @@ "JointList": [ { "Index": 1, - "JointType": "FULL_H" + "JointType": "FULL_V" }, { "Index": 2, - "JointType": "FULL_H" + "JointType": "FULL_V" }, { "Index": 3, - "JointType": "FULL_H" + "JointType": "FULL_V" }, { "Index": 4, - "JointType": "FULL_H" + "JointType": "FULL_V" } ], "Hardware": "000635", diff --git a/Test.UI/Data/ArcoAntaDoppia.jwd b/Test.UI/Data/ArcoAntaDoppia.jwd new file mode 100644 index 0000000..b9032e7 --- /dev/null +++ b/Test.UI/Data/ArcoAntaDoppia.jwd @@ -0,0 +1,150 @@ +{ + "ProfilePath": "Profilo78", + "Material": "Pino", + "ColorMaterial": "Black", + "Glass": "Vetro BE 2S 4T/16/4T", + "AreaList": [ + { + "Shape": "ARC", + "DimensionList": [ + { + "Index": 1, + "Name": "Width", + "Value": 800.0 + }, + { + "Index": 2, + "Name": "Height", + "Value": 1500.0 + }, + { + "Index": 3, + "Name": "Full Height", + "Value": 1800.0 + } + ], + "JointList": [ + { + "Index": 1, + "JointType": "FULL_H" + }, + { + "Index": 2, + "JointType": "FULL_H" + }, + { + "Index": 3, + "JointType": "FULL_V" + }, + { + "Index": 4, + "JointType": "FULL_V" + } + ], + "BottomRail": false, + "BottomRailQty": 0, + "ArcElement": { + "Section": 10.0, + "CutEdge": true, + "IsAlign": true + }, + "GroupId": 1, + "AreaList": [ + { + "IsSashVertical": true, + "ArcElement": { + "Section": 10.0, + "CutEdge": true, + "IsAlign": true + }, + "SashList": [ + { + "SashId": 1, + "OpeningType": "TILTTURN_LEFT", + "MeasureType": "PERCENTAGE", + "Dimension": 50.0, + "HasHandle": true, + "JointList": [ + { + "Index": 1, + "JointType": "FULL_V" + }, + { + "Index": 2, + "JointType": "FULL_V" + }, + { + "Index": 3, + "JointType": "FULL_V" + }, + { + "Index": 4, + "JointType": "FULL_V" + } + ] + }, + { + "SashId": 2, + "OpeningType": "TURNONLY_RIGHT", + "MeasureType": "PERCENTAGE", + "Dimension": 50.0, + "HasHandle": false, + "JointList": [ + { + "Index": 1, + "JointType": "FULL_V" + }, + { + "Index": 2, + "JointType": "FULL_V" + }, + { + "Index": 3, + "JointType": "FULL_V" + }, + { + "Index": 4, + "JointType": "FULL_V" + } + ] + } + ], + "SashType": "NULL", + "BottomRail": false, + "BottomRailQty": 0, + "Hardware": "000644", + "HwOptionList": [], + "GroupId": 2, + "AreaList": [ + { + "GroupId": 4, + "AreaList": [ + { + "FillType": "GLASS", + "GroupId": 3, + "AreaList": [], + "AreaType": "FILL" + } + ], + "AreaType": "SPLITTED" + }, + { + "GroupId": 5, + "AreaList": [ + { + "FillType": "GLASS", + "GroupId": 6, + "AreaList": [], + "AreaType": "FILL" + } + ], + "AreaType": "SPLITTED" + } + ], + "AreaType": "SASH" + } + ], + "AreaType": "FRAME" + } + ] +} \ No newline at end of file diff --git a/Test.UI/Data/FinDueAnteBottomFisso.jwd b/Test.UI/Data/FinDueAnteBottomFisso.jwd index c1d8530..9858886 100644 --- a/Test.UI/Data/FinDueAnteBottomFisso.jwd +++ b/Test.UI/Data/FinDueAnteBottomFisso.jwd @@ -29,11 +29,11 @@ }, { "Index": 3, - "JointType": "FULL_H" + "JointType": "FULL_V" }, { "Index": 4, - "JointType": "FULL_H" + "JointType": "FULL_V" } ], "BottomRail": false, @@ -91,19 +91,19 @@ "JointList": [ { "Index": 1, - "JointType": "FULL_H" + "JointType": "FULL_V" }, { "Index": 2, - "JointType": "FULL_H" + "JointType": "FULL_V" }, { "Index": 3, - "JointType": "FULL_H" + "JointType": "FULL_V" }, { "Index": 4, - "JointType": "FULL_H" + "JointType": "FULL_V" } ], "Hardware": "000631", diff --git a/Test.UI/Data/FinestraDueAnteSeparate.jwd b/Test.UI/Data/FinestraDueAnteSeparate.jwd index e4392b0..46fc557 100644 --- a/Test.UI/Data/FinestraDueAnteSeparate.jwd +++ b/Test.UI/Data/FinestraDueAnteSeparate.jwd @@ -34,11 +34,11 @@ }, { "Index": 3, - "JointType": "FULL_H" + "JointType": "FULL_V" }, { "Index": 4, - "JointType": "FULL_H" + "JointType": "FULL_V" } ], "BottomRail": false, @@ -78,19 +78,19 @@ "JointList": [ { "Index": 1, - "JointType": "FULL_H" + "JointType": "FULL_V" }, { "Index": 2, - "JointType": "FULL_H" + "JointType": "FULL_V" }, { "Index": 3, - "JointType": "FULL_H" + "JointType": "FULL_V" }, { "Index": 4, - "JointType": "FULL_H" + "JointType": "FULL_V" } ], "BottomRail": false, @@ -157,19 +157,19 @@ "JointList": [ { "Index": 1, - "JointType": "FULL_H" + "JointType": "FULL_V" }, { "Index": 2, - "JointType": "FULL_H" + "JointType": "FULL_V" }, { "Index": 3, - "JointType": "FULL_H" + "JointType": "FULL_V" }, { "Index": 4, - "JointType": "FULL_H" + "JointType": "FULL_V" } ], "BottomRail": false, diff --git a/Test.UI/Data/FinestraSplitGrid.jwd b/Test.UI/Data/FinestraSplitGrid.jwd index 2782718..53747ca 100644 --- a/Test.UI/Data/FinestraSplitGrid.jwd +++ b/Test.UI/Data/FinestraSplitGrid.jwd @@ -29,11 +29,11 @@ }, { "Index": 3, - "JointType": "FULL_H" + "JointType": "FULL_V" }, { "Index": 4, - "JointType": "FULL_H" + "JointType": "FULL_V" } ], "BottomRail": false, diff --git a/Test.UI/Data/FinestraSplitVert.jwd b/Test.UI/Data/FinestraSplitVert.jwd index d3feecc..a8920c8 100644 --- a/Test.UI/Data/FinestraSplitVert.jwd +++ b/Test.UI/Data/FinestraSplitVert.jwd @@ -29,11 +29,11 @@ }, { "Index": 3, - "JointType": "FULL_H" + "JointType": "FULL_V" }, { "Index": 4, - "JointType": "FULL_H" + "JointType": "FULL_V" } ], "BottomRail": false, @@ -46,10 +46,12 @@ "SplitVertList": [ { "IsRelative": true, + "MeasureType": "PERCENTAGE", "Dimension": 50.0 }, { "IsRelative": true, + "MeasureType": "PERCENTAGE", "Dimension": 50.0 } ], diff --git a/Test.UI/Test.UI.csproj b/Test.UI/Test.UI.csproj index bd45e8e..75050e1 100644 --- a/Test.UI/Test.UI.csproj +++ b/Test.UI/Test.UI.csproj @@ -34,8 +34,8 @@ - - + + @@ -43,6 +43,9 @@ + + Always + Always diff --git a/Test.UI/appsettings.json b/Test.UI/appsettings.json index 4dfc168..4c35289 100644 --- a/Test.UI/appsettings.json +++ b/Test.UI/appsettings.json @@ -10,14 +10,14 @@ "Redis": "redis.ufficio:26379, serviceName=devel, DefaultDatabase=6, keepAlive=180, connectTimeout=15000, syncTimeout=15000, asyncTimeout=15000, abortConnect=false, ssl=false, allowAdmin=true" }, "ServerConf": { - "ChannelPng": "Egw:png:img", - "ChannelSvg": "Egw:svg:img", - "ChannelShape": "Egw:shape:curr", - "ChannelHwList": "Egw:hw:list", - "ChannelHwOpt": "Egw:hw:opt", - "ChannelProfList": "Egw:prof:list", - "ChannelBom": "Egw:bom", - "ChannelUpdate": "Egw:update", + "ChannelPng": "lux:png:img", + "ChannelSvg": "lux:svg:img", + "ChannelShape": "lux:shape:curr", + "ChannelHwList": "lux:hw:list", + "ChannelHwOpt": "lux:hw:opt", + "ChannelProfList": "lux:prof:list", + "ChannelBom": "lux:bom", + "ChannelUpdate": "lux:update", "ChannelPub": "EgwEngineInput", "ChannelSub": "EgwEngineOutput", diff --git a/WebWindowComplex/Compo/AreaFrame.razor b/WebWindowComplex/Compo/AreaFrame.razor index 19908a6..f9a4a9a 100644 --- a/WebWindowComplex/Compo/AreaFrame.razor +++ b/WebWindowComplex/Compo/AreaFrame.razor @@ -5,7 +5,7 @@
Area frame
- @if (CurrSashList.Count == 0 && CurrSplitList.Count == 0) + @if (SashList.Count == 0 && SplitList.Count == 0) {
diff --git a/WebWindowComplex/Compo/AreaFrame.razor.cs b/WebWindowComplex/Compo/AreaFrame.razor.cs index b74d237..b4c30d0 100644 --- a/WebWindowComplex/Compo/AreaFrame.razor.cs +++ b/WebWindowComplex/Compo/AreaFrame.razor.cs @@ -7,14 +7,23 @@ namespace WebWindowComplex.Compo { #region Public Properties - [Parameter] + /// + /// Frame corrente + /// + [CascadingParameter(Name = "CurrFrameWindow")] public Frame CurrFrameWindow { get; set; } = null!; - [Parameter] - public List CurrSashList { get; set; } = null!; + /// + /// Lista sash + /// + [CascadingParameter(Name = "SashList")] + public List SashList { get; set; } = null!; - [Parameter] - public List CurrSplitList { get; set; } = null!; + /// + /// Lista split + /// + [CascadingParameter(Name = "SplitList")] + public List SplitList { get; set; } = null!; [Parameter] public EventCallback EC_AddSash { get; set; } @@ -27,7 +36,7 @@ namespace WebWindowComplex.Compo #region Private Methods /// - /// Sollevo evento richiesta aggiunta sash + /// Sollevo evento richiesta aggiunta sash su frame /// /// private async Task RaiseAddSash() @@ -36,7 +45,7 @@ namespace WebWindowComplex.Compo } /// - /// Sollevo evento richiesta aggiunta window + /// Sollevo evento richiesta aggiunta split su frame /// /// private async Task RaiseAddSplit() diff --git a/WebWindowComplex/Compo/AreaFrameArcElem.razor b/WebWindowComplex/Compo/AreaFrameArcElem.razor new file mode 100644 index 0000000..c167194 --- /dev/null +++ b/WebWindowComplex/Compo/AreaFrameArcElem.razor @@ -0,0 +1,66 @@ + +
+
+
Frame
+
+
+
+
+
+
+
+ +
+
+
+ Qty element + @if (insertQty) + { + @* *@ + } + else + { + + } +
+
+
+
+
+ @* *@ +
+
+ +
+
+
+
+
+
+ +
+
+
+ Section + @if (!insertQty) + { + @* *@ + } + else + { + + } +
+
+
+
+
+ @* *@ +
+
+ +
+
+
+
+
diff --git a/WebWindowComplex/Compo/AreaFrameArcElem.razor.cs b/WebWindowComplex/Compo/AreaFrameArcElem.razor.cs new file mode 100644 index 0000000..656101f --- /dev/null +++ b/WebWindowComplex/Compo/AreaFrameArcElem.razor.cs @@ -0,0 +1,84 @@ +using Microsoft.AspNetCore.Components; +using System.Runtime.CompilerServices; +using WebWindowComplex.DTO; +using WebWindowComplex.Models; + +namespace WebWindowComplex.Compo +{ + public partial class AreaFrameArcElem + { + #region Public Properties + + /// + /// Frame corrente + /// + [Parameter] + public Frame CurrFrame { get; set; } = null!; + + [Parameter] + public EventCallback EC_UpdatePreview { get; set; } + + #endregion Public Properties + + #region Protected Properties + + //protected int ArcElementQty + //{ + // get => CurrFrame.FrameArcElem.nQty; + // set + // { + // CurrFrame.FrameArcElem.nQty = value; + // _ = EC_UpdatePreview.InvokeAsync(CurrFrame); + // } + //} + + //protected double ArcSection + //{ + // get => CurrFrame.FrameArcElem.nSection; + // set + // { + // CurrFrame.FrameArcElem.nSection = value; + // _ = EC_UpdatePreview.InvokeAsync(CurrFrame); + // } + //} + + #endregion Protected Properties + + #region Protected Methods + + protected void IsCheckedQty() + { + insertQty = !insertQty; + } + + //protected void IsCheckCutEdge() + //{ + // CurrFrame.FrameArcElem.bCutEdge = !CurrFrame.FrameArcElem.bCutEdge; + // _ = EC_UpdatePreview.InvokeAsync(CurrFrame); + //} + + //protected void IsCheckAlign() + //{ + // CurrFrame.FrameArcElem.bIsAlign = !CurrFrame.FrameArcElem.bIsAlign; + // _ = EC_UpdatePreview.InvokeAsync(CurrFrame); + //} + + protected string IsUsedQty() + { + if (insertQty) + return "form-control"; + else + return "form-control disabled"; + } + + + #endregion Protected Methods + + #region Private Fields + + private bool insertQty = false; + + #endregion Private Fields + } + +} \ No newline at end of file diff --git a/WebWindowComplex/Compo/AreaHwOption.razor b/WebWindowComplex/Compo/AreaHwOption.razor index f468647..baed002 100644 --- a/WebWindowComplex/Compo/AreaHwOption.razor +++ b/WebWindowComplex/Compo/AreaHwOption.razor @@ -1,11 +1,11 @@ @using static WebWindowComplex.Json.WindowConst -
+
Hardware option
- +
@@ -30,7 +30,7 @@ {
- @foreach (var currOpt in CurrSash.HwOptionList) + @foreach (var currOpt in CurrSashGroup.HwOptionList) { switch (currOpt.Type) { diff --git a/WebWindowComplex/Compo/AreaHwOption.razor.cs b/WebWindowComplex/Compo/AreaHwOption.razor.cs index 386be5f..c455ca6 100644 --- a/WebWindowComplex/Compo/AreaHwOption.razor.cs +++ b/WebWindowComplex/Compo/AreaHwOption.razor.cs @@ -11,20 +11,14 @@ namespace WebWindowComplex.Compo /// /// Sash corrente rispetto alla lista Sash /// - [Parameter] - public Sash CurrSash { get; set; } = null!; + [CascadingParameter(Name = "CurrSashGroup")] + public Sash CurrSashGroup { get; set; } = null!; /// - /// Evento per aggiornare gli hardware option di tipo combo + /// Evento per aggiornare gli hardware option /// [Parameter] - public EventCallback EC_UpdateHwOptCombo { get; set; } - - /// - /// Evento per aggiornare gli hardware option di tipo text - /// - [Parameter] - public EventCallback EC_UpdateHwOptText { get; set; } + public EventCallback EC_UpdateHwOpt { get; set; } /// /// Evento per chiamare la prima volta la lista delle opzioni @@ -48,9 +42,9 @@ namespace WebWindowComplex.Compo private async Task changeCollapsed() { hwOptCollapsed = !hwOptCollapsed; - if (CurrSash.HwOptionList.Count == 0) + if (CurrSashGroup.HwOptionList.Count == 0) { - await EC_FirstHwOptionList.InvokeAsync(CurrSash.GroupId); + await EC_FirstHwOptionList.InvokeAsync(); } } @@ -66,7 +60,11 @@ namespace WebWindowComplex.Compo /// private async Task RaiseOptCombo(AGBOptionCombo updRec) { - await EC_UpdateHwOptCombo.InvokeAsync(updRec); + var args = new DataUpdateHwOption + { + AGBOptCombo = updRec + }; + await EC_UpdateHwOpt.InvokeAsync(args); } /// @@ -76,11 +74,25 @@ namespace WebWindowComplex.Compo /// private async Task RaiseOptText(AGBOptionText updRec) { - await EC_UpdateHwOptText.InvokeAsync(updRec); + var args = new DataUpdateHwOption + { + AGBOptText = updRec + }; + await EC_UpdateHwOpt.InvokeAsync(args); } + private bool IsLoadingHwOpt { get => IsLoading != null && IsLoading.Count > 0 && IsLoading.Contains("LoadHwOpt"); } } + + /// + /// Classe per oggetto di aggiornamento delle opzioni + /// + public class DataUpdateHwOption + { + public AGBOptionText AGBOptText { get; set; } = null; + public AGBOptionCombo AGBOptCombo { get; set; } = null; + } } \ No newline at end of file diff --git a/WebWindowComplex/Compo/AreaSash.razor b/WebWindowComplex/Compo/AreaSash.razor index da9d293..47d99f5 100644 --- a/WebWindowComplex/Compo/AreaSash.razor +++ b/WebWindowComplex/Compo/AreaSash.razor @@ -1,78 +1,174 @@ -
-
-
Sash @(CurrSashGroup.SashList.Count == 1 ? "" : (IndexSash + 1))
-
-
- - -
-
- - -
-
- Dimension - - @switch (CurrSashDim.MeasureType) - { - case Json.WindowConst.MeasureTypes.ABSOLUT: - { - mm - break; - } - case Json.WindowConst.MeasureTypes.PERCENTAGE: - { - % - break; - } - } -
-
-
- +
-
- +
+ +
-
- @if (!(CurrAnta.AreaList[0] is Split)) - { -
-
-
- -
+
+ Dimension + + @* *@ + +
+
+
+
-
+
+ +
+
+
+} +else +{ + @*
*@ +
+
Sash @(CurrSashGroup.SashList.Count == 1 ? "" : (IndexSash + 1))
+ @if (!(CurrAnta.AreaList[0] is Split)) + { +
+ +
-
+ } +
- } -
- @for (int k = 0; k <= CurrSashGroup.SashList.Count - 1; k++) - { - @if (k != IndexSash) - { - int IndexCopy = k; - int IndexModify = IndexSash; -
-
- +
+
+
+ + +
+
+ Dimension + + +
+
+
+ +
+
+ +
- } - } -
-
+
+
+
+
Joints
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+ @foreach (Joint joint in CurrSashDim.JointList) + { + + } +
+
+ @*
*@ +} diff --git a/WebWindowComplex/Compo/AreaSash.razor.cs b/WebWindowComplex/Compo/AreaSash.razor.cs index 997b23d..0719022 100644 --- a/WebWindowComplex/Compo/AreaSash.razor.cs +++ b/WebWindowComplex/Compo/AreaSash.razor.cs @@ -1,5 +1,9 @@ +using EgwCoreLib.Razor; using Microsoft.AspNetCore.Components; +using Newtonsoft.Json.Linq; +using System; using WebWindowComplex.Models; +using static WebWindowComplex.Json.WindowConst; namespace WebWindowComplex.Compo { @@ -8,7 +12,7 @@ namespace WebWindowComplex.Compo /// /// Sash group corrente /// - [Parameter] + [CascadingParameter(Name = "CurrSashGroup")] public Sash CurrSashGroup { get; set; } = null!; /// @@ -17,6 +21,18 @@ namespace WebWindowComplex.Compo [Parameter] public SashDimension CurrSashDim { get; set; } = null!; + /// + /// Lista delle sash + /// + [CascadingParameter(Name = "SashList")] + public List SashList { get; set; } = null!; + + /// + /// Modalità di visualizzazione (view /edit) + /// + [Parameter] + public bool EditMode { get; set; } = false; + /// /// Indice della sash corrente /// @@ -24,26 +40,33 @@ namespace WebWindowComplex.Compo public int IndexSash { get; set; } = 0; /// - /// Evento per cambiare l'anta su cui è presente la maniglia + /// Evento per aggiornare sash dimension /// [Parameter] - public EventCallback EC_ChangeHandle { get; set; } + public EventCallback EC_UpdateSashDim { get; set; } + /// - /// Evento per cambiare l'anta su cui è presente la maniglia + /// Evento per aggiornare sash /// [Parameter] - public EventCallback EC_CopyContentSash { get; set; } + public EventCallback EC_UpdateSash { get; set; } + + /// + /// Evento per cambiare modalità di visualizzazione + /// + [Parameter] + public EventCallback EC_EditView { get; set; } /// /// Anta corrente /// - public Area CurrAnta - { + public Area CurrAnta + { get { - if(CurrSashGroup.AreaList[IndexSash] is Splitted) -{ + if (CurrSashGroup.AreaList[IndexSash] is Splitted) + { return CurrSashGroup.AreaList[IndexSash]; } else @@ -58,49 +81,243 @@ namespace WebWindowComplex.Compo } /// - /// Sollevo evento per cambiare l'anta su cui è presente la maniglia + /// Metodo per avere il numero di decimali da usare nella form-input /// /// - private async Task RaiseChangeHandle(SashDimension sashDim, Sash currSash) + public int CssDecimals() { - var Args = new DataChangeHandle + switch (CurrSashDim.MeasureType) { - currSashDimension = sashDim, - currItem = currSash, - }; - await EC_ChangeHandle.InvokeAsync(Args); + case Json.WindowConst.MeasureTypes.ABSOLUTE: + { + return 2; + } + case Json.WindowConst.MeasureTypes.PROPORTIONAL: + { + return 0; + } + case Json.WindowConst.MeasureTypes.PERCENTAGE: + { + return 1; + } + } + return 0; } /// - /// Sollevo evento per cambiare l'anta su cui è presente la maniglia + /// Selezione tipo di apertura anta + /// + protected int OpeningTypeIndex + { + get => CurrSashDim.SelOpeningTypeIndex; + set + { + if (CurrSashDim.SelOpeningTypeIndex != value) + { + CurrSashDim.SelOpeningTypeIndex = value; + _ = EC_UpdateSashDim.InvokeAsync(CurrSashDim); + } + } + } + + /// + /// Selezione tipo di misura della dimensione dell'anta + /// + protected int MeasureTypeIndex + { + get => CurrSashDim.SelMeasureTypeIndex; + set + { + if (CurrSashDim.SelMeasureTypeIndex != value) + { + CurrSashDim.SelMeasureTypeIndex = value; + _ = EC_UpdateSashDim.InvokeAsync(CurrSashDim); + } + } + } + + /// + /// Inserimento dimensione anta + /// + protected double Dimension + { + get => CurrSashDim.dDimension; + set + { + if (CurrSashDim.dDimension != value) + { + CurrSashDim.dDimension = value; + _ = EC_UpdateSashDim.InvokeAsync(CurrSashDim); + } + } + } + + /// + /// Sollevo evento richiesta per cambiare tutti i Joint /// /// - private async Task RaiseCopyContentSash(Sash currSash, int indexC, int indexM) + private async Task ChangeAllJoints(Json.WindowConst.Joints JointType) { - var Args = new DataCopyContentSash + foreach (var item in CurrSashDim.JointList) + item.SetSelJointType(JointType); + await EC_UpdateSashDim.InvokeAsync(CurrSashDim); + } + + /// + /// Aggiornamento joint + /// + /// + /// + private async Task UpdateJoint(Joint updRec) + { + // cerco il record + var currRec = CurrSashDim.JointList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex); + // lo aggiorno + if (updRec != null) { - currItem = currSash, - indexCopy = indexC, - indexModify = indexM, + currRec = updRec; + await EC_UpdateSashDim.InvokeAsync(CurrSashDim); + } + } + + /// + /// Metodo per cambiare l'anta su cui è presente la maniglia + /// + /// + private async Task ChangeHandle() + { + // Cerco la Sash che si sta considerando nella lista Sash + var s = SashList.Where(x => x.GroupId == CurrSashGroup.GroupId).FirstOrDefault(); + if (s != null) + { + // Setto la presenza o meno della maniglia per ogni anta + foreach (SashDimension item in s.SashList) + { + if (item.Equals(CurrSashDim)) + { + item.bHasHandle = true; + } + else + { + if (item.bHasHandle) + { + switch (item.SelOpeningType) + { + case Openings.TILTTURN_LEFT: + { + item.SetOpeningType(Openings.TURNONLY_LEFT); + break; + } + case Openings.TILTTURN_RIGHT: + { + item.SetOpeningType(Openings.TURNONLY_RIGHT); + break; + } + default: + { + break; + } + } + } + item.bHasHandle = false; + } + } + } + CurrSashGroup.RefreshHardwareList(); + CurrSashGroup.SetFirstHardware(); + await EC_UpdateSash.InvokeAsync(CurrSashGroup); + } + + /// + /// Copio contenuto anta da indexCopy a IndexModify + /// + /// + private async Task CopyContentSash(int IndexCopy, int IndexModify) + { + isOpen = !isOpen; + // Anta selezionata + Area sashSplitted = CurrSashGroup.AreaList[IndexModify]; + // Rimuovo riempimento da anta selezionata + sashSplitted.AreaList.RemoveAt(0); + // Creo la copia dell'anta scelta + Area a = CurrSashGroup.AreaList[IndexCopy].AreaList.First().Copy(sashSplitted); + // Aggiungo copia all'anta selezionata + CurrSashGroup.AreaList[IndexModify].AreaList.Add(a); + await EC_UpdateSash.InvokeAsync(CurrSashGroup); + } + + /// + /// Metodo per aggiungere lo split nella singola anta + /// + /// + private async Task AddSplitToSash() + { + CurrAnta.AddSplit(); + await EC_UpdateSash.InvokeAsync(CurrSashGroup); + } + + private bool isOpen = false; + + private void ToggleDropdown() + { + isOpen = !isOpen; + } + + /// + /// Metodo per determinare la visualizzazione dei pulsanti dei joint + /// + /// + /// + private string ButtonJointCss(WebWindowComplex.Json.WindowConst.Joints type) + { + foreach (var item in CurrSashDim.JointList) + { + if (!item.SelJointType.Equals(type)) + return "btn btn-outline-secondary btn-sm"; + } + return "btn btn-secondary btn-sm"; + } + + private enum ModeView + { + NULL = 0, + View = 1, + Edit = 2 + } + protected override void OnParametersSet() + { + if (EditMode) + mode = ModeView.Edit; + else + mode = ModeView.View; + } + private ModeView mode { get; set; } = ModeView.View; + private void doEdit(int index) + { + var args = new DataChangeMode + { + Edit = true, + IndexSashEdit = index, + IndexSashClose = -1 }; - await EC_CopyContentSash.InvokeAsync(Args); + _ = EC_EditView.InvokeAsync(args); + } + protected void ClosePopup(int index) + { + var args = new DataChangeMode + { + Edit = false, + IndexSashEdit = -1, + IndexSashClose = index + }; + _ = EC_EditView.InvokeAsync(args); } } - public class DataChangeHandle - { - public SashDimension currSashDimension { get; set; } = null!; - public Sash currItem { get; set; } = null!; - + public class DataChangeMode { + public bool Edit { get; set; } + public int IndexSashEdit { get; set; } + public int IndexSashClose { get; set; } } - public class DataCopyContentSash - { - public Sash currItem { get; set; } = null!; - - public int indexCopy { get; set; } = 0; - - public int indexModify { get; set; } = 0; - - } } \ No newline at end of file diff --git a/WebWindowComplex/Compo/AreaSashArcElem.razor b/WebWindowComplex/Compo/AreaSashArcElem.razor new file mode 100644 index 0000000..4c0f3ae --- /dev/null +++ b/WebWindowComplex/Compo/AreaSashArcElem.razor @@ -0,0 +1,58 @@ + +
+
+
Sash
+
+
+
+
+
+
+
+ +
+
+
+ Qty element + @if (insertQty) + { + @* *@ + } + else + { + + } +
+
+
+
+
+ @* *@ +
+
+ +
+
+
+
+
+
+ +
+
+
+ Section + @if (!insertQty) + { + @* *@ + } + else + { + + } +
+
+
+
+
+
diff --git a/WebWindowComplex/Compo/AreaSashArcElem.razor.cs b/WebWindowComplex/Compo/AreaSashArcElem.razor.cs new file mode 100644 index 0000000..07e06d7 --- /dev/null +++ b/WebWindowComplex/Compo/AreaSashArcElem.razor.cs @@ -0,0 +1,78 @@ +using Microsoft.AspNetCore.Components; +using System.Runtime.CompilerServices; +using WebWindowComplex.DTO; +using WebWindowComplex.Models; + +namespace WebWindowComplex.Compo +{ + public partial class AreaSashArcElem + { + #region Public Properties + + /// + /// Sash corrente + /// + [Parameter] + public Sash CurrSashGroup { get; set; } = null!; + + [Parameter] + public EventCallback EC_UpdatePreview { get; set; } + + #endregion Public Properties + + #region Protected Properties + + //protected int ArcElementQty + //{ + // get => CurrSashGroup.SashArcElem.nQty; + // set + // { + // CurrSashGroup.SashArcElem.nQty = value; + // _ = EC_UpdatePreview.InvokeAsync(CurrSashGroup); + // } + //} + + //protected double ArcSection + //{ + // get => CurrSashGroup.SashArcElem.nSection; + // set + // { + // CurrSashGroup.SashArcElem.nSection = value; + // _ = EC_UpdatePreview.InvokeAsync(CurrSashGroup); + // } + //} + + #endregion Protected Properties + + #region Protected Methods + + protected void IsCheckedQty() + { + insertQty = !insertQty; + } + + //protected void IsCheckCutEdge() + //{ + // CurrSashGroup.SashArcElem.bCutEdge = !CurrSashGroup.SashArcElem.bCutEdge; + // _ = EC_UpdatePreview.InvokeAsync(CurrSashGroup); + //} + + protected string IsUsedQty() + { + if (insertQty) + return "form-control"; + else + return "form-control disabled"; + } + + + #endregion Protected Methods + + #region Private Fields + + private bool insertQty = false; + + #endregion Private Fields + } + +} \ No newline at end of file diff --git a/WebWindowComplex/Compo/AreaSplit.razor b/WebWindowComplex/Compo/AreaSplit.razor index 4b2664d..96087ee 100644 --- a/WebWindowComplex/Compo/AreaSplit.razor +++ b/WebWindowComplex/Compo/AreaSplit.razor @@ -1,20 +1,20 @@ 
-
-
Area split @(CurrSplittedList.Count > 1 ? (CurrSplittedList.IndexOf(CurrSplitted) + 1) : "")
+
+
Area split @(SplittedList.Count > 1 ? (SplittedList.IndexOf(CurrSplitted) + 1) : "")
- +
- @for (int j = 0; j < CurrSashList.Count; j++) + @for (int j = 0; j < SashList.Count; j++) { int Index = j;
- +
}
diff --git a/WebWindowComplex/Compo/AreaSplit.razor.cs b/WebWindowComplex/Compo/AreaSplit.razor.cs index 61e8cac..aba53c8 100644 --- a/WebWindowComplex/Compo/AreaSplit.razor.cs +++ b/WebWindowComplex/Compo/AreaSplit.razor.cs @@ -12,80 +12,56 @@ namespace WebWindowComplex.Compo /// Lista delle sash ///
[Parameter] - public List CurrSashList { get; set; } = null; + public List SashList { get; set; } = null!; /// /// Oggetto splitted corrente /// [Parameter] - public Splitted CurrSplitted { get; set; } = null; + public Splitted CurrSplitted { get; set; } = null!; /// /// Lista degli Splitted /// [Parameter] - public List CurrSplittedList { get; set; } = null; - - /// - /// Evento per copiare Sash - /// - [Parameter] - public EventCallback EC_CopySash { get; set; } + public List SplittedList { get; set; } = null!; /// /// Evento per aggiungere Sash /// [Parameter] - public EventCallback EC_AddSash { get; set; } + public EventCallback EC_UpdateSplitted { get; set; } #endregion Public Properties #region Private Methods /// - /// Sollevo evento richiesta copia sash + /// Metodo per copiare sash /// /// - private async Task RaiseCopySash(Splitted item, int indexCurrSash) + private async Task RaiseCopySash(int indexCurrSash) { - var Args = new DataAreaSplit - { - splitted = item, - index = indexCurrSash, - }; - await EC_CopySash.InvokeAsync(Args); + //Rimuovo contenuto di Splitted e rimuovo area da conteggio gruppi + CurrSplitted.AreaList.RemoveAll(i => i != null); + // Copio sash + Area a = SashList[indexCurrSash].Copy(CurrSplitted); + a.SetParentArea(CurrSplitted); + // Aggiungo copia a Splitted + CurrSplitted.AreaList.Add(a); + await EC_UpdateSplitted.InvokeAsync(CurrSplitted); } /// - /// Sollevo evento richiesta copia sash + /// Metodo per aggiungere prima sash /// /// - private async Task RaiseAddSash(Splitted item) + private async Task RaiseAddSash() { - var Args = new DataAreaSplitted - { - splitted = item - }; - await EC_AddSash.InvokeAsync(Args); + CurrSplitted.AddFirstSash(); + await EC_UpdateSplitted.InvokeAsync(CurrSplitted); } + #endregion Private Methods - - } - - /// - /// Classe per raggruppare oggetti che servono per copiare Sash - /// - public class DataAreaSplit - { - public Splitted splitted { get; set; } - public int index { get; set; } - } - - /// - /// Classe per raggruppare oggetti che servono per aggiungere Sash - /// - public class DataAreaSplitted - { - public Splitted splitted { get; set; } } } \ No newline at end of file diff --git a/WebWindowComplex/Compo/CardArcElement.razor b/WebWindowComplex/Compo/CardArcElement.razor new file mode 100644 index 0000000..e29174e --- /dev/null +++ b/WebWindowComplex/Compo/CardArcElement.razor @@ -0,0 +1,27 @@ +
+
+
+
+
Arc Element
+
+
+ +
+
+
+
+
+ + + + @foreach (var sashGroup in SashList) + { +
+ + + } +
+
+
\ No newline at end of file diff --git a/WebWindowComplex/Compo/CardArcElement.razor.cs b/WebWindowComplex/Compo/CardArcElement.razor.cs new file mode 100644 index 0000000..6d9646a --- /dev/null +++ b/WebWindowComplex/Compo/CardArcElement.razor.cs @@ -0,0 +1,60 @@ +using Microsoft.AspNetCore.Components; +using WebWindowComplex.DTO; +using WebWindowComplex.Models; + +namespace WebWindowComplex.Compo +{ + public partial class CardArcElement + { + #region Public Properties + + /// + /// Frame corrente + /// + [Parameter] + public Frame CurrFrame { get; set; } = null!; + + /// + /// Lista sash group + /// + [Parameter] + public List SashList { get; set; } = null!; + + [Parameter] + public EventCallback EC_UpdatePreview { get; set; } + + [Parameter] + public EventCallback EC_ReqClose { get; set; } + + #endregion Public Properties + + private async Task UpdatePreview() + { + var args = new DataUpdateFrame + { + currFrame = CurrFrame + }; + await EC_UpdatePreview.InvokeAsync(args); + } + + private async Task UpdatePreviewSash(Sash CurrSashGRoup) + { + var currRec = SashList.First(x => x.GroupId == CurrSashGRoup.GroupId); + if (currRec != null) + { + currRec = CurrSashGRoup; + var args = new DataUpdateFrame + { + currFrame = CurrFrame + }; + await EC_UpdatePreview.InvokeAsync(args); + } + } + + private void ReqClose() + { + _ = EC_ReqClose.InvokeAsync(true); + } + } + +} \ No newline at end of file diff --git a/WebWindowComplex/Compo/CardFill.razor b/WebWindowComplex/Compo/CardFill.razor index 5d40cd8..8f357f6 100644 --- a/WebWindowComplex/Compo/CardFill.razor +++ b/WebWindowComplex/Compo/CardFill.razor @@ -1,7 +1,7 @@ 
-
+
Fill @(CurrIndex + 1)
@@ -11,8 +11,8 @@
-
-
+
+
Select only current fill
@@ -26,7 +26,7 @@
-
+ @*
Selected all fill
@@ -40,19 +40,16 @@
-
+
*@
-@foreach (var currSplitted in SplittedList) +@* @foreach (var currSplitted in SplittedList) { - @if (currSplitted.AreaList.First().Equals(CurrItem)) + @if (currSplitted.AreaList.First().Equals(CurrFill)) { - } -} - +} *@ diff --git a/WebWindowComplex/Compo/CardFill.razor.cs b/WebWindowComplex/Compo/CardFill.razor.cs index 1ec78ca..7b5c001 100644 --- a/WebWindowComplex/Compo/CardFill.razor.cs +++ b/WebWindowComplex/Compo/CardFill.razor.cs @@ -18,31 +18,13 @@ namespace WebWindowComplex.Compo /// Fill corrente rispetto alla lista fill ///
[Parameter] - public Fill CurrItem { get; set; } = null!; + public Fill CurrFill { get; set; } = null!; /// /// Evento per cambiare tutti i fill /// [Parameter] - public EventCallback EC_ChangeAllType { get; set; } - - /// - /// Evento per cambiare solo il fill corrente - /// - [Parameter] - public EventCallback EC_ChangeType { get; set; } - - /// - /// Evento per copiare sash - /// - [Parameter] - public EventCallback EC_CopySash { get; set; } - - /// - /// Evento per aggiungere sash - /// - [Parameter] - public EventCallback EC_AddSash { get; set; } + public EventCallback EC_UpdatePreviewFill { get; set; } /// /// Evento per tornare nella pagine Tree @@ -50,67 +32,19 @@ namespace WebWindowComplex.Compo [Parameter] public EventCallback EC_ReqClose { get; set; } - /// - /// Lista dei Fill - /// - [Parameter] - public List FillList { get; set; } = null!; - - /// - /// Lista delle sash - /// - [Parameter] - public List SashList { get; set; } = null!; - - /// - /// Lista degli Splitted - /// - [Parameter] - public List SplittedList { get; set; } = null!; - - #endregion Public Properties #region Protected Methods /// - /// Sollevo evento per cambiare tutti i Fill - /// - /// tipo di fill richiesto - /// - protected async Task ChangeAllFill(FillTypes reqFillType) - { - await EC_ChangeAllType.InvokeAsync(reqFillType); - } - - /// - /// Sollevo evento per cambiare solo il Fill corrente + /// Metodo per cambiare solo il Fill corrente /// /// tipo di fill richiesto /// protected async Task ChangeOneFill(FillTypes reqFillType) { - await EC_ChangeType.InvokeAsync(reqFillType); - } - - /// - /// Sollevo evento per copiare sash - /// - /// - /// - protected async Task CopySash(DataAreaSplit Args) - { - await EC_CopySash.InvokeAsync(Args); - } - - /// - /// Sollevo evento per aggiungere sash - /// - /// - /// - protected async Task AddSash(DataAreaSplitted Args) - { - await EC_AddSash.InvokeAsync(Args); + CurrFill.SetFillType(reqFillType); + await EC_UpdatePreviewFill.InvokeAsync(CurrFill); } #endregion Protected Methods @@ -118,7 +52,7 @@ namespace WebWindowComplex.Compo #region Private Methods /// - /// Sollevo evento per tornare alla pagina Tree + /// Metodo per tornare alla pagina Tree /// private void ReqClose() { @@ -131,7 +65,7 @@ namespace WebWindowComplex.Compo /// private string buttonFillCss(FillTypes reqFillTypes) { - return (FillList.ElementAt(CurrIndex).SelFillType == reqFillTypes) ? "btn btn-secondary btn-sm" : "btn btn-outline-secondary btn-sm"; + return (CurrFill.SelFillType == reqFillTypes) ? "btn btn-secondary btn-sm" : "btn btn-outline-secondary btn-sm"; } #endregion Private Methods diff --git a/WebWindowComplex/Compo/CardFrame.razor b/WebWindowComplex/Compo/CardFrame.razor index 15ac48b..2fda835 100644 --- a/WebWindowComplex/Compo/CardFrame.razor +++ b/WebWindowComplex/Compo/CardFrame.razor @@ -17,18 +17,10 @@
@@ -39,9 +31,9 @@
Dimension
- @foreach (FrameDimension dimension in FrameWindow.DimensionList) + @foreach (FrameDimension dimension in CurrFrameWindow.DimensionList) { - + }
@@ -66,22 +58,22 @@
- +
- +
- +
- @foreach (Joint joint in FrameWindow.JointList) + @foreach (Joint joint in CurrFrameWindow.JointList) { } @@ -96,7 +88,7 @@
Quantity - +
} @@ -105,12 +97,15 @@
-@if (!(FrameWindow.AreaList[0] is Split) || (SashList.Count == 0 && SplitList.Count == 0)) +@if (!(CurrFrameWindow.AreaList[0] is Split) || (SashList.Count == 0 && SplitList.Count == 0)) { - + @* + *@ } diff --git a/WebWindowComplex/Compo/CardFrame.razor.cs b/WebWindowComplex/Compo/CardFrame.razor.cs index be02a74..cbe300f 100644 --- a/WebWindowComplex/Compo/CardFrame.razor.cs +++ b/WebWindowComplex/Compo/CardFrame.razor.cs @@ -7,24 +7,6 @@ namespace WebWindowComplex.Compo { #region Public Properties - /// - /// Evento per aggiungere sash - /// - [Parameter] - public EventCallback EC_AddSash { get; set; } - - /// - /// Evento per aggiungere split - /// - [Parameter] - public EventCallback EC_AddSplit { get; set; } - - /// - /// Evento per cambiare tutti i Joints - /// - [Parameter] - public EventCallback EC_ChangeAllJoints { get; set; } - /// /// Evento per tornare nella pagine Tree /// @@ -35,58 +17,92 @@ namespace WebWindowComplex.Compo /// Evento per richiedere reset dizionario Shape /// [Parameter] - public EventCallback EC_ReqResetDictShape { get; set; } + public EventCallback EC_ReqResetDictShape { get; set; } /// - /// Evento per aggiornare info frame (es cambaire tutti i Joints) + /// Evento per richiedere opzioni hardware /// [Parameter] - public EventCallback EC_UpdateFrame { get; set; } - + public EventCallback EC_ReqOptionHw { get; set; } + /// - /// Evento per richiesta calcolo Shape + /// Evento per richiesta calcolo preview /// [Parameter] - public EventCallback EC_UpdateShape { get; set; } + public EventCallback EC_UpdatePreview { get; set; } /// /// Frame corrente /// - [Parameter] - public Frame FrameWindow { get; set; } = null!; + [CascadingParameter(Name = "CurrFrameWindow")] + public Frame CurrFrameWindow { get; set; } = null!; /// /// Lista di sash /// - [Parameter] + [CascadingParameter(Name = "SashList")] public List SashList { get; set; } = null!; /// /// Lista di split /// - [Parameter] + [CascadingParameter(Name = "SplitList")] public List SplitList { get; set; } = null!; #endregion Public Properties #region Protected Properties + /// + /// Metodo per selezionare shape + /// protected int SelShapeIndex { - get => FrameWindow.SelShapeIndex; + get => CurrFrameWindow.SelShapeIndex; set { - if (FrameWindow.SelShapeIndex != value) + if (CurrFrameWindow.SelShapeIndex != value) { - FrameWindow.SelShapeIndex = value; + CurrFrameWindow.SelShapeIndex = value; // richiesta reset dict shape - _ = EC_ReqResetDictShape.InvokeAsync(true); + _ = EC_ReqResetDictShape.InvokeAsync(new DataUpdateRes { req = LayoutConst.DataAction.ResetDictShape}); foreach(var s in SashList) { s.SelHardwareFromId = "000000"; } - _ = EC_UpdateFrame.InvokeAsync(FrameWindow); - _ = EC_UpdateShape.InvokeAsync(FrameWindow); + var args = new DataUpdateFrame() + { + currFrame = CurrFrameWindow, + svgNoHw = true + }; + _ = EC_UpdatePreview.InvokeAsync(args); + //_ = EC_ReqOptionHw.InvokeAsync(CurrFrameWindow); + //_ = EC_UpdateShape.InvokeAsync(CurrFrameWindow); + } + } + } + + /// + /// Selezione quantità bottom rail + /// + protected int FrameBottomRailQty + { + get => CurrFrameWindow.BottomRailQty; + set + { + if (CurrFrameWindow.BottomRailQty != value) + { + CurrFrameWindow.BottomRailQty = value; + if (CurrFrameWindow.BottomRailQty > 0) + CurrFrameWindow.SetBottomRail(true); + else + CurrFrameWindow.SetBottomRail(false); + var args = new DataUpdateFrame() + { + currFrame = CurrFrameWindow, + svgNoHw = false + }; + _ = EC_UpdatePreview.InvokeAsync(args); } } } @@ -96,36 +112,56 @@ namespace WebWindowComplex.Compo #region Private Methods /// - /// Sollevo evento richiesta aggiunta sash + /// Metodo per aggiungere sash /// /// private async Task AddSash() { - //await EC_UpdateShape.InvokeAsync(FrameWindow); - await EC_AddSash.InvokeAsync(true); + CurrFrameWindow.AddFirstSash(); + var args = new DataUpdateFrame() + { + currFrame = CurrFrameWindow, + svgNoHw = true + }; + await EC_UpdatePreview.InvokeAsync(args); } /// - /// Sollevo evento richiesta aggiunta window + /// Metodo per aggiungere window /// /// private async Task AddSplit() { - await EC_AddSplit.InvokeAsync(true); + CurrFrameWindow.AddSplit(); + var args = new DataUpdateFrame() + { + currFrame = CurrFrameWindow, + svgNoHw = true + }; + await EC_ReqResetDictShape.InvokeAsync(); + await EC_ReqOptionHw.InvokeAsync(CurrFrameWindow); + await EC_UpdatePreview.InvokeAsync(args); } /// - /// Sollevo evento richiesta copia sash + /// Metodo per cambiare tutti i joint /// /// private async Task ChangeAllJoints(Json.WindowConst.Joints JointType, Area a) { - var Args = new DataChangeJoints + if (a is Frame) { - currJointType = JointType, - currArea = a, + foreach (Joint joint in CurrFrameWindow.JointList) + { + joint.SetSelJointType(JointType); + } + } + var args = new DataUpdateFrame() + { + currFrame = CurrFrameWindow, + svgNoHw = false }; - await EC_ChangeAllJoints.InvokeAsync(Args); + await EC_UpdatePreview.InvokeAsync(args); } /// @@ -143,45 +179,70 @@ namespace WebWindowComplex.Compo private async Task UpdateDim(FrameDimension updRec) { // cerco il record - var currRec = FrameWindow.DimensionList.FirstOrDefault(x => x.ParentFrame == updRec.ParentFrame && x.nIndex == updRec.nIndex); + var currRec = CurrFrameWindow.DimensionList.FirstOrDefault(x => x.ParentFrame == updRec.ParentFrame && x.nIndex == updRec.nIndex); // lo aggiorno if (updRec != null) { currRec = updRec; - await EC_UpdateShape.InvokeAsync(FrameWindow); - await EC_UpdateFrame.InvokeAsync(FrameWindow); + var args = new DataUpdateFrame() + { + currFrame = CurrFrameWindow, + svgNoHw = true + }; + await EC_ReqResetDictShape.InvokeAsync(); + await EC_UpdatePreview.InvokeAsync(args); } } /// - /// Report aggiornamento joint + /// Aggiornamento joint /// /// /// private async Task UpdateJoint(Joint updRec) { // cerco il record - var currRec = FrameWindow.JointList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex); + var currRec = CurrFrameWindow.JointList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex); // lo aggiorno if (updRec != null) { currRec = updRec; - await EC_UpdateFrame.InvokeAsync(FrameWindow); + var args = new DataUpdateFrame() + { + currFrame = CurrFrameWindow, + svgNoHw = false + }; + await EC_UpdatePreview.InvokeAsync(args); } } + /// + /// Metodo per la visualizzazione dei pulsanti joint + /// + /// + /// + private string ButtonJointCss(WebWindowComplex.Json.WindowConst.Joints type) + { + foreach (var item in CurrFrameWindow.JointList) + { + if (!item.SelJointType.Equals(type)) + return "btn btn-outline-secondary btn-sm"; + } + return "btn btn-secondary btn-sm"; + } + #endregion Private Methods } /// - /// Classe per raggruppare oggetti che servono per copiare Sash + /// Classe per raggruppare oggetti che servono per aggiornare frame /// - public class DataChangeJoints + public class DataUpdateFrame { #region Public Properties - public Area currArea { get; set; } = null!; - public Json.WindowConst.Joints currJointType { get; set; } + public Frame currFrame { get; set; } = null!; + public bool svgNoHw { get; set; } = false; #endregion Public Properties } diff --git a/WebWindowComplex/Compo/CardSashGroup.razor b/WebWindowComplex/Compo/CardSashGroup.razor index 5077b35..66f411e 100644 --- a/WebWindowComplex/Compo/CardSashGroup.razor +++ b/WebWindowComplex/Compo/CardSashGroup.razor @@ -1,14 +1,15 @@ -@using static WebWindowComplex.Json.WindowConst +@using WebWindowComplex.Models +@using static WebWindowComplex.Json.WindowConst
-
Sash group @(SashList.Count > 1 ? (CurrIndex + 1) : "")
+
Sash group @(SashList.Count > 1 ? (SashList.IndexOf(CurrSashGroup) + 1) : "")
- +
@@ -21,7 +22,7 @@
Qty sash - +
@@ -29,20 +30,18 @@
- + @foreach (var orientationSash in CurrSashGroup.OrientationSashTypeList) { } - @* - *@
Qty bottom rail - +
@@ -56,7 +55,7 @@
- @if (Sash.s_FamilyHardwareList == null || Sash.s_FamilyHardwareList.Count == 0) { @@ -70,7 +69,7 @@ }
- @if (string.IsNullOrEmpty(CurrItem.SashShape)) + @if (string.IsNullOrEmpty(CurrSashGroup.SashShape)) {
@@ -85,64 +84,75 @@
- - }
-
-
-
Joints
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
- @foreach (Joint joint in CurrItem.JointList) - { - - } + +
- -
-
-
- @for (int i = 0; i < CurrItem.SashList.Count; i++) - { - - - } -
-
-
- - \ No newline at end of file +
+
+
+ +
+
+ @for (int i = 0; i < CurrSashGroup.SashList.Count; i++) + { + @if (editMode && currSashDimEdit.Contains(i)) + { +
+ + +
+ } + else if(currSashDimEdit.Count == 0) + { + + + } + } +
+
+
\ No newline at end of file diff --git a/WebWindowComplex/Compo/CardSashGroup.razor.cs b/WebWindowComplex/Compo/CardSashGroup.razor.cs index 534b447..9b2bade 100644 --- a/WebWindowComplex/Compo/CardSashGroup.razor.cs +++ b/WebWindowComplex/Compo/CardSashGroup.razor.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Components; using WebWindowComplex.Models; using static WebWindowComplex.Json.WindowConst; +using static WebWindowComplex.LayoutConst; namespace WebWindowComplex.Compo { @@ -8,41 +9,17 @@ namespace WebWindowComplex.Compo { #region Public Properties - /// - /// Indice della sash corrente rispetto alla lista sash - /// - [Parameter] - public int CurrIndex { get; set; } = 0; - /// /// Sash corrente rispetto alla lista Sash /// - [Parameter] - public Sash CurrItem { get; set; } = null!; - - /// - /// Evento per cambiare tutti i Joints - /// - [Parameter] - public EventCallback EC_ChangeAllJoints { get; set; } - - /// - /// Evento per cambiare l'anta su cui è presente la maniglia - /// - [Parameter] - public EventCallback EC_ChangeHandle { get; set; } - - /// - /// Evento per cambiare l'anta su cui è presente la maniglia - /// - [Parameter] - public EventCallback EC_CopyContentSash { get; set; } + [CascadingParameter(Name = "CurrSashGroup")] + public Sash CurrSashGroup { get; set; } = null!; /// /// Evento per cambiare tutti i fill /// [Parameter] - public EventCallback EC_RemoveArea { get; set; } + public EventCallback EC_UpdateFrame { get; set; } /// /// Evento per tornare nella pagine Tree @@ -54,48 +31,155 @@ namespace WebWindowComplex.Compo /// Evento per richiedere reset dizionario Shape /// [Parameter] - public EventCallback EC_ReqResetDictShape { get; set; } + public EventCallback EC_ReqResetDictShape { get; set; } /// - /// Evento per cambiare tutti i Joints + /// Evento per richiedere reset dizionario Hw option /// [Parameter] - public EventCallback EC_UpdateSash { get; set; } + public EventCallback EC_ReqResetDictHwOpt { get; set; } /// - /// Evento per segnalare cambio hw e richiesta calcolo + /// Evento per richiedere opzioni hardware /// [Parameter] - public EventCallback EC_UpdateSashHardware { get; set; } + public EventCallback EC_ReqOptionHw { get; set; } /// - /// Evento per richiedere la prima volta le opzioni hardware + /// Evento per richiedere per la prima volta opzioni hardware /// [Parameter] - public EventCallback EC_CallFirstHwOpt { get; set; } + public EventCallback EC_ReqFirstOptionHw { get; set; } + + /// + /// Evento per segnalare aggiornamento + /// + [Parameter] + public EventCallback EC_UpdatePreview { get; set; } /// /// Lista di sash /// - [Parameter] + [CascadingParameter(Name = "SashList")] public List SashList { get; set; } = null!; + /// + /// Frame corrente + /// + [Parameter] + public Frame FrameWindow { get; set; } = null!; + #endregion Public Properties #region Protected Properties + /// + /// Selezione quantità di ante + /// + protected int SashQty + { + get => CurrSashGroup.nSashQty; + set + { + if (CurrSashGroup.nSashQty != value) + { + CurrSashGroup.nSashQty = value; + var args = new DataUpdateSash() + { + currSash = CurrSashGroup, + svgNoHw = true + }; + _ = EC_UpdatePreview.InvokeAsync(args); + //_ = EC_ReqResetDictShape.InvokeAsync(true); + _ = EC_ReqOptionHw.InvokeAsync(CurrSashGroup); + } + } + } + + /// + /// Selezione quantità bottom rail + /// + protected int SashBottomRailQty + { + get => CurrSashGroup.SashBottomRailQty; + set + { + if (CurrSashGroup.SashBottomRailQty != value) + { + CurrSashGroup.SashBottomRailQty = value; + if (CurrSashGroup.SashBottomRailQty > 0) + CurrSashGroup.SetSashBottomRail(true); + else + CurrSashGroup.SetSashBottomRail(false); + var args = new DataUpdateSash() + { + currSash = CurrSashGroup + }; + _ = EC_UpdatePreview.InvokeAsync(args); + } + } + } + + /// + /// Selezione tipo di orientamento della sash + /// + protected int OrientationSashTypeIndex + { + get => CurrSashGroup.SelOrientationSashTypeIndex; + set + { + if (CurrSashGroup.SelOrientationSashTypeIndex != value) + { + CurrSashGroup.SelOrientationSashTypeIndex = value; + var args = new DataUpdateSash() + { + currSash = CurrSashGroup + }; + _ = EC_UpdatePreview.InvokeAsync(args); + } + } + } + + /// + /// Selezione famiglia hardware + /// + protected string FamilyHardware + { + get => CurrSashGroup.SelFamilyHardware; + set + { + if (CurrSashGroup.SelFamilyHardware != value) + { + CurrSashGroup.SelFamilyHardware = value; + var args = new DataUpdateSash() + { + currSash = CurrSashGroup, + svgNoHw = true + }; + _ = EC_UpdatePreview.InvokeAsync(args); + _ = EC_ReqResetDictHwOpt.InvokeAsync(new DataUpdateRes { req = DataAction.ResetHwOpt}); + _ = EC_ReqOptionHw.InvokeAsync(CurrSashGroup); + } + } + } + /// /// Selezione hardware /// protected string SelHwType { - get => CurrItem.SelHardwareFromId; + get => CurrSashGroup.SelHardwareFromId; set { - if (CurrItem.SelHardwareFromId != value) + if (CurrSashGroup.SelHardwareFromId != value) { - CurrItem.SelHardwareFromId = value; - _ = EC_UpdateSashHardware.InvokeAsync(CurrItem); + CurrSashGroup.SelHardwareFromId = value; + var args = new DataUpdateSash + { + currSash = CurrSashGroup + }; + _ = EC_UpdatePreview.InvokeAsync(args); + _ = EC_ReqOptionHw.InvokeAsync(CurrSashGroup); } } } @@ -105,51 +189,92 @@ namespace WebWindowComplex.Compo #region Protected Methods /// - /// Sollevo evento per rimuovere area + /// Metodo per rimuovere area /// /// area da rimuovere /// - protected async Task RemoveArea(Area currArea) + protected async Task RemoveArea() { + CurrSashGroup.Remove(); + var args = new DataUpdateFrame() + { + currFrame = FrameWindow + }; // richiesta reset dict shape - await EC_ReqResetDictShape.InvokeAsync(true); - await EC_RemoveArea.InvokeAsync(currArea); + await EC_ReqResetDictShape.InvokeAsync(new DataUpdateRes { req=DataAction.ResetDictShape}); + await EC_UpdateFrame.InvokeAsync(args); + await EC_ReqClose.InvokeAsync(true); + } + + /// + /// Metodo per scegliere tipo di misura + /// + /// + /// + protected async Task SetMeasureType(MeasureTypes type) + { + isOpen = !isOpen; + foreach (var item in CurrSashGroup.SashList) + { + item.SetSelMeasureType(type); + } + var args = new DataUpdateSash + { + currSash = CurrSashGroup + }; + await EC_UpdatePreview.InvokeAsync(args); + } + + /// + /// Metodo per aggiornare la sash dimension + /// + /// + /// + protected async Task UpdateSashDimension(SashDimension updateSD) + { + var currRec = CurrSashGroup.SashList.First(x => x.nSashId == updateSD.nSashId); + if(currRec != null) + { + currRec = updateSD; + var args = new DataUpdateSash + { + currSash = CurrSashGroup + }; + await EC_UpdatePreview.InvokeAsync(args); + } + } + + /// + /// Metodo per aggiornare sash + /// + /// + /// + protected async Task UpdateSash(Sash updateS) + { + if (updateS != null) + { + CurrSashGroup = updateS; + var args = new DataUpdateSash + { + currSash = CurrSashGroup + }; + await EC_UpdatePreview.InvokeAsync(args); + } } #endregion Protected Methods #region Private Methods - /// - /// Sollevo evento richiesta per cambiare tutti i Joint - /// - /// - private async Task ChangeAllJoints(Json.WindowConst.Joints JointType, Area a) + private bool editMode = false; + private List currSashDimEdit = new List(); + private void EditView(DataChangeMode args) { - var Args = new DataChangeJoints - { - currJointType = JointType, - currArea = a, - }; - await EC_ChangeAllJoints.InvokeAsync(Args); - } - - /// - /// Sollevo evento per cambiare l'anta su cui è presente la maniglia - /// - /// - private async Task ChangeHandle(DataChangeHandle Args) - { - await EC_ChangeHandle.InvokeAsync(Args); - } - - /// - /// Sollevo evento per cambiare l'anta su cui è presente la maniglia - /// - /// - private async Task CopyContentSash(DataCopyContentSash Args) - { - await EC_CopyContentSash.InvokeAsync(Args); + editMode = args.Edit; + if(args.IndexSashEdit != -1) + currSashDimEdit.Add(args.IndexSashEdit); + if (args.IndexSashClose != -1) + currSashDimEdit.Remove(args.IndexSashClose); } /// @@ -161,53 +286,45 @@ namespace WebWindowComplex.Compo } /// - /// Report aggiornamento joint + /// Aggiornamento opzioni hardware /// /// /// - private async Task UpdateJoint(Joint updRec) + private async Task UpdateOpt(DataUpdateHwOption argsHw) { - // cerco il record - var currRec = CurrItem.JointList.FirstOrDefault(x => x.ParentArea == updRec.ParentArea && x.nIndex == updRec.nIndex); - // lo aggiorno - if (updRec != null) + AGBOptionCombo AGBOptCombo = argsHw.AGBOptCombo; + AGBOptionText AGBOptText = argsHw.AGBOptText; + if (AGBOptCombo != null) { - currRec = updRec; - await EC_UpdateSash.InvokeAsync(CurrItem); + // cerco il record + var currRec = CurrSashGroup.HwOptionList.FirstOrDefault(x => x.sName == AGBOptCombo.sName && x.sDescription == AGBOptCombo.sDescription); + // lo aggiorno + if (AGBOptCombo != null) + { + currRec = AGBOptCombo; + var args = new DataUpdateSash + { + currSash = CurrSashGroup + }; + await EC_UpdatePreview.InvokeAsync(args); + await EC_ReqOptionHw.InvokeAsync(CurrSashGroup); + } } - } - - /// - /// Report aggiornamento Option Combo - /// - /// - /// - private async Task UpdateOptCombo(AGBOptionCombo updRec) - { - // cerco il record - var currRec = CurrItem.HwOptionList.FirstOrDefault(x => x.sName == updRec.sName && x.sDescription == updRec.sDescription); - // lo aggiorno - if (updRec != null) + else { - currRec = updRec; - await EC_UpdateSashHardware.InvokeAsync(CurrItem); - } - } - - /// - /// Report aggiornamento Option Text - /// - /// - /// - private async Task UpdateOptText(AGBOptionText updRec) - { - // cerco il record - var currRec = CurrItem.HwOptionList.FirstOrDefault(x => x.sName == updRec.sName && x.sDescription == updRec.sDescription); - // lo aggiorno - if (updRec != null) - { - currRec = updRec; - await EC_UpdateSashHardware.InvokeAsync(CurrItem); + // cerco il record + var currRec = CurrSashGroup.HwOptionList.FirstOrDefault(x => x.sName == AGBOptText.sName && x.sDescription == AGBOptText.sDescription); + // lo aggiorno + if (AGBOptText != null) + { + currRec = AGBOptText; + var args = new DataUpdateSash + { + currSash = CurrSashGroup + }; + await EC_UpdatePreview.InvokeAsync(args); + await EC_ReqOptionHw.InvokeAsync(CurrSashGroup); + } } } @@ -216,11 +333,42 @@ namespace WebWindowComplex.Compo /// /// /// - private async Task FirstHwOptionList(int groupId) + private async Task FirstHwOptionList() { - await EC_CallFirstHwOpt.InvokeAsync(groupId); + var args = new DataUpdateSash + { + currSash = CurrSashGroup + }; + //await EC_UpdatePreview.InvokeAsync(args); + await EC_ReqFirstOptionHw.InvokeAsync(CurrSashGroup); } + private string ButtonMeasureCss(MeasureTypes type) + { + foreach(var item in CurrSashGroup.SashList) + { + if (!item.SelMeasureType.Equals(type)) + return "btn btn-outline-secondary btn-sm"; + } + return "btn btn-secondary btn-sm"; + } + + private bool isOpen = false; + private void ToggleDropdown() + { + isOpen = !isOpen; + } #endregion Private Methods } + + public class DataUpdateSash + { + public Sash currSash { get; set; } = null!; + public bool svgNoHw { get; set; } = false; + } + + public class DataUpdateRes + { + public DataAction req { get; set; } = DataAction.None; + } } \ No newline at end of file diff --git a/WebWindowComplex/Compo/CardSplit.razor b/WebWindowComplex/Compo/CardSplit.razor index 81551b6..35b83e7 100644 --- a/WebWindowComplex/Compo/CardSplit.razor +++ b/WebWindowComplex/Compo/CardSplit.razor @@ -1,9 +1,10 @@ - +@using static WebWindowComplex.Json.WindowConst +
-
@(descParentSplit(CurrItem))
+
@(descParentSplit())
@@ -11,119 +12,247 @@
-
-
-
Split
-
-
- @if ((CurrItem.nSplitQtyVert == 1 && CurrItem.nSplitQtyHoriz == 0) || (CurrItem.nSplitQtyVert == 0 && CurrItem.nSplitQtyHoriz == 1)) - { -
- -
- } -
-
+
+
Split
+ @if ((CurrSplit.nSplitQtyVert == 1 && CurrSplit.nSplitQtyHoriz == 0) || (CurrSplit.nSplitQtyVert == 0 && CurrSplit.nSplitQtyHoriz == 1)) + {
- +
+ } +
+ +
+
- + @foreach (var shapeType in CurrSplit.SplitShapeList) { } - @* - - - *@
- @if (CurrItem.nSplitQtyVert > 0) + @if (CurrSplit.nSplitQtyVert > 0) {
QtyVert - +
} - @if (CurrItem.nSplitQtyHoriz > 0) + @if (CurrSplit.nSplitQtyHoriz > 0) {
QtyHoriz - +
}
- @if (CurrItem.SplitVertList.Count > 0 && CurrItem.SplitHorizList.Count > 0) + @if (CurrSplit.SplitVertList.Count > 0 && CurrSplit.SplitHorizList.Count > 0) {
- @foreach (var dim in CurrItem.SplitVertList) + @for (int i = 0; i < CurrSplit.SplitVertList.Count; i++) { -
+ + + @*
Width - % -
+ +
*@ }
- @foreach (var dim in CurrItem.SplitHorizList) + @for (int i = 0; i < CurrSplit.SplitHorizList.Count; i++) { -
+ + + @*
Height - % -
+ +
*@ } -
+
} - else if (CurrItem.SplitHorizList.Count > 0) + else if (CurrSplit.SplitHorizList.Count > 0) { - @foreach (var dim in CurrItem.SplitHorizList) + @for (int i = 0; i < CurrSplit.SplitHorizList.Count; i++) { -
+ + + @*
Height - % +
-
+
*@ } } - else if (CurrItem.SplitVertList.Count > 0) + else if (CurrSplit.SplitVertList.Count > 0) { - @foreach (var dim in CurrItem.SplitVertList) + @for (int i = 0; i < CurrSplit.SplitVertList.Count; i++) { -
+ + + @*
Width - % +
-
+
*@ } }
- @if (CurrItem.SelSplitShape == Json.WindowConst.SplitShapes.GRID) + @if (CurrSplit.SelSplitShape == Json.WindowConst.SplitShapes.GRID) {
- +
diff --git a/WebWindowComplex/Compo/CardSplit.razor.cs b/WebWindowComplex/Compo/CardSplit.razor.cs index 72e18e9..6cf3404 100644 --- a/WebWindowComplex/Compo/CardSplit.razor.cs +++ b/WebWindowComplex/Compo/CardSplit.razor.cs @@ -1,21 +1,19 @@ using Microsoft.AspNetCore.Components; +using Newtonsoft.Json.Linq; using WebWindowComplex.Models; +using static WebWindowComplex.Json.WindowConst; +using static WebWindowComplex.LayoutConst; namespace WebWindowComplex.Compo { public partial class CardSplit { + /// - /// Indice del fill corrente rispetto alla lista fill + /// Split corrente rispetto alla lista split /// [Parameter] - public int CurrIndex { get; set; } = 0; - - /// - /// Fill corrente rispetto alla lista fill - /// - [Parameter] - public Split CurrItem { get; set; } = null!; + public Split CurrSplit { get; set; } = null!; /// /// Lista di sash @@ -30,28 +28,34 @@ namespace WebWindowComplex.Compo public List SplitList { get; set; } = null!; /// - /// Evento per scambiare le aree di uno split + /// Frame /// [Parameter] - public EventCallback EC_SwapTwoAree { get; set; } - - /// - /// Evento per rimuovere split - /// - [Parameter] - public EventCallback EC_RemoveArea { get; set; } - - /// - /// Evento per cambiare nel caso di split a griglia se inizia con lo split verticale - /// - [Parameter] - public EventCallback EC_ChangeStartVert { get; set; } + public Frame FrameWindow { get; set; } = null!; /// /// Evento per richiedere reset dizionario Shape /// [Parameter] - public EventCallback EC_ReqResetDictShape { get; set; } + public EventCallback EC_ReqResetDictShape { get; set; } + + /// + /// Evento per richiedere reset dizionario opzioni hardware + /// + [Parameter] + public EventCallback EC_ReqResetDictHwOpt { get; set; } + + /// + /// Evento per aggiornare Split + /// + [Parameter] + public EventCallback EC_UpdatePreview { get; set; } + + /// + /// Evento per aggiornare Frame + /// + [Parameter] + public EventCallback EC_UpdateFrame { get; set; } /// /// Evento per tornare nella pagine Tree @@ -60,64 +64,183 @@ namespace WebWindowComplex.Compo public EventCallback EC_ReqClose { get; set; } /// - /// Sollevo evento per scambiare le aree di uno split + /// Metodo per scambiare le aree di uno split (solo se si hanno due aree) /// /// split corrente /// - protected async Task SwapTwoAree(Split item) + protected async Task SwapTwoAree() { - // richiesta reset dict shape - _ = EC_ReqResetDictShape.InvokeAsync(true); - await EC_SwapTwoAree.InvokeAsync(item); - } - - /// - /// Sollevo evento per rimuovere split - /// - /// split corrente - /// - protected async Task RemoveArea(Split item) - { - // richiesta reset dict shape - await EC_ReqResetDictShape.InvokeAsync(true); - await EC_RemoveArea.InvokeAsync(item); - } - - /// - /// Sollevo evento per rimuovere split - /// - /// split corrente - /// - protected async Task ChangeStartVert(ChangeEventArgs e, Split item) - { - var Args = new DataChangeStartVert - { - eventArg = e, - currItem = item, + CurrSplit.SwapAree(); + var args = new DataUpdateSplit(){ + currSplit = CurrSplit, + svgNoHw = true }; - await EC_ChangeStartVert.InvokeAsync(Args); + await EC_ReqResetDictShape.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDictShape }); + await EC_UpdatePreview.InvokeAsync(args); + } + + /// + /// Metodo per rimuovere split + /// + /// split corrente + /// + protected async Task RemoveArea() + { + CurrSplit.Remove(); + var args = new DataUpdateFrame() + { + currFrame = FrameWindow + }; + // richiesta reset dict shape + await EC_ReqResetDictShape.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDictShape }); + await EC_UpdateFrame.InvokeAsync(args); + await EC_ReqClose.InvokeAsync(true); + } + + /// + /// Proprietà per selezionare shape split + /// + /// + protected int SplitShapeIndex + { + get => CurrSplit.SelSplitShapeIndex; + set + { + if (CurrSplit.SelSplitShapeIndex != value) + { + CurrSplit.SelSplitShapeIndex = value; + var args = new DataUpdateSplit() + { + currSplit = CurrSplit + }; + if (SearchSash(CurrSplit)) + { + _ = EC_ReqResetDictShape.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDictShape }); + _ = EC_ReqResetDictHwOpt.InvokeAsync(new DataUpdateRes { req = DataAction.ResetHwOpt }); + } + _ = EC_UpdatePreview.InvokeAsync(args); + } + } + } + + private bool SearchSash(Area area) + { + if (area is Sash) + return true; + foreach (var item in area.AreaList) + return SearchSash(item); + return false; + } + + /// + /// Proprietà per selezionare numero di split verticali + /// + /// + protected int SplitQtyVert + { + get => CurrSplit.nSplitQtyVert; + set + { + if (CurrSplit.nSplitQtyVert != value) + { + CurrSplit.nSplitQtyVert = value; + var args = new DataUpdateSplit() + { + currSplit = CurrSplit + }; + _ = EC_UpdatePreview.InvokeAsync(args); + } + } + } + + /// + /// Proprietà per selezionare numero di split verticali + /// + /// + protected int SplitQtyHoriz + { + get => CurrSplit.nSplitQtyHoriz; + set + { + if (CurrSplit.nSplitQtyHoriz != value) + { + CurrSplit.nSplitQtyHoriz = value; + var args = new DataUpdateSplit() + { + currSplit = CurrSplit + }; + _ = EC_UpdatePreview.InvokeAsync(args); + } + } + } + + /// + /// Metodo per aggiornare la dimensione dello split + /// + /// + /// + protected async Task UpdateDimension(DataUpdateSplitDimension updRec) + { + SplitDimension currSplitDim = updRec.currSplit; + SplitDimension currRec = null; + // cerco il record + if (currSplitDim.bIsVertListDim) + currRec = CurrSplit.SplitVertList.ElementAt(updRec.index); + else + currRec = CurrSplit.SplitHorizList.ElementAt(updRec.index); + // lo aggiorno + if (currSplitDim != null) + { + currRec = currSplitDim; + var args = new DataUpdateSplit() + { + currSplit = CurrSplit + }; + await EC_ReqResetDictShape.InvokeAsync(new DataUpdateRes { req = DataAction.ResetDictShape }); + await EC_UpdatePreview.InvokeAsync(args); + } + } + + /// + /// Metodo per rimuovere split + /// + /// + /// + protected async Task ChangeStartVert(ChangeEventArgs e) + { + foreach (Split s in SplitList) + { + if (s.Equals(CurrSplit)) + { + s.SetSplitStartVert((bool)e.Value); + } + } + var args = new DataUpdateSplit() + { + currSplit = CurrSplit + }; + await EC_UpdatePreview.InvokeAsync(args); } /// /// Metodo per determinare la descrizione del parent dello split corrente /// - /// split corrente /// - protected string descParentSplit(Split currSplit) + protected string descParentSplit() { - if ((currSplit.ParentArea is Splitted || currSplit.ParentArea is Sash) && SashList.Count > 0) + if ((CurrSplit.ParentArea is Splitted || CurrSplit.ParentArea is Sash) && SashList.Count > 0) { for (int j = 0; j < SashList.Count; j++) { - if (SashList[j].Equals(currSplit.ParentArea)) + if (SashList[j].Equals(CurrSplit.ParentArea)) { return "Sash " + (j + 1); } - else if (SashList[j].Equals(currSplit.ParentArea.ParentArea)) + else if (SashList[j].Equals(CurrSplit.ParentArea.ParentArea)) { for (int k = 0; k < SashList[j].AreaList.Count; k++) { - if (SashList[j].AreaList[k].AreaList[0].Equals(currSplit)) + if (SashList[j].AreaList[k].AreaList[0].Equals(CurrSplit)) { return "Sash group " + (j + 1) + " - sash " + (k + 1); } @@ -139,11 +262,43 @@ namespace WebWindowComplex.Compo { _ = EC_ReqClose.InvokeAsync(true); } + + private bool isOpen = false; + private void ToggleDropdown() + { + isOpen = !isOpen; + } + + /// + /// Metodo per cambiare il tipo di misura di tutti gli SplitDimension + /// + /// nuovo tipo + /// + protected async Task SetMeasureType(MeasureTypes type) + { + isOpen = !isOpen; + foreach (var item in CurrSplit.SplitVertList) + { + item.SetSelMeasureType(type); + } + foreach (var item in CurrSplit.SplitHorizList) + { + item.SetSelMeasureType(type); + } + var args = new DataUpdateSplit() + { + currSplit = CurrSplit + }; + await EC_UpdatePreview.InvokeAsync(args); + } } - public class DataChangeStartVert + /// + /// Classe per raggruppare oggetti che servono per aggiornare split + /// + public class DataUpdateSplit { - public ChangeEventArgs eventArg { get; set; } = null!; - public Split currItem { get; set; } + public Split currSplit { get; set; } = null!; + public bool svgNoHw { get; set; } = false; } } \ No newline at end of file diff --git a/WebWindowComplex/Compo/CardTree.razor b/WebWindowComplex/Compo/CardTree.razor index 9e7c659..ad3f3d5 100644 --- a/WebWindowComplex/Compo/CardTree.razor +++ b/WebWindowComplex/Compo/CardTree.razor @@ -37,6 +37,11 @@ } + @* @if (ItemTableList[i].Type is Json.WindowConst.AreaTypes.SASH || + ItemTableList[i].Type is Json.WindowConst.AreaTypes.SPLIT) + { + + } *@ } else diff --git a/WebWindowComplex/Compo/CardTree.razor.cs b/WebWindowComplex/Compo/CardTree.razor.cs index 923541a..ad4d1b5 100644 --- a/WebWindowComplex/Compo/CardTree.razor.cs +++ b/WebWindowComplex/Compo/CardTree.razor.cs @@ -29,7 +29,7 @@ namespace WebWindowComplex.Compo public EventCallback EC_NextStep { get; set; } /// - /// Sollevo evento richiesta prossimo step + /// Metodo per richiesta prossimo step /// /// private async Task RaiseNextStep(CompileStep cs, int indexStep) @@ -42,6 +42,16 @@ namespace WebWindowComplex.Compo await EC_NextStep.InvokeAsync(Args); } + //private async Task Remove(CompileStep cs, int indexStep) + //{ + // var Args = new DataNextStep + // { + // currCompileStep = cs, + // index = indexStep, + // }; + // await EC_NextStep.InvokeAsync(Args); + //} + /// /// Metodo per riempire tabella con contenuto vuoto o con i simboli per rappresentare la struttura /// diff --git a/WebWindowComplex/Compo/EditDimensions.razor b/WebWindowComplex/Compo/EditFrameDimensions.razor similarity index 100% rename from WebWindowComplex/Compo/EditDimensions.razor rename to WebWindowComplex/Compo/EditFrameDimensions.razor diff --git a/WebWindowComplex/Compo/EditDimensions.razor.cs b/WebWindowComplex/Compo/EditFrameDimensions.razor.cs similarity index 77% rename from WebWindowComplex/Compo/EditDimensions.razor.cs rename to WebWindowComplex/Compo/EditFrameDimensions.razor.cs index d94acb8..75352ab 100644 --- a/WebWindowComplex/Compo/EditDimensions.razor.cs +++ b/WebWindowComplex/Compo/EditFrameDimensions.razor.cs @@ -3,10 +3,13 @@ using WebWindowComplex.Models; namespace WebWindowComplex.Compo { - public partial class EditDimensions + public partial class EditFrameDimensions { #region Public Properties + /// + /// Frame dimension corrente + /// [Parameter] public FrameDimension CurrRec { get; set; } = null!; @@ -17,6 +20,9 @@ namespace WebWindowComplex.Compo #region Private Properties + /// + /// Metodo per aggiornare valore dimension + /// private double CurrVal { get => CurrRec.dValue; diff --git a/WebWindowComplex/Compo/EditJoint.razor b/WebWindowComplex/Compo/EditJoint.razor index f2545cc..1489955 100644 --- a/WebWindowComplex/Compo/EditJoint.razor +++ b/WebWindowComplex/Compo/EditJoint.razor @@ -1,13 +1,10 @@ @using static WebWindowComplex.LayoutConst
- @foreach (var typeJoint in CurrRec.JointTypeList) { } - @* - - *@
\ No newline at end of file diff --git a/WebWindowComplex/Compo/EditJoint.razor.cs b/WebWindowComplex/Compo/EditJoint.razor.cs index 2835920..f3f02ba 100644 --- a/WebWindowComplex/Compo/EditJoint.razor.cs +++ b/WebWindowComplex/Compo/EditJoint.razor.cs @@ -7,9 +7,13 @@ namespace WebWindowComplex.Compo { #region Public Properties + /// + /// Joint corrente + /// [Parameter] public Joint CurrRec { get; set; } = null!; + [Parameter] public EventCallback EC_Update { get; set; } @@ -17,7 +21,10 @@ namespace WebWindowComplex.Compo #region Private Properties - private int CurrVal + /// + /// Metodo per aggiornare joint corrente + /// + private int CurrJoint { get => CurrRec.SelJointTypeIndex; set diff --git a/WebWindowComplex/Compo/EditOptionCombo.razor.cs b/WebWindowComplex/Compo/EditOptionCombo.razor.cs index 13b0c35..17e625e 100644 --- a/WebWindowComplex/Compo/EditOptionCombo.razor.cs +++ b/WebWindowComplex/Compo/EditOptionCombo.razor.cs @@ -7,6 +7,9 @@ namespace WebWindowComplex.Compo { #region Public Properties + /// + /// Opzione hardware combo corrente + /// [Parameter] public AGBOptionCombo CurrOpt { get; set; } = null!; @@ -17,6 +20,9 @@ namespace WebWindowComplex.Compo #region Private Properties + /// + /// Metodo per aggiornare opzione hardware corrente + /// private string CurrValue { get => CurrOpt.sValue.sValue; diff --git a/WebWindowComplex/Compo/EditOptionText.razor.cs b/WebWindowComplex/Compo/EditOptionText.razor.cs index 55b5d12..9ef614c 100644 --- a/WebWindowComplex/Compo/EditOptionText.razor.cs +++ b/WebWindowComplex/Compo/EditOptionText.razor.cs @@ -7,6 +7,9 @@ namespace WebWindowComplex.Compo { #region Public Properties + /// + /// Opzione hardware text corrente + /// [Parameter] public AGBOptionText CurrOpt { get; set; } = null!; @@ -17,6 +20,9 @@ namespace WebWindowComplex.Compo #region Private Properties + /// + /// Metodo per aggiornare opzione hardware text corrente + /// private string CurrValue { get => CurrOpt.sValue; diff --git a/WebWindowComplex/Compo/EditSplitDimensions.razor b/WebWindowComplex/Compo/EditSplitDimensions.razor new file mode 100644 index 0000000..621a0c8 --- /dev/null +++ b/WebWindowComplex/Compo/EditSplitDimensions.razor @@ -0,0 +1,32 @@ + +
+
+ @Name + + +
+
diff --git a/WebWindowComplex/Compo/EditSplitDimensions.razor.cs b/WebWindowComplex/Compo/EditSplitDimensions.razor.cs new file mode 100644 index 0000000..87179c7 --- /dev/null +++ b/WebWindowComplex/Compo/EditSplitDimensions.razor.cs @@ -0,0 +1,96 @@ +using Microsoft.AspNetCore.Components; +using WebWindowComplex.Models; + +namespace WebWindowComplex.Compo +{ + public partial class EditSplitDimensions + { + #region Public Properties + + /// + /// Split dimension corrente + /// + [Parameter] + public SplitDimension CurrRec { get; set; } = null!; + + /// + /// Nome dello split dimension corrente + /// + [Parameter] + public string Name { get; set; } = null!; + + /// + /// Indice dello split dimension + /// + [Parameter] + public int Index { get; set; } = -1; + + [Parameter] + public EventCallback EC_Update { get; set; } + + #endregion Public Properties + + #region Private Properties + + /// + /// Metodo per aggiornare la dimensione + /// + private double CurrVal + { + get => CurrRec.dDimension; + set + { + if (CurrRec.dDimension != value) + { + CurrRec.dDimension = value; + var args = new DataUpdateSplitDimension() + { + currSplit = CurrRec, + index = Index + }; + _ = EC_Update.InvokeAsync(args); + } + } + } + + /// + /// Metodo per aggiornare il tipo della dimensione + /// + private int CurrType + { + get => CurrRec.SelMeasureTypeIndex; + set + { + if (CurrRec.SelMeasureTypeIndex != value) + { + CurrRec.SelMeasureTypeIndex = value; + var args = new DataUpdateSplitDimension() + { + currSplit = CurrRec, + index=Index + }; + _ = EC_Update.InvokeAsync(args); + } + } + } + + private string SplitDimCss() + { + if (CurrRec.Parent.SelSplitShape.Equals(Json.WindowConst.SplitShapes.GRID)) + return ""; + else + return "col-md-12 col-lg-6"; + } + + #endregion Private Properties + } + + /// + /// Classe per aggiornare split dimension + /// + public class DataUpdateSplitDimension + { + public SplitDimension currSplit { get; set; } = null!; + public int index { get; set; } = -1; + } +} \ No newline at end of file diff --git a/WebWindowComplex/Compo/General.razor.cs b/WebWindowComplex/Compo/General.razor.cs index 9ed2b11..24c8d51 100644 --- a/WebWindowComplex/Compo/General.razor.cs +++ b/WebWindowComplex/Compo/General.razor.cs @@ -15,16 +15,7 @@ namespace WebWindowComplex.Compo public Window CurrWindow { get; set; } = null!; [Parameter] - public EventCallback EC_SelColor { get; set; } - - [Parameter] - public EventCallback EC_SelGlass { get; set; } - - [Parameter] - public EventCallback EC_SelWindMat { get; set; } - - [Parameter] - public EventCallback EC_SelProfile { get; set; } + public EventCallback EC_UpdateGeneral { get; set; } [Parameter] public EventCallback EC_ReqClose { get; set; } @@ -45,43 +36,71 @@ namespace WebWindowComplex.Compo #region Protected Properties + /// + /// Colore corrente + /// protected string CurrColor { get => currColor; set { currColor = value; - _ = EC_SelColor.InvokeAsync(value); + var args = new DataUpdateGeneral + { + Color = value, + }; + _ = EC_UpdateGeneral.InvokeAsync(args); } } + /// + /// Vetro corrente + /// protected string CurrGlass { get => currGlass; set { currGlass = value; - _ = EC_SelGlass.InvokeAsync(value); + var args = new DataUpdateGeneral + { + Glass = value, + }; + _ = EC_UpdateGeneral.InvokeAsync(args); } } + /// + /// Materiale corrente + /// protected string CurrMaterial { get => currMaterial; set { currMaterial = value; - _ = EC_SelWindMat.InvokeAsync(value); + var args = new DataUpdateGeneral + { + Material = value, + }; + _ = EC_UpdateGeneral.InvokeAsync(args); } } + /// + /// Profilo corrente + /// protected string CurrProfile { get => currProfile; set { currProfile = value; - _ = EC_SelProfile.InvokeAsync(value); + var args = new DataUpdateGeneral + { + Profile = value, + }; + _ = EC_UpdateGeneral.InvokeAsync(args); } } @@ -123,4 +142,16 @@ namespace WebWindowComplex.Compo _ = EC_ReqClose.InvokeAsync(true); } } + + + /// + /// Classe per aggiornamento dati general + /// + public class DataUpdateGeneral + { + public string Color { get; set; } = ""; + public string Glass { get; set; } = ""; + public string Material { get; set; } = ""; + public string Profile { get; set; } = ""; + } } \ No newline at end of file diff --git a/WebWindowComplex/ItemTable.cs b/WebWindowComplex/ItemTable.cs index 08d8c0c..5383e3b 100644 --- a/WebWindowComplex/ItemTable.cs +++ b/WebWindowComplex/ItemTable.cs @@ -9,6 +9,9 @@ namespace WebWindowComplex { public class ItemTable { + /// + /// Tipo di area + /// private AreaTypes m_type; public AreaTypes Type { @@ -22,6 +25,9 @@ namespace WebWindowComplex } } + /// + /// Descrizione + /// private string m_desc; public string Desc { @@ -35,6 +41,9 @@ namespace WebWindowComplex } } + /// + /// Numero di riga nell'albero gerarchico + /// private int m_row; public int Row { @@ -48,6 +57,9 @@ namespace WebWindowComplex } } + /// + /// Numero di colonna nell'albero gerarchico + /// private int m_col; public int Col { diff --git a/WebWindowComplex/Json/JsonUtility.cs b/WebWindowComplex/Json/JsonUtility.cs index d9310dc..ef9d0de 100644 --- a/WebWindowComplex/Json/JsonUtility.cs +++ b/WebWindowComplex/Json/JsonUtility.cs @@ -229,6 +229,20 @@ namespace WebWindowComplex.Json } } + //private JsonFrameArcElement m_FrameArcElem; + //[JsonProperty] + //public JsonFrameArcElement ArcElement + //{ + // get + // { + // return m_FrameArcElem; + // } + // set + // { + // m_FrameArcElem = value; + // } + //} + public JsonFrame() : base(AreaTypes.FRAME) { } @@ -249,9 +263,11 @@ namespace WebWindowComplex.Json newFrame.SetSelShape(m_Shape); newFrame.SetBottomRail(m_bBottomRail); newFrame.SetBottomRailQty(m_nBottomRailQty); + //if(ArcElement != null) + // newFrame.SetFrameArcElem(ArcElement.Deserialize(newFrame, ParentWindow)); //Frame.AppliedDone(); for (var DimensionIndex = 0; DimensionIndex <= m_DimensionList.Count - 1; DimensionIndex++) - newFrame.DimensionList[DimensionIndex].dValue = m_DimensionList[DimensionIndex].Value; + newFrame.DimensionList[DimensionIndex].SetDimension(m_DimensionList[DimensionIndex].Value); for (var JointIndex = 0; JointIndex <= m_JointList.Count - 1; JointIndex++) newFrame.JointList[JointIndex].SetSelJointType(m_JointList[JointIndex].JointType); foreach (var Area in AreaList) @@ -311,20 +327,6 @@ namespace WebWindowComplex.Json } } - private List m_JointList = new List(); - [JsonProperty] - public List JointList - { - get - { - return m_JointList; - } - set - { - m_JointList = value; - } - } - private bool m_bBottomRail; [JsonProperty] public bool BottomRail @@ -353,6 +355,20 @@ namespace WebWindowComplex.Json } } + //private JsonSashArcElement m_SashArcElem; + //[JsonProperty] + //public JsonSashArcElement ArcElement + //{ + // get + // { + // return m_SashArcElem; + // } + // set + // { + // m_SashArcElem = value; + // } + //} + private string m_Hardware; [JsonProperty] public string Hardware @@ -409,16 +425,17 @@ namespace WebWindowComplex.Json newSash.SashList[SashIndex].SetOpeningType(m_SashList[SashIndex].OpeningType); newSash.SashList[SashIndex].SetHasHandle(m_SashList[SashIndex].HasHandle); newSash.SashList[SashIndex].SetDimension(m_SashList[SashIndex].Dimension); + newSash.SashList[SashIndex].SetMeasureType(m_SashList[SashIndex].MeasureType); + foreach (var Joint in m_SashList[SashIndex].JointList) + newSash.SashList[SashIndex].JointList.Add(Joint.Deserialize((Area)ParentArea)); } - foreach (var Joint in m_JointList) - newSash.JointList.Add(Joint.Deserialize((Area)ParentArea)); newSash.SetSelFamilyHardwareFromIndex(Hardware); - newSash.ReqRefreshShape(); + //newSash.ReqRefreshShape(); newSash.SetSelHardwareFromId(Hardware); foreach (var HwOption in m_HwOptionList) newSash.SelHwOptionList.Add(HwOption.Name, HwOption.Value); - //foreach (var HwOption in m_HwOptionList) - // newSash.HwOptionList.Add(HwOption.Deserialize()); + //if (ArcElement != null) + // newSash.SetSashArcElem(ArcElement.Deserialize(newSash, ParentWindow)); foreach (var Area in AreaList) { var AreaDeserealized = Area.Deserialize(newSash, ParentWindow); @@ -511,24 +528,24 @@ namespace WebWindowComplex.Json Split.SetSplitQtyVert(0); else { - //Split.SplitVertList.Clear(); Split.SetSplitQtyVert(m_SplitVertList.Count - 1); for (var SplitIndex = 0; SplitIndex <= m_SplitVertList.Count - 1; SplitIndex++) { Split.SplitVertList[SplitIndex].SetIsRelative(m_SplitVertList[SplitIndex].IsRelative); Split.SplitVertList[SplitIndex].SetDimension(m_SplitVertList[SplitIndex].Dimension); + Split.SplitVertList[SplitIndex].SetMeasureType(m_SplitVertList[SplitIndex].MeasureType); } } if (m_SplitHorizList.Count == 0) Split.SetSplitQtyHoriz(0); else { - //Split.SplitHorizList.Clear(); Split.SetSplitQtyHoriz(m_SplitHorizList.Count - 1); for (var SplitIndex = 0; SplitIndex <= m_SplitHorizList.Count - 1; SplitIndex++) { Split.SplitHorizList[SplitIndex].SetIsRelative(m_SplitHorizList[SplitIndex].IsRelative); Split.SplitHorizList[SplitIndex].SetDimension(m_SplitHorizList[SplitIndex].Dimension); + Split.SplitHorizList[SplitIndex].SetMeasureType(m_SplitHorizList[SplitIndex].MeasureType); } } foreach (var Area in AreaList) @@ -618,6 +635,107 @@ namespace WebWindowComplex.Json } } + //public class JsonFrameArcElement + //{ + // private double m_Section; + // [JsonProperty] + // public double Section + // { + // get + // { + // return m_Section; + // } + // set + // { + // m_Section = value; + // } + // } + + // private bool m_bCutEdge; + // [JsonProperty] + // public bool CutEdge + // { + // get + // { + // return m_bCutEdge; + // } + // set + // { + // m_bCutEdge = value; + // } + // } + + // private bool m_bIsAlign; + // [JsonProperty] + // public bool IsAlign + // { + // get + // { + // return m_bIsAlign; + // } + // set + // { + // m_bIsAlign = value; + // } + // } + + // public JsonFrameArcElement(double Section, bool CutEdge, bool IsAlign) + // { + // m_Section = Section; + // m_bCutEdge = CutEdge; + // m_bIsAlign = IsAlign; + // } + + // internal FrameArcElement Deserialize(Area ParentArea, Window ParentWindow) + // { + // FrameArcElement arcElement = new FrameArcElement(ParentArea, ParentWindow, m_Section, m_bCutEdge, m_bIsAlign); + // return arcElement; + // } + //} + + //public class JsonSashArcElement + //{ + // private double m_Section; + // [JsonProperty] + // public double Section + // { + // get + // { + // return m_Section; + // } + // set + // { + // m_Section = value; + // } + // } + + // private bool m_bCutEdge; + // [JsonProperty] + // public bool CutEdge + // { + // get + // { + // return m_bCutEdge; + // } + // set + // { + // m_bCutEdge = value; + // } + // } + + // public JsonSashArcElement(double Section, bool CutEdge) + // { + // m_Section = Section; + // m_bCutEdge = CutEdge; + // } + + // internal SashArcElement Deserialize(Area ParentArea, Window ParentWindow) + // { + // SashArcElement arcElement = new SashArcElement(ParentArea, ParentWindow, m_Section, m_bCutEdge); + // return arcElement; + // } + //} + public class JsonJoint { private int m_nIndex; @@ -769,17 +887,14 @@ namespace WebWindowComplex.Json } } - private bool m_bHasHandle; + private MeasureTypes m_MeasureType; [JsonProperty] - public bool HasHandle + [JsonConverter(typeof(StringEnumConverter))] + public MeasureTypes MeasureType { get { - return m_bHasHandle; - } - set - { - m_bHasHandle = value; + return m_MeasureType; } } @@ -797,9 +912,38 @@ namespace WebWindowComplex.Json } } - public JsonSashDimension(Openings OpeningType, bool HasHandle, double Dimension, int SashId) + private bool m_bHasHandle; + [JsonProperty] + public bool HasHandle + { + get + { + return m_bHasHandle; + } + set + { + m_bHasHandle = value; + } + } + + private List m_JointList = new List(); + [JsonProperty] + public List JointList + { + get + { + return m_JointList; + } + set + { + m_JointList = value; + } + } + + public JsonSashDimension(Openings OpeningType, MeasureTypes MeasureType, bool HasHandle, double Dimension, int SashId) { m_OpeningType = OpeningType; + m_MeasureType = MeasureType; m_bHasHandle = HasHandle; m_dDimension = Dimension; m_nSashId = SashId; @@ -832,10 +976,22 @@ namespace WebWindowComplex.Json } } - public JsonSplitDimension(bool IsRelative, double Dimension) + private MeasureTypes m_MeasureType; + [JsonProperty] + [JsonConverter(typeof(StringEnumConverter))] + public MeasureTypes MeasureType + { + get + { + return m_MeasureType; + } + } + + public JsonSplitDimension(bool IsRelative, double Dimension, MeasureTypes MeasureType) { m_bIsRelative = IsRelative; m_dDimension = Dimension; + m_MeasureType = MeasureType; } } diff --git a/WebWindowComplex/Json/WindowConst.cs b/WebWindowComplex/Json/WindowConst.cs index 34a7e29..e691ed2 100644 --- a/WebWindowComplex/Json/WindowConst.cs +++ b/WebWindowComplex/Json/WindowConst.cs @@ -121,7 +121,7 @@ namespace WebWindowComplex.Json public enum MeasureTypes: int { NULL = 0, - ABSOLUT = 1, + ABSOLUTE = 1, PROPORTIONAL = 2, PERCENTAGE = 3 } diff --git a/WebWindowComplex/LayoutConst.cs b/WebWindowComplex/LayoutConst.cs index 28b2951..e563965 100644 --- a/WebWindowComplex/LayoutConst.cs +++ b/WebWindowComplex/LayoutConst.cs @@ -15,7 +15,8 @@ namespace WebWindowComplex Split, Sash, Fill, - General + General, + ArcElement } public enum PositionJoints @@ -25,5 +26,22 @@ namespace WebWindowComplex TR, // Top Right TL // Top Left } + + public enum DataAction + { + /// + /// Nessuna richiesta + /// + None = 0, + + /// + /// Reset dizionario shape + /// + ResetDictShape, + /// + /// Reset dizionario HwOptions + /// + ResetHwOpt + } } } diff --git a/WebWindowComplex/Models/AGBOptionText.cs b/WebWindowComplex/Models/AGBOptionText.cs index fb6cbc5..85b7762 100644 --- a/WebWindowComplex/Models/AGBOptionText.cs +++ b/WebWindowComplex/Models/AGBOptionText.cs @@ -54,7 +54,9 @@ namespace WebWindowComplex.Models { foreach (var Value in HdwOptionParam.Opzioni) m_ValueList.Add(Value.Valore); - m_sValue = m_ValueList.FirstOrDefault(x => x == HdwOptionParam.ValoreCorrente) ?? ""; + m_sValue = m_ValueList.FirstOrDefault(x => x == HdwOptionParam.ValoreCorrente); + if (string.IsNullOrEmpty(m_sValue)) + m_sValue = m_ValueList.FirstOrDefault(); } else { diff --git a/WebWindowComplex/Models/Area.cs b/WebWindowComplex/Models/Area.cs index 26ee675..7ccbb24 100644 --- a/WebWindowComplex/Models/Area.cs +++ b/WebWindowComplex/Models/Area.cs @@ -69,7 +69,7 @@ namespace WebWindowComplex.Models set { m_nAreaId = value; - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + //m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } @@ -108,8 +108,15 @@ namespace WebWindowComplex.Models SashArea.SetSelFamilyHardware(""); // Inserisco hardware di default SashArea.SetSelHardwareFromId("000000"); + //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 - List ContentArea = new List(); + List ContentArea = new List(); ContentArea.Add(AreaList[0]); AreaList.Remove(AreaList[0]); // Aggiungo area @@ -118,7 +125,7 @@ namespace WebWindowComplex.Models AreaList[0].AreaList.Add(ContentArea[0]); AreaList[0].AreaList[0].SetParentArea(AreaList[0]); // Richiesta SVG con hardware di default - ParentWindow.OnUpdatePreview(ParentWindow.sSerialized()); + //ParentWindow.OnUpdatePreview(ParentWindow.sSerialized()); } public void AddSplit() @@ -157,7 +164,6 @@ namespace WebWindowComplex.Models // All'area Split aggiunto le due aree Splitted for (int i = 0; i < 2; i++) AreaList[0].AreaList.Add(newSplittedList[i]); - ParentWindow.OnUpdatePreview(ParentWindow.sSerialized()); } public abstract Area Copy(Area ParentArea); @@ -194,6 +200,164 @@ namespace WebWindowComplex.Models m_ParentArea = ParentArea; } + /// + /// Metodo per calcolare larghezza area + /// + /// area di partenza + /// larghezza di partenza + /// + internal double CalculateWidthArea(Area area, double width) + { + for (int i = 0; i < area.AreaList.Count; i++) + { + double risultato = -1; + if (area.Equals(this)) + return width; + Area item = area.AreaList[i]; + if (area is Split) + { + Split split = (Split)area; + if (split.SplitVertList.Count > 0) + { + switch (split.SplitVertList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + risultato = CalculateWidthArea(item, split.SplitVertList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PROPORTIONAL: + { + //risultato = CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PERCENTAGE: + { + risultato = CalculateWidthArea(item, split.SplitVertList.ElementAt(i).dDimension * width / 100); + break; + } + } + } + else + { + risultato = CalculateWidthArea(item, width); + } + if (risultato != -1) + return risultato; + } + else if (area is Sash) + { + Sash sash = (Sash)area; + switch (sash.SashList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + risultato = CalculateWidthArea(item, sash.SashList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PROPORTIONAL: + { + //risultato = CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PERCENTAGE: + { + risultato = CalculateWidthArea(item, sash.SashList.ElementAt(i).dDimension * width / 100); + break; + } + } + if (risultato != -1) + return risultato; + } + else + { + risultato = CalculateWidthArea(item, width); + if (risultato != -1) + return risultato; + } + } + return width; + } + + /// + /// Metodo per calcolare larghezza area + /// + /// area di partenza + /// altezza di partenza + /// + internal double CalculateHeightArea(Area area, double height) + { + for (int i = 0; i < area.AreaList.Count; i++) + { + double risultato = -1; + if (area.Equals(this)) + return height; + Area item = area.AreaList[i]; + if (area is Split) + { + Split split = (Split)area; + if (split.SplitHorizList.Count > 0) + { + switch (split.SplitHorizList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + risultato = CalculateHeightArea(item, split.SplitHorizList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PROPORTIONAL: + { + //risultato = CalculateHeighthArea(item, split.SplitHorizList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PERCENTAGE: + { + risultato = CalculateHeightArea(item, split.SplitHorizList.ElementAt(i).dDimension * height / 100); + break; + } + } + } + else + { + risultato = CalculateHeightArea(item, height); + } + if (risultato != -1) + return risultato; + } + else if (area is Sash) + { + Sash sash = (Sash)area; + switch (sash.SashList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + risultato = CalculateHeightArea(item, sash.SashList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PROPORTIONAL: + { + //risultato = CalculateHeighthArea(item, sash.SashList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PERCENTAGE: + { + risultato = CalculateHeightArea(item, sash.SashList.ElementAt(i).dDimension * height / 100); + break; + } + } + if (risultato != -1) + return risultato; + } + else + { + risultato = CalculateHeightArea(item, height); + if (risultato != -1) + return risultato; + } + } + return height; + } + #endregion Internal Methods #region Protected Fields diff --git a/WebWindowComplex/Models/Fill.cs b/WebWindowComplex/Models/Fill.cs index 27cb798..30beb75 100644 --- a/WebWindowComplex/Models/Fill.cs +++ b/WebWindowComplex/Models/Fill.cs @@ -52,7 +52,6 @@ namespace WebWindowComplex.Models set { m_SelFillType = (FillTypes)IdNameStruct.IdFromInd(value, m_FillTypeList); - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } @@ -97,7 +96,6 @@ namespace WebWindowComplex.Models internal void SetSelFillType(FillTypes value) { m_SelFillType = value; - //m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } internal void SetFillType(FillTypes value) { diff --git a/WebWindowComplex/Models/Frame.cs b/WebWindowComplex/Models/Frame.cs index 3e231f5..692fca8 100644 --- a/WebWindowComplex/Models/Frame.cs +++ b/WebWindowComplex/Models/Frame.cs @@ -20,6 +20,18 @@ namespace WebWindowComplex.Models #region Public Properties + //public FrameArcElement? FrameArcElem + //{ + // get + // { + // return m_FrameArcElem; + // } + // set + // { + // m_FrameArcElem = value!; + // } + //} + public bool BottomRail { get @@ -29,7 +41,6 @@ namespace WebWindowComplex.Models set { m_bBottomRail = value; - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } @@ -53,7 +64,6 @@ namespace WebWindowComplex.Models m_bBottomRail = false; } } - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } @@ -79,12 +89,10 @@ namespace WebWindowComplex.Models { get { - //return IdNameStruct.IndFromId((int)m_Shape, m_ShapeList); return (int)m_Shape; } set { - //Shapes SelShape = (Shapes)IdNameStruct.IdFromInd(value, m_ShapeList); Shapes SelShape = (Shapes)value; if (m_Shape != SelShape) { @@ -100,7 +108,7 @@ namespace WebWindowComplex.Models case Shapes.ARC_FULL: { DimensionList.Add(new FrameDimension(this, 1, "Width", widthVal, true)); - DimensionList.Add(new FrameDimension(this, 2, "Height", 1800, true)); + DimensionList.Add(new FrameDimension(this, 2, "Height", 1400, true)); break; } @@ -124,7 +132,7 @@ namespace WebWindowComplex.Models case Shapes.ARC: { DimensionList.Add(new FrameDimension(this, 1, "Width", widthVal, true)); - DimensionList.Add(new FrameDimension(this, 2, "Height", 1500, true)); + DimensionList.Add(new FrameDimension(this, 2, "Height", 1800 - (0.4 * widthVal), true)); DimensionList.Add(new FrameDimension(this, 3, "Full Height", 1800, true)); break; } @@ -132,7 +140,7 @@ namespace WebWindowComplex.Models case Shapes.DOUBLEARC: { DimensionList.Add(new FrameDimension(this, 1, "Width", widthVal, true)); - DimensionList.Add(new FrameDimension(this, 2, "Height", 1500, true)); + DimensionList.Add(new FrameDimension(this, 2, "Height", 2400 - (0.6 * widthVal), true)); DimensionList.Add(new FrameDimension(this, 3, "Full Height", 2400, true)); break; } @@ -162,6 +170,9 @@ namespace WebWindowComplex.Models } // salvo tipo Joint List oldJointType = new List(JointList); + // salvo la lista di sash + List sashList = new List(); + SearchSash(sashList, this); // aggiungo Joint m_JointList.Clear(); switch (SelShape) @@ -176,7 +187,10 @@ namespace WebWindowComplex.Models JointList.Add(new Joint(this, 1, oldJointType[0].SelJointType)); JointList.Add(new Joint(this, 2, oldJointType[1].SelJointType)); JointList.Add(new Joint(this, 3, oldJointType[2].SelJointType)); - JointList.Add(new Joint(this, 4, oldJointType[3].SelJointType)); + if(oldJointType.Count > 3) + JointList.Add(new Joint(this, 4, oldJointType[3].SelJointType)); + else + JointList.Add(new Joint(this, 4, Joints.FULL_V)); break; } @@ -202,21 +216,70 @@ namespace WebWindowComplex.Models JointList.Add(new Joint(this, 1, oldJointType[0].SelJointType)); JointList.Add(new Joint(this, 2, oldJointType[1].SelJointType)); JointList.Add(new Joint(this, 3, Joints.ANGLED)); + foreach(var s in sashList) + { + foreach(var sashDim in s.SashList) + { + sashDim.JointList.RemoveAt(sashDim.JointList.Count - 1); + sashDim.JointList.Last().SelJointType = Joints.ANGLED; + } + } break; } - case Shapes.CUSTOM: { JointList.Clear(); break; } } + if(JointList.Count > 3) + { + foreach (var s in sashList) + { + foreach(var sashDim in s.SashList) + { + if (sashDim.JointList.Count == 3) + sashDim.JointList.Add(new Joint(s, 4, Joints.FULL_V)); + } + } + } + //switch (SelShape) + //{ + // case Shapes.RECTANGLE: + // case Shapes.RIGHTCHAMFER: + // case Shapes.LEFTCHAMFER: + // case Shapes.DOUBLECHAMFER: + // case Shapes.TRIANGLE: + // { + // FrameArcElem = null; + // foreach (var s in sashList) + // s.SashArcElem = null; + // break; + // } + //} m_Shape = SelShape; } - //m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } + protected List SearchSash(List sashList,Area node) + { + 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; + } + public Shapes Shape { get @@ -246,14 +309,20 @@ namespace WebWindowComplex.Models #region Internal Methods + //internal void SetFrameArcElem(FrameArcElement arcElement) + //{ + // m_FrameArcElem = arcElement; + //} + internal static Area CreateFrame(Window Window) { - Frame NewFrame = new Frame(null, Window); - NewFrame.SetAreaType(AreaTypes.FRAME); - NewFrame.SetSelShape(Shapes.RECTANGLE); - NewFrame.SetBottomRail(false); - NewFrame.SetBottomRailQty(0); - return NewFrame; + Frame newFrame = new Frame(null, Window); + newFrame.SetAreaType(AreaTypes.FRAME); + newFrame.SetSelShape(Shapes.RECTANGLE); + newFrame.SetBottomRail(false); + newFrame.SetBottomRailQty(0); + //newFrame.FrameArcElem = null; + return newFrame; } internal override JsonArea Serialize(bool hideHw) @@ -262,6 +331,10 @@ namespace WebWindowComplex.Models if (nCounterGroup < GroupId) Area.nCounterGroup = GroupId; JsonFrame JsonFrame = new JsonFrame(m_Shape, m_bBottomRail, m_nBottomRailQty, GroupId); + //if (FrameArcElem != null) + // JsonFrame.ArcElement = FrameArcElem.Serialize(); + //else + // JsonFrame.ArcElement = null; foreach (var Dimension in DimensionList) JsonFrame.DimensionList.Add(Dimension.Serialize()); foreach (var Joint in JointList) @@ -400,6 +473,8 @@ namespace WebWindowComplex.Models #region Private Fields + //private FrameArcElement m_FrameArcElem = new FrameArcElement(); + private bool m_bBottomRail; private List m_DimensionList = new List(); diff --git a/WebWindowComplex/Models/FrameArcElement.cs b/WebWindowComplex/Models/FrameArcElement.cs new file mode 100644 index 0000000..6202099 --- /dev/null +++ b/WebWindowComplex/Models/FrameArcElement.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using WebWindowComplex.Json; +using static WebWindowComplex.Json.WindowConst; + +namespace WebWindowComplex.Models +{ + public class FrameArcElement + { + #region Public Constructors + + public FrameArcElement() { } + + public FrameArcElement(Area ParentArea, Window ParentWindow, double nSection, bool bCutEdge, bool bIsAlign) + { + m_ParentArea = ParentArea; + m_ParentWindow = ParentWindow; + m_nSection = nSection; + m_bCutEdge = bCutEdge; + m_bIsAlign = bIsAlign; + } + + #endregion Public Constructors + + #region Public Properties + + public int nQty + { + get + { + return m_nQty; + } + set + { + m_nQty = value; + } + } + + public double nSection + { + get + { + return m_nSection; + } + set + { + m_nSection = value; + } + } + + public bool bCutEdge + { + get + { + return m_bCutEdge; + } + set + { + m_bCutEdge = value; + } + } + + public bool bIsAlign + { + get + { + return m_bIsAlign; + } + set + { + m_bIsAlign = value; + } + } + + #endregion Public Properties + + #region Internal Methods + + internal void SetQty(int Qty) + { + m_nQty = Qty; + } + + internal void SetSection(double Section) + { + m_nSection = Section; + } + + //internal JsonFrameArcElement Serialize() + //{ + // JsonFrameArcElement jArcElement = new JsonFrameArcElement(nSection, bCutEdge, bIsAlign); + // return jArcElement; + //} + + #endregion Internal Methods + + #region Protected Fields + + protected Area m_ParentArea; + protected Window m_ParentWindow; + + #endregion Protected Fields + + #region Private Fields + + private double m_nSection; + + private int m_nQty; + + private bool m_bCutEdge = false; + + private bool m_bIsAlign = false; + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/WebWindowComplex/Models/FrameDimension.cs b/WebWindowComplex/Models/FrameDimension.cs index 6c6feac..ef3c347 100644 --- a/WebWindowComplex/Models/FrameDimension.cs +++ b/WebWindowComplex/Models/FrameDimension.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using WebWindowComplex.Json; +using static WebWindowComplex.Json.WindowConst; namespace WebWindowComplex.Models { @@ -32,16 +33,102 @@ namespace WebWindowComplex.Models } set { - m_dValue = value; - if (value > MaxDim) + if(m_dValue != value) { - m_dValue = MaxDim; + if (ParentFrame.SelShapeIndex == (int)Shapes.RECTANGLE || + ParentFrame.SelShapeIndex == (int)Shapes.RIGHTCHAMFER || + ParentFrame.SelShapeIndex == (int)Shapes.LEFTCHAMFER || + ParentFrame.SelShapeIndex == (int)Shapes.DOUBLECHAMFER || + ParentFrame.SelShapeIndex == (int)Shapes.TRIANGLE) + { + if (value > MaxDim) + { + m_dValue = MaxDim; + } + else if (value < MinDim && !m_sName.Equals("Radius") && !m_sName.Equals("Height projection")) + { + m_dValue = MinDim; + } + else + m_dValue = value; + } + else + { + if (ParentFrame.SelShapeIndex == (int)Shapes.ARC_FULL) + { + var width = ParentFrame.DimensionList.First(x => x.sName.Equals("Width")).dValue; + var height = ParentFrame.DimensionList.First(x => x.sName.Equals("Height")).dValue; + if (sName.Equals("Height") && value > 0.5 * width && value < MaxDim) + { + m_dValue = value; + } + else if (sName.Equals("Width") && height > 0.5 * value && value > MinDim) + { + m_dValue = value; + } + } + else if (ParentFrame.SelShapeIndex == (int)Shapes.ARC) + { + var width = ParentFrame.DimensionList.First(x => x.sName.Equals("Width")).dValue; + var height = ParentFrame.DimensionList.First(x => x.sName.Equals("Height")).dValue; + var fullHeight = ParentFrame.DimensionList.First(x => x.sName.Equals("Full Height")).dValue; + if (sName.Equals("Full Height") && (value - height) < 0.5 * width && value < MaxDim) + { + m_dValue = value; + } + else if (sName.Equals("Height") && (fullHeight - value) < 0.5 * width && value < MaxDim) + { + m_dValue = value; + } + else if (sName.Equals("Width") && (fullHeight - height) < 0.5 * value && value < MaxDim) + { + m_dValue = value; + } + } + else if (ParentFrame.SelShapeIndex == (int)Shapes.THREECENTERARC) + { + var width = ParentFrame.DimensionList.First(x => x.sName.Equals("Width")).dValue; + var height = ParentFrame.DimensionList.First(x => x.sName.Equals("Height")).dValue; + var fullHeight = ParentFrame.DimensionList.First(x => x.sName.Equals("Full Height")).dValue; + if (sName.Equals("Full Height") && (value - height) < 0.5 * width && value < MaxDim) + { + m_dValue = value; + } + else if (sName.Equals("Height") && (fullHeight - value) < 0.5 * width && value < MaxDim) + { + m_dValue = value; + } + else if (sName.Equals("Width") && (fullHeight - height) < 0.5 * value) + { + m_dValue = value; + } + else if (sName.Equals("Radius") && value < 0.5 * width) + { + m_dValue = value; + } + } + else if (ParentFrame.SelShapeIndex == (int)Shapes.DOUBLEARC) + { + var width = ParentFrame.DimensionList.First(x => x.sName.Equals("Width")).dValue; + var height = ParentFrame.DimensionList.First(x => x.sName.Equals("Height")).dValue; + var fullHeight = ParentFrame.DimensionList.First(x => x.sName.Equals("Full Height")).dValue; + if (sName.Equals("Full Height") && (value - height) > 0.5 * width && value < MaxDim) + { + m_dValue = value; + } + else if (sName.Equals("Height") && (fullHeight - value) > 0.5 * width && value < MaxDim) + { + m_dValue = value; + } + else if (sName.Equals("Width") && (fullHeight - height) > 0.5 * value && value > MinDim) + { + m_dValue = value; + } + } + } + if (ParentFrame.AreaList.Count > 0) + SearchAreaList(ParentFrame); } - else if (value < MinDim && !m_sName.Equals("Radius")) - { - m_dValue = MinDim; - } - m_ParentFrame.ParentWindow.OnUpdatePreview(m_ParentFrame.ParentWindow.sSerialized()); } } @@ -73,12 +160,160 @@ namespace WebWindowComplex.Models #region Internal Methods + /// + /// Cerca nell'albero gli oggetti Sash e Split per associare la larghezza + /// + /// + protected void SearchAreaList(Area node) + { + if (node != null) + { + if (node.AreaType.Equals(AreaTypes.SASH)) + UpdateDimSubArea((Sash)node); + else if (node.AreaType.Equals(AreaTypes.SPLIT)) + UpdateDimSubArea((Split)node); + foreach (var item in node.AreaList) + { + SearchAreaList(item); + } + } + } + + protected void UpdateDimSubArea(Area area) + { + if(area is Sash && sName.Equals("Width")) + { + Sash sash = (Sash)area; + 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(); + if (countAbsolute == sash.SashList.Count) + { + double sum = sash.SashList.Sum(x => x.dDimension); + double res = dValue - sum; + if (res > 0) + { + foreach (var sashDim in sash.SashList) + { + sashDim.SetDimension(sashDim.dDimension + res / countAbsolute); + } + } + else + { + foreach (var sashDim in sash.SashList) + { + // Sommo perchè res è negativo + sashDim.SetDimension(sashDim.dDimension + res / countAbsolute); + } + } + } + else if (countAbsolute < sash.SashList.Count) + { + if (countPercentage > 0 && countPercentage <= sash.SashList.Count && countProportional == 0) + { + double widthTot = ParentFrame.CalculateWidthArea(ParentFrame, ParentFrame.DimensionList.First(x => x.m_sName.Equals("Width")).dValue); + 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(ConvertIn((widthTot - sumAbsolute) / countPercentage, i.MeasureType, widthTot, sash)); + } + } + } + } + else if(area is Split) + { + Split split = (Split)area; + List splitList = null; + if (sName.Equals("Width")) + splitList = split.SplitVertList; + else + splitList = split.SplitHorizList; + int countAbsolute = splitList.Where(x => x.MeasureType.Equals(MeasureTypes.ABSOLUTE)).Count(); + if (countAbsolute != 0 && countAbsolute == splitList.Count) + { + double sum = splitList.Sum(x => x.dDimension); + double res = dValue - sum; + if (res > 0) + { + foreach (var sashDim in splitList) + { + sashDim.SetDimension(sashDim.dDimension + res / countAbsolute); + } + } + else + { + foreach (var sashDim in splitList) + { + // Sommo perchè res è negativo + sashDim.SetDimension(sashDim.dDimension + res / countAbsolute); + } + } + } + } + } + + internal void SetDimension(double dValue) + { + m_dValue = dValue; + } + internal JsonFrameDimension Serialize() { JsonFrameDimension JsonFrameDimension = new JsonFrameDimension(m_nIndex, m_sName, m_dValue); return JsonFrameDimension; } + /// + /// Metodo per convertire una dimensione da un valore assoluto al suo rispettivo tipo + /// + /// Valore assoluto + /// Tipo di misura della dimensione + /// Larghezza totale + /// + internal double ConvertIn(double absoluteVal, MeasureTypes type, double widthTot, Sash sash) + { + switch (type) + { + case MeasureTypes.ABSOLUTE: + { + return absoluteVal; + } + case MeasureTypes.PROPORTIONAL: + { + return ProportionalFromAbsoluteVal(absoluteVal, widthTot, sash); + } + case MeasureTypes.PERCENTAGE: + { + return (absoluteVal / widthTot) * 100; + } + } + return -1; + } + + /// + /// Metodo per trasformare il valore proporzionale in assoluto + /// + /// + internal double ProportionalFromAbsoluteVal(double absoluteVal, double widthTot, Sash sash) + { + double tot = widthTot; + //Somma misura non proporzionali + double sumNotProp = sash.SashList + .Where(m => m.MeasureType != MeasureTypes.PROPORTIONAL) + .Sum(m => m.CalculateAbsoluteValue(tot)); + //Calcolo residuo + double res = tot - sumNotProp; + if (res < 0) res = 0; + //Misure proporzionali + var proportionalList = sash.SashList + .Where(m => m.SelMeasureType == MeasureTypes.PROPORTIONAL) + .ToList(); + double sumPesi = proportionalList.Sum(p => p.dDimension); + if (sumPesi == 0) sumPesi = 1; + return res / sumPesi * absoluteVal; + } + #endregion Internal Methods #region Protected Fields diff --git a/WebWindowComplex/Models/Joint.cs b/WebWindowComplex/Models/Joint.cs index b15340e..ba05570 100644 --- a/WebWindowComplex/Models/Joint.cs +++ b/WebWindowComplex/Models/Joint.cs @@ -63,14 +63,11 @@ namespace WebWindowComplex.Models { get { - //return IdNameStruct.IndFromId((int)m_SelJointType, m_JointTypeList); return (int)m_SelJointType; } set { - //m_SelJointType = (Joints)IdNameStruct.IdFromInd(value, m_JointTypeList); m_SelJointType = (Joints)value; - m_ParentArea.ParentWindow.OnUpdatePreview(m_ParentArea.ParentWindow.sSerialized()); } } diff --git a/WebWindowComplex/ParametriOpzioni.cs b/WebWindowComplex/Models/ParametriOpzioni.cs similarity index 54% rename from WebWindowComplex/ParametriOpzioni.cs rename to WebWindowComplex/Models/ParametriOpzioni.cs index 90c5c39..4a52bef 100644 --- a/WebWindowComplex/ParametriOpzioni.cs +++ b/WebWindowComplex/Models/ParametriOpzioni.cs @@ -4,23 +4,23 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace WebWindowComplex +namespace WebWindowComplex.Models { public partial class ParametriOpzioni { private ParametriOpzioniParametri[] itemsField; /// - [System.Xml.Serialization.XmlElementAttribute("Parametri", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + [System.Xml.Serialization.XmlElement("Parametri", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] public ParametriOpzioniParametri[] Items { get { - return this.itemsField; + return itemsField; } set { - this.itemsField = value; + itemsField = value; } } } @@ -42,100 +42,100 @@ namespace WebWindowComplex private ParametriOpzioniParametriOpzioni[] opzioniField; /// - [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + [System.Xml.Serialization.XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] public string NomeParametro { get { - return this.nomeParametroField; + return nomeParametroField; } set { - this.nomeParametroField = value; + nomeParametroField = value; } } /// - [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + [System.Xml.Serialization.XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] public string DescrizioneParametro { get { - return this.descrizioneParametroField; + return descrizioneParametroField; } set { - this.descrizioneParametroField = value; + descrizioneParametroField = value; } } /// - [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + [System.Xml.Serialization.XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] public string ValoreCorrente { get { - return this.valoreCorrenteField; + return valoreCorrenteField; } set { - this.valoreCorrenteField = value; + valoreCorrenteField = value; } } /// - [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + [System.Xml.Serialization.XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] public string Tipo { get { - return this.tipoField; + return tipoField; } set { - this.tipoField = value; + tipoField = value; } } /// - [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + [System.Xml.Serialization.XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] public string Visible { get { - return this.visibleField; + return visibleField; } set { - this.visibleField = value; + visibleField = value; } } /// - [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + [System.Xml.Serialization.XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] public string RicalcolaSeModificato { get { - return this.ricalcolaSeModificatoField; + return ricalcolaSeModificatoField; } set { - this.ricalcolaSeModificatoField = value; + ricalcolaSeModificatoField = value; } } /// - [System.Xml.Serialization.XmlElementAttribute("Opzioni", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + [System.Xml.Serialization.XmlElement("Opzioni", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] public ParametriOpzioniParametriOpzioni[] Opzioni { get { - return this.opzioniField; + return opzioniField; } set { - this.opzioniField = value; + opzioniField = value; } } } @@ -149,44 +149,44 @@ namespace WebWindowComplex private string valoreField; /// - [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + [System.Xml.Serialization.XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] public string NomeParametro { get { - return this.nomeParametroField; + return nomeParametroField; } set { - this.nomeParametroField = value; + nomeParametroField = value; } } /// - [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + [System.Xml.Serialization.XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] public string DescrizioneOpzione { get { - return this.descrizioneOpzioneField; + return descrizioneOpzioneField; } set { - this.descrizioneOpzioneField = value; + descrizioneOpzioneField = value; } } /// - [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] + [System.Xml.Serialization.XmlElement(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] public string Valore { get { - return this.valoreField; + return valoreField; } set { - this.valoreField = value; + valoreField = value; } } } diff --git a/WebWindowComplex/Models/Sash.cs b/WebWindowComplex/Models/Sash.cs index 1ba799b..54163a8 100644 --- a/WebWindowComplex/Models/Sash.cs +++ b/WebWindowComplex/Models/Sash.cs @@ -46,14 +46,6 @@ namespace WebWindowComplex.Models } } - //public bool bIsPercentage - //{ - // get - // { - // return m_bIsPercentage; - // } - //} - public bool bIsSashVertical { get @@ -66,6 +58,18 @@ namespace WebWindowComplex.Models } } + //public SashArcElement? SashArcElem + //{ + // get + // { + // return m_SashArcElement; + // } + // set + // { + // m_SashArcElement = value!; + // } + //} + public List HardwareList { get @@ -78,7 +82,7 @@ namespace WebWindowComplex.Models { get { - return m_HwdOptionList; + return m_HwOptionList; } } @@ -86,19 +90,7 @@ namespace WebWindowComplex.Models { get { - return m_SelHwdOptionList; - } - } - - public List JointList - { - get - { - return m_JointList; - } - set - { - m_JointList = value; + return m_SelHwOptionList; } } @@ -112,15 +104,18 @@ namespace WebWindowComplex.Models { if (value > 0 && value <= 3) { + double widthTot = CalculateWidthArea(ParentWindow.AreaList.First(), ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dValue); if (value > m_SashList.Count) { // recupero larghezza ultimo - double dLastDimension = 100; - double dNewDimension = 100; + double dLastDimension = widthTot; + double dNewDimension = widthTot; if (m_SashList.Count > 0) { dLastDimension = m_SashList[m_SashList.Count - 1].dDimension; dNewDimension = dLastDimension / (value + 1 - nSashQty); + if (m_SashList[m_SashList.Count - 1].MeasureType.Equals(MeasureTypes.PROPORTIONAL)) + dNewDimension = 1; m_SashList[m_SashList.Count - 1].SetDimension(dNewDimension); } else @@ -128,7 +123,12 @@ namespace WebWindowComplex.Models // aggiungo area Sash di default for (var SplitIndex = m_SashList.Count; SplitIndex <= value - 1; SplitIndex++) { - SashList.Add(new SashDimension(dNewDimension, MeasureTypes.PERCENTAGE, this, SplitIndex + 1)); + var addSashDim = new SashDimension(dNewDimension, m_SashList[m_SashList.Count - 1].MeasureType, this, SplitIndex + 1); + for(int i = 1; i <= 4; i++) + { + addSashDim.JointList.Add(new Joint(this, i, Joints.FULL_V)); + } + SashList.Add(addSashDim); } } else if (value < m_SashList.Count) @@ -136,12 +136,20 @@ namespace WebWindowComplex.Models if (value > 0) { double dLastDimension = 0; + SashDimension itemDelete = null; + double deleteDim; for (var SplitIndex = m_SashList.Count - 1; SplitIndex >= value; SplitIndex += -1) { - dLastDimension += m_SashList[SplitIndex].dDimension; + //dLastDimension += m_SashList[SplitIndex].dDimension; + itemDelete = m_SashList[SplitIndex]; SashList.RemoveAt(SplitIndex); } - dLastDimension += m_SashList[SashList.Count - 1].dDimension; + if (!itemDelete.SelMeasureType.Equals(m_SashList[SashList.Count - 1].SelMeasureType)) + deleteDim = itemDelete.ConvertDimension(itemDelete.SelMeasureType, m_SashList[SashList.Count - 1].SelMeasureType, widthTot); + else + deleteDim = itemDelete.dDimension; + //dLastDimension += m_SashList[SashList.Count - 1].dDimension; + dLastDimension = deleteDim + m_SashList[SashList.Count - 1].dDimension; SashList[SashList.Count - 1].SetDimension(dLastDimension); if (value == 1) SashList.First().SetHasHandle(true); @@ -221,11 +229,8 @@ namespace WebWindowComplex.Models } } RefreshHardwareList(); - RefreshHardwareOptionList(); + ClearHardwareOptionList(); SetFirstHardware(); - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); - ReqRefreshHwOption(); - //m_ParentWindow.OnReqHwOptionPreview(m_ParentWindow.sSerialized(), GroupId); } } @@ -277,7 +282,6 @@ namespace WebWindowComplex.Models { m_bSashBottomRail = false; } - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } } @@ -315,7 +319,6 @@ namespace WebWindowComplex.Models set { SetSelFamilyHardware(value); - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } @@ -330,8 +333,7 @@ namespace WebWindowComplex.Models m_SelHardware = value; if (HwOptionList.Count != 0) { - RefreshHardwareOptionList(); - ReqRefreshHwOption(); + ClearHardwareOptionList(); } } } @@ -350,8 +352,6 @@ namespace WebWindowComplex.Models { SelHwOptionList.Clear(); } - ReqRefreshHwOption(); - //ParentWindow.OnUpdatePreview(ParentWindow.sSerialized()); } } @@ -371,12 +371,10 @@ namespace WebWindowComplex.Models { get { - //return IdNameStruct.IndFromId((int)m_SelOrientationSashType, m_OrientationSashTypeList); return (int)m_SelOrientationSashType; } set { - //m_SelOrientationSashType = (OrientationSash)IdNameStruct.IdFromInd(value, m_OrientationSashTypeList); m_SelOrientationSashType = (OrientationSash)value; if (value == 0) { @@ -386,7 +384,7 @@ namespace WebWindowComplex.Models { m_bIsSashVertical = false; } - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + //m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } @@ -411,10 +409,6 @@ namespace WebWindowComplex.Models newSash.SetIsSashVertical(bIsSashVertical); newSash.SetOrientationSashType(OrientationSashType); newSash.SetSashBottomRailQty(SashBottomRailQty); - newSash.SetSelFamilyHardwareFromIndex(m_SelHardware.Id); - newSash.ReqRefreshShape(); - newSash.RefreshHardwareOptionList(); - newSash.SetSelHardware(m_SelHardware); for (int i = 0; i < SashList.Count; i++) { //Cancello SashDimension di default e aggiungo la copia @@ -422,16 +416,20 @@ namespace WebWindowComplex.Models SashDimension newSashDim = SashList[i].Copy(); newSash.SashList.Insert(i, newSashDim); } - foreach (var item in JointList) - { - Joint newJoint = item.Copy(); - newSash.JointList.Add(newJoint); - } foreach (var item in AreaList) { Area newArea = item.Copy(newSash); newSash.AreaList.Add(newArea); } + newSash.SetSelFamilyHardwareFromIndex(m_SelHardware.Id); + newSash.SetSelHardwareFromId(CustomHwId); + //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) + // newSash.SashArcElem = new SashArcElement(newSash, ParentWindow, 10, true); + //else + // newSash.SashArcElem = null; return newSash; } @@ -444,6 +442,8 @@ namespace WebWindowComplex.Models { m_HardwareList.Clear(); Enums.OpeningTypes sOpeningType = ConvertOpeningType(); + if (string.IsNullOrEmpty(m_SelFamilyHardware)) + m_SelFamilyHardware = s_FamilyHardwareList.FirstOrDefault(); var iComp = StringComparison.InvariantCultureIgnoreCase; var rawList = m_HardwareCompleteList .Where(x => x.Id == "000000" || @@ -454,43 +454,51 @@ namespace WebWindowComplex.Models x.OpeningType == sOpeningType) ) .ToList() ?? new List(); + if(rawList.Count == 0 || rawList == null) + { + Hardware hw = new Hardware(CustomHwId, m_SelFamilyHardware, "Custom", sOpeningType, m_CurrShape, nSashQty, 1); + rawList.Add(hw); + } m_HardwareList = new List(rawList); } } + /// + /// Metodo per rimuovere l'intero sash group + /// public void Remove() { ParentArea.AreaList.Remove(this); Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS); newFill.SetAreaType(AreaTypes.FILL); ParentArea.AreaList.Add(newFill); - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + //m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } - /// - /// Richiesta calcolo shape corrente - /// - public void ReqRefreshShape() - { - if (m_HardwareCompleteList != null && m_HardwareCompleteList.Count > 0) - { - m_HardwareList.Clear(); - // reset shape corrente - m_CurrShape = ""; - // chiamata evento calcolo shape: gruppo da calcolare - m_ParentWindow.OnReqShapePreview(m_ParentWindow.sSerialized(), GroupId); - } - } + ///// + ///// Richiesta calcolo shape corrente + ///// + //public void ReqRefreshShape() + //{ + // if (m_HardwareCompleteList != null && m_HardwareCompleteList.Count > 0) + // { + // m_HardwareList.Clear(); + // // reset shape corrente + // m_CurrShape = ""; + // // chiamata evento calcolo shape: gruppo da calcolare + // } + //} - /// - /// Richiesta calcolo hardware option list - /// - public void ReqRefreshHwOption() - { - HwOptionList.Clear(); - // chiamata evento calcolo opzioni hardware - m_ParentWindow.OnReqHwOptionPreview(m_ParentWindow.sSerialized(), GroupId); - } + ///// + ///// Richiesta calcolo hardware option list + ///// + //public void ReqRefreshHwOption() + //{ + // HwOptionList.Clear(); + // m_ReqHwOption = true; + // // chiamata evento calcolo opzioni hardware + // //m_ParentWindow.OnReqHwOptionPreview(m_ParentWindow.sSerialized(), GroupId); + //} public void SetSelFamilyHardware(string sFamilyHw) { @@ -502,10 +510,7 @@ namespace WebWindowComplex.Models } SetFirstHardware(); if (HwOptionList.Count != 0) - { - RefreshHardwareOptionList(); - ReqRefreshHwOption(); - } + ClearHardwareOptionList(); } /// @@ -520,38 +525,118 @@ namespace WebWindowComplex.Models if(string.IsNullOrEmpty(m_SelFamilyHardware) || m_SelFamilyHardware == "") { var listHwValid = Sash.m_HardwareCompleteList - .Where(x => x.Shape == m_CurrShape && - x.SashQty == nSashQty && - x.OpeningType == ConvertOpeningType() - ) - .FirstOrDefault(); + .FirstOrDefault(x => x.Shape == m_CurrShape && + x.SashQty == nSashQty && + x.OpeningType == ConvertOpeningType() + ); if(listHwValid == null) { noHwValid = true; var familyHwValid = Sash.m_HardwareCompleteList .Select(x => x.FamilyName) .First(); + SelHardwareFromId = "000000"; + ClearHardwareOptionList(); } else + { SetSelFamilyHardware(listHwValid.FamilyName); - } - if (noHwValid) - { - SelHardwareFromId = "000000"; + } } else { RefreshHardwareList(); // se il vecchio hw selezionato non va più bene viene selezionato il primo della lista if (!HardwareList.Contains(m_SelHardware) || m_SelHardware.Shape != m_CurrShape) + { SetFirstHardware(); + ClearHardwareOptionList(); + } } } #endregion Public Methods #region Internal Methods - + + ///// + ///// Metodo per calcolare larghezza intera sash group + ///// + ///// area di partenza + ///// larghezza di partenza + ///// + //internal double CalculateWidthSashGroup(Area area, double width) + //{ + // for (int i = 0; i < area.AreaList.Count; i++) + // { + // double risultato = -1; + // if (area.Equals(this)) + // return width; + // Area item = area.AreaList[i]; + // if (area is Split) + // { + // Split split = (Split)area; + // if(split.SplitVertList.Count > 0) + // { + // switch (split.SplitVertList.ElementAt(i).SelMeasureType) + // { + // case MeasureTypes.ABSOLUTE: + // { + // risultato = CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension); + // break; + // } + // case MeasureTypes.PROPORTIONAL: + // { + // //risultato = CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension); + // break; + // } + // case MeasureTypes.PERCENTAGE: + // { + // risultato = CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension * width / 100); + // break; + // } + // } + // } + // else + // { + // risultato = CalculateWidthSashGroup(item, width); + // } + // if (risultato != -1) + // return risultato; + // } + // else if (area is Sash) + // { + // Sash sash = (Sash)area; + // switch (sash.SashList.ElementAt(i).SelMeasureType) + // { + // case MeasureTypes.ABSOLUTE: + // { + // risultato = CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension); + // break; + // } + // case MeasureTypes.PROPORTIONAL: + // { + // //risultato = CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension); + // break; + // } + // case MeasureTypes.PERCENTAGE: + // { + // risultato = CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension * width / 100); + // break; + // } + // } + // if (risultato != -1) + // return risultato; + // } + // else + // { + // risultato = CalculateWidthSashGroup(item, width); + // if (risultato != -1) + // return risultato; + // } + // } + // return width; + //} internal static Sash CreateSash(Area Area) { Sash newSash = new Sash(Area, Area.ParentWindow); @@ -561,13 +646,17 @@ namespace WebWindowComplex.Models newSash.SetSashQty(1); newSash.SetOrientationSashType(OrientationSash.VERTICAL); newSash.SetIsSashVertical(true); - for (var JointIndex = 0; JointIndex <= 3; JointIndex++) - newSash.JointList.Add(new Joint(newSash, JointIndex + 1, Joints.FULL_H)); + foreach(var sashDim in newSash.SashList) + { + for (var JointIndex = 0; JointIndex <= 3; JointIndex++) + sashDim.JointList.Add(new Joint(newSash, JointIndex + 1, Joints.FULL_V)); + } newSash.SetSashBottomRail(false); newSash.SetSashBottomRailQty(0); newSash.SetSelFamilyHardware(Sash.s_FamilyHardwareList.First()); - newSash.RefreshHardwareOptionList(); + newSash.ClearHardwareOptionList(); newSash.SetFirstHardware(); + //newSash.SashArcElem = null; return newSash; } @@ -651,10 +740,9 @@ namespace WebWindowComplex.Models } } - internal void RefreshHardwareOptionList() + internal void ClearHardwareOptionList() { - m_HwdOptionList.Clear(); - //ReqRefreshHwOption(); + m_HwOptionList.Clear(); } internal override JsonArea Serialize(bool hideHw) @@ -665,8 +753,6 @@ namespace WebWindowComplex.Models JsonSash JsonSash = new JsonSash(m_bIsSashVertical, m_SashType, m_bSashBottomRail, m_nSashBottomRailQty, currHwId, GroupId); foreach (var SashDimension in SashList) JsonSash.SashList.Add(SashDimension.Serialize()); - foreach (var Joint in JointList) - JsonSash.JointList.Add(Joint.Serialize()); if(HwOptionList.Count > 0) { foreach (var HwOption in HwOptionList) @@ -677,11 +763,20 @@ namespace WebWindowComplex.Models foreach (var HwOption in SelHwOptionList) JsonSash.HwOptionList.Add(new JsonHwOption(HwOption.Key, HwOption.Value)); } + //if (SashArcElem != null) + // JsonSash.ArcElement = SashArcElem.Serialize(); + //else + // JsonSash.ArcElement = null; foreach (var Area in AreaList) JsonSash.AreaList.Add(Area.Serialize(hideHw)); return JsonSash; } + //internal void SetSashArcElem(SashArcElement arcElement) + //{ + // m_SashArcElement = arcElement; + //} + internal void SetFirstHardware() { if (m_HardwareList.Count > 0) @@ -718,19 +813,19 @@ namespace WebWindowComplex.Models HwOptions = (ParametriOpzioni)serializer.Deserialize(reader); if (HwOptions.Items != null) { - m_HwdOptionList.Clear(); + m_HwOptionList.Clear(); foreach (var HwOption in HwOptions.Items) { switch (HwOption.Tipo) { case "Text": { - m_HwdOptionList.Add(new AGBOptionText(HwOption)); + m_HwOptionList.Add(new AGBOptionText(HwOption)); break; } case "List": { - m_HwdOptionList.Add(new AGBOptionCombo(HwOption)); + m_HwOptionList.Add(new AGBOptionCombo(HwOption)); break; } } @@ -750,14 +845,18 @@ namespace WebWindowComplex.Models case HwOptionTypes.COMBO: { AGBOptionCombo OptCombo = (AGBOptionCombo)HwOption; - var selValue = OptCombo.ValueList.Where(x => x.sValue == selHwOption).First(); - OptCombo.sValue = selValue; + var selValue = OptCombo.ValueList.Where(x => x.sValue == selHwOption).FirstOrDefault(); + if (selValue != null) + OptCombo.sValue = selValue; + else + OptCombo.sValue = OptCombo.ValueList.First(); break; } case HwOptionTypes.TEXT: { AGBOptionText OptText = (AGBOptionText)HwOption; - OptText.sValue = selHwOption; + if(OptText.ValueList.FirstOrDefault(x => x.Equals(selHwOption)) != null) + OptText.sValue = selHwOption; break; } } @@ -804,7 +903,12 @@ namespace WebWindowComplex.Models dNewDimension = dLastDimension / (Qty + 1 - nSashQty); // aggiungo area Sash di default for (var SplitIndex = m_SashList.Count; SplitIndex <= Qty - 1; SplitIndex++) - SashList.Add(new SashDimension(dNewDimension, MeasureTypes.PERCENTAGE, this, SplitIndex + 1)); + { + SashDimension newSashDim = new SashDimension(dNewDimension, MeasureTypes.PERCENTAGE, this, SplitIndex + 1); + //for (var JointIndex = 0; JointIndex <= 3; JointIndex++) + // newSashDim.JointList.Add(new Joint(this, JointIndex + 1, Joints.FULL_H)); + SashList.Add(newSashDim); + } } else if (Qty < m_SashList.Count) { @@ -833,11 +937,6 @@ namespace WebWindowComplex.Models return SelFamilyHardware; } - internal void SetSelHardware(Hardware value) - { - SelHardware = value; - } - internal void SetSelHardwareFromId(string sId) { if (m_HardwareList.Count == 0) @@ -871,10 +970,10 @@ namespace WebWindowComplex.Models private string m_CurrShape = ""; private List m_HardwareList = new List(); - private List m_HwdOptionList = new List(); - private Dictionary m_SelHwdOptionList = new Dictionary(); + private List m_HwOptionList = new List(); + private Dictionary m_SelHwOptionList = new Dictionary(); - private List m_JointList = new List(); + //private List m_JointList = new List(); private int m_nSashBottomRailQty; @@ -886,9 +985,10 @@ namespace WebWindowComplex.Models private List m_SashList = new List(); private SashTypes m_SashType; - private string m_SelFamilyHardware; + private string m_SelFamilyHardware = ""; private Hardware m_SelHardware; private OrientationSash m_SelOrientationSashType; + //private SashArcElement m_SashArcElement; #endregion Private Fields diff --git a/WebWindowComplex/Models/SashArcElement.cs b/WebWindowComplex/Models/SashArcElement.cs new file mode 100644 index 0000000..175524d --- /dev/null +++ b/WebWindowComplex/Models/SashArcElement.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using WebWindowComplex.Json; +using static WebWindowComplex.Json.WindowConst; + +namespace WebWindowComplex.Models +{ + public class SashArcElement + { + #region Public Constructors + + public SashArcElement() { } + + public SashArcElement(Area ParentArea, Window ParentWindow, double nSection, bool bCutEdge) + { + m_ParentArea = ParentArea; + m_ParentWindow = ParentWindow; + m_nSection = nSection; + m_bCutEdge = bCutEdge; + } + + #endregion Public Constructors + + #region Public Properties + + public int nQty + { + get + { + return m_nQty; + } + set + { + m_nQty = value; + } + } + + public double nSection + { + get + { + return m_nSection; + } + set + { + m_nSection = value; + } + } + + public bool bCutEdge + { + get + { + return m_bCutEdge; + } + set + { + m_bCutEdge = value; + } + } + + #endregion Public Properties + + #region Internal Methods + + //internal JsonSashArcElement Serialize() + //{ + // JsonSashArcElement jArcElement = new JsonSashArcElement(nSection, bCutEdge); + // return jArcElement; + //} + + #endregion Internal Methods + + #region Protected Fields + + protected Area m_ParentArea; + protected Window m_ParentWindow; + + #endregion Protected Fields + + #region Private Fields + + private double m_nSection; + + private int m_nQty; + + private bool m_bCutEdge = false; + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/WebWindowComplex/Models/SashDimension.cs b/WebWindowComplex/Models/SashDimension.cs index 1f3350b..0738633 100644 --- a/WebWindowComplex/Models/SashDimension.cs +++ b/WebWindowComplex/Models/SashDimension.cs @@ -1,4 +1,6 @@ -using WebWindowComplex.Json; +using System.Runtime.InteropServices; +using System.Security.Principal; +using WebWindowComplex.Json; using static WebWindowComplex.Json.WindowConst; namespace WebWindowComplex.Models @@ -101,7 +103,18 @@ namespace WebWindowComplex.Models set { m_bHasHandle = value; - //m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); + } + } + + public List JointList + { + get + { + return m_JointList; + } + set + { + m_JointList = value; } } @@ -113,150 +126,159 @@ namespace WebWindowComplex.Models } set { - double valMax = 0; + double widthTot = CalculateWidthSashGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dValue); + double valMinAbsolute = 200; + double valMaxAbsolute = widthTot - valMinAbsolute * (m_Parent.SashList.Count - 1); bool valueAccept = false; switch (MeasureType) { - case MeasureTypes.ABSOLUT: + case MeasureTypes.ABSOLUTE: { - valMax = m_Parent.SashList.Sum(x => x.dDimension); - valueAccept = (value < valMax && value > 0) ? true: false; + valueAccept = (value < valMaxAbsolute && value > valMinAbsolute) ? true : false; break; } case MeasureTypes.PROPORTIONAL: { - valMax = m_Parent.SashList.Sum(x => x.dDimension); + valMaxAbsolute = 20; + valueAccept = (value >= 1) ? true : false; break; } case MeasureTypes.PERCENTAGE: { - valMax = 100; - valueAccept = (value < valMax && value > 0) ? true : false; + valMaxAbsolute = valMaxAbsolute / widthTot * 100; + valMinAbsolute = valMinAbsolute / widthTot * 100; + valueAccept = (value < valMaxAbsolute && value > valMinAbsolute) ? true : false; break; } } - if (!MeasureType.Equals(MeasureTypes.PROPORTIONAL)) + if (valueAccept) { - if (valueAccept) + List dimensions = m_Parent.SashList; + List absoluteValList = new List(); + foreach (var item in m_Parent.SashList) { - - // verifico se ci sono altri in percentuale - List DimList = m_Parent.SashList.Where(x => x.MeasureType.Equals(MeasureType)).ToList(); - if (DimList.Count > 0) + absoluteValList.Add(item.CalculateAbsoluteValue(widthTot)); + } + int nIndex = dimensions.IndexOf(this); + int proportionalCount = dimensions.Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count; + int percentageCount = dimensions.Where(x => x.MeasureType.Equals(MeasureTypes.PERCENTAGE)).ToList().Count; + // Le dimensioni sono solo in proporzionale + if (proportionalCount == absoluteValList.Count || SelMeasureType.Equals(MeasureTypes.PROPORTIONAL) || + (SelMeasureType.Equals(MeasureTypes.ABSOLUTE) && proportionalCount == absoluteValList.Count -1)) + { + m_dDimension = value; + } + // Le dimensioni sono solo in percentuale + else if (percentageCount == dimensions.Count) + { + if (value < dDimension) { - int nIndex = DimList.IndexOf(this); - // se diminuisce dimensione - if (value < m_dDimension) - { - if (nIndex < DimList.Count - 1) - DimList[nIndex + 1].SetDimension(DimList[nIndex + 1].dDimension + (m_dDimension - value)); - else if (DimList.Count > 1) - DimList[nIndex - 1].SetDimension(DimList[nIndex - 1].dDimension + (m_dDimension - value)); - else - { - m_dDimension = valMax; - return; - } - } - // se aumenta dimensione + // L'anta modificata non è l'ultima + if (nIndex < dimensions.Count - 1) + dimensions[nIndex + 1].SetDimension(dimensions[nIndex + 1].dDimension + (m_dDimension - value)); + else if (dimensions.Count > 1) + dimensions[nIndex - 1].SetDimension(dimensions[nIndex - 1].dDimension + (m_dDimension - value)); else { - double dRes = value; - // se non ultima anta - if (nIndex < DimList.Count - 1) + m_dDimension = 100; + return; + } + } + else + { + double dRes = value; + // se non ultima anta + if (nIndex < dimensions.Count - 1) + { + for (var nInd = 0; nInd <= nIndex - 1; nInd++) + dRes += dimensions[nInd].dDimension; + dRes = (100 - dRes) / (dimensions.Count - nIndex - 1); + for (var Ind = nIndex + 1; Ind <= dimensions.Count - 1; Ind++) + dimensions[Ind].SetDimension(dRes); + } + // se ultima anta + else if (dimensions.Count > 1) + { + if (dimensions.Count > 2) { - for (var nInd = 0; nInd <= nIndex - 1; nInd++) - dRes += DimList[nInd].dDimension; - dRes = (100 - dRes) / (DimList.Count - nIndex - 1); - for (var Ind = nIndex + 1; Ind <= DimList.Count - 1; Ind++) - DimList[Ind].SetDimension(dRes); - } - // se ultima anta - else if (DimList.Count > 1) - { - if (DimList.Count > 2) - { - for (var Ind = 0; Ind <= nIndex - 2; Ind++) - dRes += DimList[Ind].dDimension; - } - dRes = (valMax - dRes); - DimList[nIndex - 1].SetDimension(dRes); - } - else - { - m_dDimension = valMax; - return; + for (var Ind = 0; Ind <= nIndex - 2; Ind++) + dRes += dimensions[Ind].dDimension; } + dRes = (100 - dRes); + dimensions[nIndex - 1].SetDimension(dRes); + } + else + { + m_dDimension = 100; + return; } } m_dDimension = value; - m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); + } + // Le dimensioni sono miste o solo in assoluto + else + { + double valueInAbsolute = 0; + switch (MeasureType) + { + case MeasureTypes.ABSOLUTE: + { + valueInAbsolute = value; + break; + } + case MeasureTypes.PROPORTIONAL: + { + var pesi = value + dimensions + .Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL) && !x.Equals(this)) + .Sum(x => x.m_dDimension); + valueInAbsolute = widthTot / pesi * value; + break; + } + case MeasureTypes.PERCENTAGE: + { + valueInAbsolute = (value / 100) * widthTot; + break; + } + } + if (value < dDimension) + { + // L'anta modificata non è l'ultima + if (nIndex < absoluteValList.Count - 1) + { + absoluteValList[nIndex + 1] = absoluteValList[nIndex + 1] + (absoluteValList[nIndex] - valueInAbsolute); + absoluteValList[nIndex] = valueInAbsolute; + } + // L'anta modificata è l'ultima + else if (dimensions.Count > 1) + { + absoluteValList[nIndex - 1] = absoluteValList[nIndex - 1] + (absoluteValList[nIndex] - valueInAbsolute); + absoluteValList[nIndex] = valueInAbsolute; + } + } + else + { + // L'anta modificata non è l'ultima + if (nIndex < absoluteValList.Count - 1) + { + absoluteValList[nIndex + 1] = absoluteValList[nIndex + 1] - (valueInAbsolute - absoluteValList[nIndex]); + absoluteValList[nIndex] = valueInAbsolute; + } + // L'anta modificata è l'ultima + else if (dimensions.Count > 1) + { + absoluteValList[nIndex - 1] = absoluteValList[nIndex - 1] - (valueInAbsolute - absoluteValList[nIndex]); + absoluteValList[nIndex] = valueInAbsolute; + } + } + if (MeasureType.Equals(MeasureTypes.PROPORTIONAL)) + m_dDimension = value; + for (int i = 0; i < absoluteValList.Count; i++) + { + var item = m_Parent.SashList.ElementAt(i); + item.SetDimension(ConvertIn(absoluteValList[i], (MeasureTypes)item.SelMeasureTypeIndex, widthTot)); + } } } - else - { - m_dDimension = value; - m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); - } - //// se sono in percentuale - //if (m_MeasureType.Equals(MeasureTypes.PERCENTAGE)) - //{ - // // Controllo che il valore inserito sia compreso tra 0 e 100 - // if (value > 0 && value < 100) - // { - // // verifico se ci sono altri in percentuale - // List RelativeDimList = m_Parent.SashList.Where(x => x.MeasureType.Equals(MeasureTypes.PERCENTAGE)).ToList(); - // if (RelativeDimList.Count > 0) - // { - // int nIndex = RelativeDimList.IndexOf(this); - // // se diminuisce dimensione - // if (value < m_dDimension) - // { - // if (nIndex < RelativeDimList.Count - 1) - // RelativeDimList[nIndex + 1].SetDimension(RelativeDimList[nIndex + 1].dDimension + (m_dDimension - value)); - // else if (RelativeDimList.Count > 1) - // RelativeDimList[nIndex - 1].SetDimension(RelativeDimList[nIndex - 1].dDimension + (m_dDimension - value)); - // else - // { - // m_dDimension = 100; - // return; - // } - // } - // // se aumenta dimensione - // else - // { - // double dRes = value; - // // se non ultima anta - // if (nIndex < RelativeDimList.Count - 1) - // { - // for (var nInd = 0; nInd <= nIndex - 1; nInd++) - // dRes += RelativeDimList[nInd].dDimension; - // dRes = (100 - dRes) / (RelativeDimList.Count - nIndex - 1); - // for (var Ind = nIndex + 1; Ind <= RelativeDimList.Count - 1; Ind++) - // RelativeDimList[Ind].SetDimension(dRes); - // } - // // se ultima anta - // else if (RelativeDimList.Count > 1) - // { - // if (RelativeDimList.Count > 2) - // { - // for (var Ind = 0; Ind <= nIndex - 2; Ind++) - // dRes += RelativeDimList[Ind].dDimension; - // } - // dRes = (100 - dRes); - // RelativeDimList[nIndex - 1].SetDimension(dRes); - // } - // else - // { - // m_dDimension = 100; - // return; - // } - // } - // } - // } - // m_dDimension = value; - // m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); - //} } } @@ -293,8 +315,7 @@ namespace WebWindowComplex.Models set { m_SelOpeningType = value; - m_Parent.ReqRefreshShape(); - m_Parent.RefreshHardwareOptionList(); + m_Parent.ClearHardwareOptionList(); m_Parent.SetFirstHardware(); } } @@ -303,22 +324,19 @@ namespace WebWindowComplex.Models { get { - //return IdNameStruct.IndFromId((int)m_SelOpeningType, m_OpeningTypeList); return (int)m_SelOpeningType; } set { - //Openings newOpening = (Openings)IdNameStruct.IdFromInd(value, m_OpeningTypeList); Openings newOpening = (Openings)value; if ((newOpening != Openings.TILTTURN_LEFT && newOpening != Openings.TILTTURN_RIGHT) || (newOpening == Openings.TILTTURN_LEFT && m_bHasHandle) || (newOpening == Openings.TILTTURN_RIGHT && m_bHasHandle)) { m_SelOpeningType = newOpening; - m_Parent.ReqRefreshShape(); - m_Parent.RefreshHardwareOptionList(); + m_Parent.ClearHardwareOptionList(); + m_Parent.RefreshHardwareList(); m_Parent.SetFirstHardware(); - m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); } } } @@ -359,7 +377,13 @@ namespace WebWindowComplex.Models } set { - m_SelMeasureType = (MeasureTypes)value; + if(m_SelMeasureType != (MeasureTypes)value) + { + MeasureTypes newType = (MeasureTypes)value; + double widthTot = CalculateWidthSashGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dValue); + m_dDimension = ConvertDimension(m_SelMeasureType, newType, widthTot); + m_SelMeasureType = (MeasureTypes)value; + } } } @@ -367,12 +391,72 @@ namespace WebWindowComplex.Models #region Public Methods + /// + /// Metodo per convertire la dimensione dal vecchio tipo al nuovo tipo + /// + /// Vecchio tipo + /// Nuovo tipo + /// + public double ConvertDimension(MeasureTypes oldType, MeasureTypes newType, double widthTot) + { + switch (oldType) + { + case MeasureTypes.ABSOLUTE: + { + if (newType.Equals(MeasureTypes.PERCENTAGE)) + { + //return Double.Round((m_dDimension / m_Parent.Width) * 100, 1); + return (m_dDimension / widthTot) * 100; + } + else + { + return CalculatePropVal(widthTot); + } + } + case MeasureTypes.PROPORTIONAL: + { + if (newType.Equals(MeasureTypes.ABSOLUTE)) + { + //return Double.Round(ConvertFromPropVal(newType), 2); + return ConvertFromPropVal(newType, widthTot); + } + else + { + //return Double.Round(ConvertFromPropVal(newType), 1); + return ConvertFromPropVal(newType, widthTot); + } + } + case MeasureTypes.PERCENTAGE: + { + if (newType.Equals(MeasureTypes.ABSOLUTE)) + { + //return Double.Round((m_dDimension * m_Parent.Width) / 100, 2); + return (m_dDimension * widthTot) / 100; + } + else + { + return CalculatePropVal(widthTot); + } + } + } + return -1; + } + + /// + /// Metodo per copiare l'intero oggetto + /// + /// public SashDimension Copy() { SashDimension newSashDim = new SashDimension(dDimension, MeasureType, m_Parent, m_nSashId); newSashDim.SetMeasureType(MeasureType); newSashDim.SetOpeningType(SelOpeningType); newSashDim.SetHasHandle(bHasHandle); + foreach (var item in JointList) + { + Joint newJoint = item.Copy(); + newSashDim.JointList.Add(newJoint); + } return newSashDim; } @@ -380,9 +464,257 @@ namespace WebWindowComplex.Models #region Internal Methods + /// + /// Metodo per calcolare larghezza intera sash group + /// + /// area di partenza + /// larghezza di partenza + /// + internal double CalculateWidthSashGroup(Area area, double width) + { + for(int i = 0; i < area.AreaList.Count; i++) + { + double risultato = -1; + if (area.Equals(m_Parent)) + return width; + Area item = area.AreaList[i]; + if (area is Split) + { + Split split = (Split)area; + if (split.SplitVertList.Count > 0) + { + switch (split.SplitVertList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + risultato = CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PROPORTIONAL: + { + //risultato = CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PERCENTAGE: + { + risultato = CalculateWidthSashGroup(item, split.SplitVertList.ElementAt(i).dDimension * width / 100); + break; + } + } + if (risultato != -1) + return risultato; + } + else + { + risultato = CalculateWidthSashGroup(item, width); + } + } + else if (area is Sash) + { + Sash sash = (Sash)area; + switch (sash.SashList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + risultato = CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PROPORTIONAL: + { + //risultato = CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PERCENTAGE: + { + risultato = CalculateWidthSashGroup(item, sash.SashList.ElementAt(i).dDimension * width / 100); + break; + } + } + if (risultato != -1) + return risultato; + } + else + { + risultato = CalculateWidthSashGroup(item, width); + if (risultato != -1) + return risultato; + } + } + return width; + } + + /// + /// Calcolo MCD + /// + /// + /// + /// + internal static double CalculateMCD(double a, double b) + { + while (b >= 0.01) + { + double temp = b; + b = a % b; + a = temp; + } + //return Double.Round(a,2); + return a; + } + + /// + /// Metodo per ricalcolare i valori proporzionali a causa della modifica di uno + /// + /// + internal double CalculatePropVal(double widthTot) + { + if (m_Parent.SashList.Where(m => m.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count == 0) + { + return 1; + } + List absoluteValue = new List(); + foreach (var item in m_Parent.SashList) + { + absoluteValue.Add(item.CalculateAbsoluteValue(widthTot)); + } + for (int i = 0; i < m_Parent.SashList.Count; i++) + { + if (!m_Parent.SashList.ElementAt(i).Equals(this) && + m_Parent.SashList.ElementAt(i).MeasureType.Equals(MeasureTypes.PROPORTIONAL)) + { + int nIndex = m_Parent.SashList.IndexOf(this); + if (absoluteValue.ElementAt(nIndex) <= absoluteValue.ElementAt(i)) + { + var mcd = CalculateMCD(absoluteValue.ElementAt(nIndex), absoluteValue.ElementAt(i)); + m_Parent.SashList.ElementAt(i).m_dDimension = absoluteValue.ElementAt(i) / mcd; + m_dDimension = absoluteValue.ElementAt(nIndex) / mcd; + } + else + { + var mcd = CalculateMCD(absoluteValue.ElementAt(nIndex), absoluteValue.ElementAt(i)); + m_Parent.SashList.ElementAt(i).m_dDimension = absoluteValue.ElementAt(i) / mcd; + m_dDimension = absoluteValue.ElementAt(nIndex) / mcd; + } + break; + } + } + return m_dDimension; + } + + /// + /// Metodo per trasformare una dimensione in valore assoluto rispetto alla larghezza totale + /// + /// Larghezza totale + /// + internal double CalculateAbsoluteValue(double widthTot) + { + switch (MeasureType) + { + case MeasureTypes.ABSOLUTE: + { + //return Double.Round(dDimension, 2); + return dDimension; + } + case MeasureTypes.PROPORTIONAL: + { + //return Double.Round(Proportional2AbsolutVal(), 2); + return ProportionalFromAbsoluteVal(widthTot); + } + case MeasureTypes.PERCENTAGE: + { + //return Double.Round((dDimension / 100) * widthTot, 1); + return (dDimension / 100) * widthTot; + } + } + return 0; + } + + /// + /// Metodo per convertire una dimensione da un valore assoluto al suo rispettivo tipo + /// + /// Valore assoluto + /// Tipo di misura della dimensione + /// Larghezza totale + /// + internal double ConvertIn(double absoluteVal, MeasureTypes type, double widthTot) + { + switch (type) + { + case MeasureTypes.ABSOLUTE: + { + return absoluteVal; + } + case MeasureTypes.PROPORTIONAL: + { + return ProportionalFromAbsoluteVal(widthTot); + } + case MeasureTypes.PERCENTAGE: + { + return (absoluteVal / widthTot) * 100; + } + } + return -1; + } + + /// + /// Metodo per convertire da misura proporzionale a misura assoluta o percentuale + /// + /// + /// + internal double ConvertFromPropVal(MeasureTypes newType, double widthTot) + { + double tot = widthTot; + //Somma misura non proporzionali + double sumNotProp = m_Parent.SashList + .Where(m => m.MeasureType != MeasureTypes.PROPORTIONAL && !m.Equals(this)) + .Sum(m => m.CalculateAbsoluteValue(tot)); + //Calcolo residuo + double res = tot - sumNotProp; + if (res < 0) res = 0; + //Misure proporzionali + var proportionalList = m_Parent.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 * dDimension; + } + else + { + return (res / sumPesi * dDimension) / tot * 100; + } + } + + /// + /// Metodo per trasformare il valore proporzionale in assoluto + /// + /// + internal double ProportionalFromAbsoluteVal(double widthTot) + { + double tot = widthTot; + //Somma misura non proporzionali + double sumNotProp = m_Parent.SashList + .Where(m => m.MeasureType != MeasureTypes.PROPORTIONAL) + .Sum(m => m.CalculateAbsoluteValue(tot)); + //Calcolo residuo + double res = tot - sumNotProp; + if (res < 0) res = 0; + //Misure proporzionali + var proportionalList = m_Parent.SashList + .Where(m => m.SelMeasureType == MeasureTypes.PROPORTIONAL) + .ToList(); + double sumPesi = proportionalList.Sum(p => p.dDimension); + if (sumPesi == 0) sumPesi = 1; + return res / sumPesi * dDimension; + } + internal JsonSashDimension Serialize() { - JsonSashDimension JsonSashDimension = new JsonSashDimension(OpeningType, m_bHasHandle, m_dDimension, m_nSashId); + JsonSashDimension JsonSashDimension = new JsonSashDimension(OpeningType, MeasureType, m_bHasHandle, m_dDimension, m_nSashId); + foreach (var Joint in JointList) + JsonSashDimension.JointList.Add(Joint.Serialize()); return JsonSashDimension; } @@ -406,6 +738,17 @@ namespace WebWindowComplex.Models m_SelMeasureType = value; } + internal void SetSelMeasureType(MeasureTypes value) + { + if (m_SelMeasureType != (MeasureTypes)value) + { + MeasureTypes newType = (MeasureTypes)value; + double widthTot = CalculateWidthSashGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dValue); + m_dDimension = ConvertDimension(m_SelMeasureType, newType, widthTot); + m_SelMeasureType = (MeasureTypes)value; + } + } + #endregion Internal Methods #region Private Fields @@ -447,7 +790,7 @@ namespace WebWindowComplex.Models private List m_MeasureTypeList = new List { - new IdNameStruct((int)MeasureTypes.ABSOLUT, "Absolut"), + new IdNameStruct((int)MeasureTypes.ABSOLUTE, "Absolute"), new IdNameStruct((int)MeasureTypes.PROPORTIONAL, "Proportional"), new IdNameStruct((int)MeasureTypes.PERCENTAGE, "Percentage"), }; @@ -455,47 +798,13 @@ namespace WebWindowComplex.Models // reference private Sash m_Parent; + private List m_JointList = new List(); + private Openings m_SelOpeningType; private MeasureTypes m_SelMeasureType; #endregion Private Fields - #region Private Methods - - /// - /// Recupero della larghezza del frame - /// - /// - private double GetWidth() - { - double width = 0; - int indexSash = 0; - if (m_Parent.ParentArea != null && m_Parent.ParentArea.ParentArea != null && m_Parent.ParentArea.ParentArea is Split) - { - Split splitParent = (Split)m_Parent.ParentArea.ParentArea; - if(splitParent.SplitVertList.Count > 0) - { - for(int i = 0; i < splitParent.AreaList.Count; i++) - { - if (splitParent.AreaList[i].AreaList[0].Equals(this)) - { - indexSash = i; - } - - } - } - //int indexSash = splitParent.AreaList.Where(x => x.AreaList[0].Equals(this)); - } - else - { - Frame a = m_Parent.ParentWindow.AreaList[0]; - FrameDimension? fd = a.DimensionList.Where(x => x.sName == "Width").SingleOrDefault(); - width = fd.dValue; - } - return width; - } - - #endregion Private Methods } } \ No newline at end of file diff --git a/WebWindowComplex/Models/Split.cs b/WebWindowComplex/Models/Split.cs index 084f696..4169ecf 100644 --- a/WebWindowComplex/Models/Split.cs +++ b/WebWindowComplex/Models/Split.cs @@ -20,13 +20,13 @@ namespace WebWindowComplex.Models #region Public Properties - public bool bIsPercentage - { - get - { - return m_bIsPercentage; - } - } + //public bool bIsPercentage + //{ + // get + // { + // return m_bIsPercentage; + // } + //} public bool bSplitStartVert { @@ -37,7 +37,6 @@ namespace WebWindowComplex.Models set { m_bSplitStartVert = value; - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } @@ -49,81 +48,87 @@ namespace WebWindowComplex.Models } set { - if (value == 0) + if(value >= 0 && value < 6) { - for (var SplitIndex = m_SplitHorizList.Count - 1; SplitIndex >= value; SplitIndex += -1) - m_SplitHorizList.RemoveAt(SplitIndex); - if (nSplitQtyVert == 0) + if (value == 0) { - ParentArea.AreaList.Remove(this); - Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS); - newFill.SetAreaType(AreaTypes.FILL); - ParentArea.AreaList.Add(newFill); - } - else - SetSplitShape(SplitShapes.VERTICAL); - } - else - { - // Ricalcolo dimensioni aggiungendo split - if (value > m_SplitHorizList.Count - 1) - { - // recupero larghezza ultimo - double dLastDimension = 100; - double dNewDimension = 100; - if (m_SplitHorizList.Count > 0) + for (var SplitIndex = m_SplitHorizList.Count - 1; SplitIndex >= value; SplitIndex += -1) + m_SplitHorizList.RemoveAt(SplitIndex); + if (nSplitQtyVert == 0) { - dLastDimension = m_SplitHorizList[m_SplitHorizList.Count - 1].dDimension; - dNewDimension = dLastDimension / (value + 1 - nSplitQtyHoriz); - m_SplitHorizList[m_SplitHorizList.Count - 1].SetDimension(dNewDimension); + ParentArea.AreaList.Remove(this); + Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS); + newFill.SetAreaType(AreaTypes.FILL); + ParentArea.AreaList.Add(newFill); } else - dNewDimension = dLastDimension / (value + 1 - nSplitQtyHoriz); - // aggiungo area Split di default - for (var SplitIndex = m_SplitHorizList.Count; SplitIndex <= value; SplitIndex++) - m_SplitHorizList.Add(new SplitDimension(dNewDimension, true, this, false)); + SetSplitShape(SplitShapes.VERTICAL); } - // Ricalcolo dimensioni rimuovendo split else { - double dLastDimension = 0; - for (var SplitIndex = m_SplitHorizList.Count - 1; SplitIndex >= value + 1; SplitIndex += -1) + double heightTot = CalculateHeightArea(ParentWindow.AreaList.First(), HeightFrame()); + // Ricalcolo dimensioni aggiungendo split + if (value > m_SplitHorizList.Count - 1) { - dLastDimension += m_SplitHorizList[SplitIndex].dDimension; - m_SplitHorizList.RemoveAt(SplitIndex); + // recupero larghezza ultimo + double dLastDimension = heightTot; + double dNewDimension = heightTot; + if (m_SplitHorizList.Count > 0) + { + dLastDimension = m_SplitHorizList[m_SplitHorizList.Count - 1].dDimension; + dNewDimension = dLastDimension / (value + 1 - nSplitQtyHoriz); + if (m_SplitHorizList[m_SplitHorizList.Count - 1].MeasureType.Equals(MeasureTypes.PROPORTIONAL)) + dNewDimension = 1; + m_SplitHorizList[m_SplitHorizList.Count - 1].SetDimension(dNewDimension); + } + else + dNewDimension = dLastDimension / (value + 1 - nSplitQtyHoriz); + // aggiungo area Split di default + for (var SplitIndex = m_SplitHorizList.Count; SplitIndex <= value; SplitIndex++) + m_SplitHorizList.Add(new SplitDimension(dNewDimension, m_SplitHorizList[m_SplitHorizList.Count - 1].MeasureType, true, this, false)); } - dLastDimension += m_SplitHorizList[m_SplitHorizList.Count - 1].dDimension; - m_SplitHorizList[m_SplitHorizList.Count - 1].SetDimension(dLastDimension); - } - // Controllo quanti split verticali ci sono - int nVert = m_SplitVertList.Count > 0 ? m_SplitVertList.Count : 1; - // Se aggiungo split devo aggiungere vetro nell'area splitted aggiunta - for (var SplitIndex = AreaList.Count; SplitIndex <= (m_SplitHorizList.Count * nVert) - 1; SplitIndex++) - { - AreaList.Add(Splitted.CreateSplitted(this)); - Fill newFill = Fill.CreateFill(AreaList[SplitIndex], FillTypes.GLASS); - newFill.SetAreaType(AreaTypes.FILL); - AreaList[AreaList.Count - 1].AreaList.Add(newFill); - } - // Se ho più di uno split, elimino l'ultimo - if (AreaList.Count > 2) - { - int nAreaList = AreaList.Count - 1; - for (var SplitIndex = (m_SplitHorizList.Count * nVert); SplitIndex <= nAreaList; SplitIndex++) + // Ricalcolo dimensioni rimuovendo split + else { - AreaList.Remove(AreaList[AreaList.Count - 1]); + double dLastDimension = 0; + for (var SplitIndex = m_SplitHorizList.Count - 1; SplitIndex >= value + 1; SplitIndex += -1) + { + dLastDimension += m_SplitHorizList[SplitIndex].dDimension; + m_SplitHorizList.RemoveAt(SplitIndex); + } + dLastDimension += m_SplitHorizList[m_SplitHorizList.Count - 1].dDimension; + m_SplitHorizList[m_SplitHorizList.Count - 1].SetDimension(dLastDimension); + } + // Controllo quanti split verticali ci sono + int nVert = m_SplitVertList.Count > 0 ? m_SplitVertList.Count : 1; + // Se aggiungo split devo aggiungere vetro nell'area splitted aggiunta + for (var SplitIndex = AreaList.Count; SplitIndex <= (m_SplitHorizList.Count * nVert) - 1; SplitIndex++) + { + AreaList.Add(Splitted.CreateSplitted(this)); + Fill newFill = Fill.CreateFill(AreaList[SplitIndex], FillTypes.GLASS); + newFill.SetAreaType(AreaTypes.FILL); + AreaList[AreaList.Count - 1].AreaList.Add(newFill); + } + // Se ho più di uno split, elimino l'ultimo + if (AreaList.Count > 2) + { + int nAreaList = AreaList.Count - 1; + for (var SplitIndex = (m_SplitHorizList.Count * nVert); SplitIndex <= nAreaList; SplitIndex++) + { + AreaList.Remove(AreaList[AreaList.Count - 1]); + } + } + // Se elimino l'unico split presente + else + { + Splitted s = (Splitted)AreaList[0]; + s.SetParentArea(ParentArea); + ParentArea.AreaList.Add(s); + ParentArea.AreaList.Remove(this); } } - // Se elimino l'unico split presente - else - { - Splitted s = (Splitted)AreaList[0]; - s.SetParentArea(ParentArea); - ParentArea.AreaList.Add(s); - ParentArea.AreaList.Remove(this); - } + //m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } @@ -135,86 +140,91 @@ namespace WebWindowComplex.Models } set { - if (value == 0) + if (value >= 0 && value < 6) { - for (var SplitIndex = m_SplitVertList.Count - 1; SplitIndex >= value; SplitIndex += -1) - m_SplitVertList.RemoveAt(SplitIndex); - if (nSplitQtyHoriz == 0) + if (value == 0) { - ParentArea.AreaList.Remove(this); - Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS); - newFill.SetAreaType(AreaTypes.FILL); - ParentArea.AreaList.Add(newFill); - } - else - SetSplitShape(SplitShapes.HORIZONTAL); - } - else - { - // Ricalcolo dimensioni aggiungendo split - if (value > m_SplitVertList.Count - 1) - { - // recupero larghezza ultimo - double dLastDimension = 100; - double dNewDimension = 100; - if (m_SplitVertList.Count > 0) + for (var SplitIndex = m_SplitVertList.Count - 1; SplitIndex >= value; SplitIndex += -1) + m_SplitVertList.RemoveAt(SplitIndex); + if (nSplitQtyHoriz == 0) { - dLastDimension = m_SplitVertList[m_SplitVertList.Count - 1].dDimension; - dNewDimension = dLastDimension / (value + 1 - nSplitQtyVert); - m_SplitVertList[m_SplitVertList.Count - 1].SetDimension(dNewDimension); + ParentArea.AreaList.Remove(this); + Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS); + newFill.SetAreaType(AreaTypes.FILL); + ParentArea.AreaList.Add(newFill); } else - dNewDimension = dLastDimension / (value + 1 - nSplitQtyVert); - // aggiungo area Split di default - for (var SplitIndex = m_SplitVertList.Count; SplitIndex <= value; SplitIndex++) - m_SplitVertList.Add(new SplitDimension(dNewDimension, true, this, true)); + SetSplitShape(SplitShapes.HORIZONTAL); } - else if (value == 0) - { - m_SplitVertList.RemoveAt(1); - m_SplitVertList.RemoveAt(0); - } - // Ricalcolo dimensioni rimuovendo split else { - double dLastDimension = 0; - for (var SplitIndex = m_SplitVertList.Count - 1; SplitIndex >= value + 1; SplitIndex += -1) + double widthTot = CalculateWidthArea(ParentWindow.AreaList.First(), ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dValue); + // Ricalcolo dimensioni aggiungendo split + if (value > m_SplitVertList.Count - 1) { - dLastDimension += m_SplitVertList[SplitIndex].dDimension; - m_SplitVertList.RemoveAt(SplitIndex); + // recupero larghezza ultimo + double dLastDimension = widthTot; + double dNewDimension = widthTot; + if (m_SplitVertList.Count > 0) + { + dLastDimension = m_SplitVertList[m_SplitVertList.Count - 1].dDimension; + dNewDimension = dLastDimension / (value + 1 - nSplitQtyVert); + if (m_SplitVertList[m_SplitVertList.Count - 1].MeasureType.Equals(MeasureTypes.PROPORTIONAL)) + dNewDimension = 1; + m_SplitVertList[m_SplitVertList.Count - 1].SetDimension(dNewDimension); + } + else + dNewDimension = dLastDimension / (value + 1 - nSplitQtyVert); + // aggiungo area Split di default + for (var SplitIndex = m_SplitVertList.Count; SplitIndex <= value; SplitIndex++) + m_SplitVertList.Add(new SplitDimension(dNewDimension, m_SplitVertList[m_SplitVertList.Count - 1].MeasureType, true, this, true)); } - dLastDimension += m_SplitVertList[m_SplitVertList.Count - 1].dDimension; - m_SplitVertList[m_SplitVertList.Count - 1].SetDimension(dLastDimension); - } - // Controllo quanti split orizzontali ci sono - int nHoriz = m_SplitHorizList.Count > 0 ? m_SplitHorizList.Count : 1; - // Se aggiungo split devo aggiungere vetro nell'area splitted aggiunta - for (var SplitIndex = AreaList.Count; SplitIndex <= (m_SplitVertList.Count * nHoriz) - 1; SplitIndex++) - { - AreaList.Add(Splitted.CreateSplitted(this)); - Fill newFill = Fill.CreateFill(AreaList[SplitIndex], FillTypes.GLASS); - newFill.SetAreaType(AreaTypes.FILL); - AreaList[AreaList.Count - 1].AreaList.Add(newFill); - } - // Se ho più di uno split, elimino l'ultimo - if (AreaList.Count > 2) - { - int nAreaList = AreaList.Count - 1; - for (var SplitIndex = (m_SplitVertList.Count * nHoriz); SplitIndex <= nAreaList; SplitIndex++) + else if (value == 0) { - AreaList.Remove(AreaList[AreaList.Count - 1]); + m_SplitVertList.RemoveAt(1); + m_SplitVertList.RemoveAt(0); + } + // Ricalcolo dimensioni rimuovendo split + else + { + double dLastDimension = 0; + for (var SplitIndex = m_SplitVertList.Count - 1; SplitIndex >= value + 1; SplitIndex += -1) + { + dLastDimension += m_SplitVertList[SplitIndex].dDimension; + m_SplitVertList.RemoveAt(SplitIndex); + } + dLastDimension += m_SplitVertList[m_SplitVertList.Count - 1].dDimension; + m_SplitVertList[m_SplitVertList.Count - 1].SetDimension(dLastDimension); + } + // Controllo quanti split orizzontali ci sono + int nHoriz = m_SplitHorizList.Count > 0 ? m_SplitHorizList.Count : 1; + // Se aggiungo split devo aggiungere vetro nell'area splitted aggiunta + for (var SplitIndex = AreaList.Count; SplitIndex <= (m_SplitVertList.Count * nHoriz) - 1; SplitIndex++) + { + AreaList.Add(Splitted.CreateSplitted(this)); + Fill newFill = Fill.CreateFill(AreaList[SplitIndex], FillTypes.GLASS); + newFill.SetAreaType(AreaTypes.FILL); + AreaList[AreaList.Count - 1].AreaList.Add(newFill); + } + // Se ho più di uno split, elimino l'ultimo + if (AreaList.Count > 2) + { + int nAreaList = AreaList.Count - 1; + for (var SplitIndex = (m_SplitVertList.Count * nHoriz); SplitIndex <= nAreaList; SplitIndex++) + { + AreaList.Remove(AreaList[AreaList.Count - 1]); + } + } + // Se elimino l'unico split presente + else + { + Splitted s = (Splitted)AreaList[0]; + s.SetParentArea(ParentArea); + ParentArea.AreaList.Add(s); + ParentArea.AreaList.Remove(this); } - } - // Se elimino l'unico split presente - else - { - Splitted s = (Splitted)AreaList[0]; - s.SetParentArea(ParentArea); - ParentArea.AreaList.Add(s); - ParentArea.AreaList.Remove(this); } } - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } @@ -222,12 +232,10 @@ namespace WebWindowComplex.Models { get { - //return IdNameStruct.IndFromId((int)m_SelSplitShape, m_SplitShapeList); return (int)m_SelSplitShape; } set { - //m_SelSplitShape = (SplitShapes)IdNameStruct.IdFromInd(value, m_SplitShapeList); m_SelSplitShape = (SplitShapes)value; // Cancello elementi nello split e azzero quantità orizzontale e verticale AreaList.Clear(); @@ -262,7 +270,6 @@ namespace WebWindowComplex.Models newFill.SetAreaType(AreaTypes.FILL); AreaList[SplitIndex].AreaList.Add(newFill); } - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } } @@ -320,12 +327,16 @@ namespace WebWindowComplex.Models AddCounterGroup(); newSplit.SetGroupId(nCounterGroup); newSplit.SetSplitStartVert(bSplitStartVert); - newSplit.SetSplitQtyVert(nSplitQtyVert); for (int i = 0; i < SplitVertList.Count; i++) - newSplit.SplitVertList.ElementAt(i).SetDimension(SplitVertList.ElementAt(i).dDimension); - newSplit.SetSplitQtyHoriz(nSplitQtyHoriz); + newSplit.SplitVertList.Add(SplitVertList[i].Copy()); for (int i = 0; i < SplitHorizList.Count; i++) - newSplit.SplitHorizList.ElementAt(i).SetDimension(SplitHorizList.ElementAt(i).dDimension); + 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 AreaList) @@ -342,7 +353,7 @@ namespace WebWindowComplex.Models Fill newFill = Fill.CreateFill(ParentArea, FillTypes.GLASS); newFill.SetAreaType(AreaTypes.FILL); ParentArea.AreaList.Add(newFill); - m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); + //m_ParentWindow.OnUpdatePreview(m_ParentWindow.sSerialized()); } #endregion Public Methods @@ -405,7 +416,7 @@ namespace WebWindowComplex.Models dNewDimension = dLastDimension / (QtyHoriz + 1 - nSplitQtyHoriz); // aggiungo area Split di default for (var SplitIndex = m_SplitHorizList.Count; SplitIndex <= QtyHoriz; SplitIndex++) - m_SplitHorizList.Add(new SplitDimension(dNewDimension, true, this, false)); + m_SplitHorizList.Add(new SplitDimension(dNewDimension, MeasureTypes.PERCENTAGE, true, this, false)); } else if (QtyHoriz < m_SplitHorizList.Count) { @@ -431,7 +442,7 @@ namespace WebWindowComplex.Models dNewDimension = dLastDimension / (QtyVert + 1 - nSplitQtyVert); // aggiungo area Split di default for (var SplitIndex = m_SplitVertList.Count; SplitIndex <= QtyVert; SplitIndex++) - m_SplitVertList.Add(new SplitDimension(dNewDimension, true, this, true)); + m_SplitVertList.Add(new SplitDimension(dNewDimension, MeasureTypes.PERCENTAGE, true, this, true)); } else if (QtyVert < m_SplitVertList.Count) { @@ -450,6 +461,31 @@ namespace WebWindowComplex.Models m_bSplitStartVert = SplitStartVert; } + internal double HeightFrame() + { + switch (ParentWindow.AreaList.First().SelShapeIndex) + { + case (int)Shapes.RECTANGLE: + case (int)Shapes.TRIANGLE: + case (int)Shapes.ARC_FULL: + { + return ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Height").First().dValue; + } + case (int)Shapes.RIGHTCHAMFER: + { + return ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Left Height").First().dValue; + } + case (int)Shapes.LEFTCHAMFER: + { + return ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Right Height").First().dValue; + } + default: + { + return ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Full Height").First().dValue; + } + } + } + #endregion Internal Methods #region Private Fields @@ -472,6 +508,8 @@ namespace WebWindowComplex.Models private List m_SplitVertList = new List(); + //private double m_Width = 0; + #endregion Private Fields } } \ No newline at end of file diff --git a/WebWindowComplex/Models/SplitDimension.cs b/WebWindowComplex/Models/SplitDimension.cs index 8849369..5df5ceb 100644 --- a/WebWindowComplex/Models/SplitDimension.cs +++ b/WebWindowComplex/Models/SplitDimension.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using WebWindowComplex.Json; +using static WebWindowComplex.Json.WindowConst; namespace WebWindowComplex.Models { @@ -11,9 +12,10 @@ namespace WebWindowComplex.Models { #region Public Constructors - public SplitDimension(double dDimension, bool bIsRelative, Split Parent, bool IsVertList) + public SplitDimension(double dDimension, MeasureTypes MeasureType, bool bIsRelative, Split Parent, bool IsVertList) { m_dDimension = dDimension; + m_SelMeasureType = MeasureType; m_bIsRelative = bIsRelative; m_Parent = Parent; m_bIsVertListDim = IsVertList; @@ -47,80 +49,243 @@ namespace WebWindowComplex.Models } set { - // Controllo che il valore inserito sia compreso tra 0 e 100 - if (value > 0 && value < 100) + double dimensionTot = 0; + List dimensions = null; + if (bIsVertListDim) { - // se sono in percentuale - if (m_bIsRelative) - { - List RelativeDimList = new List(); - if (bIsVertListDim) - RelativeDimList = m_Parent.SplitVertList.Where(x => x.bIsRelative).ToList(); - else - RelativeDimList = m_Parent.SplitHorizList.Where(x => x.bIsRelative).ToList(); - // verifico se ci sono assoluti - //List RelativeDimList = m_Parent.SplitPositionList.Where(x => x.bIsRelative).ToList(); - if (RelativeDimList.Count > 0) + dimensions = m_Parent.SplitVertList; + dimensionTot = CalculateWidthSplitGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dValue); + } + else + { + dimensions = m_Parent.SplitHorizList; + dimensionTot = CalculateHeightSplitGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), HeightTot()); + } + double valMinAbsolute = 100; + double valMaxAbsolute = dimensionTot - valMinAbsolute * (dimensions.Count - 1); + bool valueAccept = false; + switch (MeasureType) + { + case MeasureTypes.ABSOLUTE: { - if (m_Parent.bIsPercentage) + valueAccept = (value < valMaxAbsolute && value > valMinAbsolute) ? true : false; + break; + } + case MeasureTypes.PROPORTIONAL: + { + valMaxAbsolute = 20; + valueAccept = (value >= 1) ? true : false; + break; + } + case MeasureTypes.PERCENTAGE: + { + valMaxAbsolute = valMaxAbsolute / dimensionTot * 100; + valMinAbsolute = valMinAbsolute / dimensionTot * 100; + valueAccept = (value < valMaxAbsolute && value > valMinAbsolute) ? true : false; + break; + } + } + if (valueAccept) + { + List absoluteValList = new List(); + foreach (var item in dimensions) + { + absoluteValList.Add(item.CalculateAbsoluteValue(dimensionTot, dimensions)); + } + int nIndex = dimensions.IndexOf(this); + int proportionalCount = dimensions.Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count; + int percentageCount = dimensions.Where(x => x.MeasureType.Equals(MeasureTypes.PERCENTAGE)).ToList().Count; + // Le dimensioni sono solo in proporzionale + if (proportionalCount == absoluteValList.Count) + { + m_dDimension = value; + } + // Le dimensioni sono solo in percentuale + else if (percentageCount == dimensions.Count) + { + if (value < dDimension) + { + // L'anta modificata non è l'ultima + if (nIndex < dimensions.Count - 1) + dimensions[nIndex + 1].SetDimension(dimensions[nIndex + 1].dDimension + (m_dDimension - value)); + else if (dimensions.Count > 1) + dimensions[nIndex - 1].SetDimension(dimensions[nIndex - 1].dDimension + (m_dDimension - value)); + else { - int nIndex = RelativeDimList.IndexOf(this); - if (value < m_dDimension) + m_dDimension = 100; + return; + } + } + else + { + double dRes = value; + // se non ultima anta + if (nIndex < dimensions.Count - 1) + { + for (var nInd = 0; nInd <= nIndex - 1; nInd++) + dRes += dimensions[nInd].dDimension; + dRes = (100 - dRes) / (dimensions.Count - nIndex - 1); + for (var Ind = nIndex + 1; Ind <= dimensions.Count - 1; Ind++) + dimensions[Ind].SetDimension(dRes); + } + // se ultima anta + else if (dimensions.Count > 1) + { + if (dimensions.Count > 2) { - if (nIndex < RelativeDimList.Count - 1) - RelativeDimList[nIndex + 1].SetDimension(RelativeDimList[nIndex + 1].dDimension + (m_dDimension - value)); - else if (RelativeDimList.Count > 1) - RelativeDimList[nIndex - 1].SetDimension(RelativeDimList[nIndex - 1].dDimension + (m_dDimension - value)); - else - { - m_dDimension = 100; - return; - } - } - else - { - double dRes = value; - if (nIndex < RelativeDimList.Count - 1) - { - for (var nInd = 0; nInd <= nIndex - 1; nInd++) - dRes += RelativeDimList[nInd].dDimension; - dRes = (100 - dRes) / (RelativeDimList.Count - nIndex - 1); - if (dRes != 0) - { - for (var Ind = nIndex + 1; Ind <= RelativeDimList.Count - 1; Ind++) - RelativeDimList[Ind].SetDimension(dRes); - } - else - return; - } - else if (RelativeDimList.Count > 1) - { - if (RelativeDimList.Count > 2) - { - for (var Ind = 0; Ind <= nIndex - 2; Ind++) - dRes += RelativeDimList[Ind].dDimension; - } - dRes = (100 - dRes); - if (dRes != 0) - RelativeDimList[nIndex - 1].SetDimension(dRes); - else - return; - } - else - { - m_dDimension = 100; - return; - } + for (var Ind = 0; Ind <= nIndex - 2; Ind++) + dRes += dimensions[Ind].dDimension; } + dRes = (100 - dRes); + dimensions[nIndex - 1].SetDimension(dRes); } else { + m_dDimension = 100; + return; } } + m_dDimension = value; } - m_dDimension = value; - m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); + // Le dimensioni sono miste o solo in assoluto + else + { + double valueInAbsolute = 0; + switch (MeasureType) + { + case MeasureTypes.ABSOLUTE: + { + valueInAbsolute = value; + break; + } + case MeasureTypes.PROPORTIONAL: + { + var pesi = value + dimensions + .Where(x => x.MeasureType.Equals(MeasureTypes.PROPORTIONAL) && !x.Equals(this)) + .Sum(x => x.m_dDimension); + valueInAbsolute = dimensionTot / pesi * value; + break; + } + case MeasureTypes.PERCENTAGE: + { + valueInAbsolute = (value / 100) * dimensionTot; + break; + } + } + if (value < dDimension) + { + // L'anta modificata non è l'ultima + if (nIndex < absoluteValList.Count - 1) + { + absoluteValList[nIndex + 1] = absoluteValList[nIndex + 1] + (absoluteValList[nIndex] - valueInAbsolute); + absoluteValList[nIndex] = valueInAbsolute; + } + // L'anta modificata è l'ultima + else if (dimensions.Count > 1) + { + absoluteValList[nIndex - 1] = absoluteValList[nIndex - 1] + (absoluteValList[nIndex] - valueInAbsolute); + absoluteValList[nIndex] = valueInAbsolute; + } + } + else + { + // L'anta modificata non è l'ultima + if (nIndex < absoluteValList.Count - 1) + { + absoluteValList[nIndex + 1] = absoluteValList[nIndex + 1] - (valueInAbsolute - absoluteValList[nIndex]); + absoluteValList[nIndex] = valueInAbsolute; + } + // L'anta modificata è l'ultima + else if (dimensions.Count > 1) + { + absoluteValList[nIndex - 1] = absoluteValList[nIndex - 1] - (valueInAbsolute - absoluteValList[nIndex]); + absoluteValList[nIndex] = valueInAbsolute; + } + } + if (MeasureType.Equals(MeasureTypes.PROPORTIONAL)) + m_dDimension = value; + for (int i = 0; i < absoluteValList.Count; i++) + { + var item = dimensions.ElementAt(i); + item.SetDimension(ConvertIn(absoluteValList[i], (MeasureTypes)item.SelMeasureTypeIndex, dimensionTot, dimensions)); + } + } + //m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); } + //// Controllo che il valore inserito sia compreso tra 0 e 100 + //if (value > 0 && value < 100) + //{ + // // se sono in percentuale + // if (m_bIsRelative) + // { + // List RelativeDimList = new List(); + // if (bIsVertListDim) + // RelativeDimList = m_Parent.SplitVertList.Where(x => x.bIsRelative).ToList(); + // else + // RelativeDimList = m_Parent.SplitHorizList.Where(x => x.bIsRelative).ToList(); + // // verifico se ci sono assoluti + // //List RelativeDimList = m_Parent.SplitPositionList.Where(x => x.bIsRelative).ToList(); + // if (RelativeDimList.Count > 0) + // { + // if (m_Parent.bIsPercentage) + // { + // int nIndex = RelativeDimList.IndexOf(this); + // if (value < m_dDimension) + // { + // if (nIndex < RelativeDimList.Count - 1) + // RelativeDimList[nIndex + 1].SetDimension(RelativeDimList[nIndex + 1].dDimension + (m_dDimension - value)); + // else if (RelativeDimList.Count > 1) + // RelativeDimList[nIndex - 1].SetDimension(RelativeDimList[nIndex - 1].dDimension + (m_dDimension - value)); + // else + // { + // m_dDimension = 100; + // return; + // } + // } + // else + // { + // double dRes = value; + // if (nIndex < RelativeDimList.Count - 1) + // { + // for (var nInd = 0; nInd <= nIndex - 1; nInd++) + // dRes += RelativeDimList[nInd].dDimension; + // dRes = (100 - dRes) / (RelativeDimList.Count - nIndex - 1); + // if (dRes != 0) + // { + // for (var Ind = nIndex + 1; Ind <= RelativeDimList.Count - 1; Ind++) + // RelativeDimList[Ind].SetDimension(dRes); + // } + // else + // return; + // } + // else if (RelativeDimList.Count > 1) + // { + // if (RelativeDimList.Count > 2) + // { + // for (var Ind = 0; Ind <= nIndex - 2; Ind++) + // dRes += RelativeDimList[Ind].dDimension; + // } + // dRes = (100 - dRes); + // if (dRes != 0) + // RelativeDimList[nIndex - 1].SetDimension(dRes); + // else + // return; + // } + // else + // { + // m_dDimension = 100; + // return; + // } + // } + // } + // else + // { + // } + // } + // } + // m_dDimension = value; + // m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); + //} } } @@ -136,13 +301,122 @@ namespace WebWindowComplex.Models } } + public MeasureTypes MeasureType + { + get + { + return m_SelMeasureType; + } + } + + public List MeasureTypeList + { + get + { + return m_MeasureTypeList; + } + } + + public MeasureTypes SelMeasureType + { + get + { + return m_SelMeasureType; + } + set + { + m_SelMeasureType = value; + } + } + + public int SelMeasureTypeIndex + { + get + { + return (int)m_SelMeasureType; + } + set + { + if (m_SelMeasureType != (MeasureTypes)value) + { + MeasureTypes newType = (MeasureTypes)value; + List splitList = null; + double tot = 0; + if (bIsVertListDim) + { + splitList = m_Parent.SplitVertList; + tot = CalculateWidthSplitGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dValue); + } + else + { + splitList = m_Parent.SplitHorizList; + tot = CalculateHeightSplitGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), HeightTot()); + } + m_dDimension = ConvertDimension(m_SelMeasureType, newType, tot, splitList); + m_SelMeasureType = (MeasureTypes)value; + //m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); + } + } + } + #endregion Public Properties #region Public Methods + /// + /// Metodo per convertire la dimensione dal vecchio tipo al nuovo tipo + /// + /// Vecchio tipo + /// Nuovo tipo + /// + public double ConvertDimension(MeasureTypes oldType, MeasureTypes newType, double widthTot, List splitList) + { + switch (oldType) + { + case MeasureTypes.ABSOLUTE: + { + if (newType.Equals(MeasureTypes.PERCENTAGE)) + { + //return Double.Round((m_dDimension / m_Parent.Width) * 100, 1); + return (m_dDimension / widthTot) * 100; + } + else + { + return CalculatePropVal(widthTot, splitList); + } + } + case MeasureTypes.PROPORTIONAL: + { + if (newType.Equals(MeasureTypes.ABSOLUTE)) + { + //return Double.Round(ConvertFromPropVal(newType), 2); + return ConvertFromPropVal(newType, widthTot, splitList); + } + else + { + //return Double.Round(ConvertFromPropVal(newType), 1); + return ConvertFromPropVal(newType, widthTot, splitList); + } + } + case MeasureTypes.PERCENTAGE: + { + if (newType.Equals(MeasureTypes.ABSOLUTE)) + { + //return Double.Round((m_dDimension * m_Parent.Width) / 100, 2); + return (m_dDimension * widthTot) / 100; + } + else + { + return CalculatePropVal(widthTot, splitList); + } + } + } + return -1; + } + public SplitDimension Copy() { - SplitDimension newSplitDim = new SplitDimension(dDimension, bIsRelative, m_Parent, bIsVertListDim); + SplitDimension newSplitDim = new SplitDimension(dDimension, MeasureType, bIsRelative, m_Parent, bIsVertListDim); return newSplitDim; } @@ -150,9 +424,310 @@ namespace WebWindowComplex.Models #region Internal Methods + /// + /// Metodo per calcolare larghezza intero split group + /// + /// area di partenza + /// larghezza di partenza + /// + internal double CalculateWidthSplitGroup(Area area, double width) + { + for (int i = 0; i < area.AreaList.Count; i++) + { + double risultato = -1; + if (area.Equals(m_Parent)) + return width; + Area item = area.AreaList[i]; + if (area is Split) + { + Split split = (Split)area; + if(split.SplitVertList.Count > 0) + { + switch (split.SplitVertList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + risultato = CalculateWidthSplitGroup(item, split.SplitVertList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PROPORTIONAL: + { + //risultato = CalculateWidthSplitGroup(item, split.SplitVertList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PERCENTAGE: + { + risultato = CalculateWidthSplitGroup(item, split.SplitVertList.ElementAt(i).dDimension * width / 100); + break; + } + } + if (risultato != -1) + return risultato; + } + else + { + risultato = CalculateWidthSplitGroup(item, width); + } + } + else if (area is Sash) + { + Sash sash = (Sash)area; + switch (sash.SashList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + risultato = CalculateWidthSplitGroup(item, sash.SashList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PROPORTIONAL: + { + //risultato = CalculateWidthSplitGroup(item, sash.SashList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PERCENTAGE: + { + risultato = CalculateWidthSplitGroup(item, sash.SashList.ElementAt(i).dDimension * width / 100); + break; + } + } + if (risultato != -1) + return risultato; + } + else + { + risultato = CalculateWidthSplitGroup(item, width); + if (risultato != -1) + return risultato; + } + } + return width; + } + + /// + /// Metodo per calcolare altezza intero split group + /// + /// area di partenza + /// altezza di partenza + /// + internal double CalculateHeightSplitGroup(Area area, double height) + { + for (int i = 0; i < area.AreaList.Count; i++) + { + double risultato = -1; + if (area.Equals(m_Parent)) + return height; + Area item = area.AreaList[i]; + if (area is Split) + { + Split split = (Split)area; + if (split.SplitHorizList.Count > 0) + { + switch (split.SplitHorizList.ElementAt(i).SelMeasureType) + { + case MeasureTypes.ABSOLUTE: + { + risultato = CalculateHeightSplitGroup(item, split.SplitHorizList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PROPORTIONAL: + { + //risultato = CalculateHeightSplitGroup(item, split.SplitVertList.ElementAt(i).dDimension); + break; + } + case MeasureTypes.PERCENTAGE: + { + risultato = CalculateHeightSplitGroup(item, split.SplitHorizList.ElementAt(i).dDimension * height / 100); + break; + } + } + if (risultato != -1) + return risultato; + } + else + { + risultato = CalculateHeightSplitGroup(item, height); + } + } + else + { + risultato = CalculateHeightSplitGroup(item, height); + if (risultato != -1) + return risultato; + } + } + return height; + } + + /// + /// Calcolo MCD + /// + /// + /// + /// + internal static double CalculateMCD(double a, double b) + { + while (b >= 0.01) + { + double temp = b; + b = a % b; + a = temp; + } + //return Double.Round(a,2); + return a; + } + + /// + /// Metodo per ricalcolare i valori proporzionali a causa della modifica di uno + /// + /// + internal double CalculatePropVal(double widthTot, List splitList) + { + if (splitList.Where(m => m.MeasureType.Equals(MeasureTypes.PROPORTIONAL)).ToList().Count == 0) + { + return 1; + } + List absoluteValue = new List(); + foreach (var item in splitList) + { + absoluteValue.Add(item.CalculateAbsoluteValue(widthTot, splitList)); + } + for (int i = 0; i < splitList.Count; i++) + { + if (!splitList.ElementAt(i).Equals(this) && + splitList.ElementAt(i).MeasureType.Equals(MeasureTypes.PROPORTIONAL)) + { + int nIndex = splitList.IndexOf(this); + if (absoluteValue.ElementAt(nIndex) <= absoluteValue.ElementAt(i)) + { + var mcd = CalculateMCD(absoluteValue.ElementAt(nIndex), absoluteValue.ElementAt(i)); + splitList.ElementAt(i).m_dDimension = absoluteValue.ElementAt(i) / mcd; + m_dDimension = absoluteValue.ElementAt(nIndex) / mcd; + } + else + { + var mcd = CalculateMCD(absoluteValue.ElementAt(nIndex), absoluteValue.ElementAt(i)); + splitList.ElementAt(i).m_dDimension = absoluteValue.ElementAt(i) / mcd; + m_dDimension = absoluteValue.ElementAt(nIndex) / mcd; + } + break; + } + } + return m_dDimension; + } + + /// + /// Metodo per trasformare una dimensione in valore assoluto rispetto alla larghezza totale + /// + /// Larghezza totale + /// + internal double CalculateAbsoluteValue(double widthTot, List splitList) + { + switch (MeasureType) + { + case MeasureTypes.ABSOLUTE: + { + //return Double.Round(dDimension, 2); + return dDimension; + } + case MeasureTypes.PROPORTIONAL: + { + //return Double.Round(Proportional2AbsolutVal(), 2); + return Proportional2AbsoluteVal(widthTot, splitList); + } + case MeasureTypes.PERCENTAGE: + { + //return Double.Round((dDimension / 100) * widthTot, 1); + return (dDimension / 100) * widthTot; + } + } + return 0; + } + + /// + /// Metodo per convertire una dimensione da un valore assoluto al suo rispettivo tipo + /// + /// Valore assoluto + /// Tipo di misura della dimensione + /// Larghezza totale + /// + internal double ConvertIn(double absoluteVal, MeasureTypes type, double widthTot, List splitList) + { + switch (type) + { + case MeasureTypes.ABSOLUTE: + { + return absoluteVal; + } + case MeasureTypes.PROPORTIONAL: + { + return Proportional2AbsoluteVal(widthTot, splitList); + } + case MeasureTypes.PERCENTAGE: + { + return (absoluteVal / widthTot) * 100; + } + } + return -1; + } + + /// + /// Metodo per convertire da misura proporzionale a misura assoluta o percentuale + /// + /// + /// + internal double ConvertFromPropVal(MeasureTypes newType, double widthTot, List splitList) + { + double tot = widthTot; + //Somma misura non proporzionali + double sumNotProp = splitList + .Where(m => m.MeasureType != MeasureTypes.PROPORTIONAL && !m.Equals(this)) + .Sum(m => m.CalculateAbsoluteValue(tot, splitList)); + //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; + if (newType.Equals(MeasureTypes.ABSOLUTE)) + { + return res / sumPesi * dDimension; + } + else + { + return (res / sumPesi * dDimension) / tot * 100; + } + } + + /// + /// Metodo per trasformare il valore proporzionale in assoluto + /// + /// + internal double Proportional2AbsoluteVal(double widthTot, List splitList) + { + double tot = widthTot; + //Somma misura non proporzionali + double sumNotProp = splitList + .Where(m => m.MeasureType != MeasureTypes.PROPORTIONAL) + .Sum(m => m.CalculateAbsoluteValue(tot, splitList)); + //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 * dDimension; + } + internal JsonSplitDimension Serialize() { - JsonSplitDimension JsonSplitDimension = new JsonSplitDimension(m_bIsRelative, m_dDimension); + JsonSplitDimension JsonSplitDimension = new JsonSplitDimension(m_bIsRelative, m_dDimension, MeasureType); return JsonSplitDimension; } @@ -171,6 +746,57 @@ namespace WebWindowComplex.Models m_bIsVertListDim = value; } + internal void SetMeasureType(MeasureTypes value) + { + m_SelMeasureType = value; + } + + internal void SetSelMeasureType(MeasureTypes value) + { + if (m_SelMeasureType != (MeasureTypes)value) + { + MeasureTypes newType = (MeasureTypes)value; + double tot = 0; + if (bIsVertListDim) + { + tot = CalculateWidthSplitGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Width").First().dValue); + m_dDimension = ConvertDimension(m_SelMeasureType, newType, tot, m_Parent.SplitVertList); + } + else + { + tot = CalculateHeightSplitGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), HeightTot()); + m_dDimension = ConvertDimension(m_SelMeasureType, newType, tot, m_Parent.SplitHorizList); + } + m_SelMeasureType = (MeasureTypes)value; + //m_Parent.ParentWindow.OnUpdatePreview(m_Parent.ParentWindow.sSerialized()); + } + } + + internal double HeightTot() + { + switch (m_Parent.ParentWindow.AreaList.First().SelShapeIndex) + { + case (int)Shapes.RECTANGLE: + case (int)Shapes.TRIANGLE: + case (int)Shapes.ARC_FULL: + { + return CalculateHeightSplitGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Height").First().dValue); + } + case (int)Shapes.RIGHTCHAMFER: + { + return CalculateHeightSplitGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Left Height").First().dValue); + } + case (int)Shapes.LEFTCHAMFER: + { + return CalculateHeightSplitGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Right Height").First().dValue); + } + default: + { + return CalculateHeightSplitGroup(m_Parent.ParentWindow.AreaList.FirstOrDefault(), m_Parent.ParentWindow.AreaList.FirstOrDefault().DimensionList.Where(x => x.sName == "Full Height").First().dValue); + } + } + } + #endregion Internal Methods #region Private Fields @@ -181,6 +807,15 @@ namespace WebWindowComplex.Models private double m_dDimension; + private List m_MeasureTypeList = new List + { + new IdNameStruct((int)MeasureTypes.ABSOLUTE, "Absolute"), + new IdNameStruct((int)MeasureTypes.PROPORTIONAL, "Proportional"), + new IdNameStruct((int)MeasureTypes.PERCENTAGE, "Percentage"), + }; + + private MeasureTypes m_SelMeasureType; + // reference private Split m_Parent; diff --git a/WebWindowComplex/Models/Window.cs b/WebWindowComplex/Models/Window.cs index ab31bdc..593460a 100644 --- a/WebWindowComplex/Models/Window.cs +++ b/WebWindowComplex/Models/Window.cs @@ -11,7 +11,7 @@ using System.Xml.Linq; using System.Xml.Serialization; using WebWindowComplex.Json; using static WebWindowComplex.Json.WindowConst; -using static WebWindowComplex.ParametriOpzioni; +using static WebWindowComplex.Models.ParametriOpzioni; namespace WebWindowComplex.Models { @@ -19,9 +19,9 @@ namespace WebWindowComplex.Models { #region Public Events - public event EventHandler OnPreview = delegate { }; - public event EventHandler OnReqShape = delegate { }; - public event EventHandler OnReqHwOption = delegate { }; + //public event EventHandler OnPreview = delegate { }; + //public event EventHandler OnReqShape = delegate { }; + //public event EventHandler OnReqHwOption = delegate { }; #endregion Public Events @@ -48,7 +48,6 @@ namespace WebWindowComplex.Models set { m_sColorMaterial = value; - OnUpdatePreview(sSerialized()); } } @@ -61,7 +60,6 @@ namespace WebWindowComplex.Models set { m_sGlass = value; - OnUpdatePreview(sSerialized()); } } @@ -74,7 +72,6 @@ namespace WebWindowComplex.Models set { m_sMaterial = value; - OnUpdatePreview(sSerialized()); } } @@ -87,7 +84,6 @@ namespace WebWindowComplex.Models set { m_sProfilePath = value; - OnUpdatePreview(sSerialized()); } } @@ -95,35 +91,35 @@ namespace WebWindowComplex.Models #region Internal Methods - internal void OnUpdatePreview(string sJwd) - { - OnPreviewEventArgs e = new OnPreviewEventArgs(sJwd); - EventHandler handler = OnPreview; - if (handler != null) - { - handler(this, e); - } - } + //internal void OnUpdatePreview(string sJwd) + //{ + // OnPreviewEventArgs e = new OnPreviewEventArgs(sJwd); + // EventHandler handler = OnPreview; + // if (handler != null) + // { + // handler(this, e); + // } + //} - internal void OnReqShapePreview(string sJwd, int groupId) - { - OnReqShapeEventArgs e = new OnReqShapeEventArgs(sJwd, groupId); - EventHandler handler = OnReqShape; - if (handler != null) - { - handler(this, e); - } - } + //internal void OnReqShapePreview(string sJwd, int groupId) + //{ + // OnReqShapeEventArgs e = new OnReqShapeEventArgs(sJwd, groupId); + // EventHandler handler = OnReqShape; + // if (handler != null) + // { + // handler(this, e); + // } + //} - internal void OnReqHwOptionPreview(string sJwd, int groupId) - { - OnReqHwOptEventArgs e = new OnReqHwOptEventArgs(sJwd, groupId); - EventHandler handler = OnReqHwOption; - if (handler != null) - { - handler(this, e); - } - } + //internal void OnReqHwOptionPreview(string sJwd, int groupId) + //{ + // OnReqHwOptEventArgs e = new OnReqHwOptEventArgs(sJwd, groupId); + // EventHandler handler = OnReqHwOption; + // if (handler != null) + // { + // handler(this, e); + // } + //} /// /// Serializzazione dell'oggetto windows diff --git a/WebWindowComplex/TableComp.razor b/WebWindowComplex/TableComp.razor index 6158c55..ea69c70 100644 --- a/WebWindowComplex/TableComp.razor +++ b/WebWindowComplex/TableComp.razor @@ -21,7 +21,7 @@
} - else if (listErrLink != null && listErrLink.Count > 0) + @* else if (listErrLink != null && listErrLink.Count > 0) {
Errore configurazione:
@@ -34,7 +34,7 @@
- } + } *@ else {
@@ -49,6 +49,15 @@ + @* @if (FrameWindow.Shape == Json.WindowConst.Shapes.ARC || + FrameWindow.Shape == Json.WindowConst.Shapes.ARC_FULL || + FrameWindow.Shape == Json.WindowConst.Shapes.DOUBLEARC || + FrameWindow.Shape == Json.WindowConst.Shapes.THREECENTERARC) + { + + } *@
@@ -78,96 +87,125 @@ { m_PreviousWindow = m_CurrWindow; } - - + + + + + + + + } else if (currStep == CompileStep.Split) { - @if (currSplit >= SplitList.Count || currSplit == -1) + @if (currSplitIndex >= SplitList.Count || currSplitIndex == -1) { currStep = CompileStep.Tree; } else { - } } else if (currStep == CompileStep.Sash) { - @if (currSash >= SashList.Count || currSash == -1) + @if (currSashIndex >= SashList.Count || currSashIndex == -1) { currStep = CompileStep.Tree; } else { - - + + + + + + - } + } } else if (currStep == CompileStep.Fill) { - @if (currFill >= FillList.Count || currFill == -1) + @if (currFillIndex >= FillList.Count || currFillIndex == -1) { currStep = CompileStep.Tree; } else { - + +
+
+
+
+
All fill
+
+
+ +
+
+ +
+
+
+
+ Splitted currSplitted = SplittedList.Where(x => x.AreaList.First().Equals(FillList[currFillIndex])).FirstOrDefault(); + @if (currSplitted != null) { + + + } + @* @foreach (var currSplitted in m_SplittedList) + { + @if (currSplitted.AreaList.First().Equals(FillList[currFillIndex])) + { + + } + } *@ } } else if (currStep == CompileStep.General) { - } + @* else if (currStep == CompileStep.ArcElement) + { + + + } *@
diff --git a/WebWindowComplex/TableComp.razor.cs b/WebWindowComplex/TableComp.razor.cs index 0d1b445..ad477d0 100644 --- a/WebWindowComplex/TableComp.razor.cs +++ b/WebWindowComplex/TableComp.razor.cs @@ -1,13 +1,13 @@ using Egw.Window.Data; using Microsoft.AspNetCore.Components; using Newtonsoft.Json; -using System.Reflection.Metadata; +using System.Threading.Tasks; using WebWindowComplex.Compo; using WebWindowComplex.DTO; using WebWindowComplex.Json; using WebWindowComplex.Models; -using static WebWindowComplex.LayoutConst; using static WebWindowComplex.Json.WindowConst; +using static WebWindowComplex.LayoutConst; namespace WebWindowComplex { @@ -15,23 +15,6 @@ namespace WebWindowComplex { #region Public Enums - public enum DataAction - { - /// - /// Nessuna richiesta - /// - None = 0, - - /// - /// Reset dizionario shape - /// - ResetDictShape, - /// - /// Reset dizionario HwOptions - /// - ResetHwOpt - } - public enum DataReq { /// @@ -117,9 +100,6 @@ namespace WebWindowComplex { if (m_CurrWindow != null) { - m_CurrWindow.OnPreview -= M_CurrWindow_OnPreview; - m_CurrWindow.OnReqHwOption -= M_CurrWindow_OnHwOption; - m_CurrWindow.OnReqShape -= M_CurrWindow_OnShape; m_CurrWindow = null; } } @@ -173,6 +153,11 @@ namespace WebWindowComplex get => m_SashList; } + protected List SplittedList + { + get => m_SplittedList; + } + protected string SelColorMaterial { get; set; } = ""; protected string SelFamilyHardware { get; set; } = ""; protected string SelGlass { get; set; } = ""; @@ -188,78 +173,6 @@ namespace WebWindowComplex #region Protected Methods - /// - /// Metodo per la scelta della maniglia univoca - /// - /// anta su cui si seleziona la maniglia - /// - protected void ChangeHandle(DataChangeHandle Args) - { - SashDimension sashDim = Args.currSashDimension; - Sash currSash = Args.currItem; - // Cerco la Sash che si sta considerando nella lista Sash - var s = SashList.Where(x => x.GroupId == currSash.GroupId).FirstOrDefault(); - if (s != null) - { - // Setto la presenza o meno della maniglia per ogni anta - foreach (SashDimension item in s.SashList) - { - if (item.Equals(sashDim)) - { - item.bHasHandle = true; - } - else - { - if (item.bHasHandle) - { - switch (item.SelOpeningType) - { - case Openings.TILTTURN_LEFT: - { - item.SetOpeningType(Openings.TURNONLY_LEFT); - break; - } - case Openings.TILTTURN_RIGHT: - { - item.SetOpeningType(Openings.TURNONLY_RIGHT); - break; - } - default: - { - break; - } - } - } - item.bHasHandle = false; - } - } - } - // Per ogni anta della Sash setto HasHandle - currSash.RefreshHardwareList(); - currSash.SetFirstHardware(); - _ = DoPreviewSvg(); - } - - /// - /// Metodo per la scelta dello split intero nella modalità griglia - /// - /// split su cui si sceglie - /// - protected async Task changeStartVert(DataChangeStartVert Args) - { - ChangeEventArgs e = Args.eventArg; - Split currSplit = Args.currItem; - // Cerco la Sash che si sta considerando nella lista Sash - foreach (Split s in SplitList) - { - if (s.Equals(currSplit)) - { - s.SetSplitStartVert((bool)e.Value); - } - } - await DoPreviewSvg(); - } - /// /// Metodo per riempire la lista ItemTable in modo da poter rappresentarla come tabella /// @@ -503,7 +416,7 @@ namespace WebWindowComplex } /// - /// Richiesta calcolo Options HW da JWD + /// Richiesta calcolo Options HW /// /// Lista degli ID numerici dei gruppi da valutare /// @@ -649,6 +562,39 @@ namespace WebWindowComplex catch (Exception ex) { listErrLink.Add("Window", $"Deserializing Error:{Environment.NewLine}{ex}"); + // uso un oggetto "basico" per non fermarmi + //string jwd = "{\r\n \"ProfilePath\": \"Profilo78\",\r\n \"Material\": \"Pino\",\r\n \"ColorMaterial\": \"Black\",\r\n \"Glass\": \"Vetro BE 2S 4T/16/4T\",\r\n \"AreaList\": [\r\n {\r\n \"Shape\": \"RECTANGLE\",\r\n \"DimensionList\": [\r\n {\r\n \"Index\": 1,\r\n \"Name\": \"Width\",\r\n \"Value\": 800.0\r\n },\r\n {\r\n \"Index\": 2,\r\n \"Name\": \"Height\",\r\n \"Value\": 1200.0\r\n }\r\n ],\r\n \"JointList\": [\r\n {\r\n \"Index\": 1,\r\n \"JointType\": \"FULL_H\"\r\n },\r\n {\r\n \"Index\": 2,\r\n \"JointType\": \"FULL_H\"\r\n },\r\n {\r\n \"Index\": 3,\r\n \"JointType\": \"FULL_H\"\r\n },\r\n {\r\n \"Index\": 4,\r\n \"JointType\": \"FULL_H\"\r\n }\r\n ],\r\n \"BottomRail\": false,\r\n \"BottomRailQty\": 0,\r\n \"GroupId\": 1,\r\n \"AreaList\": [\r\n {\r\n \"FillType\": \"GLASS\",\r\n \"GroupId\": 7,\r\n \"AreaList\": [],\r\n \"AreaType\": \"FILL\"\r\n }\r\n ],\r\n \"AreaType\": \"FRAME\"\r\n }\r\n ]\r\n}"; + //WindowFromJson = JsonConvert.DeserializeObject(jwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); + //setCurrWindow(WindowFromJson); + //await DoPreviewSvg(true); + Window window = new Window(); + Frame frame = new Frame(null, window); + 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) + }; + //FrameArcElement ae = new FrameArcElement(frame, window, 10, true, true); + JsonWindow jsonWindow = new JsonWindow("Profilo78", "Pino", "Black", "Vetro BE 2S 4T/16/4T"); + JsonFrame jsonFrame = new JsonFrame(Shapes.RECTANGLE, false, 0, 1); + jsonWindow.AreaList.Add(jsonFrame); + //jsonFrame.ArcElement = ae.Serialize(); + foreach (var Dimension in DimensionList) + jsonFrame.DimensionList.Add(Dimension.Serialize()); + foreach (var Joint in JointList) + jsonFrame.JointList.Add(Joint.Serialize()); + jsonFrame.AreaList.Add(Fill.CreateFill(frame, FillTypes.GLASS).Serialize(true)); + string jwd = JsonConvert.SerializeObject(jsonWindow); + WindowFromJson = JsonConvert.DeserializeObject(jwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", ""); + setCurrWindow(WindowFromJson); + await DoPreviewSvg(true); } } else @@ -660,12 +606,12 @@ namespace WebWindowComplex checkWarnings(); if (SashList.Count > 0) { - currAnta = 0; + currAntaIndex = 0; } if (updRequested) { // se mancasse dizionario forme chiamo quello - if (LiveData.DictShape.Count == 0) + if (LiveData.DictShape.Count == 0 && listErrLink.Count == 0) { if (firstDisplay && isRendered) { @@ -676,13 +622,21 @@ namespace WebWindowComplex List reqList = SashList.Select(x => x.GroupId).ToList(); if (reqList.Count > 0) { + //prevReq = (int)DataReq.ReqShape; await DoReqShape(reqList); } } else { // chiedo SVG - await DoPreviewSvg(true); + //prevReq = (int)DataReq.ReqSvg; + 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); + } } } } @@ -702,22 +656,24 @@ namespace WebWindowComplex { if (m_CurrWindow != null) { - m_CurrWindow.OnPreview -= M_CurrWindow_OnPreview; - m_CurrWindow.OnReqHwOption -= M_CurrWindow_OnHwOption; - m_CurrWindow.OnReqShape -= M_CurrWindow_OnShape; m_CurrWindow = null; } m_CurrWindow = WindowFromJson.Deserialize(); - m_CurrWindow.OnPreview += M_CurrWindow_OnPreview; - m_CurrWindow.OnReqHwOption += M_CurrWindow_OnHwOption; - m_CurrWindow.OnReqShape += M_CurrWindow_OnShape; - // Recupero dimensioni Frame e Joint del frame della finestra precedente + FrameWindow = m_CurrWindow.AreaList[0]; if (m_PreviousWindow != null) { for (int i = 0; i < 2; i++) - m_CurrWindow.AreaList.First().DimensionList[i] = m_PreviousWindow.AreaList.First().DimensionList[i]; - for (int i = 0; i < 4; i++) - m_CurrWindow.AreaList.First().JointList[i] = m_PreviousWindow.AreaList.First().JointList[i]; + m_CurrWindow.AreaList.First().DimensionList[i].dValue = m_PreviousWindow.AreaList.First().DimensionList[i].dValue; + if(m_CurrWindow.AreaList.First().Shape == Shapes.TRIANGLE) + { + for (int i = 0; i < 2; i++) + m_CurrWindow.AreaList.First().JointList[i].SetSelJointType(m_PreviousWindow.AreaList.First().JointList[i].SelJointType); + } + else + { + for (int i = 0; i < 4; i++) + m_CurrWindow.AreaList.First().JointList[i].SetSelJointType(m_PreviousWindow.AreaList.First().JointList[i].SelJointType); + } } if (m_CurrWindow != null) { @@ -725,10 +681,7 @@ namespace WebWindowComplex UpdateLists(); } if (SashList.Count > 0) - currAnta = 0; -#if false - _ = InvokeAsync(StateHasChanged); -#endif + currAntaIndex = 0; // Aggiorno window con dati shape e hw option UpdateDict(); } @@ -744,10 +697,17 @@ namespace WebWindowComplex // Inserisco le forme ricevuto nei sash group foreach (var item in LiveData.DictShape) { - Sash sashFromGroupId = SashList.Where(x => x.GroupId == item.Key).First(); + Sash sashFromGroupId = SashList.First(x => x.GroupId == item.Key); sashFromGroupId.SashShape = item.Value; sashFromGroupId.UpdateShape(item.Value); } + if(prevReq == (int)DataReq.ReqShape){ + if(reqHwOpt > 0) + { + List reqList = SashList.Select(x => x.GroupId).ToList(); + _=DoReqOptHardware(reqList); + } + } } // se ho le opzioni hw le aggiungo if (LiveData.DictOptionsXml.Count > 0) @@ -800,13 +760,13 @@ namespace WebWindowComplex #region Private Fields - private int currAnta = 0; + private int currAntaIndex = 0; - private int currFill = -1; + private int currFillIndex = -1; - private int currSash = -1; + private int currSashIndex = -1; - private int currSplit = -1; + private int currSplitIndex = -1; private CompileStep currStep; @@ -860,8 +820,6 @@ namespace WebWindowComplex private Window? m_PreviousWindow { get; set; } = null; - private string m_SelFamilyHardware { get; set; } = ""; - /// /// Salvataggio JWD precedente x evitare loop su update (aggiornato dopo chiamate redis) /// @@ -871,51 +829,12 @@ namespace WebWindowComplex /// 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 aggiungere una Sash - /// - /// - /// - private void AddSashIntoSplit(DataAreaSplitted Args) - { - Splitted currSplitted = Args.splitted; - currSplitted.AddFirstSash(); - // ricalcolo liste - UpdateLists(); - // richiedo update shape - List reqList = SashList.Select(x => x.GroupId).ToList(); - _ = DoReqShape(reqList); - //_ = DoReqOptHardware(reqList); - } - - /// - /// Metodo per aggiungere una sash di default al Frame - /// - /// - private void AddSashToFrame(Frame f) - { - f.AddFirstSash(); - // ricalcolo liste - UpdateLists(); - // richiedo update shape - List reqList = SashList.Select(x => x.GroupId).ToList(); - _ = DoReqShape(reqList); - } - - /// - /// Metodo per aggiungere uno split di default al Frame - /// - /// - private void AddSplitToFrame(Frame f) - { - f.AddSplit(); - } - /// /// Metodo per andare allo step successivo /// @@ -923,74 +842,9 @@ namespace WebWindowComplex private void AdvStep(CompileStep newStep) { currStep = newStep; - currSash = -1; - currFill = -1; - currSplit = -1; - } - - /// - /// Prima chiamata alle opzioni hardware - /// - /// Group Id del sash group di cui si vuole Hw option - /// - private async Task CallFirstHwOpt(int groupId) - { - bool isFirst = true; - List reqList = new List() { groupId }; - await DoReqOptHardware(reqList, isFirst); - } - - /// - /// Metodo per settare tutti i Fill in contemporanea - /// - /// tipo di riempimento (GLASS o WOOD) - /// - private async Task ChangeAllFill(FillTypes type) - { - foreach (Fill currFill in FillList) - { - currFill.SetSelFillType(type); - } - await DoPreviewSvg(); - } - - /// - /// Metodo per settare tutti i Joints di Frame o Sash come ANGLED o FULL_H o FULL_V - /// - /// - /// - private async Task ChangeAllJoints(DataChangeJoints Args) - { - WindowConst.Joints type = Args.currJointType; - Area area = Args.currArea; - if (area is Frame) - { - foreach (Joint joint in FrameWindow.JointList) - { - joint.SetSelJointType(type); - } - } - else - { - Sash a = (Sash)area; - foreach (Joint joint in a.JointList) - { - joint.SetSelJointType(type); - } - } - await DoPreviewSvg(); - } - - /// - /// Metodo per settare tutti i Fill in contemporanea - /// - /// tipo di riempimento (GLASS o WOOD) - /// - private async Task ChangeOneFill(FillTypes type) - { - Fill fillChange = FillList.ElementAt(currFill); - fillChange.SetSelFillType(type); - await DoPreviewSvg(); + currSashIndex = -1; + currFillIndex = -1; + currSplitIndex = -1; } /// @@ -1059,46 +913,6 @@ namespace WebWindowComplex } } - /// - /// Metodo per copiare contenuto di un'anta in un'altra anta - /// - /// - private async Task CopyContentSash(DataCopyContentSash Args) - { - Sash sashItem = Args.currItem; - int IndexCopy = Args.indexCopy; - int IndexModify = Args.indexModify; - // Anta selezionata - Area sashSplitted = sashItem.AreaList[IndexModify]; - // Rimuovo riempimento da anta selezionata - sashSplitted.AreaList.RemoveAt(0); - // Creo la copia dell'anta scelta - Area a = sashItem.AreaList[IndexCopy].AreaList.First().Copy(sashSplitted); - // Aggiungo copia all'anta selezionata - sashItem.AreaList[IndexModify].AreaList.Add(a); - await DoPreviewSvg(); - } - - /// - /// Metodo per copiare una Sash intera - /// - /// - /// - private async Task CopySash(DataAreaSplit Args) - { - Splitted currSplitted = Args.splitted; - int numSash = Args.index; - //Rimuovo contenuto di Splitted e rimuovo area da conteggio gruppi - currSplitted.AreaList.RemoveAll(i => i != null); - //Area.DelCounterGroup(); - // Copio sash - Area a = SashList[numSash].Copy(currSplitted); - a.SetParentArea(currSplitted); - // Aggiungo copia a Splitted - currSplitted.AreaList.Add(a); - await DoPreviewSvg(); - } - /// /// Helper aggiunta elemento a lista caricamento /// @@ -1123,41 +937,6 @@ namespace WebWindowComplex } } - private void M_CurrWindow_OnHwOption(object? sender, OnReqHwOptEventArgs e) - { - // chiamo reset dizionario - ReqResetHwOpt(true); - // setto che sto chiedendo update opzioni - loadListAdd("LoadHwOpt"); - _ = InvokeAsync(StateHasChanged); - Dictionary Args = new Dictionary(); - Args.Add("Mode", $"{(int)Enums.QuestionModes.HARDWARE}"); - Args.Add("SubMode", $"{(int)Enums.QuestionHwSubModes.HARDWAREOPTIONS}"); - Args.Add("SerializedData", e.sJwd); - string listGroupId = JsonConvert.SerializeObject(new List { e.nGroupId }); - Args.Add("GroupId", listGroupId); - _ = EC_DoUpdate.InvokeAsync(Args); - } - - private void M_CurrWindow_OnPreview(object? sender, OnPreviewEventArgs e) - { - Dictionary Args = new Dictionary(); - Args.Add("Mode", $"{(int)Enums.QuestionModes.PREVIEW}"); - Args.Add("SerializedData", e.sJwd); - _ = EC_DoUpdate.InvokeAsync(Args); - } - - private void M_CurrWindow_OnShape(object? sender, OnReqShapeEventArgs e) - { - Dictionary Args = new Dictionary(); - Args.Add("Mode", $"{(int)Enums.QuestionModes.HARDWARE}"); - Args.Add("SubMode", $"{(int)Enums.QuestionHwSubModes.SASHSHAPE}"); - Args.Add("SerializedData", e.sJwd); - string listGroupId = JsonConvert.SerializeObject(new List { e.groupId }); - Args.Add("GroupId", listGroupId); - _ = EC_DoUpdate.InvokeAsync(Args); - } - /// /// Metodo per cambiare step /// @@ -1170,23 +949,23 @@ namespace WebWindowComplex { case CompileStep.Sash: { - currSash = Index; - currFill = -1; - currSplit = -1; + currSashIndex = Index; + currFillIndex = -1; + currSplitIndex = -1; break; } case CompileStep.Fill: { - currFill = Index; - currSash = -1; - currSplit = -1; + currFillIndex = Index; + currSashIndex = -1; + currSplitIndex = -1; break; } case CompileStep.Split: { - currSplit = Index; - currSash = -1; - currFill = -1; + currSplitIndex = Index; + currSashIndex = -1; + currFillIndex = -1; break; } } @@ -1203,38 +982,13 @@ namespace WebWindowComplex NextStep(newStep, Index); } - /// - /// Metodo per eliminare Split o Sash - /// - /// Area corrente - /// - private void RemoveArea(Area currArea) - { - if (currArea is Split) - ((Split)currArea).Remove(); - else if (currArea is Sash) - { - ((Sash)currArea).Remove(); - } - currStep = CompileStep.Tree; - } - /// /// Richiesta reset dizionario Shape con action /// /// - private void ReqResetDict(bool args) + private async Task ReqResetDict(DataUpdateRes args) { - _ = EC_ActionReq.InvokeAsync(DataAction.ResetDictShape); - } - - /// - /// Richiesta reset dizionario options con action - /// - /// - private void ReqResetHwOpt(bool args) - { - _ = EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt); + _ = EC_ActionReq.InvokeAsync(args.req); } /// @@ -1246,23 +1000,15 @@ namespace WebWindowComplex AdvStep(CompileStep.Tree); } - /// - /// Cerca e aggiorna la sash - /// - /// area corrente che si sta valutando - /// id della sash che si sta cercando - /// nuova sash - /// - private Area SearchSash(Area currentArea, int idSearch, Sash newSash) - { - if (currentArea.GroupId == idSearch && currentArea.AreaType.Equals(AreaTypes.SASH)) + private Area SearchArea(Area currentArea, int idSearch, Area itemSearch) + { + if (currentArea.GroupId == idSearch && currentArea.AreaType.Equals(itemSearch.AreaType)) { - currentArea = newSash; return currentArea; } foreach (Area child in currentArea.AreaList) { - Area found = SearchSash(child, idSearch, newSash); + Area found = SearchArea(child, idSearch, itemSearch); if (found != null) { return found; @@ -1272,70 +1018,26 @@ namespace WebWindowComplex } /// - /// Selezione del colore + /// Metodo per aggiornare valori della sezione General /// /// - private void SelectColor(string newVal) + 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) { - m_CurrWindow.sColorMaterial = newVal; - } - } - - /// - /// Selezione del vetro - /// - /// - private void SelectGlass(string newVal) - { - if (m_CurrWindow != null) - { - m_CurrWindow.sGlass = newVal; - } - } - - /// - /// Selezione del materiale - /// - /// - private void SelectMat(string newVal) - { - if (m_CurrWindow != null) - { - m_CurrWindow.sMaterial = newVal; - } - } - - /// - /// Selezione del profilo - /// - /// - private void SelectProfile(string newVal) - { - if (m_CurrWindow != null) - { - m_CurrWindow.sProfilePath = newVal; - } - } - - /// - /// Metodo per scambiare due aree di uno split - /// - /// Area corrente - /// - private async Task SwapTwoAree(Area currArea) - { - currArea.SwapAree(); - await DoPreviewSvg(true, true); - if (currArea is Split) - { - List reqShape = new List(); - if (currArea.AreaList[0].AreaList.Where(x => x.AreaType == AreaTypes.SASH).ToList().Count() > 0) - reqShape.Add(currArea.AreaList[0].AreaList.Where(x => x.AreaType == AreaTypes.SASH).Select(x => x.GroupId).FirstOrDefault()); - if (currArea.AreaList[1].AreaList.Where(x => x.AreaType == AreaTypes.SASH).ToList().Count() > 0) - reqShape.Add(currArea.AreaList[1].AreaList.Where(x => x.AreaType == AreaTypes.SASH).Select(x => x.GroupId).FirstOrDefault()); - await DoReqShape(reqShape); + 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(); } } @@ -1348,21 +1050,21 @@ namespace WebWindowComplex { if (testStep == CompileStep.Sash) { - if ((currSash == 0 && Index == 0) || (currSash == 1 && Index == 1)) + if ((currSashIndex == 0 && Index == 0) || (currSashIndex == 1 && Index == 1)) return "nav-link active fw-bold"; else return "nav-link text-secondary"; } else if (testStep == CompileStep.Fill) { - if ((currFill == 0 && Index == 0) || (currFill == 1 && Index == 1)) + if ((currFillIndex == 0 && Index == 0) || (currFillIndex == 1 && Index == 1)) return "nav-link active fw-bold"; else return "nav-link text-secondary"; } else if (testStep == CompileStep.Split) { - if ((currSplit == 0 && Index == 0) || (currSplit == 1 && Index == 1)) + if ((currSplitIndex == 0 && Index == 0) || (currSplitIndex == 1 && Index == 1)) return "nav-link active fw-bold"; else return "nav-link text-secondary"; @@ -1370,15 +1072,190 @@ namespace WebWindowComplex return (testStep == currStep) ? "nav-link active fw-bold" : "nav-link text-secondary"; } + /// + /// Metodo per cambiare tutti i Fill e richiedere aggiornamento SVG + /// + /// tipo di fill richiesto + /// + protected async Task ChangeAllFill(FillTypes reqFillType) + { + updateAllFill(FrameWindow, reqFillType); + await DoPreviewSvg(); + } + + /// + /// Metodo per aggiornare tutti i Fill al nuovo tipo + /// + /// area corrente + /// tipo a cui aggiornare + private void updateAllFill(Area area, FillTypes type) + { + if (area.AreaType.Equals(AreaTypes.FILL)) + { + Fill fill = (Fill)area; + fill.SetSelFillType(type); + return; + } + foreach (Area child in area.AreaList) + { + updateAllFill(child, type); + } + } + + /// + /// Aggiornamento Fill + /// + /// Fill da aggiornare + /// + private async Task UpdatePreviewFill(Fill newFill) + { + if (newFill != null) + { + // cerco il record + var currRec = (Fill)SearchArea(FrameWindow, newFill.GroupId, newFill); + // lo aggiorno + currRec = newFill; + await DoPreviewSvg(); + } + } + /// /// Aggiornamento Frame /// - /// + /// nuovo frame /// - private async Task UpdateFrame(Frame newFrame) + private async Task UpdatePreviewFrame(DataUpdateFrame args) { - FrameWindow = newFrame; - await DoPreviewSvg(); + Frame newFrame = args.currFrame; + bool forceSvgNoHw = args.svgNoHw; + if (newFrame != null) + { + // cerco il record + var currRec = m_CurrWindow.AreaList.FirstOrDefault(x => x.GroupId == newFrame.GroupId); + // lo aggiorno + currRec = newFrame; + if(forceSvgNoHw) + await DoPreviewSvg(true,true); + else + await DoPreviewSvg(); + } + } + + /// + /// 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 = SashList.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 = SearchArea(FrameWindow, newSash.GroupId, newSash); + // lo aggiorno + currRec = newSash; + // 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 = SashList.Select(x => x.GroupId).ToList(); + // chiamo con gruppo della nuova sash + 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 = SearchArea(FrameWindow, newSash.GroupId, newSash); + // lo aggiorno + currRec = newSash; + // resetto hw lst + 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 + await DoReqOptHardware(reqList); + } + } + + /// + /// Aggiornamento Frame + /// + /// nuovo frame + /// + private async Task UpdatePreviewSplit(DataUpdateSplit args) + { + Split newSplit = args.currSplit; + bool forceSvgNoHw = args.svgNoHw; + if (newSplit != null) + { + // cerco il record + var currRec = SearchArea(FrameWindow, newSplit.GroupId, newSplit); + // lo aggiorno + currRec = newSplit; + if(forceSvgNoHw) + await DoPreviewSvg(true,true); + else + await DoPreviewSvg(); + } + } + + /// + /// Metodo per aggiornare Splitted + /// + /// Splitted da aggiornare + /// + private async Task UpdatePreviewSplitted(Splitted currSplitted) + { + if (currSplitted != null) + { + var item = SearchArea(FrameWindow, currSplitted.GroupId, currSplitted); + item = currSplitted; + // ricalcolo liste + UpdateLists(); + // richiedo update shape + List reqList = SashList.Select(x => x.GroupId).ToList(); + await DoPreviewSvg(); + await DoReqShape(reqList); + } + } /// @@ -1386,42 +1263,27 @@ namespace WebWindowComplex /// /// nuova sash /// - private async Task UpdateHwOptions(Sash newSash) + private async Task UpdatePreviewSashGroup(DataUpdateSash args) { - // resetto hw lst - await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt); - // richiesta calcolo opzioni hardware per la singola sash group - //string req = newSash.SelHardware.Id; - List reqList = new List() { newSash.GroupId }; - // chiamo con gruppo della nuova sash - await DoReqOptHardware(reqList); - //ReqResetHwOpt(); - } - - /// - /// Aggiornamento Sash e Frame - /// - /// nuova sash - /// - private async Task UpdateSash(Sash newSash) - { - SearchSash(FrameWindow, newSash.GroupId, newSash); - await DoPreviewSvg(); - } - - /// - /// Aggiornamento Shape x ogni Group di Sash della finestra - /// - /// - /// - private async Task UpdateShape(Frame newFrame) - { - FrameWindow = newFrame; - if (SashList.Count > 0) + Sash newSash = args.currSash; + bool svgNoHw = args.svgNoHw; + if (svgNoHw) { - // ciclo x ogni group della mia frame - List reqList = SashList.Select(x => x.GroupId).ToList(); - await DoReqShape(reqList); + Sash item = (Sash)SearchArea(FrameWindow, newSash.GroupId, newSash); + if (newSash != null && item != null) + { + item = newSash; + await DoPreviewSvg(true, true); + } + } + else + { + Sash item = (Sash)SearchArea(FrameWindow, newSash.GroupId, newSash); + if (newSash != null && item != null) + { + item = newSash; + await DoPreviewSvg(); + } } } diff --git a/WebWindowComplex/WebWindowComplex.csproj b/WebWindowComplex/WebWindowComplex.csproj index bf62610..2537da0 100644 --- a/WebWindowComplex/WebWindowComplex.csproj +++ b/WebWindowComplex/WebWindowComplex.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.11.1109 + 2.7.12.515 Annamaria Sassi Egalware Componente gestione Configurazioni avanzate Window per LUX @@ -49,6 +49,193 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index 4240629..894a46b 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.11.1109 + 2.7.12.515 Annamaria Sassi Egalware Componente gestione JWD per LUX @@ -69,6 +69,321 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WebWindowConfigurator/Window.cs b/WebWindowConfigurator/Window.cs index 223bd9b..c35b778 100644 --- a/WebWindowConfigurator/Window.cs +++ b/WebWindowConfigurator/Window.cs @@ -1011,114 +1011,12 @@ namespace WebWindowConfigurator } } - //private Hardware m_SelHardware; - //public Hardware SelHardware - //{ - // get - // { - // return m_SelHardware; - // } - // set - // { - // m_SelHardware = value; - // if (m_SelHardware != null && m_SelHardware.sId != "000000") - // { - // string sHwdOptPath = ""; - // var gf = EgtLuaCreateGlobTable("WDG"); - // var tft = EgtLuaSetGlobIntVar("WDG.AREAID", m_nAreaId); - // var tfy = EgtLuaSetGlobStringVar("WDG.HDWFAVOURITE", value.sId); - // SashDimension HandleSash = m_SashList.FirstOrDefault(x => x.bHasHandle); - // string sHandle = "Dx"; - // switch (GetOpeningSide(HandleSash.OpeningType)) - // { - // case object _ when OpeningSides.LEFT: - // { - // sHandle = "Sx"; - // break; - // } - - // case object _ when OpeningSides.RIGHT: - // { - // sHandle = "Dx"; - // break; - // } - // } - // var tfd = EgtLuaSetGlobStringVar("WDG.HDWHANDLE", sHandle); - // var tlt = EgtLuaCallFunction("WinCreate_GetHardwareOptionPath"); - // var tltf = EgtLuaGetGlobStringVar("WDG.HWDOPTPATH", sHwdOptPath); - // if (!string.IsNullOrWhiteSpace(sHwdOptPath)) - // { - // XmlSerializer serializer = new XmlSerializer(typeof(ParametriOpzioni)); - // ParametriOpzioni HwdOptions = null/* TODO Change to default(_) if this is not a reference type */; - // string sHdwOptPath = Path.ChangeExtension(sHwdOptPath, ".opt"); - // bool bHdwOptFound = false; - // for (var WaitIndex = 0; WaitIndex <= 100; WaitIndex++) - // { - // if (File.Exists(sHdwOptPath)) - // { - // bHdwOptFound = true; - // break; - // } - // System.Threading.Thread.Sleep(100); - // } - // if (bHdwOptFound) - // { - // string sHwdOptText = ""; - // try - // { - // sHwdOptText = File.ReadAllText(sHdwOptPath); - // } - // catch (Exception ex) - // { - // EgtOutLog("Hardware file opt not found or read!"); - // } - // if (!string.IsNullOrWhiteSpace(sHwdOptText)) - // { - // using (TextReader reader = new StringReader(sHwdOptText)) - // { - // HwdOptions = serializer.Deserialize(reader); - // } - // if (!IsNothing(HwdOptions)) - // { - // m_HwdOptionList.Clear(); - // foreach (var HdwOption in HwdOptions.Items) - // m_HwdOptionList.Add(new AGBOption(HdwOption)); - // NotifyPropertyChanged(nameof(HwdOptionList)); - // } - // } - // } - // var ud = EgtLuaResetGlobVar("WDG"); - // } - // } - // } - //} - - //internal void SetSelHardware(Hardware value) - //{ - // m_SelHardware = value; - //} - - //internal void SetSelHardwareFromId(string sId) - //{ - // m_SelHardware = m_HardwareList.FirstOrDefault(x => x.sId == sId); - // if (IsNothing(m_SelHardware)) - // m_SelHardware = m_HardwareList(0); - //} - - //internal void SetFirstHardware() - //{ - // if (m_HardwareList.Count > 0) - // { - // m_SelHardware = m_HardwareList(0); - // } - //} - - private ObservableCollection m_HwdOptionList = new ObservableCollection(); - public ObservableCollection HwdOptionList + private ObservableCollection m_HwOptionList = new ObservableCollection(); + public ObservableCollection HwOptionList { get { - return m_HwdOptionList; + return m_HwOptionList; } } @@ -1248,7 +1146,7 @@ namespace WebWindowConfigurator internal void RefreshHardwareOptionList() { - m_HwdOptionList.Clear(); + m_HwOptionList.Clear(); } internal OpeningSides GetOpeningSide(Openings OpeningType) diff --git a/WebWindowTest/Models/Sash.cs b/WebWindowTest/Models/Sash.cs index aaa2f6e..2ecb53d 100644 --- a/WebWindowTest/Models/Sash.cs +++ b/WebWindowTest/Models/Sash.cs @@ -78,7 +78,7 @@ namespace WebWindowTest.Models { get { - return m_HwdOptionList; + return m_HwOptionList; } } @@ -86,7 +86,7 @@ namespace WebWindowTest.Models { get { - return m_SelHwdOptionList; + return m_SelHwOptionList; } } @@ -652,7 +652,7 @@ namespace WebWindowTest.Models internal void RefreshHardwareOptionList() { - m_HwdOptionList.Clear(); + m_HwOptionList.Clear(); //ReqRefreshHwOption(); } @@ -718,19 +718,19 @@ namespace WebWindowTest.Models HwOptions = (ParametriOpzioni)serializer.Deserialize(reader); if (HwOptions.Items != null) { - m_HwdOptionList.Clear(); + m_HwOptionList.Clear(); foreach (var HwOption in HwOptions.Items) { switch (HwOption.Tipo) { case "Text": { - m_HwdOptionList.Add(new AGBOptionText(HwOption)); + m_HwOptionList.Add(new AGBOptionText(HwOption)); break; } case "List": { - m_HwdOptionList.Add(new AGBOptionCombo(HwOption)); + m_HwOptionList.Add(new AGBOptionCombo(HwOption)); break; } } @@ -873,8 +873,8 @@ namespace WebWindowTest.Models private string m_CurrShape = ""; private List m_HardwareList = new List(); - private List m_HwdOptionList = new List(); - private Dictionary m_SelHwdOptionList = new Dictionary(); + private List m_HwOptionList = new List(); + private Dictionary m_SelHwOptionList = new Dictionary(); private List m_JointList = new List();