diff --git a/WebWindowComplex/TableComp.razor.cs b/WebWindowComplex/TableComp.razor.cs
index ae72fd3..330397e 100644
--- a/WebWindowComplex/TableComp.razor.cs
+++ b/WebWindowComplex/TableComp.razor.cs
@@ -2,8 +2,6 @@
using Microsoft.AspNetCore.Components;
using Newtonsoft.Json;
using NLog;
-using System.Collections.Generic;
-using System.Threading.Tasks;
using WebWindowComplex.Compo;
using WebWindowComplex.DTO;
using WebWindowComplex.Json;
@@ -49,18 +47,18 @@ namespace WebWindowComplex
#region Public Properties
+ ///
+ /// Livello di accesso (utente base)
+ ///
+ [Parameter]
+ public bool baseUser { get; set; } = false!;
+
///
/// Classe override css x SVG (x rescale)
///
[Parameter]
public string CssSvg { get; set; } = "responsive-svg";
- ///
- /// Preselezione valori
- ///
- [Parameter]
- public SelectPayload? SelectionData { get; set; } = null;
-
///
/// Richiesta azione al parent
///
@@ -100,10 +98,10 @@ namespace WebWindowComplex
public LivePayload LiveData { get; set; } = null!;
///
- /// Livello di accesso (utente base)
+ /// Preselezione valori
///
[Parameter]
- public bool baseUser { get; set; } = false!;
+ public SelectPayload? SelectionData { get; set; } = null;
#endregion Public Properties
@@ -119,39 +117,262 @@ namespace WebWindowComplex
#endregion Public Methods
- #region Protected Fields
+ #region Protected Methods
- protected List currLoading = new List();
+ protected override async Task OnAfterRenderAsync(bool firstRender)
+ {
+ if (forceSvgUpdate)
+ {
+ firstDisplay = false;
+ forceSvgUpdate = false;
+ // preview SVG senza HW
+ await DoPreviewSvg(true, true);
+ if (LiveData.ProfElementList.Count == 0)
+ await UpdateElement(FrameWindow);
+ }
+ isRendered = true;
+ }
+
+ ///
+ /// Primo init componente
+ ///
+ protected override void OnInitialized()
+ {
+ // reset editLock...
+ editLock = false;
+ listErrPre = new Dictionary();
+ listErrLink = new Dictionary();
+ listWarnings = new Dictionary();
+ }
+
+ ///
+ /// Gestione update post ricezione parametri da controllo chiamante
+ ///
+ protected override async Task OnParametersSetAsync()
+ {
+ isLoading = true;
+ // SOLO SE sono presenti...
+ listErrLink = new Dictionary();
+ okParams = ListPayload.IsPopulated();
+ okJwd = LiveData.IsValid();
+ if (okParams && okJwd)
+ {
+ bool updRequested = false;
+ listErrPre = new Dictionary();
+ listWarnings = new Dictionary();
+ // controllo elenchi BasePayload siano validi...
+ if (ListPayload.IsValid())
+ {
+ // SOLO SE modificato live data...
+ if (prevLiveData == null || !prevLiveData.Equals(LiveData))
+ {
+ bool needDeser = prevLiveData == null || !prevLiveData.JwdEqual(LiveData);
+ updRequested = true;
+ prevLiveData = new LivePayload()
+ {
+ CurrJwd = LiveData.CurrJwd,
+ DictOptionsXml = LiveData.DictOptionsXml,
+ DictShape = LiveData.DictShape,
+ SvgPreview = LiveData.SvgPreview,
+ ProfElementList = LiveData.ProfElementList
+ };
+ // Aggiornati parametri di ingresso selezionati
+ UpdateSelParameter();
+ // provo a deserializzare SE necessario
+ if (needDeser)
+ {
+ JsonWindow WindowFromJson = new JsonWindow("", "", "", "");
+ try
+ {
+ WindowFromJson = JsonConvert.DeserializeObject(LiveData.CurrJwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", "");
+ if (WindowFromJson == null || WindowFromJson.AreaList == null || WindowFromJson.AreaList.Count == 0)
+ {
+ WindowFromJson = BuildWindowDefault();
+ Log.Info("Ricostruito jwd");
+ }
+ UpdateInputList(WindowFromJson);
+ setCurrWindow(WindowFromJson);
+ //SOLO SE non sono in edit...
+ if (!editLock)
+ {
+ currStep = CompileStep.Tree;
+ }
+ }
+ // altrimenti errore!
+ catch (Exception ex)
+ {
+ listErrLink.Add("Window", $"Deserializing Error:{Environment.NewLine}{ex}");
+ Log.Error($"Errore nel deserializzare jwd: {ex.Message}");
+ // costruisco una finestra base
+ WindowFromJson = BuildWindowDefault();
+ await DoPreviewSvg(true);
+ }
+ }
+ else
+ {
+ // usando m_currWindow (preesistente) impostare i parametri...
+ UpdateDict();
+ }
+ }
+ if (m_CurrWindow != null && m_CurrWindow.AreaList != null && m_CurrWindow.AreaList.Count > 0)
+ {
+ checkWarnings();
+ if (SashGroupList.Count > 0)
+ currAntaIndex = 0;
+ if (updRequested)
+ {
+ // se mancasse dizionario forme chiamo quello
+ if (LiveData.DictShape.Count == 0 && listErrLink.Count == 0)
+ {
+ if (firstDisplay && isRendered)
+ {
+ firstDisplay = false;
+ // preview SVG senza HW
+ await DoPreviewSvg(true, true);
+ if (LiveData.ProfElementList.Count == 0)
+ await UpdateElement(FrameWindow);
+ }
+ else
+ {
+ forceSvgUpdate = true;
+ }
+ List reqList = SashGroupList.Select(x => x.GroupId).ToList();
+ if (reqList.Count > 0)
+ {
+ await DoReqShape(reqList);
+ }
+ }
+ else
+ {
+ // chiedo SVG
+ if (prevReq != (int)DataReq.ReqSvg || !prevLiveData.JwdEqual(LiveData.CurrJwd))
+ {
+ if (prevReq != (int)DataReq.ReqHwOpt)
+ await DoPreviewSvg(true);
+ else if (LiveData.DictOptionsXml.Count > 0)
+ await DoPreviewSvg(true);
+ }
+ }
+ }
+ }
+ else
+ {
+ JsonWindow WindowFromJson = new JsonWindow("", "", "", "");
+ WindowFromJson = BuildWindowDefault();
+ await DoPreviewSvg(true);
+ }
+ }
+ else
+ {
+ checkErrorPre();
+ }
+ }
+ isLoading = false;
+ }
+
+ #endregion Protected Methods
+
+ #region Private Fields
+
+ private static Logger Log = LogManager.GetCurrentClassLogger();
+
+ private int currAntaIndex = 0;
+
+ private int currFillIndex = -1;
+
+ private List currLoading = new List();
+
+ private int currSashIndex = -1;
+
+ private int currSplitIndex = -1;
+
+ private CompileStep currStep;
+
+ private bool editLock = false;
+
+ private bool firstDisplay = true;
+
+ private bool forceSvgUpdate = false;
+
+ private bool groupIdOK = false;
+
+ ///
+ /// Booleana fase loading
+ ///
+ private bool isLoading = false;
+
+ private bool isRendered = false;
+
+ ///
+ /// ELenco errori di coerenza/link dati (vanno risolti per disegnare/procedere)
+ ///
+ private Dictionary listErrLink = new Dictionary();
+
+ ///
+ /// Elenco errori preliminari (mancano elementi di base di validazione modello dati))
+ ///
+ private Dictionary listErrPre = new Dictionary();
+
+ ///
+ /// Elenco warnings non bloccanti
+ ///
+ private Dictionary listWarnings = new Dictionary();
+
+ private List m_FillList = new List();
+
+ private Frame? m_Frame;
+
+ private List m_ItemTableList = new List();
+
+ private int m_maxCol = 0;
+
+ private int m_maxRow = 0;
+
+ private List m_SashList = new List();
+
+ private List m_SplitList = new List();
+
+ private List m_SplittedList = new List();
+
+ private bool okJwd = false;
+
+ private bool okParams = false;
///
/// Dati live precedenti x comparazione
///
- protected LivePayload? prevLiveData = null;
+ private LivePayload? prevLiveData = null;
- #endregion Protected Fields
+ #endregion Private Fields
- #region Protected Properties
+ #region Private Properties
- protected List FillList
+ private Dictionary Child { get; set; } = new Dictionary();
+
+ private List FillList
{
get => m_FillList;
}
- protected Frame FrameWindow
+ private Frame FrameWindow
{
get => m_Frame!;
set => m_Frame = value;
}
- protected List ItemTableList
+ private List ItemTableList
{
get => m_ItemTableList;
}
+ private Window? m_CurrWindow { get; set; } = null;
+
+ private Window? m_PreviousWindow { get; set; } = null;
+
///
/// Componente SVG da mostrare
///
- protected MarkupString outSvg
+ private MarkupString outSvg
{
get
{
@@ -161,29 +382,255 @@ namespace WebWindowComplex
}
}
- protected List SashGroupList
+ ///
+ /// Salvataggio JWD precedente x evitare loop su update (aggiornato dopo chiamate redis)
+ ///
+ private string prevJwd { get; set; } = "";
+
+ ///
+ /// Salvataggio tipo di domanda precedente
+ ///
+ private int prevReq { get; set; } = 0;
+
+ private int reqHwOpt { get; set; } = 0;
+
+ private Dictionary RowCollapsed { get; set; } = new Dictionary();
+
+ private List SashGroupList
{
get => m_SashList;
}
- protected List SplittedList
- {
- get => m_SplittedList;
- }
- protected List SplitList
+ private string SelColorMaterial { get; set; } = "";
+
+ private string SelFamilyHardware { get; set; } = "";
+
+ private string SelGlass { get; set; } = "";
+
+ private string SelMaterial { get; set; } = ""!;
+
+ private string SelProfile { get; set; } = "";
+
+ private List SplitList
{
get => m_SplitList;
}
- protected string SelColorMaterial { get; set; } = "";
- protected string SelFamilyHardware { get; set; } = "";
- protected string SelGlass { get; set; } = "";
- protected string SelMaterial { get; set; } = ""!;
- protected string SelProfile { get; set; } = "";
+ private List SplittedList
+ {
+ get => m_SplittedList;
+ }
- #endregion Protected Properties
+ #endregion Private Properties
- #region Protected Methods
+ #region Private Methods
+
+ ///
+ /// Metodo per andare allo step successivo
+ ///
+ /// step successivo
+ private void AdvStep(CompileStep newStep)
+ {
+ currStep = newStep;
+ currSashIndex = -1;
+ currFillIndex = -1;
+ currSplitIndex = -1;
+ }
+
+ ///
+ /// Metodo per ottenere lista di tutti i groupId appartenenti alla window
+ ///
+ /// Area da aggiungere alla lista groupId
+ /// Lista group id
+ private void AllGroupIdList(Area node, List groupIdList)
+ {
+ if (node != null)
+ {
+ groupIdList.Add(node.GroupId);
+ foreach (var item in node.AreaList)
+ {
+ AllGroupIdList(item, groupIdList);
+ }
+ }
+ }
+
+ ///
+ /// Metodo per costruire una finestra con vetro fisso
+ ///
+ ///
+ private JsonWindow BuildWindowDefault()
+ {
+ // Costruisco window e setto i parametri
+ Window window = new Window();
+ window.sProfilePath = "Profilo78";
+ window.sMaterial = "Pino";
+ window.sGlass = "Vetro BE 2S 4T/16/4T";
+ window.sColorMaterial = "Wood";
+ // Costruisco frame e setto i parametri
+ Frame frame = new Frame(null, window);
+ frame.SetGroupId(1);
+ frame.SetAreaType(AreaTypes.FRAME);
+ frame.SetSelShape(Shapes.RECTANGLE);
+ frame.SetSelThresholdFromName("Bottom");
+ frame.SetBottomRail(false);
+ frame.SetBottomRailQty(0);
+ window.AreaList.Add(frame);
+ List DimensionList = new List
+ {
+ new FrameDimension(frame, 1, "Width", 800, false),
+ new FrameDimension(frame, 1, "Height", 1200, true)
+ };
+ List JointList = new List
+ {
+ new Joint(frame, 1, Joints.FULL_H),
+ new Joint(frame, 2, Joints.FULL_H),
+ new Joint(frame, 3, Joints.FULL_H),
+ new Joint(frame, 4, Joints.FULL_H)
+ };
+ frame.JointList = JointList;
+ frame.DimensionList = DimensionList;
+ // Costruisco fill e setto i parametri
+ Fill fill = new Fill(frame, window);
+ fill.AreaType = AreaTypes.FILL;
+ fill.SelFillType = FillTypes.GLASS;
+ fill.GroupId = 2;
+ frame.AreaList.Add(fill);
+ JsonWindow jsonWindow = window.Serialize();
+ string jwd = JsonConvert.SerializeObject(jsonWindow);
+ return JsonConvert.DeserializeObject(jwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", "");
+ }
+
+ ///
+ /// Calcola bottone per tutti i Fill
+ ///
+ ///
+ private string buttonFillCss(FillTypes reqFillTypes)
+ {
+ foreach (var fill in FillList)
+ {
+ if (!fill.FillType.Equals(reqFillTypes))
+ return "btn btn-outline-secondary btn-sm";
+ }
+ return "btn btn-secondary btn-sm";
+ }
+
+ ///
+ /// Metodo per cambiare tutti i Fill e richiedere aggiornamento SVG
+ ///
+ /// tipo di fill richiesto
+ ///
+ private Task ChangeAllFill(FillTypes reqFillType)
+ {
+ updateAllFill(FrameWindow, reqFillType);
+ return DoPreviewSvg();
+ }
+
+ ///
+ /// Verifica errori prelimionari per mostrare dove sia il problema
+ ///
+ private void checkErrorPre()
+ {
+ // verifico 1:1 le liste e indico cosa manca
+ if (ListPayload.Hardware == null || ListPayload.Hardware.Count == 0)
+ {
+ listErrPre.Add("Hardware", "Missing Hardware List!");
+ Log.Warn("Missing Hardware List");
+ }
+ else
+ {
+ if (ListPayload.FamilyHardware == null || ListPayload.FamilyHardware.Count == 0)
+ {
+ listErrPre.Add("FamilyHardware", "Missing Family HW List!");
+ Log.Warn(" Missing Family HW List");
+ }
+ }
+ if (ListPayload.Glass == null || ListPayload.Glass.Count == 0)
+ {
+ listErrPre.Add("Glass", "Missing Glass List!");
+ Log.Warn(" Missing Glass List");
+ }
+ if (ListPayload.Material == null || ListPayload.Material.Count == 0)
+ {
+ listErrPre.Add("Material", "Missing Material List!");
+ Log.Warn(" Missing Material List");
+ }
+ if (ListPayload.ColorMaterial == null || ListPayload.ColorMaterial.Count == 0)
+ {
+ listErrPre.Add("ColorMaterial", "Missing ColorMaterial List!");
+ Log.Warn("Missing ColorMaterial List");
+ }
+ if (ListPayload.ProfileList == null || ListPayload.ProfileList.Count == 0)
+ {
+ listErrPre.Add("Profile", "Missing Profile data!");
+ Log.Warn("Missing Profile data");
+ }
+ }
+
+ ///
+ /// Metodo per controllare che non ci siano duplicati di GroupId
+ ///
+ ///
+ ///
+ private bool CheckGroupId(Window window)
+ {
+ List groupIdList = new List();
+ AllGroupIdList(window.AreaList.First(), groupIdList);
+ var duplicati = groupIdList.GroupBy(x => x)
+ .Where(g => g.Count() > 1)
+ .Select(g => g.Key)
+ .ToList();
+ return duplicati.Count > 0 ? false : true;
+ }
+
+ ///
+ /// Verifica warning minori (es coerenza colori...)
+ ///
+ private void checkWarnings()
+ {
+ // verifico 1:1 le liste e i valori siano coerenti...
+ if (ListPayload.ColorMaterial != null && ListPayload.ColorMaterial.Count > 0)
+ {
+ if (m_CurrWindow != null)
+ {
+ if (ListPayload.ColorMaterial == null || !ListPayload.ColorMaterial.Contains(m_CurrWindow.sColorMaterial))
+ {
+ listWarnings.Add("ColorMaterial", $"Missing Color: {m_CurrWindow.sColorMaterial}");
+ }
+ if (ListPayload.Glass == null || !ListPayload.Glass.Contains(m_CurrWindow.sGlass))
+ {
+ listWarnings.Add("Glass", $"Missing Glass: {m_CurrWindow.sGlass}");
+ }
+ if (ListPayload.Material == null || !ListPayload.Material.Contains(m_CurrWindow.sMaterial))
+ {
+ listWarnings.Add("Material", $"Missing Material: {m_CurrWindow.sMaterial}");
+ }
+ if (ListPayload.ProfileList == null || !ListPayload.ProfileList.Any(x => x.ProfileName.Contains(m_CurrWindow.sProfilePath)))
+ {
+ listWarnings.Add("Profile", $"Missing Profile: {m_CurrWindow.sProfilePath}");
+ }
+ if (!groupIdOK)
+ {
+ listWarnings.Add("GroupId", "JWD not correct!");
+ }
+ }
+ }
+ }
+
+ ///
+ /// Metodo per aggiornare il valore collassato degli elementi della gerarchia
+ ///
+ ///
+ private void CollapsedRowTree(Dictionary Args)
+ {
+ foreach (var item in Args)
+ {
+ RowCollapsed[item.Key] = Args[item.Key] ? true : false;
+ if (m_ItemTableList.FirstOrDefault(x => x.Row == item.Key) != null)
+ {
+ Child[item.Key] = m_ItemTableList.FirstOrDefault(x => x.Row == item.Key)!.NumChild;
+ }
+ }
+ }
///
/// Metodo per riempire la lista ItemTable in modo da poter rappresentarla come tabella
@@ -193,7 +640,7 @@ namespace WebWindowComplex
/// numero di colonna
/// numero di riga massimo
/// numero di colonna massimo
- protected void CreateElementTable(Area node, int row, int col, int maxRow, int maxCol)
+ private void CreateElementTable(Area node, int row, int col, int maxRow, int maxCol)
{
if (node != null)
{
@@ -336,7 +783,7 @@ namespace WebWindowComplex
///
/// Area da classificare
/// Parametro per sapere se si è dentro un'anta
- protected void CreateWindowsList(Area node, bool IntoSash)
+ private void CreateWindowsList(Area node, bool IntoSash)
{
if (node != null)
{
@@ -385,7 +832,7 @@ namespace WebWindowComplex
///
///
///
- protected string cssValid(string fKey)
+ private string cssValid(string fKey)
{
return listWarnings.ContainsKey(fKey) ? "border border-danger" : "";
}
@@ -394,7 +841,7 @@ namespace WebWindowComplex
/// Richiesta chiusura SENZA salvataggio (= restore prev)
///
///
- protected async Task DoClose()
+ private async Task DoClose()
{
editLock = false;
Log.Info("Richiesta Chiusura");
@@ -422,7 +869,7 @@ namespace WebWindowComplex
/// Forza richiesta anche con JWD invariato
/// Nasconde hw (def. false) poiché senza è piu rapido
///
- protected async Task DoPreviewSvg(bool doForce = false, bool hideHw = false)
+ private async Task DoPreviewSvg(bool doForce = false, bool hideHw = false)
{
if (m_CurrWindow != null)
{
@@ -447,12 +894,42 @@ namespace WebWindowComplex
}
}
+ ///
+ /// Richiesta Profili Element da JWD
+ ///
+ ///
+ private async Task DoReqElement(List groupIdList)
+ {
+ if (m_CurrWindow != null)
+ {
+#if DEBUG
+ var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize(), Formatting.Indented);
+#else
+ var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize());
+#endif
+ // verifico variazione JWD
+ if (!prevJwd.Equals(CurrJwd) || prevReq != (int)DataReq.ReqElement)
+ {
+ Log.Info("Richiesta profili elementi");
+ prevJwd = CurrJwd;
+ prevReq = (int)DataReq.ReqElement;
+ Dictionary Args = new Dictionary();
+ Args.Add("Mode", $"{(int)Enums.QuestionModes.HARDWARE}");
+ Args.Add("SubMode", $"{(int)Enums.QuestionHwSubModes.PROFILEDATAFROMAREA}");
+ Args.Add("SerializedData", CurrJwd);
+ string listGroupId = JsonConvert.SerializeObject(groupIdList);
+ Args.Add("GroupId", listGroupId);
+ await EC_DoUpdate.InvokeAsync(Args);
+ }
+ }
+ }
+
///
/// Richiesta calcolo Options HW
///
/// Lista degli ID numerici dei gruppi da valutare
///
- protected async Task DoReqOptHardware(List groupIdList, bool isFirst = false)
+ private async Task DoReqOptHardware(List groupIdList, bool isFirst = false)
{
if (m_CurrWindow != null)
{
@@ -484,7 +961,7 @@ namespace WebWindowComplex
///
/// Lista degli ID numerici dei gruppi da valutare
///
- protected async Task DoReqShape(List groupIdList)
+ private async Task DoReqShape(List groupIdList)
{
if (m_CurrWindow != null)
{
@@ -511,40 +988,10 @@ namespace WebWindowComplex
}
}
- ///
- /// Richiesta Profili Element da JWD
- ///
- ///
- protected async Task DoReqElement(List groupIdList)
- {
- if (m_CurrWindow != null)
- {
-#if DEBUG
- var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize(), Formatting.Indented);
-#else
- var CurrJwd = JsonConvert.SerializeObject(m_CurrWindow.Serialize());
-#endif
- // verifico variazione JWD
- if (!prevJwd.Equals(CurrJwd) || prevReq != (int)DataReq.ReqElement)
- {
- Log.Info("Richiesta profili elementi");
- prevJwd = CurrJwd;
- prevReq = (int)DataReq.ReqElement;
- Dictionary Args = new Dictionary();
- Args.Add("Mode", $"{(int)Enums.QuestionModes.HARDWARE}");
- Args.Add("SubMode", $"{(int)Enums.QuestionHwSubModes.PROFILEDATAFROMAREA}");
- Args.Add("SerializedData", CurrJwd);
- string listGroupId = JsonConvert.SerializeObject(groupIdList);
- Args.Add("GroupId", listGroupId);
- await EC_DoUpdate.InvokeAsync(Args);
- }
- }
- }
-
///
/// Metodo di reset
///
- protected Task DoReset()
+ private Task DoReset()
{
Log.Info("Richiesta reset");
return Task.CompletedTask;
@@ -555,7 +1002,7 @@ namespace WebWindowComplex
/// Richiesta chiusura con salvataggio
///
///
- protected Task DoSave()
+ private Task DoSave()
{
editLock = false;
Log.Info("Richiesta Salvataggio");
@@ -578,523 +1025,6 @@ namespace WebWindowComplex
return null;
}
- protected override void OnAfterRender(bool firstRender)
- {
- isRendered = true;
- }
-
- ///
- /// Primo init componente
- ///
- protected override void OnInitialized()
- {
- // reset editLock...
- editLock = false;
- listErrPre = new Dictionary();
- listErrLink = new Dictionary();
- listWarnings = new Dictionary();
- }
-
- ///
- /// Gestione update post ricezione parametri da controllo chiamante
- ///
- protected override async Task OnParametersSetAsync()
- {
- isLoading = true;
- // SOLO SE sono presenti...
- listErrLink = new Dictionary();
- okParams = ListPayload.IsPopulated();
- okJwd = LiveData.IsValid();
- if (okParams && okJwd)
- {
- bool updRequested = false;
- listErrPre = new Dictionary();
- listWarnings = new Dictionary();
- // controllo elenchi BasePayload siano validi...
- if (ListPayload.IsValid())
- {
- // SOLO SE modificato live data...
- if (prevLiveData == null || !prevLiveData.Equals(LiveData))
- {
- bool needDeser = prevLiveData == null || !prevLiveData.JwdEqual(LiveData);
- updRequested = true;
- prevLiveData = new LivePayload()
- {
- CurrJwd = LiveData.CurrJwd,
- DictOptionsXml = LiveData.DictOptionsXml,
- DictShape = LiveData.DictShape,
- SvgPreview = LiveData.SvgPreview,
- ProfElementList = LiveData.ProfElementList
- };
- // Aggiornati parametri di ingresso selezionati
- UpdateSelParameter();
- // provo a deserializzare SE necessario
- if (needDeser)
- {
- JsonWindow WindowFromJson = new JsonWindow("", "", "", "");
- try
- {
- WindowFromJson = JsonConvert.DeserializeObject(LiveData.CurrJwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", "");
- if (WindowFromJson == null || WindowFromJson.AreaList == null || WindowFromJson.AreaList.Count == 0)
- {
- WindowFromJson = BuildWindowDefault();
- Log.Info("Ricostruito jwd");
- }
- UpdateInputList(WindowFromJson);
- setCurrWindow(WindowFromJson);
- //SOLO SE non sono in edit...
- if (!editLock)
- {
- currStep = CompileStep.Tree;
- }
- }
- // altrimenti errore!
- catch (Exception ex)
- {
- listErrLink.Add("Window", $"Deserializing Error:{Environment.NewLine}{ex}");
- Log.Error($"Errore nel deserializzare jwd: {ex.Message}");
- // costruisco una finestra base
- WindowFromJson = BuildWindowDefault();
- await DoPreviewSvg(true);
- }
- }
- else
- {
- // usando m_currWindow (preesistente) impostare i parametri...
- UpdateDict();
- }
- }
- if (m_CurrWindow != null && m_CurrWindow.AreaList != null && m_CurrWindow.AreaList.Count > 0)
- {
- checkWarnings();
- if (SashGroupList.Count > 0)
- currAntaIndex = 0;
- if (updRequested)
- {
- // se mancasse dizionario forme chiamo quello
- if (LiveData.DictShape.Count == 0 && listErrLink.Count == 0)
- {
- if (firstDisplay && isRendered)
- {
- firstDisplay = false;
- // preview SVG senza HW
- await DoPreviewSvg(true, true);
- if (LiveData.ProfElementList.Count == 0)
- await UpdateElement(FrameWindow);
- }
- List reqList = SashGroupList.Select(x => x.GroupId).ToList();
- if (reqList.Count > 0)
- {
- await DoReqShape(reqList);
- }
- }
- else
- {
- // chiedo SVG
- if (prevReq != (int)DataReq.ReqSvg || !prevLiveData.JwdEqual(LiveData.CurrJwd))
- {
- if (prevReq != (int)DataReq.ReqHwOpt)
- await DoPreviewSvg(true);
- else if (LiveData.DictOptionsXml.Count > 0)
- await DoPreviewSvg(true);
- }
- }
- }
- }
- else
- {
- JsonWindow WindowFromJson = new JsonWindow("", "", "", "");
- WindowFromJson = BuildWindowDefault();
- await DoPreviewSvg(true);
- }
- }
- else
- {
- checkErrorPre();
- }
- }
- isLoading = false;
- }
-
- ///
- /// Metodo per costruire una finestra con vetro fisso
- ///
- ///
- private JsonWindow BuildWindowDefault()
- {
- // Costruisco window e setto i parametri
- Window window = new Window();
- window.sProfilePath = "Profilo78";
- window.sMaterial = "Pino";
- window.sGlass = "Vetro BE 2S 4T/16/4T";
- window.sColorMaterial = "Wood";
- // Costruisco frame e setto i parametri
- Frame frame = new Frame(null, window);
- frame.SetGroupId(1);
- frame.SetAreaType(AreaTypes.FRAME);
- frame.SetSelShape(Shapes.RECTANGLE);
- frame.SetSelThresholdFromName("Bottom");
- frame.SetBottomRail(false);
- frame.SetBottomRailQty(0);
- window.AreaList.Add(frame);
- List DimensionList = new List
- {
- new FrameDimension(frame, 1, "Width", 800, false),
- new FrameDimension(frame, 1, "Height", 1200, true)
- };
- List JointList = new List
- {
- new Joint(frame, 1, Joints.FULL_H),
- new Joint(frame, 2, Joints.FULL_H),
- new Joint(frame, 3, Joints.FULL_H),
- new Joint(frame, 4, Joints.FULL_H)
- };
- frame.JointList = JointList;
- frame.DimensionList = DimensionList;
- // Costruisco fill e setto i parametri
- Fill fill = new Fill(frame, window);
- fill.AreaType = AreaTypes.FILL;
- fill.SelFillType = FillTypes.GLASS;
- fill.GroupId = 2;
- frame.AreaList.Add(fill);
- JsonWindow jsonWindow = window.Serialize();
- string jwd = JsonConvert.SerializeObject(jsonWindow);
- return JsonConvert.DeserializeObject(jwd, new PolymorphicJsonConverter()) ?? new JsonWindow("", "", "", "");
- }
-
- ///
- /// Metodo per controllare che non ci siano duplicati di GroupId
- ///
- ///
- ///
- protected bool CheckGroupId(Window window)
- {
- List groupIdList = new List();
- AllGroupIdList(window.AreaList.First(), groupIdList);
- var duplicati = groupIdList.GroupBy(x => x)
- .Where(g => g.Count() > 1)
- .Select(g => g.Key)
- .ToList();
- return duplicati.Count > 0 ? false : true;
- }
-
- ///
- /// Metodo per costruire oggetti della Window
- ///
- ///
- protected void setCurrWindow(JsonWindow WindowFromJson)
- {
- if (m_CurrWindow != null)
- {
- m_CurrWindow = null;
- }
- m_CurrWindow = WindowFromJson.Deserialize();
- groupIdOK = CheckGroupId(m_CurrWindow);
- if (groupIdOK)
- {
- FrameWindow = m_CurrWindow.AreaList[0];
- if (m_PreviousWindow != null)
- {
- for (int i = 0; i < 2; i++)
- m_CurrWindow.AreaList.First().DimensionList[i].dDimension = m_PreviousWindow.AreaList.First().DimensionList[i].dDimension;
- if (m_CurrWindow.AreaList.First().Shape == Shapes.TRIANGLE)
- {
- for (int i = 0; i < 2; i++)
- m_CurrWindow.AreaList.First().JointList[i].SelJointType = m_PreviousWindow.AreaList.First().JointList[i].SelJointType;
- }
- else
- {
- for (int i = 0; i < 4; i++)
- m_CurrWindow.AreaList.First().JointList[i].SelJointType = m_PreviousWindow.AreaList.First().JointList[i].SelJointType;
- }
- }
- if (m_CurrWindow != null)
- {
- // Aggiornamento liste sash, split, splitted, fill e itemTable
- UpdateLists();
- }
- if (SashGroupList.Count > 0)
- currAntaIndex = 0;
- // Aggiorno window con dati shape e hw option
- UpdateDict();
- }
- }
-
- ///
- /// Aggiornamento dei dati con informazioni ricevute dai dizionari
- ///
- protected void UpdateDict()
- {
- // se ho i dizionari delle forme le aggiungo
- if (LiveData.DictShape.Count > 0)
- {
- // Inserisco le forme ricevuto nei sash group
- foreach (var item in LiveData.DictShape)
- {
- Sash? sashFromGroupId = SashGroupList.FirstOrDefault(x => x.GroupId == item.Key);
- if (sashFromGroupId != null)
- {
- sashFromGroupId.SashShape = item.Value;
- sashFromGroupId.UpdateShape(item.Value);
- }
- }
- if (prevReq == (int)DataReq.ReqShape)
- {
- if (reqHwOpt > 0)
- {
- List reqList = SashGroupList.Select(x => x.GroupId).ToList();
- if (reqList.Count > 0)
- {
- _ = DoReqOptHardware(reqList);
- }
- }
- }
- }
- // se ho le opzioni hw le aggiungo
- if (LiveData.DictOptionsXml.Count > 0)
- {
- loadListRem("LoadHwOpt");
- foreach (var item in SashGroupList)
- {
- if (LiveData.DictOptionsXml.ContainsKey(item.GroupId))
- {
- item.SetHardwareOption(LiveData.DictOptionsXml[item.GroupId]);
- }
- }
- }
- if (LiveData.ProfElementList.Count > 0)
- {
- // Inserisco i profili ricevuti nei rispettivi Element
- foreach (var item in LiveData.ProfElementList)
- {
- UpdateProfileElement(item.Profiles, item.GroupId, item.EntId);
- }
- }
- }
-
- ///
- /// Metodo che resetta le liste (sash, split, splitted, fill e itemTable) e le crea nuovamente
- ///
- protected void UpdateLists()
- {
- m_maxCol = 0;
- m_maxRow = 0;
- m_FillList = new List();
- m_SashList = new List();
- m_SplitList = new List();
- m_SplittedList = new List();
- m_ItemTableList = new List();
- CreateWindowsList((m_CurrWindow!).AreaList.First(), false);
- CreateElementTable(m_CurrWindow.AreaList.First(), 1, 1, 1, 1);
- foreach (var item in ItemTableList)
- {
- if (item.NumChild > 3)
- {
- if (!RowCollapsed.ContainsKey(item.Row))
- {
- RowCollapsed.Add(item.Row, false);
- Child.Add(item.Row, item.NumChild);
- }
- }
- else if (RowCollapsed.ContainsKey(item.Row))
- {
- RowCollapsed.Remove(item.Row);
- Child.Remove(item.Row);
- }
- }
- }
-
- ///
- /// Metodo per settare i paramteri di ingresso selezionati
- ///
- protected void UpdateInputList(JsonWindow WindowFromJson)
- {
- string profile = WindowFromJson.ProfilePath;
- Window.m_ParameterList = ListPayload.ProfileList?.FirstOrDefault(x => x.ProfileName.Equals(profile))?.ParameterDict ?? new();
- Frame.m_AllThresholdList = ListPayload.ProfileList?.FirstOrDefault(x => x.ProfileName.Equals(profile))?.ThresholdList ?? new();
- Sash.m_HardwareCompleteList = ListPayload.Hardware;
- Sash.s_FamilyHardwareList = ListPayload.FamilyHardware;
- }
-
- ///
- /// Metodo per settare i parmateri di ingresso selezionati
- ///
- protected void UpdateSelParameter()
- {
- if (SelectionData != null && SelectionData.IsValid())
- {
- SelFamilyHardware = SelectionData.FamilyHardware ?? "";
- SelColorMaterial = SelectionData.ColorMaterial ?? "";
- SelMaterial = SelectionData.Material ?? "";
- SelGlass = SelectionData.Glass ?? "";
- SelProfile = SelectionData.Profile ?? "";
- }
- }
-
- #endregion Protected Methods
-
- #region Private Fields
-
- private int currAntaIndex = 0;
- private int currFillIndex = -1;
- private int currSashIndex = -1;
- private int currSplitIndex = -1;
- private CompileStep currStep;
- private bool editLock = false;
- private bool firstDisplay = true;
- private bool groupIdOK = false;
-
- ///
- /// Booleana fase loading
- ///
- private bool isLoading = false;
- private bool okParams = false;
- private bool okJwd = false;
- private bool isRendered = false;
-
- ///
- /// ELenco errori di coerenza/link dati (vanno risolti per disegnare/procedere)
- ///
- private Dictionary listErrLink = new Dictionary();
-
- ///
- /// Elenco errori preliminari (mancano elementi di base di validazione modello dati))
- ///
- private Dictionary listErrPre = new Dictionary();
-
- ///
- /// Elenco warnings non bloccanti
- ///
- private Dictionary listWarnings = new Dictionary();
-
-
- private Frame? m_Frame;
-
- private List m_ItemTableList = new List();
-
- private int m_maxCol = 0;
-
- private int m_maxRow = 0;
-
- private List m_SashList = new List();
- private List m_SplitList = new List();
- private List m_FillList = new List();
- private List m_SplittedList = new List();
-
- private Dictionary RowCollapsed { get; set; } = new Dictionary();
- private Dictionary Child { get; set; } = new Dictionary();
-
- private static Logger Log = LogManager.GetCurrentClassLogger();
-
- #endregion Private Fields
-
- #region Private Properties
-
- private Window? m_CurrWindow { get; set; } = null;
- private Window? m_PreviousWindow { get; set; } = null;
-
- ///
- /// Salvataggio JWD precedente x evitare loop su update (aggiornato dopo chiamate redis)
- ///
- private string prevJwd { get; set; } = "";
-
- ///
- /// Salvataggio tipo di domanda precedente
- ///
- private int prevReq { get; set; } = 0;
- private int reqHwOpt { get; set; } = 0;
-
- #endregion Private Properties
-
- #region Private Methods
-
- ///
- /// Metodo per andare allo step successivo
- ///
- /// step successivo
- private void AdvStep(CompileStep newStep)
- {
- currStep = newStep;
- currSashIndex = -1;
- currFillIndex = -1;
- currSplitIndex = -1;
- }
-
- ///
- /// Verifica errori prelimionari per mostrare dove sia il problema
- ///
- private void checkErrorPre()
- {
- // verifico 1:1 le liste e indico cosa manca
- if (ListPayload.Hardware == null || ListPayload.Hardware.Count == 0)
- {
- listErrPre.Add("Hardware", "Missing Hardware List!");
- Log.Warn("Missing Hardware List");
- }
- else
- {
- if (ListPayload.FamilyHardware == null || ListPayload.FamilyHardware.Count == 0)
- {
- listErrPre.Add("FamilyHardware", "Missing Family HW List!");
- Log.Warn(" Missing Family HW List");
- }
- }
- if (ListPayload.Glass == null || ListPayload.Glass.Count == 0)
- {
- listErrPre.Add("Glass", "Missing Glass List!");
- Log.Warn(" Missing Glass List");
- }
- if (ListPayload.Material == null || ListPayload.Material.Count == 0)
- {
- listErrPre.Add("Material", "Missing Material List!");
- Log.Warn(" Missing Material List");
- }
- if (ListPayload.ColorMaterial == null || ListPayload.ColorMaterial.Count == 0)
- {
- listErrPre.Add("ColorMaterial", "Missing ColorMaterial List!");
- Log.Warn("Missing ColorMaterial List");
- }
- if (ListPayload.ProfileList == null || ListPayload.ProfileList.Count == 0)
- {
- listErrPre.Add("Profile", "Missing Profile data!");
- Log.Warn("Missing Profile data");
- }
- }
-
- ///
- /// Verifica warning minori (es coerenza colori...)
- ///
- private void checkWarnings()
- {
- // verifico 1:1 le liste e i valori siano coerenti...
- if (ListPayload.ColorMaterial != null && ListPayload.ColorMaterial.Count > 0)
- {
- if (m_CurrWindow != null)
- {
- if (ListPayload.ColorMaterial == null || !ListPayload.ColorMaterial.Contains(m_CurrWindow.sColorMaterial))
- {
- listWarnings.Add("ColorMaterial", $"Missing Color: {m_CurrWindow.sColorMaterial}");
- }
- if (ListPayload.Glass == null || !ListPayload.Glass.Contains(m_CurrWindow.sGlass))
- {
- listWarnings.Add("Glass", $"Missing Glass: {m_CurrWindow.sGlass}");
- }
- if (ListPayload.Material == null || !ListPayload.Material.Contains(m_CurrWindow.sMaterial))
- {
- listWarnings.Add("Material", $"Missing Material: {m_CurrWindow.sMaterial}");
- }
- if (ListPayload.ProfileList == null || !ListPayload.ProfileList.Any(x => x.ProfileName.Contains(m_CurrWindow.sProfilePath)))
- {
- listWarnings.Add("Profile", $"Missing Profile: {m_CurrWindow.sProfilePath}");
- }
- if (!groupIdOK)
- {
- listWarnings.Add("GroupId", "JWD not correct!");
- }
- }
- }
- }
-
///
/// Helper aggiunta elemento a lista caricamento (per caricamento opzioni hw)
///
@@ -1165,19 +1095,67 @@ namespace WebWindowComplex
}
///
- /// Metodo per aggiornare il valore collassato degli elementi della gerarchia
+ /// Rimozione area da frame corrente
///
- ///
- private void CollapsedRowTree(Dictionary Args)
+ /// oggetto da rimuovere
+ ///
+ private async Task RemoveArea(DataNextStep remove)
{
- foreach (var item in Args)
+ if (remove.currCompileStep is CompileStep.Sash)
{
- RowCollapsed[item.Key] = Args[item.Key] ? true : false;
- if (m_ItemTableList.FirstOrDefault(x => x.Row == item.Key) != null)
+ SashGroupList.ElementAt(remove.index).Remove();
+ if (FrameWindow.SelThreshold.Name.Contains("Threshold") && remove.index == 0)
{
- Child[item.Key] = m_ItemTableList.FirstOrDefault(x => x.Row == item.Key)!.NumChild;
+ Threshold? updThreshold = FrameWindow.ThresholdList.FirstOrDefault(x => x.Name != "Threshold");
+ if (updThreshold != null)
+ FrameWindow.SelThresholdFromName = updThreshold.Name;
}
+ SashGroupList.RemoveAt(remove.index);
}
+ else if (remove.currCompileStep is CompileStep.Split)
+ {
+ SplitList.ElementAt(remove.index).Remove();
+ SplitList.RemoveAt(remove.index);
+ }
+ await EC_ActionReq.InvokeAsync(DataAction.ResetDimElem);
+ await DoPreviewSvg();
+ }
+
+ ///
+ /// Richiesta opzioni hardware per la prima volta
+ ///
+ /// nuovo frame
+ ///
+ private async Task ReqFirstOptionHw(Sash newSash)
+ {
+ if (newSash != null)
+ {
+ // cerco il record
+ var currRec = SearchAreaFromGroupId(FrameWindow, newSash.GroupId);
+ // lo aggiorno
+ currRec = newSash;
+ // resetto hw list
+ await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt);
+ // richiesta calcolo opzioni hardware per la singola sash group
+ List reqList = SashGroupList.Select(x => x.GroupId).ToList();
+ // chiamo con gruppo della nuova sash
+ await DoReqOptHardware(reqList);
+ }
+ }
+
+ ///
+ /// Lista completa dei group id per le richieste
+ ///
+ /// nodo da controllare
+ /// Lista groupId
+ private void ReqGroupIdList(Area node, List groupId)
+ {
+ if (node.AreaList == null)
+ return;
+ if (node is Sash || node is Split)
+ groupId.Add(node.GroupId);
+ foreach (var child in node.AreaList)
+ ReqGroupIdList(child, groupId);
}
///
@@ -1220,114 +1198,44 @@ namespace WebWindowComplex
}
///
- /// Metodo per aggiornare i nomi dei profili degli elementi
+ /// Metodo per costruire oggetti della Window
///
- /// Lista dei profili
- /// Id Area che si sta cercando
- /// Id dell'anta o dello split (se -1 non usare)
- ///
- private void UpdateProfileElement(List profileNameList, int GroupIdSearch, int EntityIdSearch)
+ ///
+ private void setCurrWindow(JsonWindow WindowFromJson)
{
- // Cerco area corrispondente al GroupId
- Area? found = SearchAreaFromGroupId(FrameWindow, GroupIdSearch);
- List elemList = new List();
- if (found != null)
+ if (m_CurrWindow != null)
{
- switch (found.AreaType)
+ m_CurrWindow = null;
+ }
+ m_CurrWindow = WindowFromJson.Deserialize();
+ groupIdOK = CheckGroupId(m_CurrWindow);
+ if (groupIdOK)
+ {
+ FrameWindow = m_CurrWindow.AreaList[0];
+ if (m_PreviousWindow != null)
{
- case AreaTypes.FRAME:
- {
- Frame frame = (Frame)found;
- for (int index = frame.ElementDimensionList.Count; index < profileNameList.Count; index++)
- {
- double valStd = Window.m_ParameterList.GetValueOrDefault(profileNameList.ElementAt(index) + "_DimStd");
- frame.ElementDimensionList.Add(new ElementDimension(frame, index + 1, valStd));
- }
- for (int i = 0; i < frame.ElementDimensionList.Count; i++)
- {
- frame.ElementDimensionList.ElementAt(i).SetNameElement(profileNameList.ElementAt(i));
- }
- for (int index = profileNameList.Count; index < frame.ElementDimensionList.Count; index++)
- frame.ElementDimensionList.RemoveAt(index);
- elemList = frame.ElementDimensionList;
- foreach (var item in elemList)
- {
- string overlapName = string.Join("_", item.sName.Split('_').Skip(1));
- item.SetOverlapElement(Window.m_ParameterList.GetValueOrDefault(overlapName + "_Overlap"));
- }
- foreach (var elem in frame.BottomRailElemDimList)
- {
- elem.SetOverlapElement(Window.m_ParameterList.GetValueOrDefault("Frame_BottomRail_Overlap"));
- }
- break;
- }
- case AreaTypes.SASH:
- {
- Sash sash = (Sash)found;
- SashDimension anta = sash.SashList.ElementAt(EntityIdSearch - 1);
- for (int index = anta.ElementDimensionList.Count; index < profileNameList.Count; index++)
- {
- double valStd = Window.m_ParameterList.GetValueOrDefault(profileNameList.ElementAt(index) + "_DimStd");
- anta.ElementDimensionList.Add(new ElementDimension(sash, index + 1, valStd));
- }
- int numElemDelete = anta.ElementDimensionList.Count - profileNameList.Count;
- for (int i = 0; i < numElemDelete; i++)
- {
- anta.ElementDimensionList.RemoveAt(anta.ElementDimensionList.Count - 1);
- }
- for (int index = profileNameList.Count; index < anta.ElementDimensionList.Count; index++)
- anta.ElementDimensionList.RemoveAt(index);
- for (int i = 0; i < anta.ElementDimensionList.Count; i++)
- {
- anta.ElementDimensionList.ElementAt(i).SetNameElement(profileNameList.ElementAt(i));
- }
- SetOverlapSash(sash, anta, EntityIdSearch - 1, elemList);
- break;
- }
- case AreaTypes.SPLIT:
- {
- Split split = (Split)found;
- List SpElemList = split.searchElemFromSubArea(EntityIdSearch);
- for (int i = 0; i < SpElemList.Count; i++)
- {
- SpElemList.ElementAt(i).SetNameElement(profileNameList.ElementAt(i));
- SpElemList.ElementAt(i).SetMinDimension(Window.m_ParameterList.GetValueOrDefault(SpElemList.ElementAt(i).sName + "_DimMin"));
- SpElemList.ElementAt(i).SetMaxDimension(Window.m_ParameterList.GetValueOrDefault(SpElemList.ElementAt(i).sName + "_DimMax"));
- if (SpElemList.ElementAt(i).dDimension > SpElemList.ElementAt(i).dMaxDim)
- {
- SpElemList.ElementAt(i).SetDimension(SpElemList.ElementAt(i).dMaxDim);
- Frame frame = split.ParentWindow.AreaList.First();
- if (frame != null)
- {
- frame.SearchAreaList(frame, frame.AvailWidthArea(), "Width");
- frame.SearchAreaList(frame, frame.AvailHeightArea(), "Height");
- }
- }
- else if (SpElemList.ElementAt(i).dDimension < SpElemList.ElementAt(i).dMinDim)
- {
- SpElemList.ElementAt(i).SetDimension(SpElemList.ElementAt(i).dMinDim);
- Frame frame = split.ParentWindow.AreaList.First();
- if (frame != null)
- {
- frame.SearchAreaList(frame, frame.AvailWidthArea(), "Width");
- frame.SearchAreaList(frame, frame.AvailHeightArea(), "Height");
- }
- }
- string overlapName = string.Join("_", SpElemList.ElementAt(i).sName.Split('_').Skip(1));
- SpElemList.ElementAt(i).SetOverlapElement(Window.m_ParameterList.GetValueOrDefault(overlapName + "_Overlap"));
- }
- break;
- }
+ for (int i = 0; i < 2; i++)
+ m_CurrWindow.AreaList.First().DimensionList[i].dDimension = m_PreviousWindow.AreaList.First().DimensionList[i].dDimension;
+ if (m_CurrWindow.AreaList.First().Shape == Shapes.TRIANGLE)
+ {
+ for (int i = 0; i < 2; i++)
+ m_CurrWindow.AreaList.First().JointList[i].SelJointType = m_PreviousWindow.AreaList.First().JointList[i].SelJointType;
+ }
+ else
+ {
+ for (int i = 0; i < 4; i++)
+ m_CurrWindow.AreaList.First().JointList[i].SelJointType = m_PreviousWindow.AreaList.First().JointList[i].SelJointType;
+ }
}
- foreach (var item in elemList)
+ if (m_CurrWindow != null)
{
- item.SetMinDimension(Window.m_ParameterList.GetValueOrDefault(item.sName + "_DimMin"));
- item.SetMaxDimension(Window.m_ParameterList.GetValueOrDefault(item.sName + "_DimMax"));
- if (item.dDimension > item.dMaxDim)
- item.SetDimension(item.dMaxDim);
- else if (item.dMaxDim < item.dMinDim)
- item.SetDimension(item.dMinDim);
+ // Aggiornamento liste sash, split, splitted, fill e itemTable
+ UpdateLists();
}
+ if (SashGroupList.Count > 0)
+ currAntaIndex = 0;
+ // Aggiorno window con dati shape e hw option
+ UpdateDict();
}
}
@@ -1567,30 +1475,6 @@ namespace WebWindowComplex
//}
}
- ///
- /// Metodo per aggiornare valori della sezione General
- ///
- ///
- private void UpdatePreviewGeneral(DataUpdateGeneral args)
- {
- string Color = args.Color;
- string Glass = args.Glass;
- string Material = args.Material;
- string Profile = args.Profile;
- if (m_CurrWindow != null)
- {
- if (!string.IsNullOrEmpty(Color))
- m_CurrWindow.sColorMaterial = Color;
- else if (!string.IsNullOrEmpty(Glass))
- m_CurrWindow.sGlass = Glass;
- else if (!string.IsNullOrEmpty(Material))
- m_CurrWindow.sMaterial = Material;
- else if (!string.IsNullOrEmpty(Profile))
- m_CurrWindow.sProfilePath = Profile;
- _ = DoPreviewSvg();
- }
- }
-
///
/// Calcola il css del tab selezionato
///
@@ -1622,17 +1506,6 @@ namespace WebWindowComplex
return (testStep == currStep) ? "nav-link active fw-bold" : "nav-link text-dark";
}
- ///
- /// Metodo per cambiare tutti i Fill e richiedere aggiornamento SVG
- ///
- /// tipo di fill richiesto
- ///
- protected Task ChangeAllFill(FillTypes reqFillType)
- {
- updateAllFill(FrameWindow, reqFillType);
- return DoPreviewSvg();
- }
-
///
/// Metodo per aggiornare tutti i Fill al nuovo tipo
///
@@ -1652,6 +1525,220 @@ namespace WebWindowComplex
}
}
+ ///
+ /// Aggiornamento dei dati con informazioni ricevute dai dizionari
+ ///
+ private void UpdateDict()
+ {
+ // se ho i dizionari delle forme le aggiungo
+ if (LiveData.DictShape.Count > 0)
+ {
+ // Inserisco le forme ricevuto nei sash group
+ foreach (var item in LiveData.DictShape)
+ {
+ Sash? sashFromGroupId = SashGroupList.FirstOrDefault(x => x.GroupId == item.Key);
+ if (sashFromGroupId != null)
+ {
+ sashFromGroupId.SashShape = item.Value;
+ sashFromGroupId.UpdateShape(item.Value);
+ }
+ }
+ if (prevReq == (int)DataReq.ReqShape)
+ {
+ if (reqHwOpt > 0)
+ {
+ List reqList = SashGroupList.Select(x => x.GroupId).ToList();
+ if (reqList.Count > 0)
+ {
+ _ = DoReqOptHardware(reqList);
+ }
+ }
+ }
+ }
+ // se ho le opzioni hw le aggiungo
+ if (LiveData.DictOptionsXml.Count > 0)
+ {
+ loadListRem("LoadHwOpt");
+ foreach (var item in SashGroupList)
+ {
+ if (LiveData.DictOptionsXml.ContainsKey(item.GroupId))
+ {
+ item.SetHardwareOption(LiveData.DictOptionsXml[item.GroupId]);
+ }
+ }
+ }
+ if (LiveData.ProfElementList.Count > 0)
+ {
+ // Inserisco i profili ricevuti nei rispettivi Element
+ foreach (var item in LiveData.ProfElementList)
+ {
+ UpdateProfileElement(item.Profiles, item.GroupId, item.EntId);
+ }
+ }
+ }
+
+ ///
+ /// Aggiornamento Element
+ ///
+ /// nuovo frame
+ ///
+ private async Task UpdateElement(Frame newFrame)
+ {
+ if (newFrame != null)
+ {
+ // richiedo update element del frame
+ List reqList = new List();
+ reqList.Add(FrameWindow.GroupId);
+ // Aggiorno le liste sash, split
+ m_FillList = new List();
+ m_SashList = new List();
+ m_SplitList = new List();
+ m_SplittedList = new List();
+ CreateWindowsList((m_CurrWindow!).AreaList.First(), false);
+ ReqGroupIdList(FrameWindow, reqList);
+ await DoReqElement(reqList);
+ }
+ }
+
+ ///
+ /// Aggiornamento Element a causa di un cambiamento nel frame
+ ///
+ /// nuovo frame
+ ///
+ private async Task UpdateElementFrame(Frame newFrame)
+ {
+ if (newFrame != null)
+ {
+ // cerco il record
+ var currRec = m_CurrWindow?.AreaList.FirstOrDefault(x => x.GroupId == newFrame.GroupId);
+ // lo aggiorno
+ currRec = newFrame;
+ // richiedo update element del frame
+ await UpdateElement(FrameWindow);
+ }
+ }
+
+ ///
+ /// Aggiornamento Element a causa di un cambiamento nella sash
+ ///
+ ///
+ ///
+ private async Task UpdateElementSash(Sash newSash)
+ {
+ if (newSash != null)
+ {
+ Sash currRec = (Sash)SearchAreaFromGroupId(FrameWindow, newSash.GroupId)!;
+ currRec = newSash;
+ await UpdateElement(FrameWindow);
+ }
+ }
+
+ ///
+ /// Aggiornamento Element a causa di un cambiamento nello split
+ ///
+ ///
+ ///
+ private async Task UpdateElementSplit(Split newSplit)
+ {
+ if (newSplit != null)
+ {
+ Split currRec = (Split)SearchAreaFromGroupId(FrameWindow, newSplit.GroupId)!;
+ currRec = newSplit;
+ await UpdateElement(FrameWindow);
+ }
+ }
+
+ ///
+ /// Aggiornamento opzioni dato nuovo frame
+ ///
+ /// nuovo frame
+ ///
+ private async Task UpdateHwOptionsFrame(Frame newFrame)
+ {
+ if (newFrame != null)
+ {
+ // cerco il record
+ var currRec = m_CurrWindow?.AreaList.FirstOrDefault(x => x.GroupId == newFrame.GroupId);
+ // lo aggiorno
+ currRec = newFrame;
+ // resetto hw lst
+ await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt);
+ reqHwOpt++;
+ if (prevReq == (int)DataReq.ReqShape)
+ {
+ // richiesta calcolo opzioni hardware per la singola sash group
+ List reqList = SashGroupList.Select(x => x.GroupId).ToList();
+ // chiamo con gruppo della nuova sash
+ await DoReqOptHardware(reqList);
+ }
+ }
+ }
+
+ ///
+ /// Aggiornamento opzioni data nuova sash group
+ ///
+ /// nuovo frame
+ ///
+ private async Task UpdateHwOptionsSash(Sash newSash)
+ {
+ if (newSash != null)
+ {
+ // cerco il record
+ var currRec = SearchAreaFromGroupId(FrameWindow, newSash.GroupId);
+ // lo aggiorno
+ currRec = newSash;
+ // resetto hw list
+ await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt);
+ // richiesta calcolo opzioni hardware per la singola sash group
+ List reqList = SashGroupList.Select(x => x.GroupId).ToList();
+ await DoReqOptHardware(reqList);
+ }
+ }
+
+ ///
+ /// Metodo per settare i paramteri di ingresso selezionati
+ ///
+ private void UpdateInputList(JsonWindow WindowFromJson)
+ {
+ string profile = WindowFromJson.ProfilePath;
+ Window.m_ParameterList = ListPayload.ProfileList?.FirstOrDefault(x => x.ProfileName.Equals(profile))?.ParameterDict ?? new();
+ Frame.m_AllThresholdList = ListPayload.ProfileList?.FirstOrDefault(x => x.ProfileName.Equals(profile))?.ThresholdList ?? new();
+ Sash.m_HardwareCompleteList = ListPayload.Hardware;
+ Sash.s_FamilyHardwareList = ListPayload.FamilyHardware;
+ }
+
+ ///
+ /// Metodo che resetta le liste (sash, split, splitted, fill e itemTable) e le crea nuovamente
+ ///
+ private void UpdateLists()
+ {
+ m_maxCol = 0;
+ m_maxRow = 0;
+ m_FillList = new List();
+ m_SashList = new List();
+ m_SplitList = new List();
+ m_SplittedList = new List();
+ m_ItemTableList = new List();
+ CreateWindowsList((m_CurrWindow!).AreaList.First(), false);
+ CreateElementTable(m_CurrWindow.AreaList.First(), 1, 1, 1, 1);
+ foreach (var item in ItemTableList)
+ {
+ if (item.NumChild > 3)
+ {
+ if (!RowCollapsed.ContainsKey(item.Row))
+ {
+ RowCollapsed.Add(item.Row, false);
+ Child.Add(item.Row, item.NumChild);
+ }
+ }
+ else if (RowCollapsed.ContainsKey(item.Row))
+ {
+ RowCollapsed.Remove(item.Row);
+ Child.Remove(item.Row);
+ }
+ }
+ }
+
///
/// Aggiornamento Fill
///
@@ -1697,157 +1784,47 @@ namespace WebWindowComplex
}
///
- /// Aggiornamento opzioni dato nuovo frame
+ /// Metodo per aggiornare valori della sezione General
///
- /// nuovo frame
- ///
- private async Task UpdateHwOptionsFrame(Frame newFrame)
+ ///
+ private void UpdatePreviewGeneral(DataUpdateGeneral args)
{
- if (newFrame != null)
+ string Color = args.Color;
+ string Glass = args.Glass;
+ string Material = args.Material;
+ string Profile = args.Profile;
+ if (m_CurrWindow != null)
{
- // cerco il record
- var currRec = m_CurrWindow?.AreaList.FirstOrDefault(x => x.GroupId == newFrame.GroupId);
- // lo aggiorno
- currRec = newFrame;
- // resetto hw lst
- await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt);
- reqHwOpt++;
- if (prevReq == (int)DataReq.ReqShape)
- {
- // richiesta calcolo opzioni hardware per la singola sash group
- List reqList = SashGroupList.Select(x => x.GroupId).ToList();
- // chiamo con gruppo della nuova sash
- await DoReqOptHardware(reqList);
- }
+ if (!string.IsNullOrEmpty(Color))
+ m_CurrWindow.sColorMaterial = Color;
+ else if (!string.IsNullOrEmpty(Glass))
+ m_CurrWindow.sGlass = Glass;
+ else if (!string.IsNullOrEmpty(Material))
+ m_CurrWindow.sMaterial = Material;
+ else if (!string.IsNullOrEmpty(Profile))
+ m_CurrWindow.sProfilePath = Profile;
+ _ = DoPreviewSvg();
}
}
///
- /// Aggiornamento Element a causa di un cambiamento nella sash
+ /// Aggiornamento opzioni dato update sash
///
- ///
+ /// nuova sash
///
- private async Task UpdateElementSash(Sash newSash)
+ private async Task UpdatePreviewSashGroup(DataUpdateSash args)
{
- if (newSash != null)
+ Sash newSash = args.currSash;
+ bool svgNoHw = args.svgNoHw;
+ bool noSvg = args.noSvg;
+ Sash? item = (Sash?)SearchAreaFromGroupId(FrameWindow, newSash.GroupId);
+ if (!noSvg && newSash != null && item != null)
{
- Sash currRec = (Sash)SearchAreaFromGroupId(FrameWindow, newSash.GroupId)!;
- currRec = newSash;
- await UpdateElement(FrameWindow);
- }
- }
-
- ///
- /// Aggiornamento Element a causa di un cambiamento nello split
- ///
- ///
- ///
- private async Task UpdateElementSplit(Split newSplit)
- {
- if (newSplit != null)
- {
- Split currRec = (Split)SearchAreaFromGroupId(FrameWindow, newSplit.GroupId)!;
- currRec = newSplit;
- await UpdateElement(FrameWindow);
- }
- }
-
- ///
- /// Aggiornamento Element a causa di un cambiamento nel frame
- ///
- /// nuovo frame
- ///
- private async Task UpdateElementFrame(Frame newFrame)
- {
- if (newFrame != null)
- {
- // cerco il record
- var currRec = m_CurrWindow?.AreaList.FirstOrDefault(x => x.GroupId == newFrame.GroupId);
- // lo aggiorno
- currRec = newFrame;
- // richiedo update element del frame
- await UpdateElement(FrameWindow);
- }
- }
-
- ///
- /// Aggiornamento Element
- ///
- /// nuovo frame
- ///
- private async Task UpdateElement(Frame newFrame)
- {
- if (newFrame != null)
- {
- // richiedo update element del frame
- List reqList = new List();
- reqList.Add(FrameWindow.GroupId);
- // Aggiorno le liste sash, split
- m_FillList = new List();
- m_SashList = new List();
- m_SplitList = new List();
- m_SplittedList = new List();
- CreateWindowsList((m_CurrWindow!).AreaList.First(), false);
- ReqGroupIdList(FrameWindow, reqList);
- await DoReqElement(reqList);
- }
- }
-
- ///
- /// Lista completa dei group id per le richieste
- ///
- /// nodo da controllare
- /// Lista groupId
- private void ReqGroupIdList(Area node, List groupId)
- {
- if (node.AreaList == null)
- return;
- if (node is Sash || node is Split)
- groupId.Add(node.GroupId);
- foreach (var child in node.AreaList)
- ReqGroupIdList(child, groupId);
- }
-
- ///
- /// Aggiornamento opzioni data nuova sash group
- ///
- /// nuovo frame
- ///
- private async Task UpdateHwOptionsSash(Sash newSash)
- {
- if (newSash != null)
- {
- // cerco il record
- var currRec = SearchAreaFromGroupId(FrameWindow, newSash.GroupId);
- // lo aggiorno
- currRec = newSash;
- // resetto hw list
- await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt);
- // richiesta calcolo opzioni hardware per la singola sash group
- List reqList = SashGroupList.Select(x => x.GroupId).ToList();
- await DoReqOptHardware(reqList);
- }
- }
-
- ///
- /// Richiesta opzioni hardware per la prima volta
- ///
- /// nuovo frame
- ///
- private async Task ReqFirstOptionHw(Sash newSash)
- {
- if (newSash != null)
- {
- // cerco il record
- var currRec = SearchAreaFromGroupId(FrameWindow, newSash.GroupId);
- // lo aggiorno
- currRec = newSash;
- // resetto hw list
- await EC_ActionReq.InvokeAsync(DataAction.ResetHwOpt);
- // richiesta calcolo opzioni hardware per la singola sash group
- List reqList = SashGroupList.Select(x => x.GroupId).ToList();
- // chiamo con gruppo della nuova sash
- await DoReqOptHardware(reqList);
+ item = newSash;
+ if (svgNoHw)
+ await DoPreviewSvg(true, true);
+ else
+ await DoPreviewSvg();
}
}
@@ -1896,93 +1873,135 @@ namespace WebWindowComplex
await UpdateElement(FrameWindow);
await DoReqShape(reqList);
}
-
}
///
- /// Aggiornamento opzioni dato update sash
+ /// Metodo per aggiornare i nomi dei profili degli elementi
///
- /// nuova sash
+ /// Lista dei profili
+ /// Id Area che si sta cercando
+ /// Id dell'anta o dello split (se -1 non usare)
///
- private async Task UpdatePreviewSashGroup(DataUpdateSash args)
+ private void UpdateProfileElement(List profileNameList, int GroupIdSearch, int EntityIdSearch)
{
- Sash newSash = args.currSash;
- bool svgNoHw = args.svgNoHw;
- bool noSvg = args.noSvg;
- Sash? item = (Sash?)SearchAreaFromGroupId(FrameWindow, newSash.GroupId);
- if (!noSvg && newSash != null && item != null)
+ // Cerco area corrispondente al GroupId
+ Area? found = SearchAreaFromGroupId(FrameWindow, GroupIdSearch);
+ List elemList = new List();
+ if (found != null)
{
- item = newSash;
- if (svgNoHw)
- await DoPreviewSvg(true, true);
- else
- await DoPreviewSvg();
- }
- }
-
- ///
- /// Rimozione area da frame corrente
- ///
- /// oggetto da rimuovere
- ///
- private async Task RemoveArea(DataNextStep remove)
- {
- if (remove.currCompileStep is CompileStep.Sash)
- {
- SashGroupList.ElementAt(remove.index).Remove();
- if (FrameWindow.SelThreshold.Name.Contains("Threshold") && remove.index == 0)
+ switch (found.AreaType)
{
- Threshold? updThreshold = FrameWindow.ThresholdList.FirstOrDefault(x => x.Name != "Threshold");
- if (updThreshold != null)
- FrameWindow.SelThresholdFromName = updThreshold.Name;
+ case AreaTypes.FRAME:
+ {
+ Frame frame = (Frame)found;
+ for (int index = frame.ElementDimensionList.Count; index < profileNameList.Count; index++)
+ {
+ double valStd = Window.m_ParameterList.GetValueOrDefault(profileNameList.ElementAt(index) + "_DimStd");
+ frame.ElementDimensionList.Add(new ElementDimension(frame, index + 1, valStd));
+ }
+ for (int i = 0; i < frame.ElementDimensionList.Count; i++)
+ {
+ frame.ElementDimensionList.ElementAt(i).SetNameElement(profileNameList.ElementAt(i));
+ }
+ for (int index = profileNameList.Count; index < frame.ElementDimensionList.Count; index++)
+ frame.ElementDimensionList.RemoveAt(index);
+ elemList = frame.ElementDimensionList;
+ foreach (var item in elemList)
+ {
+ string overlapName = string.Join("_", item.sName.Split('_').Skip(1));
+ item.SetOverlapElement(Window.m_ParameterList.GetValueOrDefault(overlapName + "_Overlap"));
+ }
+ foreach (var elem in frame.BottomRailElemDimList)
+ {
+ elem.SetOverlapElement(Window.m_ParameterList.GetValueOrDefault("Frame_BottomRail_Overlap"));
+ }
+ break;
+ }
+ case AreaTypes.SASH:
+ {
+ Sash sash = (Sash)found;
+ SashDimension anta = sash.SashList.ElementAt(EntityIdSearch - 1);
+ for (int index = anta.ElementDimensionList.Count; index < profileNameList.Count; index++)
+ {
+ double valStd = Window.m_ParameterList.GetValueOrDefault(profileNameList.ElementAt(index) + "_DimStd");
+ anta.ElementDimensionList.Add(new ElementDimension(sash, index + 1, valStd));
+ }
+ int numElemDelete = anta.ElementDimensionList.Count - profileNameList.Count;
+ for (int i = 0; i < numElemDelete; i++)
+ {
+ anta.ElementDimensionList.RemoveAt(anta.ElementDimensionList.Count - 1);
+ }
+ for (int index = profileNameList.Count; index < anta.ElementDimensionList.Count; index++)
+ anta.ElementDimensionList.RemoveAt(index);
+ for (int i = 0; i < anta.ElementDimensionList.Count; i++)
+ {
+ anta.ElementDimensionList.ElementAt(i).SetNameElement(profileNameList.ElementAt(i));
+ }
+ SetOverlapSash(sash, anta, EntityIdSearch - 1, elemList);
+ break;
+ }
+ case AreaTypes.SPLIT:
+ {
+ Split split = (Split)found;
+ List SpElemList = split.searchElemFromSubArea(EntityIdSearch);
+ for (int i = 0; i < SpElemList.Count; i++)
+ {
+ SpElemList.ElementAt(i).SetNameElement(profileNameList.ElementAt(i));
+ SpElemList.ElementAt(i).SetMinDimension(Window.m_ParameterList.GetValueOrDefault(SpElemList.ElementAt(i).sName + "_DimMin"));
+ SpElemList.ElementAt(i).SetMaxDimension(Window.m_ParameterList.GetValueOrDefault(SpElemList.ElementAt(i).sName + "_DimMax"));
+ if (SpElemList.ElementAt(i).dDimension > SpElemList.ElementAt(i).dMaxDim)
+ {
+ SpElemList.ElementAt(i).SetDimension(SpElemList.ElementAt(i).dMaxDim);
+ Frame frame = split.ParentWindow.AreaList.First();
+ if (frame != null)
+ {
+ frame.SearchAreaList(frame, frame.AvailWidthArea(), "Width");
+ frame.SearchAreaList(frame, frame.AvailHeightArea(), "Height");
+ }
+ }
+ else if (SpElemList.ElementAt(i).dDimension < SpElemList.ElementAt(i).dMinDim)
+ {
+ SpElemList.ElementAt(i).SetDimension(SpElemList.ElementAt(i).dMinDim);
+ Frame frame = split.ParentWindow.AreaList.First();
+ if (frame != null)
+ {
+ frame.SearchAreaList(frame, frame.AvailWidthArea(), "Width");
+ frame.SearchAreaList(frame, frame.AvailHeightArea(), "Height");
+ }
+ }
+ string overlapName = string.Join("_", SpElemList.ElementAt(i).sName.Split('_').Skip(1));
+ SpElemList.ElementAt(i).SetOverlapElement(Window.m_ParameterList.GetValueOrDefault(overlapName + "_Overlap"));
+ }
+ break;
+ }
}
- SashGroupList.RemoveAt(remove.index);
- }
- else if(remove.currCompileStep is CompileStep.Split)
- {
- SplitList.ElementAt(remove.index).Remove();
- SplitList.RemoveAt(remove.index);
- }
- await EC_ActionReq.InvokeAsync(DataAction.ResetDimElem);
- await DoPreviewSvg();
- }
-
- ///
- /// Calcola bottone per tutti i Fill
- ///
- ///
- private string buttonFillCss(FillTypes reqFillTypes)
- {
- foreach (var fill in FillList)
- {
- if (!fill.FillType.Equals(reqFillTypes))
- return "btn btn-outline-secondary btn-sm";
- }
- return "btn btn-secondary btn-sm";
- }
-
- ///
- /// Metodo per ottenere lista di tutti i groupId appartenenti alla window
- ///
- /// Area da aggiungere alla lista groupId
- /// Lista group id
- protected void AllGroupIdList(Area node, List groupIdList)
- {
- if (node != null)
- {
- groupIdList.Add(node.GroupId);
- foreach (var item in node.AreaList)
+ foreach (var item in elemList)
{
- AllGroupIdList(item, groupIdList);
+ item.SetMinDimension(Window.m_ParameterList.GetValueOrDefault(item.sName + "_DimMin"));
+ item.SetMaxDimension(Window.m_ParameterList.GetValueOrDefault(item.sName + "_DimMax"));
+ if (item.dDimension > item.dMaxDim)
+ item.SetDimension(item.dMaxDim);
+ else if (item.dMaxDim < item.dMinDim)
+ item.SetDimension(item.dMinDim);
}
}
}
+ ///
+ /// Metodo per settare i parmateri di ingresso selezionati
+ ///
+ private void UpdateSelParameter()
+ {
+ if (SelectionData != null && SelectionData.IsValid())
+ {
+ SelFamilyHardware = SelectionData.FamilyHardware ?? "";
+ SelColorMaterial = SelectionData.ColorMaterial ?? "";
+ SelMaterial = SelectionData.Material ?? "";
+ SelGlass = SelectionData.Glass ?? "";
+ SelProfile = SelectionData.Profile ?? "";
+ }
+ }
+
#endregion Private Methods
}
- public class DataSave
- {
- public string currJwd { get; set; } = "";
- public bool ForceSave { get; set; } = true;
- }
-}
+}
\ No newline at end of file